PolicyQualifierInfo.cs
2.77 KB
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
using System;
namespace Org.BouncyCastle.Asn1.X509
{
/**
* Policy qualifiers, used in the X509V3 CertificatePolicies
* extension.
*
* <pre>
* PolicyQualifierInfo ::= Sequence {
* policyQualifierId PolicyQualifierId,
* qualifier ANY DEFINED BY policyQualifierId }
* </pre>
*/
public class PolicyQualifierInfo
: Asn1Encodable
{
private readonly DerObjectIdentifier policyQualifierId;
private readonly Asn1Encodable qualifier;
/**
* Creates a new <code>PolicyQualifierInfo</code> instance.
*
* @param policyQualifierId a <code>PolicyQualifierId</code> value
* @param qualifier the qualifier, defined by the above field.
*/
public PolicyQualifierInfo(
DerObjectIdentifier policyQualifierId,
Asn1Encodable qualifier)
{
this.policyQualifierId = policyQualifierId;
this.qualifier = qualifier;
}
/**
* Creates a new <code>PolicyQualifierInfo</code> containing a
* cPSuri qualifier.
*
* @param cps the CPS (certification practice statement) uri as a
* <code>string</code>.
*/
public PolicyQualifierInfo(
string cps)
{
policyQualifierId = PolicyQualifierID.IdQtCps;
qualifier = new DerIA5String(cps);
}
/**
* Creates a new <code>PolicyQualifierInfo</code> instance.
*
* @param as <code>PolicyQualifierInfo</code> X509 structure
* encoded as an Asn1Sequence.
*/
private PolicyQualifierInfo(
Asn1Sequence seq)
{
if (seq.Count != 2)
throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
policyQualifierId = DerObjectIdentifier.GetInstance(seq[0]);
qualifier = seq[1];
}
public static PolicyQualifierInfo GetInstance(
object obj)
{
if (obj is PolicyQualifierInfo)
return (PolicyQualifierInfo)obj;
if (obj == null)
return null;
return new PolicyQualifierInfo(Asn1Sequence.GetInstance(obj));
}
public virtual DerObjectIdentifier PolicyQualifierId
{
get { return policyQualifierId; }
}
public virtual Asn1Encodable Qualifier
{
get { return qualifier; }
}
/**
* Returns a Der-encodable representation of this instance.
*
* @return a <code>Asn1Object</code> value
*/
public override Asn1Object ToAsn1Object()
{
return new DerSequence(policyQualifierId, qualifier);
}
}
}