blob: 7d5d742fd0450206fdb94a3bbdaa6d698dd4bd24 (
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
|
using System;
using Org.BouncyCastle.Asn1.X509;
namespace Org.BouncyCastle.Asn1.Crmf
{
public class SinglePubInfo
: Asn1Encodable
{
public static SinglePubInfo GetInstance(object obj)
{
if (obj == null)
return null;
if (obj is SinglePubInfo singlePubInfo)
return singlePubInfo;
return new SinglePubInfo(Asn1Sequence.GetInstance(obj));
}
public static SinglePubInfo GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new SinglePubInfo(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
}
private readonly DerInteger m_pubMethod;
private readonly GeneralName m_pubLocation;
private SinglePubInfo(Asn1Sequence seq)
{
int count = seq.Count;
if (count < 1 || count > 2)
throw new ArgumentException("Bad sequence size: " + count, nameof(seq));
int pos = 0;
m_pubMethod = DerInteger.GetInstance(seq[pos++]);
if (pos < count)
{
m_pubLocation = GeneralName.GetInstance(seq[pos++]);
}
if (pos != count)
throw new ArgumentException("Unexpected elements in sequence", nameof(seq));
}
public virtual GeneralName PubLocation => m_pubLocation;
/**
* <pre>
* SinglePubInfo ::= SEQUENCE {
* pubMethod INTEGER {
* dontCare (0),
* x500 (1),
* web (2),
* ldap (3) },
* pubLocation GeneralName OPTIONAL }
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
return m_pubLocation == null
? new DerSequence(m_pubMethod)
: new DerSequence(m_pubMethod, m_pubLocation);
}
}
}
|