01: package org.bouncycastle.asn1.crmf;
02:
03: import org.bouncycastle.asn1.ASN1Encodable;
04: import org.bouncycastle.asn1.ASN1EncodableVector;
05: import org.bouncycastle.asn1.ASN1Sequence;
06: import org.bouncycastle.asn1.ASN1TaggedObject;
07: import org.bouncycastle.asn1.DERInteger;
08: import org.bouncycastle.asn1.DERObject;
09: import org.bouncycastle.asn1.DERSequence;
10: import org.bouncycastle.asn1.x509.GeneralName;
11:
12: public class CertId extends ASN1Encodable {
13: private GeneralName issuer;
14: private DERInteger serialNumber;
15:
16: private CertId(ASN1Sequence seq) {
17: issuer = GeneralName.getInstance(seq.getObjectAt(0));
18: serialNumber = DERInteger.getInstance(seq.getObjectAt(1));
19: }
20:
21: public static CertId getInstance(Object o) {
22: if (o instanceof CertId) {
23: return (CertId) o;
24: }
25:
26: if (o instanceof ASN1Sequence) {
27: return new CertId((ASN1Sequence) o);
28: }
29:
30: throw new IllegalArgumentException("Invalid object: "
31: + o.getClass().getName());
32: }
33:
34: public static CertId getInstance(ASN1TaggedObject obj,
35: boolean isExplicit) {
36: return getInstance(ASN1Sequence.getInstance(obj, isExplicit));
37: }
38:
39: public GeneralName getIssuer() {
40: return issuer;
41: }
42:
43: public DERInteger getSerialNumber() {
44: return serialNumber;
45: }
46:
47: /**
48: * <pre>
49: * CertId ::= SEQUENCE {
50: * issuer GeneralName,
51: * serialNumber INTEGER }
52: * </pre>
53: * @return a basic ASN.1 object representation.
54: */
55: public DERObject toASN1Object() {
56: ASN1EncodableVector v = new ASN1EncodableVector();
57:
58: v.add(issuer);
59: v.add(serialNumber);
60:
61: return new DERSequence(v);
62: }
63: }
|