01: package org.bouncycastle.asn1.cms;
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 serialNumber;
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(
25: "Illegal object in IssuerAndSerialNumber: "
26: + obj.getClass().getName());
27: }
28:
29: public IssuerAndSerialNumber(ASN1Sequence seq) {
30: this .name = X509Name.getInstance(seq.getObjectAt(0));
31: this .serialNumber = (DERInteger) seq.getObjectAt(1);
32: }
33:
34: public IssuerAndSerialNumber(X509Name name, BigInteger serialNumber) {
35: this .name = name;
36: this .serialNumber = new DERInteger(serialNumber);
37: }
38:
39: public IssuerAndSerialNumber(X509Name name, DERInteger serialNumber) {
40: this .name = name;
41: this .serialNumber = serialNumber;
42: }
43:
44: public X509Name getName() {
45: return name;
46: }
47:
48: public DERInteger getSerialNumber() {
49: return serialNumber;
50: }
51:
52: public DERObject toASN1Object() {
53: ASN1EncodableVector v = new ASN1EncodableVector();
54:
55: v.add(name);
56: v.add(serialNumber);
57:
58: return new DERSequence(v);
59: }
60: }
|