1 package org.bouncycastle.asn1.pkcs; 2 3 import java.math.BigInteger; 4 5 import org.bouncycastle.asn1.ASN1Encodable; 6 import org.bouncycastle.asn1.ASN1EncodableVector; 7 import org.bouncycastle.asn1.ASN1Sequence; 8 import org.bouncycastle.asn1.DERInteger; 9 import org.bouncycastle.asn1.DERObject; 10 import org.bouncycastle.asn1.DERSequence; 11 import org.bouncycastle.asn1.x509.X509Name; 12 13 public class IssuerAndSerialNumber 14 extends ASN1Encodable 15 { 16 X509Name name; 17 DERInteger certSerialNumber; 18 19 public static IssuerAndSerialNumber getInstance( 20 Object obj) 21 { 22 if (obj instanceof IssuerAndSerialNumber) 23 { 24 return (IssuerAndSerialNumber)obj; 25 } 26 else if (obj instanceof ASN1Sequence) 27 { 28 return new IssuerAndSerialNumber((ASN1Sequence)obj); 29 } 30 31 throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName()); 32 } 33 34 public IssuerAndSerialNumber( 35 ASN1Sequence seq) 36 { 37 this.name = X509Name.getInstance(seq.getObjectAt(0)); 38 this.certSerialNumber = (DERInteger)seq.getObjectAt(1); 39 } 40 41 public IssuerAndSerialNumber( 42 X509Name name, 43 BigInteger certSerialNumber) 44 { 45 this.name = name; 46 this.certSerialNumber = new DERInteger(certSerialNumber); 47 } 48 49 public IssuerAndSerialNumber( 50 X509Name name, 51 DERInteger certSerialNumber) 52 { 53 this.name = name; 54 this.certSerialNumber = certSerialNumber; 55 } 56 57 public X509Name getName() 58 { 59 return name; 60 } 61 62 public DERInteger getCertificateSerialNumber() 63 { 64 return certSerialNumber; 65 } 66 67 public DERObject toASN1Object() 68 { 69 ASN1EncodableVector v = new ASN1EncodableVector(); 70 71 v.add(name); 72 v.add(certSerialNumber); 73 74 return new DERSequence(v); 75 } 76 } 77