本文整理汇总了C#中System.IdentityModel.Tokens.SecurityToken.CanCreateKeyIdentifierClause方法的典型用法代码示例。如果您正苦于以下问题:C# SecurityToken.CanCreateKeyIdentifierClause方法的具体用法?C# SecurityToken.CanCreateKeyIdentifierClause怎么用?C# SecurityToken.CanCreateKeyIdentifierClause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IdentityModel.Tokens.SecurityToken
的用法示例。
在下文中一共展示了SecurityToken.CanCreateKeyIdentifierClause方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetExternalSecurityKeyIdentifier
// This method returns a security key identifier that can be used to refer to the provided security token when
// the provided token does not appear in the message
private SecurityKeyIdentifier GetExternalSecurityKeyIdentifier(SecurityToken t)
{
// If t is null, we're toast
if (t == null)
throw new ArgumentNullException("t");
// Set skiClause to null
SecurityKeyIdentifierClause skiClause = null;
// Try for an encrypted key reference first...
if (t.CanCreateKeyIdentifierClause<EncryptedKeyIdentifierClause>())
{
Console.WriteLine("GetExternalSecurityKeyIdentifier using EncryptedKeyIdentifierClause");
skiClause = t.CreateKeyIdentifierClause<EncryptedKeyIdentifierClause>();
}
// ... kerb token reference next...
else if (t.CanCreateKeyIdentifierClause<KerberosTicketHashKeyIdentifierClause>())
{
Console.WriteLine("GetExternalSecurityKeyIdentifier using KerberosTicketHashKeyIdentifierClause");
skiClause = t.CreateKeyIdentifierClause<KerberosTicketHashKeyIdentifierClause>();
}
// ... X509 thumbprint next...
else if (t.CanCreateKeyIdentifierClause<X509ThumbprintKeyIdentifierClause>())
{
Console.WriteLine("GetExternalSecurityKeyIdentifier using X509ThumbprintKeyIdentifierClause");
skiClause = t.CreateKeyIdentifierClause<X509ThumbprintKeyIdentifierClause>();
}
// ... X509 raw reference next...
else if (t.CanCreateKeyIdentifierClause<X509RawDataKeyIdentifierClause>())
{
Console.WriteLine("GetExternalSecurityKeyIdentifier using X509RawDataKeyIdentifierClause");
skiClause = t.CreateKeyIdentifierClause<X509RawDataKeyIdentifierClause>();
}
// ... X509 SKI next...
else if (t.CanCreateKeyIdentifierClause<X509SubjectKeyIdentifierClause>())
{
Console.WriteLine("GetExternalSecurityKeyIdentifier using X509SubjectKeyIdentifierClause");
skiClause = t.CreateKeyIdentifierClause<X509SubjectKeyIdentifierClause>();
}
// ... try for a binary secret...
else if (t.CanCreateKeyIdentifierClause<BinarySecretKeyIdentifierClause>())
{
Console.WriteLine("GetExternalSecurityKeyIdentifier using BinarySecretKeyIdentifierClause");
skiClause = t.CreateKeyIdentifierClause<BinarySecretKeyIdentifierClause>();
}
// ... then a X509IssuerSerial reference ...
else if (t.CanCreateKeyIdentifierClause<X509IssuerSerialKeyIdentifierClause>())
{
Console.WriteLine("GetExternalSecurityKeyIdentifier using X509IssuerSerialKeyIdentifierClause");
skiClause = t.CreateKeyIdentifierClause<X509IssuerSerialKeyIdentifierClause>();
}
// ... then a SAML assertion reference...
else if (t.CanCreateKeyIdentifierClause<SamlAssertionKeyIdentifierClause>())
{
Console.WriteLine("GetExternalSecurityKeyIdentifier using SamlAssertionKeyIdentifierClause");
skiClause = t.CreateKeyIdentifierClause<SamlAssertionKeyIdentifierClause>();
}
// ... then an RSA key reference...
else if (t.CanCreateKeyIdentifierClause<RsaKeyIdentifierClause>())
{
Console.WriteLine("GetExternalSecurityKeyIdentifier using RsaKeyIdentifierClause");
skiClause = t.CreateKeyIdentifierClause<RsaKeyIdentifierClause>();
}
// ... then a key name reference...
else if (t.CanCreateKeyIdentifierClause<KeyNameIdentifierClause>())
{
Console.WriteLine("GetExternalSecurityKeyIdentifier using KeyNameIdentifierClause");
skiClause = t.CreateKeyIdentifierClause<KeyNameIdentifierClause>();
}
// ... and finally an SCT reference...
else if (t.CanCreateKeyIdentifierClause<SecurityContextKeyIdentifierClause>())
{
Console.WriteLine("GetExternalSecurityKeyIdentifier using SecurityContextKeyIdentifierClause");
skiClause = t.CreateKeyIdentifierClause<SecurityContextKeyIdentifierClause>();
}
// return a SecurityKeyIdentifier
return new SecurityKeyIdentifier(skiClause);
}
示例2: CreateKeyIdentifierClause
protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (
SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
{
if (token == null)
throw new ArgumentNullException ("token");
if (referenceStyle == SecurityTokenReferenceStyle.Internal)
return new LocalIdKeyIdentifierClause (token.Id, token.GetType ());
switch (reference_style) {
default:
return token.CreateKeyIdentifierClause<X509IssuerSerialKeyIdentifierClause> ();
case X509KeyIdentifierClauseType.Thumbprint:
return token.CreateKeyIdentifierClause<X509ThumbprintKeyIdentifierClause> ();
case X509KeyIdentifierClauseType.SubjectKeyIdentifier:
return token.CreateKeyIdentifierClause<X509SubjectKeyIdentifierClause> ();
case X509KeyIdentifierClauseType.RawDataKeyIdentifier:
return token.CreateKeyIdentifierClause<X509RawDataKeyIdentifierClause> ();
case X509KeyIdentifierClauseType.Any:
if (token.CanCreateKeyIdentifierClause<X509SubjectKeyIdentifierClause> ())
goto case X509KeyIdentifierClauseType.SubjectKeyIdentifier;
goto default;
}
}
示例3: GetInternalSecurityKeyIdentifier
// This method returns a security key identifier that can be used to refer to the provided security token when
// the provided token appears in the message
private SecurityKeyIdentifier GetInternalSecurityKeyIdentifier(SecurityToken t)
{
// If t is null, we're toast
if ( t == null )
throw new ArgumentNullException ( "t" );
// Set skiClause to null
SecurityKeyIdentifierClause skiClause = null;
// Try for a local id reference first...
if (t.CanCreateKeyIdentifierClause<LocalIdKeyIdentifierClause>())
{
Console.WriteLine("GetInternalSecurityKeyIdentifier using LocalIdKeyIdentifierClause");
skiClause = t.CreateKeyIdentifierClause<LocalIdKeyIdentifierClause>();
// return a SecurityKeyIdentifier
return new SecurityKeyIdentifier(skiClause);
}
else
return GetExternalSecurityKeyIdentifier ( t );
}