本文整理汇总了C#中ClaimSet类的典型用法代码示例。如果您正苦于以下问题:C# ClaimSet类的具体用法?C# ClaimSet怎么用?C# ClaimSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClaimSet类属于命名空间,在下文中一共展示了ClaimSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1:
Task<IAccessToken> INonCachingAccessTokenProvider.ProvisionAccessTokenAsync(
ClaimSet claimSet,
IEnumerable<Scope> scopes
) {
var @this = this as INonCachingAccessTokenProvider;
return @this.ProvisionAccessTokenAsync( claimSet.ToClaims(), scopes );
}
示例2: CreatePolicy
public override IAuthorizationPolicy CreatePolicy(ClaimSet issuer, SamlSecurityTokenAuthenticator samlAuthenticator)
{
if (issuer == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("issuer");
}
if (this.policy == null)
{
List<ClaimSet> list = new List<ClaimSet>();
ClaimSet item = this.subject.ExtractSubjectKeyClaimSet(samlAuthenticator);
if (item != null)
{
list.Add(item);
}
List<Claim> claims = new List<Claim>();
ReadOnlyCollection<Claim> onlys = this.subject.ExtractClaims();
for (int i = 0; i < onlys.Count; i++)
{
claims.Add(onlys[i]);
}
this.AddClaimsToList(claims);
list.Add(new DefaultClaimSet(issuer, claims));
this.policy = new UnconditionalPolicy(this.subject.Identity, list.AsReadOnly(), System.IdentityModel.SecurityUtils.MaxUtcDateTime);
}
return this.policy;
}
示例3:
bool IClaimSetPrincipal.HasRequiredClaims(ClaimSet requiredClaims)
{
// if issuer is null, just check claims from anyone
// if not, check issuer of claims as well
return true;
}
示例4: UnconditionalPolicy
public UnconditionalPolicy(ClaimSet issuance, DateTime expirationTime)
{
if (issuance == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("issuance");
Initialize(ClaimSet.System, issuance, null, expirationTime);
}
示例5: PeerSecurityTraceRecord
protected PeerSecurityTraceRecord(string meshId, string remoteAddress, ClaimSet claimSet, Exception exception)
{
this.meshId = meshId;
this.remoteAddress = remoteAddress;
this.claimSet = claimSet;
this.exception = exception;
}
示例6: CreatePolicy
public override IAuthorizationPolicy CreatePolicy(ClaimSet issuer, SamlSecurityTokenAuthenticator samlAuthenticator)
{
if (issuer == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("issuer");
// SupportingTokenAuthenticator collection can be null when the Subject does not
// contain a key.
if (this.policy == null)
{
List<ClaimSet> claimSets = new List<ClaimSet>();
ClaimSet subjectKeyClaimset = this.subject.ExtractSubjectKeyClaimSet(samlAuthenticator);
if (subjectKeyClaimset != null)
claimSets.Add(subjectKeyClaimset);
List<Claim> claims = new List<Claim>();
ReadOnlyCollection<Claim> subjectClaims = this.subject.ExtractClaims();
for (int i = 0; i < subjectClaims.Count; ++i)
{
claims.Add(subjectClaims[i]);
}
AddClaimsToList(claims);
claimSets.Add(new DefaultClaimSet(issuer, claims));
this.policy = new UnconditionalPolicy(this.subject.Identity, claimSets.AsReadOnly(), SecurityUtils.MaxUtcDateTime);
}
return this.policy;
}
示例7: Initialize
private void Initialize(ClaimSet issuer, ClaimSet issuance, ReadOnlyCollection<ClaimSet> issuances, DateTime expirationTime)
{
_issuer = issuer;
_issuance = issuance;
_issuances = issuances;
_expirationTime = expirationTime;
// We don't yet support WindowsClaimSet
//if (issuance != null)
//{
// _disposable = issuance is WindowsClaimSet;
//}
//else
//{
// for (int i = 0; i < issuances.Count; ++i)
// {
// if (issuances[i] is WindowsClaimSet)
// {
// this.disposable = true;
// break;
// }
// }
//}
_disposable = false;
}
示例8: HasRequiredClaims
/// <summary>
/// Has required claims
/// </summary>
/// <param name="requiredClaims">Required claim set</param>
/// <returns><value>True</value> if the issuer has the required claims <value>false</value> if it doesn't</returns>
public bool HasRequiredClaims(ClaimSet requiredClaims)
{
bool hasClaims = true;
// Make sure we have claims to check
if (this.Claims == null)
{
// Token contained no claims, do we need any?
if (requiredClaims == null || requiredClaims.Count == 0)
{
return true;
}
// Deny access
return false;
}
// check issuer
bool issuerMatch = requiredClaims.Issuer.Any(c => this.Claims.Issuer.ContainsClaim(c));
// check required claims
if (issuerMatch)
{
hasClaims = requiredClaims.All(c => this.Claims.ContainsClaim(c));
}
return issuerMatch && hasClaims;
}
示例9:
async Task<IAccessToken> IAccessTokenProvider.ProvisionAccessTokenAsync(
ClaimSet claimSet,
IEnumerable<Scope> scopes,
ICache cache
) {
var @this = this as IAccessTokenProvider;
return await @this.ProvisionAccessTokenAsync( claimSet.ToClaims(), scopes, cache ).SafeAsync();
}
示例10: CreditCardTokenAuthorizationPolicy
public CreditCardTokenAuthorizationPolicy(ClaimSet issuedClaims)
{
if (issuedClaims == null)
throw new ArgumentNullException("issuedClaims");
this.issuer = issuedClaims.Issuer;
this.issuedClaimSets = new ClaimSet[] { issuedClaims };
this.id = Guid.NewGuid().ToString();
}
示例11: CustomAuthorizationPolicy
public CustomAuthorizationPolicy()
{
m_id = Guid.NewGuid();
Claim c = Claim.CreateNameClaim("http://www.thatindigogirl.com/samples/2006/07/issuer");
Claim[] claims = new Claim[1];
claims[0] = c;
m_issuer = new DefaultClaimSet(claims);
}
示例12: SecurityTokenAuthorizationPolicy
internal SecurityTokenAuthorizationPolicy( ClaimSet issuedClaims )
{
if ( issuedClaims == null )
throw new ArgumentNullException( "issuedClaims" );
_issuer = issuedClaims.Issuer;
_issuedClaimSets = new[] { issuedClaims };
_id = Guid.NewGuid().ToString();
}
示例13: AddClaimSet
public override void AddClaimSet(IAuthorizationPolicy policy, ClaimSet claimSet)
{
if (claimSet == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("claimSet");
if (_claimSets == null)
_claimSets = new List<ClaimSet>();
_claimSets.Add(claimSet);
++_generation;
}
示例14: 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;
}
示例15: UnconditionalPolicy
public UnconditionalPolicy(ClaimSet issuer, ClaimSet issuance, DateTime expirationTime, IList<IIdentity> identities)
{
if (issuer == null)
throw new ArgumentNullException("issuer");
if (issuance == null)
throw new ArgumentNullException("issuance");
this.issuer = issuer;
this.issuance = issuance;
this.identities = identities;
this.expirationTime = expirationTime;
}