01: package org.bouncycastle.asn1.cmp;
02:
03: import org.bouncycastle.asn1.ASN1Encodable;
04: import org.bouncycastle.asn1.ASN1EncodableVector;
05: import org.bouncycastle.asn1.ASN1OctetString;
06: import org.bouncycastle.asn1.ASN1Sequence;
07: import org.bouncycastle.asn1.DERInteger;
08: import org.bouncycastle.asn1.DERObject;
09: import org.bouncycastle.asn1.DERSequence;
10:
11: public class CertStatus extends ASN1Encodable {
12: private ASN1OctetString certHash;
13: private DERInteger certReqId;
14: private PKIStatusInfo statusInfo;
15:
16: private CertStatus(ASN1Sequence seq) {
17: certHash = ASN1OctetString.getInstance(seq.getObjectAt(0));
18: certReqId = DERInteger.getInstance(seq.getObjectAt(1));
19:
20: if (seq.size() > 2) {
21: statusInfo = PKIStatusInfo.getInstance(seq.getObjectAt(2));
22: }
23: }
24:
25: public static CertStatus getInstance(Object o) {
26: if (o instanceof CertStatus) {
27: return (CertStatus) o;
28: }
29:
30: if (o instanceof ASN1Sequence) {
31: return new CertStatus((ASN1Sequence) o);
32: }
33:
34: throw new IllegalArgumentException("Invalid object: "
35: + o.getClass().getName());
36: }
37:
38: public DERInteger getCertReqId() {
39: return certReqId;
40: }
41:
42: public PKIStatusInfo getStatusInfo() {
43: return statusInfo;
44: }
45:
46: /**
47: * <pre>
48: * CertStatus ::= SEQUENCE {
49: * certHash OCTET STRING,
50: * -- the hash of the certificate, using the same hash algorithm
51: * -- as is used to create and verify the certificate signature
52: * certReqId INTEGER,
53: * -- to match this confirmation with the corresponding req/rep
54: * statusInfo PKIStatusInfo OPTIONAL
55: * }
56: * </pre>
57: * @return a basic ASN.1 object representation.
58: */
59: public DERObject toASN1Object() {
60: ASN1EncodableVector v = new ASN1EncodableVector();
61:
62: v.add(certHash);
63: v.add(certReqId);
64:
65: if (statusInfo != null) {
66: v.add(statusInfo);
67: }
68:
69: return new DERSequence(v);
70: }
71: }
|