Share via


AuthorizationContext Sınıf

Tanım

Gönderilen iletideki belirteçlerden ve yöntemini çağırarak kullanılabilir tüm yetkilendirme ilkelerini değerlendirmenin GetAuthorizationPolicies(OperationContext) sonucu.

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
Devralma
AuthorizationContext
Uygulamalar

Örnekler

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

Açıklamalar

Bir yetkilendirme yöneticisindeki tüm yetkilendirme ilkelerinin değerlendirilmesi, bir nesne kümesine ClaimSet neden olur. Bu nesneler bir yetkilendirme bağlamı oluşturur.

Yetkilendirme bağlamı, bir dizi talep kümesi nesnesi, yetkilendirme bağlamının geçerli olduğu süreyi belirten süre sonu süresi ve benzersiz bir tanımlayıcı içerir.

AuthorizationContext Geçerli işlemin öğesine özelliği aracılığıyla AuthorizationContext erişilebilir.

Oluşturucular

AuthorizationContext()

AuthorizationContext sınıfının yeni bir örneğini başlatır.

Özellikler

ClaimSets

Yetkilendirme ilkesiyle ilişkili talep kümesini alır.

ExpirationTime

Bu AuthorizationContext nesnenin artık geçerli olmadığı tarih ve saati alır.

Id

Bu AuthorizationContext nesne için benzersiz bir tanımlayıcı alır.

Properties

Bu AuthorizationContext nesneyle ilişkili talep olmayan özellikler koleksiyonunu alır.

Yöntemler

CreateDefaultAuthorizationContext(IList<IAuthorizationPolicy>)

Belirtilen tüm yetkilendirme ilkelerini değerlendirin ve bir AuthorizationContextoluşturun.

Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Şunlara uygulanır