ServiceCredentialsSecurityTokenManager.CreateSecurityTokenAuthenticator(SecurityTokenRequirement, SecurityTokenResolver) Método

Definición

Crea un autenticador de tokens de seguridad basado en SecurityTokenRequirement.Creates a security token authenticator based on the SecurityTokenRequirement.

public:
 override System::IdentityModel::Selectors::SecurityTokenAuthenticator ^ CreateSecurityTokenAuthenticator(System::IdentityModel::Selectors::SecurityTokenRequirement ^ tokenRequirement, [Runtime::InteropServices::Out] System::IdentityModel::Selectors::SecurityTokenResolver ^ % outOfBandTokenResolver);
public override System.IdentityModel.Selectors.SecurityTokenAuthenticator CreateSecurityTokenAuthenticator (System.IdentityModel.Selectors.SecurityTokenRequirement tokenRequirement, out System.IdentityModel.Selectors.SecurityTokenResolver outOfBandTokenResolver);
override this.CreateSecurityTokenAuthenticator : System.IdentityModel.Selectors.SecurityTokenRequirement * SecurityTokenResolver -> System.IdentityModel.Selectors.SecurityTokenAuthenticator
Public Overrides Function CreateSecurityTokenAuthenticator (tokenRequirement As SecurityTokenRequirement, ByRef outOfBandTokenResolver As SecurityTokenResolver) As SecurityTokenAuthenticator

Parámetros

tokenRequirement
SecurityTokenRequirement

El requisito del token de seguridad.The security token requirement.

outOfBandTokenResolver
SecurityTokenResolver

Cuando este método se devuelve, contiene SecurityTokenResolver.When this method returns, contains a SecurityTokenResolver. Este parámetro se pasa sin inicializar.This parameter is passed uninitialized.

Devoluciones

SecurityTokenAuthenticator

Autenticador de token de seguridad.The security token authenticator.

Excepciones

tokenRequirement es null.tokenRequirement is null.

No se puede crear un autenticador de token de seguridad para el tokenRequirement que se pasó.A security token authenticator cannot be created for the tokenRequirement that was passed in.

Ejemplos

El siguiente código es un ejemplo de cómo invalidar este método.The following code is an example of how to override this method.

internal class MyServiceCredentialsSecurityTokenManager :
    ServiceCredentialsSecurityTokenManager
{
    ServiceCredentials credentials;
    public MyServiceCredentialsSecurityTokenManager(ServiceCredentials credentials)
        : base(credentials)
    {
        this.credentials = credentials;
    }

    public override SecurityTokenAuthenticator CreateSecurityTokenAuthenticator
        (SecurityTokenRequirement tokenRequirement, out SecurityTokenResolver outOfBandTokenResolver)
    {
        // Return your implementation of the SecurityTokenProvider based on the
        // tokenRequirement argument.
        SecurityTokenAuthenticator result;
        if (tokenRequirement.TokenType == SecurityTokenTypes.UserName)
        {
            MessageDirection direction = tokenRequirement.GetProperty<MessageDirection>
                (ServiceModelSecurityTokenRequirement.MessageDirectionProperty);
            if (direction == MessageDirection.Input)
            {
                outOfBandTokenResolver = null;
                result = new MySecurityTokenAuthenticator();
            }
            else
            {
                result = base.CreateSecurityTokenAuthenticator(tokenRequirement, out outOfBandTokenResolver);
            }
        }
        else
        {
            result = base.CreateSecurityTokenAuthenticator(tokenRequirement, out outOfBandTokenResolver);
        }

        return result;
    }
}
Friend Class MyServiceCredentialsSecurityTokenManager
    Inherits ServiceCredentialsSecurityTokenManager

    Private credentials As ServiceCredentials

    Public Sub New(ByVal credentials As ServiceCredentials)
        MyBase.New(credentials)
        Me.credentials = credentials
    End Sub

    Public Overrides Function CreateSecurityTokenAuthenticator(ByVal tokenRequirement As SecurityTokenRequirement, _
                                                               <System.Runtime.InteropServices.Out()> _
                                                               ByRef outOfBandTokenResolver _
                                                               As SecurityTokenResolver) As SecurityTokenAuthenticator
        ' Return your implementation of the SecurityTokenProvider based on the 
        ' tokenRequirement argument.
        Dim result As SecurityTokenAuthenticator
        If tokenRequirement.TokenType = SecurityTokenTypes.UserName Then
            Dim direction = tokenRequirement.GetProperty(Of MessageDirection)(ServiceModelSecurityTokenRequirement.MessageDirectionProperty)
            If direction = MessageDirection.Input Then
                outOfBandTokenResolver = Nothing
                result = New MySecurityTokenAuthenticator()
            Else
                result = MyBase.CreateSecurityTokenAuthenticator(tokenRequirement, _
                                                                 outOfBandTokenResolver)
            End If
        Else
            result = MyBase.CreateSecurityTokenAuthenticator(tokenRequirement, _
                                                             outOfBandTokenResolver)
        End If

        Return result
    End Function

End Class

Comentarios

outOfBandOpcionalmente, un solucionador de tokens puede ser devuelto por el método, que utiliza el procesador de seguridad de WCF para resolver tokens que no están en el mensaje SOAP al procesar la seguridad.An outOfBand token resolver can optionally be returned by the method, which is used by the WCF security processor to resolve tokens that are not in the SOAP message when processing security. La SecurityTokenAuthenticator devuelta por este método valida tokens y extrae notificaciones.The SecurityTokenAuthenticator that is returned by this method validates tokens and extracts claims. Un SecurityTokenAuthenticator se crea para cada clase derivada de ServiceModelSecurityTokenRequirement.One SecurityTokenAuthenticator is created for each class derived from ServiceModelSecurityTokenRequirement.

Se aplica a