本文整理汇总了C#中ClaimSet.FindClaims方法的典型用法代码示例。如果您正苦于以下问题:C# ClaimSet.FindClaims方法的具体用法?C# ClaimSet.FindClaims怎么用?C# ClaimSet.FindClaims使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClaimSet
的用法示例。
在下文中一共展示了ClaimSet.FindClaims方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetStringClaimValue
bool TryGetStringClaimValue(ClaimSet claimSet, string claimType, out string claimValue)
{
claimValue = null;
IEnumerable<Claim> matchingClaims = claimSet.FindClaims(claimType, Rights.PossessProperty);
if (matchingClaims == null)
return false;
IEnumerator<Claim> enumerator = matchingClaims.GetEnumerator();
enumerator.MoveNext();
claimValue = (enumerator.Current.Resource == null) ? null : enumerator.Current.Resource.ToString();
return true;
}
示例2: CheckDnsEquivalence
internal Claim CheckDnsEquivalence(ClaimSet claimSet, string expectedSpn)
{
// host/<machine-name> satisfies the DNS identity claim
IEnumerable<Claim> claims = claimSet.FindClaims(ClaimTypes.Spn, Rights.PossessProperty);
foreach (Claim claim in claims)
{
if (expectedSpn.Equals((string)claim.Resource, StringComparison.OrdinalIgnoreCase))
{
return claim;
}
}
return null;
}
示例3: GetUniqueRsaClaim
/// <summary>
/// Gets the Unique RSA Claim from the SAML token.
/// </summary>
/// <param name="cs">the claimset which contains the claim</param>
/// <returns>a RSA claim</returns>
private static Claim GetUniqueRsaClaim(ClaimSet cs) {
Requires.NotNull(cs, "cs");
Claim rsa = null;
foreach (Claim c in cs.FindClaims(ClaimTypes.Rsa, Rights.PossessProperty)) {
if (null == rsa) {
rsa = c;
} else if (!rsa.Equals(c)) {
// Found two non-equal RSA claims
return null;
}
}
return rsa;
}
示例4: CreateIdentityFromClaimSet
/// <summary>
/// Utility function to create an EndpointIdentity from a ClaimSet
/// </summary>
/// <param name="claims">Claims to create the EndpointIdentity with</param>
/// <returns>An EndpointIdentity</returns>
private EndpointIdentity CreateIdentityFromClaimSet(ClaimSet claims)
{
foreach (Claim claim in claims.FindClaims(null, Rights.Identity))
{
return EndpointIdentity.CreateIdentity(claim);
}
return null;
}
示例5: GetUniqueRsaClaim
/// <summary>
/// Gets the Unique RSA Claim from the SAML token.
/// </summary>
/// <param name="cs">the claimset which contains the claim</param>
/// <returns>a RSA claim</returns>
private static Claim GetUniqueRsaClaim(ClaimSet cs)
{
Contract.Requires(cs != null);
ErrorUtilities.VerifyArgumentNotNull(cs, "cs");
Claim rsa = null;
foreach (Claim c in cs.FindClaims(ClaimTypes.Rsa, Rights.PossessProperty)) {
if (null == rsa) {
rsa = c;
} else if (!rsa.Equals(c)) {
// Found two non-equal RSA claims
return null;
}
}
return rsa;
}
示例6: CheckDnsEquivalence
Claim CheckDnsEquivalence(ClaimSet claimSet, string expedtedDns)
{
IEnumerable<Claim> claims = claimSet.FindClaims(ClaimTypes.Dns, Rights.PossessProperty);
foreach (Claim claim in claims)
{
// 格外允许"localhost"
if (expedtedDns.Equals("localhost", StringComparison.OrdinalIgnoreCase))
{
return claim;
}
string strCurrent = (string)claim.Resource;
// 格外允许"DigitalPlatform"和任意出发字符串匹配
if (strCurrent.Equals("DigitalPlatform", StringComparison.OrdinalIgnoreCase))
return claim;
if (expedtedDns.Equals(strCurrent, StringComparison.OrdinalIgnoreCase))
{
return claim;
}
}
return null;
}
示例7: CheckDnsEquivalence
private Claim CheckDnsEquivalence(ClaimSet claimSet, string expectedSpn)
{
foreach (Claim claim in claimSet.FindClaims(ClaimTypes.Spn, Rights.PossessProperty))
{
if (expectedSpn.Equals((string) claim.Resource, StringComparison.OrdinalIgnoreCase))
{
return claim;
}
}
return null;
}