RequestSecurityToken Klasa

Definicja

Reprezentuje element wst:RequestSecurityToken (RST), który jest używany do żądania tokenu zabezpieczającego.

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
Dziedziczenie
RequestSecurityToken

Przykłady

Przykładowy kod używany w tym temacie jest pobierany z przykładu Custom Token . Ten przykład zawiera niestandardowe klasy, które umożliwiają przetwarzanie prostych tokenów sieci Web (SWT) i obejmują implementację pasywnej usługi STS, która może obsługiwać token SWT. Usługa STS jest implementowana przez klasę, która pochodzi z SecurityTokenServiceklasy . Wiele metod klasy wywoływanej SecurityTokenService z potoku wystawiania tokenów bierze RequestSecurityToken obiekt jako jeden, jeśli ich parametry. Aby uzyskać informacje o tym przykładzie i innych przykładach dostępnych dla programu WIF oraz o tym, gdzie je pobrać, zobacz Przykładowy indeks kodu programu WIF.

Poniższy przykład kodu przedstawia implementację SecurityTokenService.GetScope metody . Metoda przyjmuje RequestSecurityToken jako jeden z jego parametrów i właściwości tego parametru są używane do ustawiania właściwości obiektu Scope zwracanego przez metodę.

// 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));
    }
}

Uwagi

Element wst:RequestSecurityToken (message) zawiera parametry i właściwości używane do żądania tokenu zabezpieczającego z usługi tokenu zabezpieczającego (STS). Komunikat (lub element) jest skrócony jako RST. Klasa RequestSecurityToken zawiera właściwości reprezentujące elementy RST. RST może utworzyć żądanie, które odpowiada dowolnym powiązaniom żądania zdefiniowanym przez usługę WS-Trust; na przykład powiązanie wystawiania, powiązanie odnowienia, powiązanie Weryfikuj lub Powiązanie Anuluj. Wiele właściwości w RequestSecurityToken klasie odpowiada elementom, które są obecne tylko w określonych rodzajach żądań zdefiniowanych przez te powiązania. W zależności od rodzaju żądania określony RequestSecurityToken obiekt reprezentuje lub parametry obecne w określonym żądaniu, które reprezentuje, niektóre właściwości obiektu mogą być null.

Usługa STS zwraca odpowiedź na żądanie w komunikacie zawierającym element wst:RequestSecurityTokenResponse (RSTR). Ten komunikat jest reprezentowany przez klasę RequestSecurityTokenResponse .

Aby uzyskać więcej informacji na temat elementu reprezentowanego przez tę klasę, zobacz specyfikację WS-Trust, która ma zastosowanie do danego scenariusza: WS-Trust z lutego 2005 r., WS-Trust 1.3 lub WS-Trust 1.4.

Konstruktory

RequestSecurityToken()

Inicjuje nowe wystąpienie klasy RequestSecurityToken.

RequestSecurityToken(String)

Inicjuje RequestSecurityToken nowe wystąpienie klasy o określonym typie żądania.

RequestSecurityToken(String, String)

Inicjuje RequestSecurityToken nowe wystąpienie klasy o określonym typie żądania.

Właściwości

ActAs

Pobiera lub ustawia token zabezpieczający dla tożsamości, którą żądający próbuje działać jako.

AdditionalContext

Pobiera lub ustawia dodatkowe informacje kontekstowe dla żądania.

AllowPostdating

Pobiera lub ustawia zawartość elementu wst:AllowPostdating.

(Odziedziczone po WSTrustMessage)
AppliesTo

Pobiera lub ustawia zawartość elementu wsp:AppliesTo.

(Odziedziczone po WSTrustMessage)
AuthenticationType

Pobiera lub ustawia zawartość elementu wst:AuthenticationType.

(Odziedziczone po WSTrustMessage)
BinaryExchange

Pobiera lub ustawia zawartość elementu wst:BinaryExchange.

(Odziedziczone po WSTrustMessage)
CancelTarget

Pobiera lub ustawia token do anulowania w żądaniu anulowania WS-Trust.

CanonicalizationAlgorithm

Pobiera lub ustawia zawartość elementu wst:CanonicalizationAlgorithm.

(Odziedziczone po WSTrustMessage)
Claims

Pobiera typy oświadczeń żądane przez klienta (żądającego).

ComputedKeyAlgorithm

Pobiera identyfikator URI, który reprezentuje żądany algorytm do użycia, gdy klucze obliczeniowe są używane dla wystawionych tokenów.

Context

Pobiera lub ustawia zawartość atrybutu Context na RST lub RSTR.

(Odziedziczone po WSTrustMessage)
Delegatable

Pobiera lub ustawia wartość określającą, czy wystawiony token powinien być oznaczony jako delegowalny.

DelegateTo

Pobiera lub ustawia tożsamość, do której powinien być delegowany wystawiony token.

Encryption

Pobiera lub ustawia informacje dotyczące tokenu i klucza do użycia podczas szyfrowania.

EncryptionAlgorithm

Pobiera lub ustawia zawartość elementu wst:EncryptionAlgorithm.

(Odziedziczone po WSTrustMessage)
EncryptWith

Pobiera lub ustawia zawartość elementu wst:EncryptWith.

(Odziedziczone po WSTrustMessage)
Entropy

Pobiera lub ustawia zawartość elementu wst:Entropy.

(Odziedziczone po WSTrustMessage)
Forwardable

Pobiera lub ustawia wartość określającą, czy wystawiony token powinien być oznaczony jako możliwy do przekazania.

Issuer

Pobiera lub ustawia wystawcę tokenu wst:OnBehalfOf.

KeySizeInBits

Pobiera lub ustawia zawartość elementu wst:KeySize wewnątrz komunikatu RequestSecurityToken (RST).

(Odziedziczone po WSTrustMessage)
KeyType

Pobiera lub ustawia zawartość elementu wst:KeyType wewnątrz komunikatu RequestSecurityToken (RST).

(Odziedziczone po WSTrustMessage)
KeyWrapAlgorithm

Pobiera lub ustawia zawartość elementu wst:KeyWrapAlgorithm.

(Odziedziczone po WSTrustMessage)
Lifetime

Pobiera lub ustawia zawartość elementu wst:Lifetime wewnątrz komunikatu RequestSecurityToken (RST).

(Odziedziczone po WSTrustMessage)
OnBehalfOf

Pobiera lub ustawia token dla tożsamości w imieniu, z którego jest wykonywane żądanie.

Participants

Pobiera lub ustawia uczestników autoryzowanych do korzystania z wystawionego tokenu.

ProofEncryption

Pobiera lub ustawia token, który ma być używany do szyfrowania tokenu dowodowego.

Properties

Pobiera torbę właściwości, aby rozszerzyć obiekt.

(Odziedziczone po OpenObject)
Renewing

Pobiera lub ustawia semantyka odnawiania dla żądania odnowienia WS-Trust.

RenewTarget

Pobiera lub ustawia token do odnowienia w żądaniu odnowienia WS-Trust.

ReplyTo

Pobiera lub ustawia adres, który ma być używany do odpowiadania na jednostki uzależnionej.

(Odziedziczone po WSTrustMessage)
RequestType

Pobiera lub ustawia element wst:RequestType.

(Odziedziczone po WSTrustMessage)
SecondaryParameters

Pobiera lub ustawia parametry, dla których element żądający nie jest inicjatorem.

SignatureAlgorithm

Pobiera lub ustawia zawartość elementu wst:SignatureAlgorithm.

(Odziedziczone po WSTrustMessage)
SignWith

Pobiera lub ustawia zawartość elementu wst:SignWith.

(Odziedziczone po WSTrustMessage)
TokenType

Pobiera lub ustawia zawartość elementu wst:TokenType.

(Odziedziczone po WSTrustMessage)
UseKey

Pobiera lub ustawia zawartość elementu wst:UseKey.

(Odziedziczone po WSTrustMessage)
ValidateTarget

Pobiera lub ustawia token do zweryfikowania w żądaniu weryfikacji WS-Trust.

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też