WCF サービスで動作する顧客認証プロバイダーを (必死に) 取得しようとしています。これまでのところ、次のコードがあります。
web.config
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyNamespace.CustomUserNameValidator, MyNamespace" />
</serviceCredentials>
<wsHttpBinding>
<binding name="wsHttpBindingConfig" >
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
カスタム認証クラス。
public class CustomUserNameValidator : UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
// have security details been provided?
if (null == userName || null == password)
{
throw new ArgumentNullException();
}
// authenticate user
if (!(userName == "test" && password == "test"))
{
// This throws an informative fault to the client.
throw new FaultException("SecurityFailed");
}
}
}
すべて正常にコンパイルされますが、ビジュアル スタジオの WCF テスト クライアントを使用して Ping というメソッド (下記) を呼び出すと、カスタム オーセンティケーターが使用されません。Ping メソッドが実行され、CustomUserNameValidator クラスにあるすべてのブレークポイントが実行されます。
これはなぜでしょうか?すべての助けに感謝します。