RequestSecurityToken Classe
Definição
Representa o elemento wst:RequestSecurityToken (RST), que é usado para solicitar um token de segurança.Represents the wst:RequestSecurityToken element (RST), which is used to request a security token.
public ref class RequestSecurityToken : System::IdentityModel::Protocols::WSTrust::WSTrustMessage
public class RequestSecurityToken : System.IdentityModel.Protocols.WSTrust.WSTrustMessage
type RequestSecurityToken = class
inherit WSTrustMessage
Public Class RequestSecurityToken
Inherits WSTrustMessage
- Herança
Exemplos
O exemplo de código usado neste tópico é obtido do Custom Token exemplo.The code example that is used in this topic is taken from the Custom Token sample. Este exemplo fornece classes personalizadas que permitem o processamento de tokens da Web simples (SWT) e inclui uma implementação de um STS passivo que é capaz de servir um token SWT.This sample provides custom classes that enable processing of Simple Web Tokens (SWT) and it includes an implementation of a passive STS that is capable of serving an SWT token. O STS é implementado por uma classe derivada de SecurityTokenService .The STS is implemented by a class that is derived from SecurityTokenService. Muitos dos métodos da SecurityTokenService classe que são chamados de seu pipeline de emissão de token assumem um RequestSecurityToken objeto como um se seus parâmetros.Many of the methods of the SecurityTokenService class that are called from its token issuance pipeline take a RequestSecurityToken object as one if their parameters. Para obter informações sobre esse exemplo e outros exemplos disponíveis para o WIF e sobre onde baixá-los, consulte o índice de exemplo de código do WIF.For information about this sample and other samples available for WIF and about where to download them, see WIF Code Sample Index.
O exemplo de código a seguir mostra uma implementação do SecurityTokenService.GetScope método.The following code example shows an implementation of the SecurityTokenService.GetScope method. O método usa RequestSecurityToken como um de seus parâmetros e as propriedades desse parâmetro são usadas para definir propriedades no Scope objeto retornado pelo método.The method takes a RequestSecurityToken as one of its parameters and properties of this parameter are used to set properties on the Scope object that is returned by the method.
// Certificate Constants
private const string SIGNING_CERTIFICATE_NAME = "CN=localhost";
private const string ENCRYPTING_CERTIFICATE_NAME = "CN=localhost";
private SigningCredentials _signingCreds;
private EncryptingCredentials _encryptingCreds;
// Used for validating applies to address, set to URI used in RP app of application, could also have been done via config
private string _addressExpected = "http://localhost:19851/";
/// <summary>
/// This method returns the configuration for the token issuance request. The configuration
/// is represented by the Scope class. In our case, we are only capable of issuing a token to a
/// single RP identity represented by the _encryptingCreds field.
/// </summary>
/// <param name="principal">The caller's principal</param>
/// <param name="request">The incoming RST</param>
/// <returns></returns>
protected override Scope GetScope(ClaimsPrincipal principal, RequestSecurityToken request)
{
// Validate the AppliesTo address
ValidateAppliesTo( request.AppliesTo );
// Create the scope using the request AppliesTo address and the RP identity
Scope scope = new Scope( request.AppliesTo.Uri.AbsoluteUri, _signingCreds );
if (Uri.IsWellFormedUriString(request.ReplyTo, UriKind.Absolute))
{
if (request.AppliesTo.Uri.Host != new Uri(request.ReplyTo).Host)
scope.ReplyToAddress = request.AppliesTo.Uri.AbsoluteUri;
else
scope.ReplyToAddress = request.ReplyTo;
}
else
{
Uri resultUri = null;
if (Uri.TryCreate(request.AppliesTo.Uri, request.ReplyTo, out resultUri))
scope.ReplyToAddress = resultUri.AbsoluteUri;
else
scope.ReplyToAddress = request.AppliesTo.Uri.ToString() ;
}
// Note: In this sample app only a single RP identity is shown, which is localhost, and the certificate of that RP is
// populated as _encryptingCreds
// If you have multiple RPs for the STS you would select the certificate that is specific to
// the RP that requests the token and then use that for _encryptingCreds
scope.EncryptingCredentials = _encryptingCreds;
return scope;
}
/// <summary>
/// Validates the appliesTo and throws an exception if the appliesTo is null or appliesTo contains some unexpected address.
/// </summary>
/// <param name="appliesTo">The AppliesTo parameter in the request that came in (RST)</param>
/// <returns></returns>
void ValidateAppliesTo(EndpointReference appliesTo)
{
if (appliesTo == null)
{
throw new InvalidRequestException("The appliesTo is null.");
}
if (!appliesTo.Uri.Equals(new Uri(_addressExpected)))
{
throw new InvalidRequestException(String.Format("The relying party address is not valid. Expected value is {0}, the actual value is {1}.", _addressExpected, appliesTo.Uri.AbsoluteUri));
}
}
Comentários
O elemento WST: RequestSecurityToken (Message) contém os parâmetros e as propriedades usados para solicitar um token de segurança de um STS (serviço de token de segurança).The wst:RequestSecurityToken element (message) contains the parameters and properties used to request a security token from a security token service (STS). A mensagem (ou o elemento) é abreviada como RST.The message (or element) is abbreviated as RST. A RequestSecurityToken classe contém propriedades que representam os elementos do RST.The RequestSecurityToken class contains properties that represent the elements of the RST. Um RST pode formar uma solicitação que corresponde a qualquer uma das associações de solicitação definidas por WS-Trust; por exemplo, a associação de emissão, a associação de renovação, a associação de validação ou a associação de cancelamento.An RST can form a request that corresponds to any of the request bindings defined by WS-Trust; for example, the Issuance binding, the Renewal binding, the Validate binding, or the Cancel binding. Muitas das propriedades na RequestSecurityToken classe correspondem aos elementos que estão presentes somente em tipos específicos de solicitações, conforme definido por essas associações.Many of the properties in the RequestSecurityToken class correspond to elements that are present only in specific kinds of requests as defined by these bindings. Dependendo do tipo de solicitação que um determinado RequestSecurityToken objeto representa ou dos parâmetros presentes na solicitação específica que ele representa, algumas propriedades do objeto podem ser null .Depending on the kind of request a particular RequestSecurityToken object represents or the parameters present in the specific request that it represents, some properties of the object may be null.
O STS retorna uma resposta à solicitação em uma mensagem que contém um elemento de WST: RequestSecurityTokenResponse (RSTR).The STS returns a response to the request in a message that contains a wst:RequestSecurityTokenResponse element (RSTR). Essa mensagem é representada pela RequestSecurityTokenResponse classe.This message is represented by the RequestSecurityTokenResponse class.
Para saber mais sobre o elemento que esta classe representa, consulte a especificação WS-Trust que se aplica ao cenário: WS-Trust – fevereiro de 2005, WS-Trust 1.3 ou WS-Trust 1.4.For more information about the element that this class represents, see the WS-Trust specification that applies to your scenario: WS-Trust February 2005, WS-Trust 1.3, or WS-Trust 1.4.
Construtores
| RequestSecurityToken() |
Inicializa uma nova instância da classe RequestSecurityToken.Initializes a new instance of the RequestSecurityToken class. |
| RequestSecurityToken(String) |
Inicializa uma nova instância da classe RequestSecurityToken com o tipo de solicitação especificado.Initializes a new instance of the RequestSecurityToken class with the specified request type. |
| RequestSecurityToken(String, String) |
Inicializa uma nova instância da classe RequestSecurityToken com o tipo de solicitação especificado.Initializes a new instance of the RequestSecurityToken class with the specified request type. |
Propriedades
| ActAs |
Obtém ou define o token de segurança para a identidade como a qual o solicitante está tentando atuar.Gets or sets the security token for the identity that the requestor is attempting to act as. |
| AdditionalContext |
Obtém ou define as informações de contexto adicionais para a solicitação.Gets or sets the additional context information for the request. |
| AllowPostdating |
Obtém ou define o conteúdo do elemento wst:AllowPostdating.Gets or sets the contents of the wst:AllowPostdating element. (Herdado de WSTrustMessage) |
| AppliesTo |
Obtém ou define o conteúdo do elemento wsp:AppliesTo.Gets or sets the contents of the wsp:AppliesTo element. (Herdado de WSTrustMessage) |
| AuthenticationType |
Obtém ou define o conteúdo do elemento wst:AuthenticationType.Gets or sets the contents of the wst:AuthenticationType element. (Herdado de WSTrustMessage) |
| BinaryExchange |
Obtém ou define o conteúdo do elemento wst:BinaryExchange.Gets or sets the contents of the wst:BinaryExchange element. (Herdado de WSTrustMessage) |
| CancelTarget |
Obtém ou define o token a ser cancelado em uma solicitação de cancelamento WS-Trust.Gets or sets the token to be canceled in a WS-Trust cancel request. |
| CanonicalizationAlgorithm |
Obtém ou define o conteúdo do elemento wst:CanonicalizationAlgorithm.Gets or sets the contents of the wst:CanonicalizationAlgorithm element. (Herdado de WSTrustMessage) |
| Claims |
Obtém os tipos de declaração solicitados pelo cliente (solicitante).Gets the claim types requested by the client (requestor). |
| ComputedKeyAlgorithm |
Obtém um URI que representa o algoritmo desejado a ser usado quando chaves computadas são usadas para tokens emitidos.Gets a URI that represents the desired algorithm to use when computed keys are used for issued tokens. |
| Context |
Obtém ou define o conteúdo do atributo de contexto no RST ou no RSTR.Gets or sets the contents of the Context attribute on the RST or RSTR. (Herdado de WSTrustMessage) |
| Delegatable |
Obtém ou define um valor que especifica se o token emitido deve ser marcado como delegável.Gets or sets a value that specifies if the issued token should be marked as delegatable. |
| DelegateTo |
Obtém ou define a identidade à qual o token emitido deve ser delegado.Gets or sets the identity to which the issued token should be delegated. |
| Encryption |
Obtém ou define informações sobre o token e a chave a serem usados ao criptografar.Gets or sets information on the token and key to use when encrypting. |
| EncryptionAlgorithm |
Obtém ou define o conteúdo do elemento wst:EncryptionAlgorithm.Gets or sets the contents of the wst:EncryptionAlgorithm element. (Herdado de WSTrustMessage) |
| EncryptWith |
Obtém ou define o conteúdo do elemento wst:EncryptWith.Gets or sets the contents of the wst:EncryptWith element. (Herdado de WSTrustMessage) |
| Entropy |
Obtém ou define o conteúdo do elemento wst:Entropy.Gets or sets the contents of the wst:Entropy element. (Herdado de WSTrustMessage) |
| Forwardable |
Obtém ou define um valor que especifica se o token emitido deve ser marcado como encaminhável.Gets or sets a value that specifies if the issued token should be marked forwardable. |
| Issuer |
Obtém ou define o emissor do token wst:OnBehalfOf.Gets or sets the issuer of the wst:OnBehalfOf token. |
| KeySizeInBits |
Obtém ou define o conteúdo do elemento wst:KeySize dentro de uma mensagem RequestSecurityToken (RST).Gets or sets the contents of the wst:KeySize element inside a RequestSecurityToken (RST) message. (Herdado de WSTrustMessage) |
| KeyType |
Obtém ou define o conteúdo do elemento wst:KeyType dentro de uma mensagem RST (RequestSecurityToken).Gets or sets the contents of the wst:KeyType element inside a RequestSecurityToken (RST) message. (Herdado de WSTrustMessage) |
| KeyWrapAlgorithm |
Obtém ou define o conteúdo do elemento wst:KeyWrapAlgorithm.Gets or sets the contents of the wst:KeyWrapAlgorithm element. (Herdado de WSTrustMessage) |
| Lifetime |
Obtém ou define o conteúdo do elemento wst:Lifetime dentro de uma mensagem (RST) (RequestSecurityToken).Gets or sets the contents of the wst:Lifetime element inside a RequestSecurityToken (RST) message. (Herdado de WSTrustMessage) |
| OnBehalfOf |
Obtém ou define o token para a identidade em nome da qual a solicitação está sendo feita.Gets or sets the token for the identity on behalf of which the request is being made. |
| Participants |
Obtém ou define os participantes autorizados a usar o token emitido.Gets or sets the participants that are authorized to use the issued token. |
| ProofEncryption |
Obtém ou define o token a ser usado para criptografar o token de prova.Gets or sets the token to be used to encrypt the proof token. |
| Properties |
Obtém o recipiente de propriedades para estender o objeto.Gets the properties bag to extend the object. (Herdado de OpenObject) |
| Renewing |
Obtém ou define a semântica de renovação para uma solicitação de renovação de WS-Trust.Gets or sets the renew semantics for a WS-Trust renew request. |
| RenewTarget |
Obtém ou define o token a ser renovado em uma solicitação de cancelamento WS-Trust.Gets or sets the token to be renewed in a WS-Trust renew request. |
| ReplyTo |
Obtém ou define o endereço a ser usado para responder à terceira parte confiável.Gets or sets the address to be used for replying to the Relying Party. (Herdado de WSTrustMessage) |
| RequestType |
Obtém ou define o elemento wst:RequestType.Gets or sets the wst:RequestType element. (Herdado de WSTrustMessage) |
| SecondaryParameters |
Obtém ou define os parâmetros para os quais o solicitante não é o originador.Gets or sets parameters for which the requestor is not the originator. |
| SignatureAlgorithm |
Obtém ou define o conteúdo do elemento wst:SignatureAlgorithm.Gets or sets the contents of the wst:SignatureAlgorithm element. (Herdado de WSTrustMessage) |
| SignWith |
Obtém ou define o conteúdo do elemento wst:SignWith.Gets or sets the contents of the wst:SignWith element. (Herdado de WSTrustMessage) |
| TokenType |
Obtém ou define o conteúdo do elemento wst:TokenType.Gets or sets the contents of the wst:TokenType element. (Herdado de WSTrustMessage) |
| UseKey |
Obtém ou define o conteúdo do elemento wst:UseKey.Gets or sets the contents of the wst:UseKey element. (Herdado de WSTrustMessage) |
| ValidateTarget |
Obtém ou define o token a ser validado em uma solicitação de validação WS-Trust.Gets or sets the token to be validated in a WS-Trust validate request. |
Métodos
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object. (Herdado de Object) |
| GetHashCode() |
Serve como a função de hash padrão.Serves as the default hash function. (Herdado de Object) |
| GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (Herdado de Object) |
| ToString() |
Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object. (Herdado de Object) |