Condividi tramite


Claim Classe

Definizione

Rappresenta un'attestazione associata a un'entità.

public ref class Claim
public class Claim
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.xmlsoap.org/ws/2005/05/identity")]
public class Claim
type Claim = class
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.xmlsoap.org/ws/2005/05/identity")>]
type Claim = class
Public Class Claim
Ereditarietà
Claim
Attributi

Esempio

// Run this method from within a method protected by the PrincipalPermissionAttribute
// to see the security context data, including the primary identity.
public void WriteServiceSecurityContextData(string fileName)
{
    using (StreamWriter sw = new StreamWriter(fileName))
    {
        // Write the primary identity and Windows identity. The primary identity is derived from the
        // the credentials used to authenticate the user. The Windows identity may be a null string.
        sw.WriteLine("PrimaryIdentity: {0}", ServiceSecurityContext.Current.PrimaryIdentity.Name);
        sw.WriteLine("WindowsIdentity: {0}", ServiceSecurityContext.Current.WindowsIdentity.Name);
        sw.WriteLine();
        // Write the claimsets in the authorization context. By default, there is only one claimset
        // provided by the system.
        foreach (ClaimSet claimset in ServiceSecurityContext.Current.AuthorizationContext.ClaimSets)
        {
            foreach (Claim claim in claimset)
            {
                // Write out each claim type, claim value, and the right. There are two
                // possible values for the right: "identity" and "possessproperty".
                sw.WriteLine("Claim Type = {0}", claim.ClaimType);
                sw.WriteLine("\t Resource = {0}", claim.Resource.ToString());
                sw.WriteLine("\t Right = {0}", claim.Right);
            }
        }
    }
}
' Run this method from within a method protected by the PrincipalPermissionAttribute
' to see the security context data, including the primary identity.
Public Sub WriteServiceSecurityContextData(ByVal fileName As String)
    Dim sw As New StreamWriter(fileName)
    Try
        ' Write the primary identity and Windows identity. The primary identity is derived from the
        ' the credentials used to authenticate the user. The Windows identity may be a null string.
        sw.WriteLine("PrimaryIdentity: {0}", ServiceSecurityContext.Current.PrimaryIdentity.Name)
        sw.WriteLine("WindowsIdentity: {0}", ServiceSecurityContext.Current.WindowsIdentity.Name)
        sw.WriteLine()
        ' Write the claimsets in the authorization context. By default, there is only one claimset
        ' provided by the system. 
        Dim claimset As ClaimSet
        For Each claimset In ServiceSecurityContext.Current.AuthorizationContext.ClaimSets
            Dim claim As Claim
            For Each claim In claimset
                ' Write out each claim type, claim value, and the right. There are two
                ' possible values for the right: "identity" and "possessproperty". 
                sw.WriteLine("Claim Type = {0}", claim.ClaimType)
                sw.WriteLine(vbTab + " Resource = {0}", claim.Resource.ToString())
                sw.WriteLine(vbTab + " Right = {0}", claim.Right)
            Next claim
        Next claimset
    Finally
        sw.Dispose()
    End Try

End Sub

Commenti

Il modello di identità è un sistema di autorizzazione basato sulle attestazioni. Le attestazioni descrivono le funzionalità associate a un'entità nel sistema, spesso un utente di tale sistema. Il set di attestazioni associate a una determinata entità può essere considerato come una chiave. Le attestazioni particolari definiscono la forma di tale chiave; molto simile a una chiave fisica viene usata per aprire una serratura in una porta. In questo modo, le attestazioni vengono usate per ottenere l'accesso alle risorse. L'accesso a una determinata risorsa protetta viene determinato confrontando le attestazioni necessarie per accedere a tale risorsa con le attestazioni associate all'entità che tenta di accedere.

Un'attestazione è l'espressione di un diritto rispetto a un determinato valore. Un diritto può essere letto, scritto o posseduto. Un valore può essere un database, un file, una cassetta postale o una proprietà. Anche le dichiarazioni hanno un tipo di dichiarazione. La combinazione del tipo di attestazione e del diritto fornisce il meccanismo per le funzionalità specificate rispetto al valore. Ad esempio, un'attestazione di tipo file con il diritto read sul valore biography.doc indica che l'entità con tale attestazione ha accesso in lettura al file biography.doc. Un'attestazione di tipo name con il diritto PossessProperty sul valore Martin indica che l'entità con l'attestazione possiede una Name proprietà con il valore Martin.

Anche se diversi tipi di attestazione e diritti sono definiti come parte del modello di identità, il sistema è estendibile. I vari sistemi basati sull'infrastruttura del modello di identità possono definire i tipi di attestazione e i diritti in base alle esigenze.

Costruttori

Nome Descrizione
Claim(String, Object, String)

Inizializza una nuova istanza della classe con il tipo, la Claim risorsa e il diritto specificati.

Proprietà

Nome Descrizione
ClaimType

Ottiene il tipo dell'attestazione.

DefaultComparer

Ottiene un oggetto che può confrontare due Claim oggetti per verificarne l'uguaglianza.

Resource

Ottiene la risorsa a cui è associato questo Claim oggetto.

Right

Rappresentazione di stringa di un URI (Uniform Resource Identifier) che specifica il diritto associato a questo Claim oggetto. I diritti predefiniti sono disponibili come proprietà statiche della Rights classe .

System

Attestazione predefinita che rappresenta l'entità di sistema.

Metodi

Nome Descrizione
CreateDenyOnlyWindowsSidClaim(SecurityIdentifier)

Crea un Claim oggetto che rappresenta un IDENTIFICATORe di sicurezza specificato solo nega (SID).

CreateDnsClaim(String)

Crea un Claim oggetto che rappresenta il nome DNS (Domain Name System) specificato.

CreateHashClaim(Byte[])

Crea un Claim oggetto che rappresenta il valore hash specificato.

CreateMailAddressClaim(MailAddress)

Crea un Claim oggetto che rappresenta l'indirizzo di posta elettronica specificato.

CreateNameClaim(String)

Crea un Claim oggetto che rappresenta il nome specificato.

CreateRsaClaim(RSA)

Crea un Claim oggetto che rappresenta la chiave RSA specificata.

CreateSpnClaim(String)

Crea un Claim oggetto che rappresenta il nome dell'entità servizio (SPN) specificato.

CreateThumbprintClaim(Byte[])

Crea un Claim oggetto che rappresenta l'identificazione personale specificata.

CreateUpnClaim(String)

Crea un Claim oggetto che rappresenta il nome dell'entità universale (UPN) specificato.

CreateUriClaim(Uri)

Crea un Claim oggetto che rappresenta l'URL (Uniform Resource Locator) specificato.

CreateWindowsSidClaim(SecurityIdentifier)

Crea un Claim oggetto che rappresenta l'identificatore di sicurezza (SID) specificato.

CreateX500DistinguishedNameClaim(X500DistinguishedName)

Crea un Claim oggetto che rappresenta il nome distinto X.500 specificato.

Equals(Object)

Determina se l'oggetto specificato rappresenta la stessa attestazione dell'oggetto corrente Claim .

GetHashCode()

Restituisce un codice hash per l'attestazione corrente.

GetType()

Ottiene il Type dell'istanza corrente.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale del Objectcorrente.

(Ereditato da Object)
ToString()

Restituisce una rappresentazione di stringa di questo Claim oggetto.

Si applica a