現在、を使用しUserNamePasswordValidator
てクライアントユーザーを認証するサービスがあります。検証のコードは次のとおりです。
public override void Validate(String userName, String password)
{
if (userName == null) || (password == null)
throw new FaultException("Username and/or password not specified.");
if (userName != "test") && (password != "tset")
throw new FaultException("Invalid username and/or password.");
}
ご覧のとおり、何か問題がある場合、コードは常に例外をスローします。
さて、質問です-関数ServiceSecurityContext.Current.PrimaryIdentity.IsAuthenticated
内で真であるかどうかを確認する必要がある理由はありますか?OperationContract
例えば、
public interface IMyService
{
[OperationContract]
void myOpContract();
}
public class MyService : IMyService
{
public void myOpContract()
{
// Do I really need this conditional statement?
if (ServiceSecurityContext.Current.PrimaryIdentity.IsAuthenticated)
// Proceed as expected
else
// Fail?
}
}
どんな助けでも大歓迎です。