File: X509EncryptingCredentials.cs

package info (click to toggle)
mono 6.14.1%2Bds2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,282,732 kB
  • sloc: cs: 11,182,461; xml: 2,850,281; ansic: 699,123; cpp: 122,919; perl: 58,604; javascript: 30,841; asm: 21,845; makefile: 19,602; sh: 10,973; python: 4,772; pascal: 925; sql: 859; sed: 16; php: 1
file content (103 lines) | stat: -rw-r--r-- 4,618 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//-----------------------------------------------------------------------
// <copyright file="X509EncryptingCredentials.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace System.IdentityModel.Tokens
{
    using System.Security.Cryptography.X509Certificates;

    /// <summary>
    /// Use x509 token as the encrypting credential. This is usually used as key wrapping credentials.
    /// </summary>
    public class X509EncryptingCredentials : EncryptingCredentials
    {
        private X509Certificate2 certificate;

        /// <summary>
        /// Constructs an encrypting credential based on the x509 certificate.
        /// </summary>
        /// <param name="certificate">The x509 certificate.</param>
        public X509EncryptingCredentials(X509Certificate2 certificate)
            : this(new X509SecurityToken(certificate))
        {
        }

        /// <summary>
        /// Constructs an encrypting credential based on the x509 certificate and key wrapping algorithm.
        /// </summary>
        /// <param name="certificate">The x509 certificate.</param>
        /// <param name="keyWrappingAlgorithm">The key wrapping al----htm.</param>
        public X509EncryptingCredentials(X509Certificate2 certificate, string keyWrappingAlgorithm)
            : this(new X509SecurityToken(certificate), keyWrappingAlgorithm)
        {
        }

        /// <summary>
        /// Constructs an encrypting credential based on the x509 certificate and security key identifier.
        /// </summary>
        /// <param name="certificate">The x509 certificate.</param>
        /// /// <param name="ski">The security key identifier to be used.</param>
        public X509EncryptingCredentials(X509Certificate2 certificate, SecurityKeyIdentifier ski)
            : this(new X509SecurityToken(certificate), ski, SecurityAlgorithms.DefaultAsymmetricKeyWrapAlgorithm)
        {
        }

        /// <summary>
        /// Constructs an encrypting credential based on the x509 certificate, key wrapping algorithm, and security key identifier.
        /// </summary>
        /// <param name="certificate">The x509 certificate.</param>
        /// <param name="ski">The security key identifier to be used.</param>
        /// <param name="keyWrappingAlgorithm">The key wrapping al----htm.</param>
        public X509EncryptingCredentials(X509Certificate2 certificate, SecurityKeyIdentifier ski, string keyWrappingAlgorithm)
            : this(new X509SecurityToken(certificate), ski, keyWrappingAlgorithm)
        {
        }

        /// <summary>
        /// Constructs an encrypting credential based on the x509 token.
        /// </summary>
        /// <param name="token">The x509 security token.</param>
        internal X509EncryptingCredentials(X509SecurityToken token)
            : this(
            token,
            new SecurityKeyIdentifier(token.CreateKeyIdentifierClause<X509IssuerSerialKeyIdentifierClause>()),
            SecurityAlgorithms.DefaultAsymmetricKeyWrapAlgorithm)
        {
        }

        /// <summary>
        /// Constructs an encrypting credential based on the x509 token and key wrapping algorithm.
        /// </summary>
        /// <param name="token">The x509 security token.</param>
        /// <param name="keyWrappingAlgorithm">The key wrapping al----htm.</param>
        internal X509EncryptingCredentials(X509SecurityToken token, string keyWrappingAlgorithm)
            : this(token, new SecurityKeyIdentifier(token.CreateKeyIdentifierClause<X509IssuerSerialKeyIdentifierClause>()), keyWrappingAlgorithm)
        {
        }

        /// <summary>
        /// Constructs an encrypting credential based on the x509 token, key wrapping algorithm, and security key identifier.
        /// </summary>
        /// <param name="token">The x509 security token.</param>
        /// <param name="ski">The security key identifier to be used.</param>
        /// <param name="keyWrappingAlgorithm">The key wrapping al----htm.</param>
        internal X509EncryptingCredentials(X509SecurityToken token, SecurityKeyIdentifier ski, string keyWrappingAlgorithm)
            : base(token.SecurityKeys[0], ski, keyWrappingAlgorithm)
        {
            this.certificate = token.Certificate;
        }

        /// <summary>
        /// Gets the x509 certificate.
        /// </summary>
        public X509Certificate2 Certificate
        {
            get
            {
                return this.certificate;
            }
        }
    }
}