AuthorizationContext Klas
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Het resultaat van het evalueren van alle autorisatiebeleidsregels die beschikbaar zijn op basis van de tokens in het verzonden bericht en door de methode aan te GetAuthorizationPolicies(OperationContext) roepen.
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
- Overname
-
AuthorizationContext
- Implementeringen
Voorbeelden
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
Opmerkingen
Het evalueren van alle autorisatiebeleidsregels in een autorisatiebeheer resulteert in een set ClaimSet objecten. Deze objecten vormen een autorisatiecontext.
Een autorisatiecontext bevat een set claimsetobjecten, een verlooptijd die de periode aangeeft waarin de autorisatiecontext geldig is en een unieke id.
De AuthorizationContext voor de huidige bewerking kan worden geopend via de AuthorizationContext eigenschap.
Constructors
| Name | Description |
|---|---|
| AuthorizationContext() |
Initialiseert een nieuw exemplaar van de AuthorizationContext klasse. |
Eigenschappen
| Name | Description |
|---|---|
| ClaimSets |
Hiermee haalt u de set claims op die zijn gekoppeld aan een autorisatiebeleid. |
| ExpirationTime |
Hiermee haalt u de datum en tijd op waarop dit AuthorizationContext object niet meer geldig is. |
| Id |
Hiermee haalt u een unieke id voor dit AuthorizationContext object op. |
| Properties |
Hiermee haalt u een verzameling niet-claimeigenschappen op die aan dit AuthorizationContext object zijn gekoppeld. |
Methoden
| Name | Description |
|---|---|
| CreateDefaultAuthorizationContext(IList<IAuthorizationPolicy>) |
Evalueer alle opgegeven autorisatiebeleidsregels en maak een AuthorizationContext. |
| Equals(Object) |
Bepaalt of het opgegeven object gelijk is aan het huidige object. (Overgenomen van Object) |
| GetHashCode() |
Fungeert als de standaardhashfunctie. (Overgenomen van Object) |
| GetType() |
Hiermee haalt u de Type huidige instantie op. (Overgenomen van Object) |
| MemberwiseClone() |
Hiermee maakt u een ondiepe kopie van de huidige Object. (Overgenomen van Object) |
| ToString() |
Retourneert een tekenreeks die het huidige object vertegenwoordigt. (Overgenomen van Object) |