blob: 86664eed9e1af59abdb5668bbf32cc25c19936a3 (
plain)
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
|
package org.spongycastle.asn1.cmp;
import java.math.BigInteger;
import org.spongycastle.asn1.ASN1EncodableVector;
import org.spongycastle.asn1.ASN1Integer;
import org.spongycastle.asn1.ASN1Object;
import org.spongycastle.asn1.ASN1OctetString;
import org.spongycastle.asn1.ASN1Primitive;
import org.spongycastle.asn1.ASN1Sequence;
import org.spongycastle.asn1.DEROctetString;
import org.spongycastle.asn1.DERSequence;
public class CertStatus
extends ASN1Object
{
private ASN1OctetString certHash;
private ASN1Integer certReqId;
private PKIStatusInfo statusInfo;
private CertStatus(ASN1Sequence seq)
{
certHash = ASN1OctetString.getInstance(seq.getObjectAt(0));
certReqId = ASN1Integer.getInstance(seq.getObjectAt(1));
if (seq.size() > 2)
{
statusInfo = PKIStatusInfo.getInstance(seq.getObjectAt(2));
}
}
public CertStatus(byte[] certHash, BigInteger certReqId)
{
this.certHash = new DEROctetString(certHash);
this.certReqId = new ASN1Integer(certReqId);
}
public CertStatus(byte[] certHash, BigInteger certReqId, PKIStatusInfo statusInfo)
{
this.certHash = new DEROctetString(certHash);
this.certReqId = new ASN1Integer(certReqId);
this.statusInfo = statusInfo;
}
public static CertStatus getInstance(Object o)
{
if (o instanceof CertStatus)
{
return (CertStatus)o;
}
if (o != null)
{
return new CertStatus(ASN1Sequence.getInstance(o));
}
return null;
}
public ASN1OctetString getCertHash()
{
return certHash;
}
public ASN1Integer getCertReqId()
{
return certReqId;
}
public PKIStatusInfo getStatusInfo()
{
return statusInfo;
}
/**
* <pre>
* CertStatus ::= SEQUENCE {
* certHash OCTET STRING,
* -- the hash of the certificate, using the same hash algorithm
* -- as is used to create and verify the certificate signature
* certReqId INTEGER,
* -- to match this confirmation with the corresponding req/rep
* statusInfo PKIStatusInfo OPTIONAL
* }
* </pre>
* @return a basic ASN.1 object representation.
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(certHash);
v.add(certReqId);
if (statusInfo != null)
{
v.add(statusInfo);
}
return new DERSequence(v);
}
}
|