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


C# Tokens.SecurityKey类代码示例

本文整理汇总了C#中System.IdentityModel.Tokens.SecurityKey的典型用法代码示例。如果您正苦于以下问题:C# SecurityKey类的具体用法?C# SecurityKey怎么用?C# SecurityKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SecurityKey类属于System.IdentityModel.Tokens命名空间,在下文中一共展示了SecurityKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ComputeSignature

 public void ComputeSignature(SecurityKey signingKey)
 {
     string signatureMethod = this.Signature.SignedInfo.SignatureMethod;
     SymmetricSecurityKey key = signingKey as SymmetricSecurityKey;
     if (key != null)
     {
         using (KeyedHashAlgorithm algorithm = key.GetKeyedHashAlgorithm(signatureMethod))
         {
             if (algorithm == null)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.IdentityModel.SR.GetString("UnableToCreateKeyedHashAlgorithm", new object[] { key, signatureMethod })));
             }
             this.ComputeSignature(algorithm);
             return;
         }
     }
     AsymmetricSecurityKey key2 = signingKey as AsymmetricSecurityKey;
     if (key2 == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.IdentityModel.SR.GetString("UnknownICryptoType", new object[] { signingKey })));
     }
     using (HashAlgorithm algorithm2 = key2.GetHashAlgorithmForSignature(signatureMethod))
     {
         if (algorithm2 == null)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.IdentityModel.SR.GetString("UnableToCreateHashAlgorithmFromAsymmetricCrypto", new object[] { signatureMethod, key2 })));
         }
         AsymmetricSignatureFormatter signatureFormatter = key2.GetSignatureFormatter(signatureMethod);
         if (signatureFormatter == null)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.IdentityModel.SR.GetString("UnableToCreateSignatureFormatterFromAsymmetricCrypto", new object[] { signatureMethod, key2 })));
         }
         this.ComputeSignature(algorithm2, signatureFormatter, signatureMethod);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:35,代码来源:SignedXml.cs

示例2: TryResolveSecurityKeyCore

        /// <summary>
        /// Inherited from <see cref="SecurityTokenResolver"/>.
        /// </summary>
        protected override bool TryResolveSecurityKeyCore( SecurityKeyIdentifierClause keyIdentifierClause, out SecurityKey key )
        {
            if ( keyIdentifierClause == null )
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull( "keyIdentifierClause" );
            }

            key = null;

            X509RawDataKeyIdentifierClause rawDataClause = keyIdentifierClause as X509RawDataKeyIdentifierClause;
            if ( rawDataClause != null )
            {
                key = rawDataClause.CreateKey();
                return true;
            }

            RsaKeyIdentifierClause rsaClause = keyIdentifierClause as RsaKeyIdentifierClause;
            if ( rsaClause != null )
            {
                key = rsaClause.CreateKey();
                return true;
            }

            if ( _wrappedTokenResolver.TryResolveSecurityKey( keyIdentifierClause, out key ) )
            {
                return true;
            }

            return false;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:33,代码来源:IssuerTokenResolver.cs

示例3: InitCrypto

 private void InitCrypto(SecurityKey securityKey)
 {
     m_securityKey = securityKey;
     List<SecurityKey> securityKeys = new List<SecurityKey>(1);
     securityKeys.Add(securityKey);
     m_securityKeys = securityKeys.AsReadOnly();
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:InfoCardProofToken.cs

示例4: EncryptingCredentials

        /// <summary>
        /// Constructs an EncryptingCredentials with a security key, a security key identifier and
        /// the encryption algorithm.
        /// </summary>
        /// <param name="key">A security key for encryption.</param>
        /// <param name="keyIdentifier">A security key identifier for the encryption key.</param>
        /// <param name="algorithm">The encryption algorithm.</param>
        /// <exception cref="ArgumentNullException">When key is null.</exception>
        /// <exception cref="ArgumentNullException">When key identifier is null.</exception>
        /// <exception cref="ArgumentNullException">When algorithm is null.</exception>
        public EncryptingCredentials(SecurityKey key, SecurityKeyIdentifier keyIdentifier, string algorithm)
        {
            if (key == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("key");
            }

            if (keyIdentifier == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("keyIdentifier");
            }

            if (string.IsNullOrEmpty(algorithm))
            {
                throw DiagnosticUtility.ThrowHelperArgumentNullOrEmptyString("algorithm");
            }

            //
            // It is possible that keyIdentifier is pointing to a token which 
            // is not capable of doing the given algorithm, we have no way verify 
            // that at this level.
            //
            _algorithm = algorithm;
            _key = key;
            _keyIdentifier = keyIdentifier;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:36,代码来源:EncryptingCredentials.cs

示例5: SigningCredentials

		public SigningCredentials (SecurityKey signingKey, string signatureAlgorithm, string digestAlgorithm, SecurityKeyIdentifier signingKeyIdentifier)
			: this (signingKey, signatureAlgorithm, digestAlgorithm)
		{
			if (signingKeyIdentifier == null)
				throw new ArgumentNullException ("signingKeyIdentifier");
			this.identifier = signingKeyIdentifier;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:SigningCredentials.cs

示例6: TryResolveSecurityKey

 public bool TryResolveSecurityKey(SecurityKeyIdentifierClause keyIdentifierClause, out SecurityKey key)
 {
     if (keyIdentifierClause == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("keyIdentifierClause");
     }
     return this.TryResolveSecurityKeyCore(keyIdentifierClause, out key);
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:8,代码来源:SecurityTokenResolver.cs

示例7: BinarySecretSecurityToken

		protected BinarySecretSecurityToken (string id, byte [] key, bool allowCrypto)
			: this (id, allowCrypto)
		{
			if (key == null)
				throw new ArgumentNullException ("key");
			this.key = key;

			SecurityKey [] arr = new SecurityKey [] {new InMemorySymmetricSecurityKey (key)};
			keys = new ReadOnlyCollection<SecurityKey> (arr);
		}
开发者ID:nickchal,项目名称:pash,代码行数:10,代码来源:BinarySecretSecurityToken.cs

示例8: SwtIssuerTokenResolver

		public SwtIssuerTokenResolver()
		{
			var signValue = ConfigurationManager.AppSettings[SigningKeyAppSetting];
			if (string.IsNullOrEmpty(signValue))
				throw new InvalidSecurityException(string.Format(
					"Required appSettings key '{0}' containing the 256-bit symmetric key for token signing was not found.",
					SigningKeyAppSetting));

			this.key = new InMemorySymmetricSecurityKey(Convert.FromBase64String(signValue));
		}
开发者ID:KonstantinDavidov,项目名称:mytestRep,代码行数:10,代码来源:SwtIssuerTokenResolver.cs

示例9: TryResolveSecurityKeyCore

		protected override bool TryResolveSecurityKeyCore (
			SecurityKeyIdentifierClause keyIdentifierClause,
			out SecurityKey key)
		{
			key = null;
			foreach (SecurityTokenResolver r in resolvers)
				if (r != null && r.TryResolveSecurityKey (keyIdentifierClause, out key))
					return true;
			return false;
		}
开发者ID:nickchal,项目名称:pash,代码行数:10,代码来源:UnionSecurityTokenResolver.cs

示例10: TryResolveSecurityKeyCore

 protected override bool TryResolveSecurityKeyCore(SecurityKeyIdentifierClause keyIdentifierClause, out SecurityKey key)
 {
     SecurityToken token;
     if (this.TryResolveTokenCore(keyIdentifierClause, out token))
     {
         key = ((SecurityContextSecurityToken) token).SecurityKeys[0];
         return true;
     }
     key = null;
     return false;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:SecurityContextSecurityTokenResolver.cs

示例11: TryResolveSecurityKeyCore

		protected override bool TryResolveSecurityKeyCore(SecurityKeyIdentifierClause keyIdentifierClause, out SecurityKey key)
		{
			// We pass ourselves a SwtSecurityKeyClause from the SwtSecurityTokenHandler on ValidateToken.
			var nameClause = keyIdentifierClause as SwtSecurityKeyClause;

			// If it wasn't us passing the clause, let the base class handle other built-in scenarios (i.e. X509)
			if (nameClause == null)
				return base.TryResolveSecurityKeyCore(keyIdentifierClause, out key);

			key = this.key;
			return true;
		}
开发者ID:KonstantinDavidov,项目名称:mytestRep,代码行数:12,代码来源:SwtIssuerTokenResolver.cs

示例12: TryResolveSecurityKeyCore

        protected override bool TryResolveSecurityKeyCore(SecurityKeyIdentifierClause keyIdentifierClause, out SecurityKey key)
        {
            key = null;
            var swtClause = keyIdentifierClause as WebTokenSecurityKeyClause;

            string value;
            if (_signingKeys.TryGetValue(swtClause.Issuer.ToLowerInvariant(), out value))
            {
                key = new InMemorySymmetricSecurityKey(Convert.FromBase64String(value));

                return true;
            }

            return false;
        }
开发者ID:bencoveney,项目名称:Thinktecture.IdentityModel.40,代码行数:15,代码来源:WebTokenIssuerTokenResolver.cs

示例13: TryResolveSecurityKeyCore

        protected override bool TryResolveSecurityKeyCore(SecurityKeyIdentifierClause keyIdentifierClause, out SecurityKey key)
        {
            key = null;
            CustomTokenKeyIdentifierClause keyClause = keyIdentifierClause as CustomTokenKeyIdentifierClause;
            if (keyClause != null)
            {
                string base64Key = null;
                _keys.TryGetValue(keyClause.Audience, out base64Key);
                if (!string.IsNullOrEmpty(base64Key))
                {
                    key = new InMemorySymmetricSecurityKey(Encoding.UTF8.GetBytes(base64Key));
                    return true;
                }
            }

            return false;
        }
开发者ID:driverpt,项目名称:SI-1213SI,代码行数:17,代码来源:CustomIssuerTokenResolver.cs

示例14: NamedKeySecurityToken

        /// <summary>
        /// Initializes a new instance of the <see cref="NamedKeySecurityToken"/> class that contains a single <see cref="SecurityKey"/>.
        /// </summary>
        /// <param name="name">A name for the <see cref="SecurityKey"/>.</param>
        /// <param name="id">the identifier for this token.</param>
        /// <param name="key">A <see cref="SecurityKey"/></param>
        /// <exception cref="ArgumentNullException">if 'name' is null or whitespace.</exception>
        /// <exception cref="ArgumentNullException">if 'id' is null or whitespace.</exception>
        /// <exception cref="ArgumentNullException">if 'key' is null.</exception>
        public NamedKeySecurityToken(string name, string id, SecurityKey key)
        {
            if (string.IsNullOrWhiteSpace(name))
                throw new ArgumentNullException("name");

            if (string.IsNullOrWhiteSpace(id))
                throw new ArgumentNullException("id");

            if (key == null)
                throw new ArgumentNullException("key");

            this.id = id;
            this.name = name;
            this.securityKeys = new List<SecurityKey>{key};
            this.validFrom = DateTime.UtcNow;

        }
开发者ID:richardschneider,项目名称:azure-activedirectory-identitymodel-extensions-for-dotnet,代码行数:26,代码来源:NamedKeySecurityToken.cs

示例15: TryResolveSecurityKeyCore

        /// <summary>
        /// Override of the base class. Resolves the given SecurityKeyIdentifierClause to a 
        /// SecurityKey.
        /// </summary>
        /// <param name="keyIdentifierClause">The Clause to be resolved.</param>
        /// <param name="key">The resolved SecurityKey</param>
        /// <returns>True if successfully resolved.</returns>
        /// <exception cref="ArgumentNullException">Input argument 'keyIdentifierClause' is null.</exception>
        protected override bool TryResolveSecurityKeyCore( SecurityKeyIdentifierClause keyIdentifierClause, out SecurityKey key )
        {
            if ( keyIdentifierClause == null )
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull( "keyIdentifierClause" );
            }

            key = null;
            foreach ( SecurityTokenResolver tokenResolver in _tokenResolvers )
            {
                if ( tokenResolver.TryResolveSecurityKey( keyIdentifierClause, out key ) )
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:26,代码来源:AggregateTokenResolver.cs


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