summary refs log tree commit diff
path: root/crypto/src/asn1/cmp/RevDetails.cs
blob: 79b30044ada092762502461a0d0b5fac9373fa14 (plain) (blame)
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
using Org.BouncyCastle.Asn1.Crmf;
using Org.BouncyCastle.Asn1.X509;

namespace Org.BouncyCastle.Asn1.Cmp
{
    /**
     * <pre>
     * RevDetails ::= SEQUENCE {
     *          certDetails         CertTemplate,
     *          -- allows requester to specify as much as they can about
     *          -- the cert. for which revocation is requested
     *          -- (e.g., for cases in which serialNumber is not available)
     *          crlEntryDetails     Extensions       OPTIONAL
     *          -- requested crlEntryExtensions
     *      }
     * </pre>
     */
    public class RevDetails
		: Asn1Encodable
	{
        public static RevDetails GetInstance(object obj)
        {
            if (obj == null)
                return null;
            if (obj is RevDetails revDetails)
                return revDetails;
            return new RevDetails(Asn1Sequence.GetInstance(obj));
        }

        public static RevDetails GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
        {
            return GetInstance(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
        }

        private readonly CertTemplate m_certDetails;
		private readonly X509Extensions m_crlEntryDetails;

        private RevDetails(Asn1Sequence seq)
		{
			m_certDetails = CertTemplate.GetInstance(seq[0]);

            if (seq.Count > 1)
            {
                m_crlEntryDetails = X509Extensions.GetInstance(seq[1]);
            }
		}

		public RevDetails(CertTemplate certDetails)
            : this(certDetails, null)
		{
		}

        public RevDetails(CertTemplate certDetails, X509Extensions crlEntryDetails)
		{
            m_certDetails = certDetails;
            m_crlEntryDetails = crlEntryDetails;
		}

		public virtual CertTemplate CertDetails => m_certDetails;

        public virtual X509Extensions CrlEntryDetails => m_crlEntryDetails;

		/**
		* <pre>
		* RevDetails ::= SEQUENCE {
		*                  certDetails         CertTemplate,
		*                   -- allows requester to specify as much as they can about
		*                   -- the cert. for which revocation is requested
		*                   -- (e.g., for cases in which serialNumber is not available)
		*                   crlEntryDetails     Extensions       OPTIONAL
		*                   -- requested crlEntryExtensions
		*             }
		* </pre>
		* @return a basic ASN.1 object representation.
		*/
		public override Asn1Object ToAsn1Object()
		{
			Asn1EncodableVector v = new Asn1EncodableVector(m_certDetails);
			v.AddOptional(m_crlEntryDetails);
			return new DerSequence(v);
		}
	}
}