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.DERObject; 25 import org.apache.geronimo.util.asn1.DERSequence; 26 import org.apache.geronimo.util.asn1.DERTaggedObject; 27 28 public class V2Form 29 extends ASN1Encodable 30 { 31 GeneralNames issuerName; 32 IssuerSerial baseCertificateID; 33 ObjectDigestInfo objectDigestInfo; 34 35 public static V2Form getInstance( 36 ASN1TaggedObject obj, 37 boolean explicit) 38 { 39 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 40 } 41 42 public static V2Form getInstance( 43 Object obj) 44 { 45 if (obj == null || obj instanceof V2Form) 46 { 47 return (V2Form)obj; 48 } 49 else if (obj instanceof ASN1Sequence) 50 { 51 return new V2Form((ASN1Sequence)obj); 52 } 53 54 throw new IllegalArgumentException ("unknown object in factory"); 55 } 56 57 public V2Form( 58 GeneralNames issuerName) 59 { 60 this.issuerName = issuerName; 61 } 62 63 public V2Form( 64 ASN1Sequence seq) 65 { 66 int index = 0; 67 68 if (!(seq.getObjectAt(0) instanceof ASN1TaggedObject)) 69 { 70 index++; 71 this.issuerName = GeneralNames.getInstance(seq.getObjectAt(0)); 72 } 73 74 for (int i = index; i != seq.size(); i++) 75 { 76 ASN1TaggedObject o = (ASN1TaggedObject)seq.getObjectAt(i); 77 if (o.getTagNo() == 0) 78 { 79 baseCertificateID = IssuerSerial.getInstance(o, false); 80 } 81 else if (o.getTagNo() == 1) 82 { 83 objectDigestInfo = ObjectDigestInfo.getInstance(o, false); 84 } 85 } 86 } 87 88 public GeneralNames getIssuerName() 89 { 90 return issuerName; 91 } 92 93 public IssuerSerial getBaseCertificateID() 94 { 95 return baseCertificateID; 96 } 97 98 public ObjectDigestInfo getObjectDigestInfo() 99 { 100 return objectDigestInfo; 101 } 102 103 116 public DERObject toASN1Object() 117 { 118 ASN1EncodableVector v = new ASN1EncodableVector(); 119 120 if (issuerName != null) 121 { 122 v.add(issuerName); 123 } 124 125 if (baseCertificateID != null) 126 { 127 v.add(new DERTaggedObject(false, 0, baseCertificateID)); 128 } 129 130 if (objectDigestInfo != null) 131 { 132 v.add(new DERTaggedObject(false, 1, objectDigestInfo)); 133 } 134 135 return new DERSequence(v); 136 } 137 } 138 | Popular Tags |