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 オブジェクトをパラメーターとして受け取ります。 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 によって定義された要求バインディングのいずれかに対応する要求を形成できます。たとえば、発行バインディング、更新バインディング、検証バインディング、キャンセル バインディングなどです。 RequestSecurityToken クラスのプロパティの多くは、これらのバインドで定義されている特定の種類の要求にのみ存在する要素に対応しています。 特定の RequestSecurityToken オブジェクトが表す要求の種類や、そのオブジェクトが表す特定の要求に存在するパラメーターによっては、オブジェクトの一部のプロパティが nullされる場合があります。

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

このクラスが表す要素の詳細については、シナリオに適用される WS-Trust 仕様 ( 2005 年 2 月WS-TrustWS-Trust 1.3、または WS-Trust 1.4) を参照してください。

コンストラクター

名前 説明
RequestSecurityToken()

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

RequestSecurityToken(String, String)

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

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

発行されたトークンを 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)

適用対象

こちらもご覧ください