Share via


AuthorizationContext Třída

Definice

Výsledek vyhodnocení všech zásad autorizace dostupných z tokenů v odeslané zprávě a voláním GetAuthorizationPolicies(OperationContext) metody.

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
Dědičnost
AuthorizationContext
Implementuje

Příklady

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

Poznámky

Vyhodnocení všech zásad autorizace ve správci autorizací má za následek sadu ClaimSet objektů. Tyto objekty tvoří kontext autorizace.

Kontext autorizace obsahuje sadu objektů sady deklarací, dobu vypršení platnosti, která určuje časové rozmezí, během kterého je kontext autorizace platný, a jedinečný identifikátor.

K AuthorizationContext aktuální operaci je možné přistupovat prostřednictvím AuthorizationContext vlastnosti .

Konstruktory

AuthorizationContext()

Inicializuje novou instanci AuthorizationContext třídy.

Vlastnosti

ClaimSets

Získá sadu deklarací identity přidružené k zásadám autorizace.

ExpirationTime

Získá datum a čas, kdy tento AuthorizationContext objekt již není platný.

Id

Získá jedinečný identifikátor pro tento AuthorizationContext objekt.

Properties

Získá kolekci vlastností bez deklarace identity přidružené k tomuto AuthorizationContext objektu.

Metody

CreateDefaultAuthorizationContext(IList<IAuthorizationPolicy>)

Vyhodnoťte všechny zadané zásady autorizace a vytvořte AuthorizationContext.

Equals(Object)

Určí, zda se zadaný objekt rovná aktuálnímu objektu.

(Zděděno od Object)
GetHashCode()

Slouží jako výchozí hashovací funkce.

(Zděděno od Object)
GetType()

Získá aktuální Type instanci.

(Zděděno od Object)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Objectsouboru .

(Zděděno od Object)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Platí pro