C# Class System.Security.Claims.ClaimsPrincipal

Inheritance: System.Security.Principal.IPrincipal
Exibir arquivo Open project: dotnet/corefx Class Usage Examples

Public Methods

Method Description
AddIdentities ( IEnumerable identities ) : void

Adds a IEnumerable{ClaimsIdentity} to the internal list.

AddIdentity ( ClaimsIdentity identity ) : void

Adds a single ClaimsIdentity to an internal list.

ClaimsPrincipal ( )
ClaimsPrincipal ( System reader )
ClaimsPrincipal ( System identities )
ClaimsPrincipal ( ) : System.Collections.Generic

Initializes an instance of ClaimsPrincipal.

ClaimsPrincipal ( BinaryReader reader ) : System.Collections.Generic

Initializes an instance of ClaimsPrincipal using a BinaryReader. Normally the BinaryReader is constructed using the bytes from WriteTo(BinaryWriter) and initialized in the same way as the BinaryWriter.

ClaimsPrincipal ( IEnumerable identities ) : System.Collections.Generic

Initializes an instance of ClaimsPrincipal.

ClaimsPrincipal ( IIdentity identity ) : System.Collections.Generic

Initializes an instance of ClaimsPrincipal

ClaimsPrincipal ( IPrincipal principal ) : System.Collections.Generic

Initializes an instance of ClaimsPrincipal

Clone ( ) : ClaimsPrincipal

Creates a new instance of ClaimsPrincipal with values copied from this object.

Clone ( ) : System.Security.Claims.ClaimsPrincipal
FindAll ( Predicate match ) : IEnumerable

Retrieves a IEnumerable{Claim} where each claim is matched by .

Each ClaimsIdentity is called. ClaimsIdentity.FindAll.

FindAll ( string type ) : IEnumerable

Retrieves a IEnumerable{Claim} where each Claim.Type equals type.

Each ClaimsIdentity is called. ClaimsIdentity.FindAll.

FindAll ( System match ) : System.Collections.Generic.IEnumerable
FindAll ( string type ) : System.Collections.Generic.IEnumerable
FindFirst ( Predicate match ) : Claim

Retrieves the first Claim that is matched by .

Each ClaimsIdentity is called. ClaimsIdentity.FindFirst.

FindFirst ( string type ) : Claim

Retrieves the first Claim where the Claim.Type equals type.

Each ClaimsIdentity is called. ClaimsIdentity.FindFirst.

FindFirst ( System match ) : System.Security.Claims.Claim
FindFirst ( string type ) : System.Security.Claims.Claim
HasClaim ( Predicate match ) : bool

Determines if a claim is contained within all the ClaimsIdentities in this ClaimPrincipal.

Each ClaimsIdentity is called. ClaimsIdentity.HasClaim.

HasClaim ( System match ) : bool
HasClaim ( string type, string value ) : bool

Determines if a claim of claimType AND claimValue exists in any of the identities.

Each ClaimsIdentity is called. ClaimsIdentity.HasClaim.

IsInRole ( string role ) : bool

IsInRole answers the question: does an identity this principal possesses contain a claim of type RoleClaimType where the value is '==' to the role.

Each Identity has its own definition of the ClaimType that represents a role.

WriteTo ( BinaryWriter writer ) : void

Serializes using a BinaryWriter

WriteTo ( System writer ) : void

Protected Methods

Method Description
ClaimsPrincipal ( System info, System context )
ClaimsPrincipal ( SerializationInfo info, StreamingContext context ) : System.Collections.Generic
CreateClaimsIdentity ( BinaryReader reader ) : ClaimsIdentity

Provides and extensibility point for derived types to create a custom ClaimsIdentity.

CreateClaimsIdentity ( System reader ) : System.Security.Claims.ClaimsIdentity
GetObjectData ( SerializationInfo info, StreamingContext context ) : void
GetObjectData ( System info, System context ) : void
WriteTo ( BinaryWriter writer, byte userData ) : void

Serializes using a BinaryWriter

WriteTo ( System writer, byte userData ) : void

Private Methods

Method Description
AddIdentities ( System identities ) : void
AddIdentity ( System identity ) : void
Initialize ( BinaryReader reader ) : void

Initializes from a BinaryReader. Normally the reader is initialized with the results from WriteTo(BinaryWriter) Normally the BinaryReader is initialized in the same way as the BinaryWriter passed to WriteTo(BinaryWriter).

OnSerializingMethod ( StreamingContext context ) : void
SelectPrimaryIdentity ( IEnumerable identities ) : ClaimsIdentity

This method iterates through the collection of ClaimsIdentities and chooses an identity as the primary.

Method Details

AddIdentities() public method

Adds a IEnumerable{ClaimsIdentity} to the internal list.
if 'identities' is null.
public AddIdentities ( IEnumerable identities ) : void
identities IEnumerable Enumeration of ClaimsIdentities to add.
return void

AddIdentity() public method

Adds a single ClaimsIdentity to an internal list.
if 'identity' is null.
public AddIdentity ( ClaimsIdentity identity ) : void
identity ClaimsIdentity the add.
return void

ClaimsPrincipal() public method

public ClaimsPrincipal ( )

ClaimsPrincipal() public method

public ClaimsPrincipal ( System reader )
reader System

ClaimsPrincipal() protected method

protected ClaimsPrincipal ( System info, System context )
info System
context System

ClaimsPrincipal() public method

public ClaimsPrincipal ( System identities )
identities System

ClaimsPrincipal() public method

Initializes an instance of ClaimsPrincipal.
public ClaimsPrincipal ( ) : System.Collections.Generic
return System.Collections.Generic

ClaimsPrincipal() public method

Initializes an instance of ClaimsPrincipal using a BinaryReader. Normally the BinaryReader is constructed using the bytes from WriteTo(BinaryWriter) and initialized in the same way as the BinaryWriter.
if 'reader' is null.
public ClaimsPrincipal ( BinaryReader reader ) : System.Collections.Generic
reader BinaryReader a pointing to a .
return System.Collections.Generic

ClaimsPrincipal() public method

Initializes an instance of ClaimsPrincipal.
if 'identities' is null.
public ClaimsPrincipal ( IEnumerable identities ) : System.Collections.Generic
identities IEnumerable the subjects in the principal.
return System.Collections.Generic

ClaimsPrincipal() public method

Initializes an instance of ClaimsPrincipal
if 'identity' is null.
public ClaimsPrincipal ( IIdentity identity ) : System.Collections.Generic
identity IIdentity representing the subject in the principal.
return System.Collections.Generic

ClaimsPrincipal() public method

Initializes an instance of ClaimsPrincipal
if 'principal' is null.
public ClaimsPrincipal ( IPrincipal principal ) : System.Collections.Generic
principal IPrincipal used to form this instance.
return System.Collections.Generic

ClaimsPrincipal() protected method

protected ClaimsPrincipal ( SerializationInfo info, StreamingContext context ) : System.Collections.Generic
info SerializationInfo
context StreamingContext
return System.Collections.Generic

Clone() public method

Creates a new instance of ClaimsPrincipal with values copied from this object.
public Clone ( ) : ClaimsPrincipal
return ClaimsPrincipal

Clone() public method

public Clone ( ) : System.Security.Claims.ClaimsPrincipal
return System.Security.Claims.ClaimsPrincipal

CreateClaimsIdentity() protected method

Provides and extensibility point for derived types to create a custom ClaimsIdentity.
if 'reader' is null.
protected CreateClaimsIdentity ( BinaryReader reader ) : ClaimsIdentity
reader BinaryReader the that points at the claim.
return ClaimsIdentity

CreateClaimsIdentity() protected method

protected CreateClaimsIdentity ( System reader ) : System.Security.Claims.ClaimsIdentity
reader System
return System.Security.Claims.ClaimsIdentity

FindAll() public method

Retrieves a IEnumerable{Claim} where each claim is matched by .
Each ClaimsIdentity is called. ClaimsIdentity.FindAll.
if 'match' is null.
public FindAll ( Predicate match ) : IEnumerable
match Predicate The predicate that performs the matching logic.
return IEnumerable

FindAll() public method

Retrieves a IEnumerable{Claim} where each Claim.Type equals type.
Each ClaimsIdentity is called. ClaimsIdentity.FindAll.
if 'type' is null.
public FindAll ( string type ) : IEnumerable
type string The type of the claim to match.
return IEnumerable

FindAll() public method

public FindAll ( System match ) : System.Collections.Generic.IEnumerable
match System
return System.Collections.Generic.IEnumerable

FindAll() public method

public FindAll ( string type ) : System.Collections.Generic.IEnumerable
type string
return System.Collections.Generic.IEnumerable

FindFirst() public method

Retrieves the first Claim that is matched by .
Each ClaimsIdentity is called. ClaimsIdentity.FindFirst.
if 'match' is null.
public FindFirst ( Predicate match ) : Claim
match Predicate The predicate that performs the matching logic.
return Claim

FindFirst() public method

Retrieves the first Claim where the Claim.Type equals type.
Each ClaimsIdentity is called. ClaimsIdentity.FindFirst.
if 'type' is null.
public FindFirst ( string type ) : Claim
type string The type of the claim to match.
return Claim

FindFirst() public method

public FindFirst ( System match ) : System.Security.Claims.Claim
match System
return System.Security.Claims.Claim

FindFirst() public method

public FindFirst ( string type ) : System.Security.Claims.Claim
type string
return System.Security.Claims.Claim

GetObjectData() protected method

protected GetObjectData ( SerializationInfo info, StreamingContext context ) : void
info SerializationInfo
context StreamingContext
return void

GetObjectData() protected method

protected GetObjectData ( System info, System context ) : void
info System
context System
return void

HasClaim() public method

Determines if a claim is contained within all the ClaimsIdentities in this ClaimPrincipal.
Each ClaimsIdentity is called. ClaimsIdentity.HasClaim.
if 'match' is null.
public HasClaim ( Predicate match ) : bool
match Predicate The predicate that performs the matching logic.
return bool

HasClaim() public method

public HasClaim ( System match ) : bool
match System
return bool

HasClaim() public method

Determines if a claim of claimType AND claimValue exists in any of the identities.
Each ClaimsIdentity is called. ClaimsIdentity.HasClaim.
if 'type' is null. if 'value' is null.
public HasClaim ( string type, string value ) : bool
type string the type of the claim to match.
value string the value of the claim to match.
return bool

IsInRole() public method

IsInRole answers the question: does an identity this principal possesses contain a claim of type RoleClaimType where the value is '==' to the role.
Each Identity has its own definition of the ClaimType that represents a role.
public IsInRole ( string role ) : bool
role string The role to check for.
return bool

WriteTo() public method

Serializes using a BinaryWriter
if 'writer' is null.
public WriteTo ( BinaryWriter writer ) : void
writer BinaryWriter
return void

WriteTo() protected method

Serializes using a BinaryWriter
if 'writer' is null.
protected WriteTo ( BinaryWriter writer, byte userData ) : void
writer BinaryWriter the to use for data storage.
userData byte additional data provided by derived type.
return void

WriteTo() public method

public WriteTo ( System writer ) : void
writer System
return void

WriteTo() protected method

protected WriteTo ( System writer, byte userData ) : void
writer System
userData byte
return void