AuthorizationContext AuthorizationContext AuthorizationContext AuthorizationContext Class

Definition

Das Auswertungsergebnis aller Autorisierungsrichtlinien, die von den Tokens in der gesendeten Nachricht und durch Aufrufen der GetAuthorizationPolicies(OperationContext)-Methode verfügbar sind.The result of evaluating all authorization policies available from the tokens in the sent message and by calling the GetAuthorizationPolicies(OperationContext) method.

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
Vererbung
AuthorizationContextAuthorizationContextAuthorizationContextAuthorizationContext
Implementiert

Beispiele

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 

Hinweise

Die Auswertung aller Autorisierungsrichtlinien in einem Autorisierungs-Manager führt zu einem Satz von ClaimSet-Objekten.Evaluating all of the authorization policies in an authorization manager results in a set of ClaimSet objects. Diese Objekte bilden einen Autorisierungskontext.These objects make up an authorization context.

Ein Autorisierungskontext enthält eine Gruppe von Anspruchsatzobjekten, eine Ablaufzeit, die den Gültigkeitszeitraum des Evaluierungskontexts angibt, und einen eindeutigen Bezeichner.An authorization context contains a set of claim set objects, an expiration time that specifies the span of time during which the authorization context is valid, and a unique identifier.

Auf den AuthorizationContext für die aktuelle Operation kann über die AuthorizationContext-Eigenschaft zugegriffen werden.The AuthorizationContext for the current operation can be accessed via the AuthorizationContext property.

Konstruktoren

AuthorizationContext() AuthorizationContext() AuthorizationContext() AuthorizationContext()

Initialisiert eine neue Instanz der AuthorizationContext-Klasse.Initializes a new instance of the AuthorizationContext class.

Eigenschaften

ClaimSets ClaimSets ClaimSets ClaimSets

Ruft den Satz von den einer Autorisierungsrichtlinie zugeordneten Ansprüchen ab.Gets the set of claims associated with an authorization policy.

ExpirationTime ExpirationTime ExpirationTime ExpirationTime

Ruft das Datum und die Zeit ab, ab wann dieses AuthorizationContext-Objekt nicht mehr gültig ist.Gets the date and time at which this AuthorizationContext object is no longer valid.

Id Id Id Id

Ruft einen eindeutigen Bezeichner für dieses AuthorizationContext-Objekt ab.Gets a unique identifier for this AuthorizationContext object.

Properties Properties Properties Properties

Ruft eine Auflistung der diesem AuthorizationContext-Objekt zugeordneten Nicht-Ansprucheigenschaften ab.Gets a collection of non-claim properties associated with this AuthorizationContext object.

Methoden

CreateDefaultAuthorizationContext(IList<IAuthorizationPolicy>) CreateDefaultAuthorizationContext(IList<IAuthorizationPolicy>) CreateDefaultAuthorizationContext(IList<IAuthorizationPolicy>) CreateDefaultAuthorizationContext(IList<IAuthorizationPolicy>)

Werten Sie alle angegebenen Autorisierungsrichtlinien aus, und erstellen Sie einen AuthorizationContext.Evaluate all of the specified authorization policies and create an AuthorizationContext.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Bestimmt, ob das angegebene Objekt mit dem aktuellen Objekt identisch ist.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Fungiert als Standardhashfunktion.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Ruft den Type der aktuellen Instanz ab.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Erstellt eine flache Kopie des aktuellen Object.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.Returns a string that represents the current object.

(Inherited from Object)

Gilt für: