本文整理汇总了C#中System.Security.Claims.ClaimsPrincipal.FindAll方法的典型用法代码示例。如果您正苦于以下问题:C# ClaimsPrincipal.FindAll方法的具体用法?C# ClaimsPrincipal.FindAll怎么用?C# ClaimsPrincipal.FindAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Claims.ClaimsPrincipal
的用法示例。
在下文中一共展示了ClaimsPrincipal.FindAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Transform
public IPrincipal Transform(ClaimsPrincipal principal)
{
var roles = principal
.FindAll(ClaimTypes.Role)
.Select(x => x.Value)
.ToArray();
return new SamplePrincipal(principal.Identity, roles);
}
示例2: ScopePresent
private bool ScopePresent(ClaimsPrincipal principal)
{
foreach (var scope in principal.FindAll("scope"))
{
if (_requiredScopes.Contains(scope.Value))
{
return true;
}
}
return false;
}
示例3: ScopesFound
private bool ScopesFound(ClaimsPrincipal principal)
{
var scopeClaims = principal.FindAll(_options.ScopeClaimType);
if (scopeClaims == null || !scopeClaims.Any())
{
return false;
}
foreach (var scope in scopeClaims)
{
if (_options.AllowedScopes.Contains(scope.Value, StringComparer.Ordinal))
{
return true;
}
}
return false;
}
示例4: FilterInternalClaims
private IEnumerable<Claim> FilterInternalClaims(ClaimsPrincipal principal)
{
return principal.FindAll(c =>
c.Type != "exp" &&
c.Type != "nbf" &&
c.Type != "iss" &&
c.Type != "aud");
}
示例5: GetUserRoles
private static IEnumerable<UserRole> GetUserRoles(ClaimsPrincipal principal)
{
var roleClaims = principal.FindAll(ClaimTypes.Role);
foreach (var claim in roleClaims)
{
UserRole role;
if (Enum.TryParse(claim.Value, true, out role))
{
yield return role;
}
}
}
示例6: GetOutputClaims
public static List<Claim> GetOutputClaims(ClaimsPrincipal principal, RequestDetails requestDetails, IClaimsRepository claimsRepository)
{
var name = principal.FindAll(ClaimTypes.Name).First().Value;
var nameId = new Claim(ClaimTypes.NameIdentifier, name);
var userClaims = new List<Claim>
{
new Claim(ClaimTypes.Name, name),
nameId,
new Claim(ClaimTypes.AuthenticationMethod, principal.FindAll(ClaimTypes.AuthenticationMethod).First().Value),
AuthenticationInstantClaim.Now
};
userClaims.AddRange(claimsRepository.GetClaims(principal, requestDetails));
return userClaims;
}
示例7: ProcessClaims
public IEnumerable<Claim> ProcessClaims(ClaimsPrincipal incomingPrincipal, IdentityProvider identityProvider, RequestDetails details)
{
var claims = incomingPrincipal.FindAll(c => c.Type != Constants.Claims.IdentityProvider);
return claims;
}
开发者ID:kievryan,项目名称:Thinktecture.IdentityServer.45,代码行数:5,代码来源:PassThruTransformationRuleRepository.cs