14 private string[] m_roles;
30 m_identity = identity;
33 m_roles =
new string[roles.Length];
34 for (
int i = 0; i < roles.Length; i++)
36 m_roles[i] = roles[i];
43 AddIdentityWithRoles(m_identity, m_roles);
54 claimsIdentity = identity;
58 if (m_roles !=
null && m_roles.Length != 0 && claimsIdentity !=
null)
60 claimsIdentity.ExternalClaims.Add(
new RoleClaimProvider(
"LOCAL AUTHORITY", m_roles, claimsIdentity).
Claims);
62 else if (claimsIdentity ==
null)
64 AddIdentityWithRoles(m_identity, m_roles);
68 [SecuritySafeCritical]
69 private void AddIdentityWithRoles(IIdentity identity,
string[] roles)
72 claimsIdentity = ((claimsIdentity ==
null) ?
new ClaimsIdentity(identity) : claimsIdentity.
Clone());
73 if (roles !=
null && roles.Length != 0)
75 claimsIdentity.ExternalClaims.Add(
new RoleClaimProvider(
"LOCAL AUTHORITY", roles, claimsIdentity).
Claims);
77 base.AddIdentity(claimsIdentity);
86 if (role ==
null || m_roles ==
null)
90 for (
int i = 0; i < m_roles.Length; i++)
92 if (m_roles[i] !=
null &&
string.Compare(m_roles[i], role,
StringComparison.OrdinalIgnoreCase) == 0)
97 return base.IsInRole(role);
override IIdentity Identity
Gets the T:System.Security.Principal.GenericIdentity of the user represented by the current T:System....
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
Describes the source and destination of a given serialized stream, and provides an additional caller-...
An T:System.Security.Principal.IPrincipal implementation that supports multiple claims-based identiti...
virtual IEnumerable< Claim > Claims
Gets a collection that contains all of the claims from all of the claims identities associated with t...
virtual ClaimsIdentity Clone()
Returns a new T:System.Security.Claims.ClaimsIdentity copied from this claims identity.
Represents a claims-based identity.
GenericPrincipal(IIdentity identity, string[] roles)
Initializes a new instance of the T:System.Security.Principal.GenericPrincipal class from a user iden...
override bool IsInRole(string role)
Determines whether the current T:System.Security.Principal.GenericPrincipal belongs to the specified ...
Specifies that the class can be serialized.
Defines the basic functionality of an identity object.
Represents a generic principal.