RequestSecurityToken クラス

定義

セキュリティ トークンを要求するために使用する wst:RequestSecurityToken 要素 (RST) を表します。

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
継承
RequestSecurityToken

このトピックで使用するコード例は、サンプルから取得したものです Custom Token 。 このサンプルでは、Simple Web Tokens (SWT) の処理を可能にするカスタム クラスを提供し、SWT トークンを提供できるパッシブ STS の実装が含まれています。 STS は、 から SecurityTokenService派生したクラスによって実装されます。 トークン発行パイプラインから呼び出される クラスのメソッドの SecurityTokenService 多くは、パラメーターの場合、オブジェクトを RequestSecurityToken 1 つとして受け取ります。 WIF で使用できるこのサンプルとその他のサンプルの詳細と、それらをダウンロードする場所については、「 WIF コード サンプル インデックス」を参照してください。

SecurityTokenService.GetScope メソッドを実装する方法を次のコード例に示します。 メソッドは、 をそのパラメーターの 1 つとして受け取り RequestSecurityToken 、このパラメーターのプロパティを使用して、 メソッドによって返されるオブジェクトの Scope プロパティを設定します。

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

注釈

wst:RequestSecurityToken 要素 (メッセージ) には、セキュリティ トークン サービス (STS) からセキュリティ トークンを要求するために使用されるパラメーターとプロパティが含まれています。 メッセージ (または要素) は RST と省略されます。 クラスには RequestSecurityToken 、RST の要素を表すプロパティが含まれています。 RST は、WS-Trust によって定義された要求バインディングのいずれかに対応する要求を形成できます。たとえば、発行バインディング、更新バインディング、検証バインド、Cancel バインディングなどです。 クラスの RequestSecurityToken プロパティの多くは、これらのバインディングで定義されている特定の種類の要求にのみ存在する要素に対応しています。 特定のオブジェクトが表す要求の種類や、その RequestSecurityToken オブジェクトが表す特定の要求に存在するパラメーターによっては、オブジェクトの一部のプロパティが である null場合があります。

STS は、wst:RequestSecurityTokenResponse 要素 (RSTR) を含むメッセージ内の要求に対する応答を返します。 このメッセージは、 クラスによって RequestSecurityTokenResponse 表されます。

このクラスが表す要素について詳しくは、それぞれのシナリオに応じて、WS-Trust February 2005WS-Trust 1.3、または WS-Trust 1.4 の各 WS-Trust 仕様をご覧ください。

コンストラクター

RequestSecurityToken()

RequestSecurityToken クラスの新しいインスタンスを初期化します。

RequestSecurityToken(String)

指定した要求型を使用して、RequestSecurityToken クラスの新しいインスタンスを初期化します。

RequestSecurityToken(String, String)

指定した要求型を使用して、RequestSecurityToken クラスの新しいインスタンスを初期化します。

プロパティ

ActAs

要求元が使用しようとしている ID のセキュリティ トークンを取得または設定します。

AdditionalContext

要求の追加のコンテキスト情報を含取得または設定します。

AllowPostdating

wst:AllowPostdating 要素の内容を取得または設定します。

(継承元 WSTrustMessage)
AppliesTo

wsp:AppliesTo 要素のコンテンツを取得または設定します。

(継承元 WSTrustMessage)
AuthenticationType

wst:AuthenticationType 要素の内容を取得または設定します。

(継承元 WSTrustMessage)
BinaryExchange

wst:BinaryExchange 要素の内容を取得または設定します。

(継承元 WSTrustMessage)
CancelTarget

WS-Trust キャンセル要求でキャンセルされるトークンを取得または設定します。

CanonicalizationAlgorithm

wst:CanonicalizationAlgorithm 要素の内容を取得または設定します。

(継承元 WSTrustMessage)
Claims

クライアント (要求元) によって要求されたクレームの種類を取得します。

ComputedKeyAlgorithm

計算されたキーが発行されるトークンに対して使用されるときに使用する必要のあるアルゴリズムを表す URI を取得します。

Context

RST または RSTR の Context 属性の内容を取得または設定します。

(継承元 WSTrustMessage)
Delegatable

発行されるトークンをデリゲート可能としてマークするかどうかを指定する値を取得または設定します。

DelegateTo

発行されたトークンをデリゲートする必要がある ID を取得または設定します。

Encryption

暗号化するときに使用するトークンとキーの情報を取得または設定します。

EncryptionAlgorithm

wst:EncryptionAlgorithm 要素の内容を取得または設定します。

(継承元 WSTrustMessage)
EncryptWith

wst:EncryptWith 要素の内容を取得または設定します。

(継承元 WSTrustMessage)
Entropy

wst:Entropy 要素の内容を取得または設定します。

(継承元 WSTrustMessage)
Forwardable

発行されるトークンを転送可能としてマークするかどうかを指定する値を取得または設定します。

Issuer

wst:OnBehalfOf トークンの発行者を取得または設定します。

KeySizeInBits

RequestSecurityToken (RST) メッセージ内の wst:KeySize 要素の内容を取得または設定します。

(継承元 WSTrustMessage)
KeyType

RequestSecurityToken (RST) メッセージ内の wst:KeyType 要素の内容を取得または設定します。

(継承元 WSTrustMessage)
KeyWrapAlgorithm

wst:KeyWrapAlgorithm 要素の内容を取得または設定します。

(継承元 WSTrustMessage)
Lifetime

RequestSecurityToken (RST) メッセージ内の wst:Lifetime 要素の内容を取得または設定します。

(継承元 WSTrustMessage)
OnBehalfOf

要求が行われている ID のトークンを取得または設定します。

Participants

発行されたトークンの使用を承認された参加者を取得または設定します。

ProofEncryption

証明トークンを暗号化するために使用されるトークンを取得または設定します。

Properties

オブジェクトを拡張するプロパティ バッグを取得します。

(継承元 OpenObject)
Renewing

WS-Trust 更新要求の更新セマンティクスを取得または設定します。

RenewTarget

WS-Trust 更新要求で更新されるトークンを取得または設定します。

ReplyTo

証明書利用者への応答に使用するアドレスを取得または設定します。

(継承元 WSTrustMessage)
RequestType

wst:RequestType 要素を取得または設定します。

(継承元 WSTrustMessage)
SecondaryParameters

要求元が発信元ではないパラメーターを取得または設定します。

SignatureAlgorithm

wst:SignatureAlgorithm 要素の内容を取得または設定します。

(継承元 WSTrustMessage)
SignWith

wst:SignWith 要素の内容を取得または設定します。

(継承元 WSTrustMessage)
TokenType

wst:TokenType 要素の内容を取得または設定します。

(継承元 WSTrustMessage)
UseKey

wst:UseKey 要素の内容を取得または設定します。

(継承元 WSTrustMessage)
ValidateTarget

WS-Trust 検証要求で検証されるトークンを取得または設定します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象

こちらもご覧ください