Class ClaimsUtil
Summary description for ClaimsUtil.
Inheritance
System.Object
ClaimsUtil
Assembly: ImageVault.Common.dll
Syntax
public static class ClaimsUtil : Object
Fields
AdfsGroupClaimType
Declaration
public const string AdfsGroupClaimType = "http://schemas.xmlsoap.org/claims/Group"
Field Value
Type |
Description |
System.String |
|
ClientId
The claim defining the client id that the user ticket is created by
Declaration
public const string ClientId = "http://schemas.imagevault.se/ws/2016/identity/claims/clientId"
Field Value
Type |
Description |
System.String |
|
ClientIdentityClaimType
Declaration
public const string ClientIdentityClaimType = "http://schemas.imagevault.se/ws/2016/identity/claims/clientidentity"
Field Value
Type |
Description |
System.String |
|
ExternalLoginProvider
Claim type to determine the current external login provider
Declaration
public const string ExternalLoginProvider = "http://schemas.imagevault.se/ws/2016/identity/claims/externalLoginProvider"
Field Value
Type |
Description |
System.String |
|
GroupClaimType
Declaration
public const string GroupClaimType = "http://schemas.microsoft.com/ws/2008/06/identity/claims/groups"
Field Value
Type |
Description |
System.String |
|
HostManagementClaimType
A constant for a Host management claim type
Declaration
public const string HostManagementClaimType = "http://schemas.imagevault.se/ws/2016/identity/claims/hostManagementClaimType"
Field Value
Type |
Description |
System.String |
|
ImpersonatingClientClaimType
Declaration
public const string ImpersonatingClientClaimType = "http://schemas.imagevault.se/ws/2016/identity/claims/impersonatingclient"
Field Value
Type |
Description |
System.String |
|
IsApproved
Claim type to determine if the current user is approved or not
Declaration
public const string IsApproved = "http://schemas.imagevault.se/ws/2016/identity/claims/isApproved"
Field Value
Type |
Description |
System.String |
|
IsApprovedTrueValue
Value for the IsApproved claim type to indicate a true value
Declaration
public const string IsApprovedTrueValue = "true"
Field Value
Type |
Description |
System.String |
|
StringValueType
The value type for string claim values
Declaration
public const string StringValueType = "http://www.w3.org/2001/XMLSchema#string"
Field Value
Type |
Description |
System.String |
|
Methods
CreateClaims(String, IList<String>)
Creates claims of a specific type
Declaration
public static IEnumerable<Claim> CreateClaims(string type, IList<string> values)
Parameters
Type |
Name |
Description |
System.String |
type |
|
System.Collections.Generic.IList<System.String> |
values |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> |
|
CreatePrincipal(String, String, IList<String>, String)
Declaration
public static ClaimsPrincipal CreatePrincipal(string authenticationType, string name, IList<string> roles = null, string impersonatingClient = null)
Parameters
Type |
Name |
Description |
System.String |
authenticationType |
The authentication type to use. If null is supplied, the System.Security.Principal.IIdentity.IsAuthenticated will return null.
|
System.String |
name |
|
System.Collections.Generic.IList<System.String> |
roles |
|
System.String |
impersonatingClient |
|
Returns
Type |
Description |
System.Security.Claims.ClaimsPrincipal |
|
GetClaims(IIdentity)
Gets the claims from the supplied System.Security.Principal.IIdentity
Declaration
public static IEnumerable<Claim> GetClaims(IIdentity identity)
Parameters
Type |
Name |
Description |
System.Security.Principal.IIdentity |
identity |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> |
|
GetClaims(IPrincipal, Boolean)
Get the claims from the supplied principal
Declaration
public static IEnumerable<Claim> GetClaims(IPrincipal principal, bool ignoreIdentity = false)
Parameters
Type |
Name |
Description |
System.Security.Principal.IPrincipal |
principal |
The principal to get claims from
|
System.Boolean |
ignoreIdentity |
If true, the underlying identity is never checked if the principal isn't a System.Security.Claims.ClaimsPrincipal
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> |
The System.Collections.Generic.IEnumerable<> of System.Security.Claims.Claim found
|
GetClaimValue(IEnumerable<Claim>, String)
Gets the claim value for a specified type
Declaration
public static string GetClaimValue(IEnumerable<Claim> claims, string type)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> |
claims |
|
System.String |
type |
|
Returns
Type |
Description |
System.String |
|
GetClaimValue(IPrincipal, String)
Gets the claim value for a specified type
Declaration
public static string GetClaimValue(IPrincipal principal, string type)
Parameters
Type |
Name |
Description |
System.Security.Principal.IPrincipal |
principal |
|
System.String |
type |
|
Returns
Type |
Description |
System.String |
|
GetClaimValues(IEnumerable<Claim>, String)
Get the claim values from the supplied claims that matches the claim type
Declaration
public static IEnumerable<string> GetClaimValues(IEnumerable<Claim> claims, string type)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> |
claims |
|
System.String |
type |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.String> |
|
GetImpersonatingClient(IEnumerable<Claim>)
Declaration
public static string GetImpersonatingClient(IEnumerable<Claim> claims)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> |
claims |
|
Returns
Type |
Description |
System.String |
|
GetImpersonatingClient(IIdentity)
Gets the impersonating client claim value if the identity has one.
Declaration
public static string GetImpersonatingClient(IIdentity identity)
Parameters
Type |
Name |
Description |
System.Security.Principal.IIdentity |
identity |
|
Returns
Type |
Description |
System.String |
|
GetImpersonatingClient(IPrincipal)
Gets the impersonating client claim value if the principal has one.
Declaration
public static string GetImpersonatingClient(IPrincipal principal)
Parameters
Type |
Name |
Description |
System.Security.Principal.IPrincipal |
principal |
|
Returns
Type |
Description |
System.String |
|
GetName(ClaimsIdentity)
Gets the name of a claims identity
Declaration
public static string GetName(ClaimsIdentity claimsIdentity)
Parameters
Type |
Name |
Description |
System.Security.Claims.ClaimsIdentity |
claimsIdentity |
|
Returns
Type |
Description |
System.String |
|
GetNameIdentifier(IPrincipal)
Declaration
public static string GetNameIdentifier(IPrincipal principal)
Parameters
Type |
Name |
Description |
System.Security.Principal.IPrincipal |
principal |
|
Returns
Type |
Description |
System.String |
|
GetRoles(IEnumerable<Claim>, String)
Gets the roles in the supplied claims
Declaration
public static string[] GetRoles(IEnumerable<Claim> claims, string type)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> |
claims |
|
System.String |
type |
|
Returns
Type |
Description |
System.String[] |
|
GetRoles(IIdentity)
Gets the roles in the supplied identity
Declaration
public static string[] GetRoles(IIdentity identity)
Parameters
Type |
Name |
Description |
System.Security.Principal.IIdentity |
identity |
|
Returns
Type |
Description |
System.String[] |
|
GetRoles(IPrincipal)
Gets the roles in the supplied principal
Declaration
public static string[] GetRoles(IPrincipal principal)
Parameters
Type |
Name |
Description |
System.Security.Principal.IPrincipal |
principal |
|
Returns
Type |
Description |
System.String[] |
|
HasClaim(IEnumerable<Claim>, String, String)
Checks if a specific claim type/value exists in the list of claims
Declaration
public static bool HasClaim(IEnumerable<Claim> claims, string type, string value)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> |
claims |
|
System.String |
type |
|
System.String |
value |
|
Returns
Type |
Description |
System.Boolean |
|
HasClaim(IPrincipal, String, String)
Checks if the principal has a matching claim
Declaration
public static bool HasClaim(IPrincipal principal, string type, string value)
Parameters
Type |
Name |
Description |
System.Security.Principal.IPrincipal |
principal |
|
System.String |
type |
|
System.String |
value |
|
Returns
Type |
Description |
System.Boolean |
|