1 17 18 package org.apache.geronimo.util.asn1.x509; 19 20 import org.apache.geronimo.util.asn1.ASN1Encodable; 21 import org.apache.geronimo.util.asn1.ASN1EncodableVector; 22 import org.apache.geronimo.util.asn1.ASN1Sequence; 23 import org.apache.geronimo.util.asn1.ASN1TaggedObject; 24 import org.apache.geronimo.util.asn1.DERBitString; 25 import org.apache.geronimo.util.asn1.DERInteger; 26 import org.apache.geronimo.util.asn1.DERObject; 27 import org.apache.geronimo.util.asn1.DERSequence; 28 29 public class IssuerSerial 30 extends ASN1Encodable 31 { 32 GeneralNames issuer; 33 DERInteger serial; 34 DERBitString issuerUID; 35 36 public static IssuerSerial getInstance( 37 Object obj) 38 { 39 if (obj == null || obj instanceof GeneralNames) 40 { 41 return (IssuerSerial)obj; 42 } 43 44 if (obj instanceof ASN1Sequence) 45 { 46 return new IssuerSerial((ASN1Sequence)obj); 47 } 48 49 throw new IllegalArgumentException ("illegal object in getInstance: " + obj.getClass().getName()); 50 } 51 52 public static IssuerSerial getInstance( 53 ASN1TaggedObject obj, 54 boolean explicit) 55 { 56 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 57 } 58 59 public IssuerSerial( 60 ASN1Sequence seq) 61 { 62 issuer = GeneralNames.getInstance(seq.getObjectAt(0)); 63 serial = (DERInteger)seq.getObjectAt(1); 64 65 if (seq.size() == 3) 66 { 67 issuerUID = (DERBitString)seq.getObjectAt(2); 68 } 69 } 70 71 public IssuerSerial( 72 GeneralNames issuer, 73 DERInteger serial) 74 { 75 this.issuer = issuer; 76 this.serial = serial; 77 } 78 79 public GeneralNames getIssuer() 80 { 81 return issuer; 82 } 83 84 public DERInteger getSerial() 85 { 86 return serial; 87 } 88 89 public DERBitString getIssuerUID() 90 { 91 return issuerUID; 92 } 93 94 104 public DERObject toASN1Object() 105 { 106 ASN1EncodableVector v = new ASN1EncodableVector(); 107 108 v.add(issuer); 109 v.add(serial); 110 111 if (issuerUID != null) 112 { 113 v.add(issuerUID); 114 } 115 116 return new DERSequence(v); 117 } 118 } 119 | Popular Tags |