当前位置: 首页>>代码示例>>C#>>正文


C# SecurityToken.CanCreateKeyIdentifierClause方法代码示例

本文整理汇总了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);
        }
开发者ID:ssickles,项目名称:archive,代码行数:82,代码来源:SecurityTokenService.cs

示例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;
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:24,代码来源:X509SecurityTokenParameters.cs

示例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 );
            
            
        }
开发者ID:ssickles,项目名称:archive,代码行数:25,代码来源:SecurityTokenService.cs


注:本文中的System.IdentityModel.Tokens.SecurityToken.CanCreateKeyIdentifierClause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。