//----------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------- namespace System.IdentityModel.Tokens { using System.Security.Cryptography.X509Certificates; /// /// Use x509 token as the encrypting credential. This is usually used as key wrapping credentials. /// public class X509EncryptingCredentials : EncryptingCredentials { private X509Certificate2 certificate; /// /// Constructs an encrypting credential based on the x509 certificate. /// /// The x509 certificate. public X509EncryptingCredentials(X509Certificate2 certificate) : this(new X509SecurityToken(certificate)) { } /// /// Constructs an encrypting credential based on the x509 certificate and key wrapping algorithm. /// /// The x509 certificate. /// The key wrapping al----htm. public X509EncryptingCredentials(X509Certificate2 certificate, string keyWrappingAlgorithm) : this(new X509SecurityToken(certificate), keyWrappingAlgorithm) { } /// /// Constructs an encrypting credential based on the x509 certificate and security key identifier. /// /// The x509 certificate. /// /// The security key identifier to be used. public X509EncryptingCredentials(X509Certificate2 certificate, SecurityKeyIdentifier ski) : this(new X509SecurityToken(certificate), ski, SecurityAlgorithms.DefaultAsymmetricKeyWrapAlgorithm) { } /// /// Constructs an encrypting credential based on the x509 certificate, key wrapping algorithm, and security key identifier. /// /// The x509 certificate. /// The security key identifier to be used. /// The key wrapping al----htm. public X509EncryptingCredentials(X509Certificate2 certificate, SecurityKeyIdentifier ski, string keyWrappingAlgorithm) : this(new X509SecurityToken(certificate), ski, keyWrappingAlgorithm) { } /// /// Constructs an encrypting credential based on the x509 token. /// /// The x509 security token. internal X509EncryptingCredentials(X509SecurityToken token) : this( token, new SecurityKeyIdentifier(token.CreateKeyIdentifierClause()), SecurityAlgorithms.DefaultAsymmetricKeyWrapAlgorithm) { } /// /// Constructs an encrypting credential based on the x509 token and key wrapping algorithm. /// /// The x509 security token. /// The key wrapping al----htm. internal X509EncryptingCredentials(X509SecurityToken token, string keyWrappingAlgorithm) : this(token, new SecurityKeyIdentifier(token.CreateKeyIdentifierClause()), keyWrappingAlgorithm) { } /// /// Constructs an encrypting credential based on the x509 token, key wrapping algorithm, and security key identifier. /// /// The x509 security token. /// The security key identifier to be used. /// The key wrapping al----htm. internal X509EncryptingCredentials(X509SecurityToken token, SecurityKeyIdentifier ski, string keyWrappingAlgorithm) : base(token.SecurityKeys[0], ski, keyWrappingAlgorithm) { this.certificate = token.Certificate; } /// /// Gets the x509 certificate. /// public X509Certificate2 Certificate { get { return this.certificate; } } } }