01: package org.bouncycastle.asn1.pkcs;
02:
03: import java.math.BigInteger;
04:
05: import org.bouncycastle.asn1.ASN1Encodable;
06: import org.bouncycastle.asn1.ASN1EncodableVector;
07: import org.bouncycastle.asn1.ASN1Sequence;
08: import org.bouncycastle.asn1.DERInteger;
09: import org.bouncycastle.asn1.DERObject;
10: import org.bouncycastle.asn1.DERSequence;
11: import org.bouncycastle.asn1.x509.X509Name;
12:
13: public class IssuerAndSerialNumber extends ASN1Encodable {
14: X509Name name;
15: DERInteger certSerialNumber;
16:
17: public static IssuerAndSerialNumber getInstance(Object obj) {
18: if (obj instanceof IssuerAndSerialNumber) {
19: return (IssuerAndSerialNumber) obj;
20: } else if (obj instanceof ASN1Sequence) {
21: return new IssuerAndSerialNumber((ASN1Sequence) obj);
22: }
23:
24: throw new IllegalArgumentException("unknown object in factory");
25: }
26:
27: public IssuerAndSerialNumber(ASN1Sequence seq) {
28: this .name = X509Name.getInstance(seq.getObjectAt(0));
29: this .certSerialNumber = (DERInteger) seq.getObjectAt(1);
30: }
31:
32: public IssuerAndSerialNumber(X509Name name,
33: BigInteger certSerialNumber) {
34: this .name = name;
35: this .certSerialNumber = new DERInteger(certSerialNumber);
36: }
37:
38: public IssuerAndSerialNumber(X509Name name,
39: DERInteger certSerialNumber) {
40: this .name = name;
41: this .certSerialNumber = certSerialNumber;
42: }
43:
44: public X509Name getName() {
45: return name;
46: }
47:
48: public DERInteger getCertificateSerialNumber() {
49: return certSerialNumber;
50: }
51:
52: public DERObject toASN1Object() {
53: ASN1EncodableVector v = new ASN1EncodableVector();
54:
55: v.add(name);
56: v.add(certSerialNumber);
57:
58: return new DERSequence(v);
59: }
60: }
|