C# Class System.Security.Claims.ClaimsIdentity

Inheritance: System.Security.Principal.IIdentity
ファイルを表示 Open project: dotnet/corefx Class Usage Examples

Private Properties

Property Type Description
AddClaim void
AddClaims void
ClaimsIdentity System.Collections.Generic
Deserialize void
Initialize void
IsCircular bool
OnDeserializedMethod void
OnSerializingMethod void
RemoveClaim void
SafeAddClaim void
SafeAddClaims void
TryRemoveClaim bool

Public Methods

Method Description
AddClaim ( Claim claim ) : void

Adds a single Claim to an internal list.

If Claim.Subject != this, then Claim.Clone(this) is called before the claim is added.

AddClaims ( IEnumerable claims ) : void

Adds a IEnumerable{Claim} to the internal list.

Each claim is examined and if Claim.Subject != this, then then Claim.Clone(this) is called before the claim is added.

ClaimsIdentity ( )
ClaimsIdentity ( System reader )
ClaimsIdentity ( System identity, System claims )
ClaimsIdentity ( System identity, System claims, string authenticationType, string nameType, string roleType )
ClaimsIdentity ( System claims )
ClaimsIdentity ( System claims, string authenticationType )
ClaimsIdentity ( System claims, string authenticationType, string nameType, string roleType )
ClaimsIdentity ( string authenticationType )
ClaimsIdentity ( string authenticationType, string nameType, string roleType )
ClaimsIdentity ( ) : System.Collections.Generic

Initializes an instance of ClaimsIdentity.

ClaimsIdentity ( BinaryReader reader ) : System.Collections.Generic

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

ClaimsIdentity ( IEnumerable claims ) : System.Collections.Generic

Initializes an instance of ClaimsIdentity.

ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string) for details on how internal values are set.

ClaimsIdentity ( IEnumerable claims, string authenticationType ) : System.Collections.Generic

Initializes an instance of ClaimsIdentity.

ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string) for details on how internal values are set.

ClaimsIdentity ( IEnumerable claims, string authenticationType, string nameType, string roleType ) : System.Collections.Generic

Initializes an instance of ClaimsIdentity.

ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string) for details on how internal values are set.

ClaimsIdentity ( IIdentity identity ) : System.Collections.Generic

Initializes an instance of ClaimsIdentity.

ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string) for details on how internal values are set.

ClaimsIdentity ( IIdentity identity, IEnumerable claims ) : System.Collections.Generic

Initializes an instance of ClaimsIdentity.

ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string) for details on how internal values are set.

ClaimsIdentity ( IIdentity identity, IEnumerable claims, string authenticationType, string nameType, string roleType ) : System.Collections.Generic

Initializes an instance of ClaimsIdentity.

If 'identity' is a ClaimsIdentity, then there are potentially multiple sources for AuthenticationType, NameClaimType, RoleClaimType.

Priority is given to the parameters: authenticationType, nameClaimType, roleClaimType.

All Claims are copied into this instance in a List{Claim}. Each Claim is examined and if Claim.Subject != this, then Claim.Clone(this) is called before the claim is added.

Any 'External' claims are ignored.

ClaimsIdentity ( string authenticationType ) : System.Collections.Generic

Initializes an instance of ClaimsIdentity.

ClaimsIdentity ( string authenticationType, string nameType, string roleType ) : System.Collections.Generic

Initializes an instance of ClaimsIdentity.

ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string) for details on how internal values are set.

Clone ( ) : ClaimsIdentity

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

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

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

FindAll ( string type ) : IEnumerable

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

Comparison is: StringComparison.OrdinalIgnoreCase.<

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 .

FindFirst ( string type ) : Claim

Retrieves the first Claim where Claim.Type equals type.

Comparison is: StringComparison.OrdinalIgnoreCase.

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 this ClaimsIdentity.

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

Determines if a claim with type AND value is contained within this ClaimsIdentity.

Comparison is: StringComparison.OrdinalIgnoreCase for Claim.Type, StringComparison.Ordinal for Claim.Value.

RemoveClaim ( Claim claim ) : void It is possible that a Claim returned from Claims cannot be removed. This would be the case for 'External' claims that are provided by reference.

object.ReferenceEquals is used to 'match'.

TryRemoveClaim ( Claim claim ) : bool It is possible that a Claim returned from Claims cannot be removed. This would be the case for 'External' claims that are provided by reference.

object.ReferenceEquals is used to 'match'.

WriteTo ( BinaryWriter writer ) : void

Serializes using a BinaryWriter

WriteTo ( System writer ) : void

Protected Methods

Method Description
ClaimsIdentity ( System info, System context )
ClaimsIdentity ( ClaimsIdentity other ) : System.Collections.Generic

Copy constructor.

ClaimsIdentity ( SerializationInfo info, StreamingContext context ) : System.Collections.Generic
CreateClaim ( BinaryReader reader ) : Claim

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

CreateClaim ( System reader ) : System.Security.Claims.Claim
GetObjectData ( SerializationInfo info, StreamingContext context ) : void

Populates the specified SerializationInfo with the serialization data for the ClaimsIdentity

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
AddClaim ( System claim ) : void
AddClaims ( System claims ) : void
ClaimsIdentity ( SerializationInfo info ) : System.Collections.Generic
Deserialize ( SerializationInfo info, StreamingContext context, bool useContext ) : 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).

IsCircular ( ClaimsIdentity subject ) : bool

Checks if a circular reference exists to 'this'

OnDeserializedMethod ( StreamingContext context ) : void
OnSerializingMethod ( StreamingContext context ) : void
RemoveClaim ( System claim ) : void
SafeAddClaim ( Claim claim ) : void

Adds claim to intenal list. Calling Claim.Clone if Claim.Subject != this.

private only call from constructor, adds to internal list.

SafeAddClaims ( IEnumerable claims ) : void

Adds claims to intenal list. Calling Claim.Clone if Claim.Subject != this.

private only call from constructor, adds to internal list.

TryRemoveClaim ( System claim ) : bool

Method Details

AddClaim() public method

Adds a single Claim to an internal list.
If Claim.Subject != this, then Claim.Clone(this) is called before the claim is added.
if 'claim' is null.
public AddClaim ( Claim claim ) : void
claim Claim the add.
return void

AddClaims() public method

Adds a IEnumerable{Claim} to the internal list.
Each claim is examined and if Claim.Subject != this, then then Claim.Clone(this) is called before the claim is added.
if 'claims' is null.
public AddClaims ( IEnumerable claims ) : void
claims IEnumerable Enumeration of claims to add.
return void

ClaimsIdentity() public method

public ClaimsIdentity ( )

ClaimsIdentity() public method

public ClaimsIdentity ( System reader )
reader System

ClaimsIdentity() protected method

protected ClaimsIdentity ( System info, System context )
info System
context System

ClaimsIdentity() public method

public ClaimsIdentity ( System identity, System claims )
identity System
claims System

ClaimsIdentity() public method

public ClaimsIdentity ( System identity, System claims, string authenticationType, string nameType, string roleType )
identity System
claims System
authenticationType string
nameType string
roleType string

ClaimsIdentity() public method

public ClaimsIdentity ( System claims )
claims System

ClaimsIdentity() public method

public ClaimsIdentity ( System claims, string authenticationType )
claims System
authenticationType string

ClaimsIdentity() public method

public ClaimsIdentity ( System claims, string authenticationType, string nameType, string roleType )
claims System
authenticationType string
nameType string
roleType string

ClaimsIdentity() public method

public ClaimsIdentity ( string authenticationType )
authenticationType string

ClaimsIdentity() public method

public ClaimsIdentity ( string authenticationType, string nameType, string roleType )
authenticationType string
nameType string
roleType string

ClaimsIdentity() public method

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

ClaimsIdentity() public method

Initializes an instance of ClaimsIdentity 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 ClaimsIdentity ( BinaryReader reader ) : System.Collections.Generic
reader BinaryReader a pointing to a .
return System.Collections.Generic

ClaimsIdentity() protected method

Copy constructor.
if 'other' is null.
protected ClaimsIdentity ( ClaimsIdentity other ) : System.Collections.Generic
other ClaimsIdentity to copy.
return System.Collections.Generic

ClaimsIdentity() public method

Initializes an instance of ClaimsIdentity.
ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string) for details on how internal values are set.
public ClaimsIdentity ( IEnumerable claims ) : System.Collections.Generic
claims IEnumerable associated with this instance.
return System.Collections.Generic

ClaimsIdentity() public method

Initializes an instance of ClaimsIdentity.
ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string) for details on how internal values are set.
public ClaimsIdentity ( IEnumerable claims, string authenticationType ) : System.Collections.Generic
claims IEnumerable associated with this instance.
authenticationType string The authentication method used to establish this identity.
return System.Collections.Generic

ClaimsIdentity() public method

Initializes an instance of ClaimsIdentity.
ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string) for details on how internal values are set.
public ClaimsIdentity ( IEnumerable claims, string authenticationType, string nameType, string roleType ) : System.Collections.Generic
claims IEnumerable associated with this instance.
authenticationType string The type of authentication used.
nameType string The used when obtaining the value of .
roleType string The used when performing logic for .
return System.Collections.Generic

ClaimsIdentity() public method

Initializes an instance of ClaimsIdentity.
ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string) for details on how internal values are set.
public ClaimsIdentity ( IIdentity identity ) : System.Collections.Generic
identity IIdentity supplies the and .
return System.Collections.Generic

ClaimsIdentity() public method

Initializes an instance of ClaimsIdentity.
ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string) for details on how internal values are set.
public ClaimsIdentity ( IIdentity identity, IEnumerable claims ) : System.Collections.Generic
identity IIdentity supplies the and .
claims IEnumerable associated with this instance.
return System.Collections.Generic

ClaimsIdentity() public method

Initializes an instance of ClaimsIdentity.
If 'identity' is a ClaimsIdentity, then there are potentially multiple sources for AuthenticationType, NameClaimType, RoleClaimType.

Priority is given to the parameters: authenticationType, nameClaimType, roleClaimType.

All Claims are copied into this instance in a List{Claim}. Each Claim is examined and if Claim.Subject != this, then Claim.Clone(this) is called before the claim is added.

Any 'External' claims are ignored.

if 'identity' is a and results in a circular refrence back to 'this'.
public ClaimsIdentity ( IIdentity identity, IEnumerable claims, string authenticationType, string nameType, string roleType ) : System.Collections.Generic
identity IIdentity supplies the and .
claims IEnumerable associated with this instance.
authenticationType string The type of authentication used.
nameType string The used when obtaining the value of .
roleType string The used when performing logic for .
return System.Collections.Generic

ClaimsIdentity() protected method

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

ClaimsIdentity() public method

Initializes an instance of ClaimsIdentity.
public ClaimsIdentity ( string authenticationType ) : System.Collections.Generic
authenticationType string The authentication method used to establish this identity.
return System.Collections.Generic

ClaimsIdentity() public method

Initializes an instance of ClaimsIdentity.
ClaimsIdentity(IIdentity, IEnumerable{Claim}, string, string, string) for details on how internal values are set.
public ClaimsIdentity ( string authenticationType, string nameType, string roleType ) : System.Collections.Generic
authenticationType string The type of authentication used.
nameType string The used when obtaining the value of .
roleType string The used when performing logic for .
return System.Collections.Generic

Clone() public method

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

Clone() public method

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

CreateClaim() protected method

Provides and extensibility point for derived types to create a custom Claim.
protected CreateClaim ( BinaryReader reader ) : Claim
reader BinaryReader the that points at the claim.
return Claim

CreateClaim() protected method

protected CreateClaim ( System reader ) : System.Security.Claims.Claim
reader System
return System.Security.Claims.Claim

FindAll() public method

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

FindAll() public method

Retrieves a IEnumerable{Claim} where each Claim.Type equals type.
Comparison is: StringComparison.OrdinalIgnoreCase.<
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 .
if 'match' is null.
public FindFirst ( Predicate match ) : Claim
match Predicate The function that performs the matching logic.
return Claim

FindFirst() public method

Retrieves the first Claim where Claim.Type equals type.
Comparison is: StringComparison.OrdinalIgnoreCase.
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

Populates the specified SerializationInfo with the serialization data for the ClaimsIdentity
Thrown if the info parameter is null.
protected GetObjectData ( SerializationInfo info, StreamingContext context ) : void
info SerializationInfo The serialization information stream to write to. Satisfies ISerializable contract.
context StreamingContext Context for serialization. Can be null.
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 this ClaimsIdentity.
if 'match' is null.
public HasClaim ( Predicate match ) : bool
match Predicate The function 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 with type AND value is contained within this ClaimsIdentity.
Comparison is: StringComparison.OrdinalIgnoreCase for Claim.Type, StringComparison.Ordinal for Claim.Value.
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

RemoveClaim() public method

It is possible that a Claim returned from Claims cannot be removed. This would be the case for 'External' claims that are provided by reference.

object.ReferenceEquals is used to 'match'.

if 'claim' cannot be removed.
public RemoveClaim ( Claim claim ) : void
claim Claim the to match.
return void

TryRemoveClaim() public method

It is possible that a Claim returned from Claims cannot be removed. This would be the case for 'External' claims that are provided by reference.

object.ReferenceEquals is used to 'match'.

public TryRemoveClaim ( Claim claim ) : bool
claim Claim the to match.
return bool

WriteTo() public method

Serializes using a BinaryWriter
if 'writer' is null.
public WriteTo ( BinaryWriter writer ) : void
writer BinaryWriter the to use for data storage.
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