AuthorizationContext クラス

定義

送信されたメッセージ内のトークンから、および GetAuthorizationPolicies(OperationContext) メソッドを呼び出すことによって取得できる、すべての承認ポリシーを評価した結果。

public ref class AuthorizationContext abstract : System::IdentityModel::Policy::IAuthorizationComponent
public abstract class AuthorizationContext : System.IdentityModel.Policy.IAuthorizationComponent
type AuthorizationContext = class
    interface IAuthorizationComponent
Public MustInherit Class AuthorizationContext
Implements IAuthorizationComponent
継承
AuthorizationContext
実装

protected override bool CheckAccessCore(OperationContext operationContext)
{
    // Extract the action URI from the OperationContext. Match this against the claims
    // in the AuthorizationContext.
    string action = operationContext.RequestContext.RequestMessage.Headers.Action;
    Console.WriteLine("action: {0}", action);

    // Iterate through the various claim sets in the AuthorizationContext.
    foreach(ClaimSet cs in operationContext.ServiceSecurityContext.AuthorizationContext.ClaimSets)
    {
        // Examine only those claim sets issued by System.
        if (cs.Issuer == ClaimSet.System)
        {
            // Iterate through claims of type "http://example.org/claims/allowedoperation".
            foreach (Claim c in cs.FindClaims("http://example.org/claims/allowedoperation", Rights.PossessProperty))
            {
                // Write the Claim resource to the console.
                Console.WriteLine("resource: {0}", c.Resource.ToString());

                // If the Claim resource matches the action URI then return true to allow access.
                if (action == c.Resource.ToString())
                    return true;
            }
        }
    }

    // If this point is reached, return false to deny access.
    return false;
}
Protected Overrides Function CheckAccessCore(ByVal operationContext As OperationContext) As Boolean
    ' Extract the action URI from the OperationContext. Match this against the claims
    ' in the AuthorizationContext.
    Dim action As String = operationContext.RequestContext.RequestMessage.Headers.Action
    Console.WriteLine("action: {0}", action)

    ' Iterate through the various claim sets in the AuthorizationContext.
    Dim cs As ClaimSet
    For Each cs In operationContext.ServiceSecurityContext.AuthorizationContext.ClaimSets
        ' Examine only those claim sets issued by System.
        If cs.Issuer Is ClaimSet.System Then
            ' Iterate through claims of type "http://example.org/claims/allowedoperation".
            Dim c As Claim
            For Each c In cs.FindClaims("http://example.org/claims/allowedoperation", Rights.PossessProperty)
                ' Write the Claim resource to the console.
                Console.WriteLine("resource: {0}", c.Resource.ToString())

                ' If the Claim resource matches the action URI then return true to allow access.
                If action = c.Resource.ToString() Then
                    Return True
                End If
            Next c
        End If
    Next cs
    ' If we get here, return false, denying access.
    Return False

End Function

注釈

承認マネージャー内のすべての承認ポリシーを評価した結果は、ClaimSet オブジェクトのセットになります。 これらのオブジェクトが、承認コンテキストを構成します。

承認コンテキストには、クレーム セット オブジェクトのセット、承認コンテキストの有効期間を指定する有効期限、および一意の識別子が含まれます。

現在の操作に対する AuthorizationContext には、AuthorizationContext プロパティを通してアクセスできます。

コンストラクター

AuthorizationContext()

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

プロパティ

ClaimSets

承認ポリシーに関連付けられたクレーム セットを取得します。

ExpirationTime

この AuthorizationContext オブジェクトが有効ではなくなる日時を取得します。

Id

この AuthorizationContext オブジェクトの一意の識別子を取得します。

Properties

この AuthorizationContext オブジェクトと関連付けられているクレーム以外のプロパティのコレクションを取得します。

メソッド

CreateDefaultAuthorizationContext(IList<IAuthorizationPolicy>)

指定されたすべての承認ポリシーを評価し、AuthorizationContext を作成します。

Equals(Object)

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

(継承元 Object)
GetHashCode()

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

(継承元 Object)
GetType()

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

(継承元 Object)
MemberwiseClone()

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

(継承元 Object)
ToString()

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

(継承元 Object)

適用対象