Share via


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)

적용 대상