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 43 public class Holder 44 extends ASN1Encodable 45 { 46 IssuerSerial baseCertificateID; 47 GeneralNames entityName; 48 ObjectDigestInfo objectDigestInfo; 49 50 public static Holder getInstance( 51 Object obj) 52 { 53 if (obj instanceof Holder) 54 { 55 return (Holder)obj; 56 } 57 else if (obj instanceof ASN1Sequence) 58 { 59 return new Holder((ASN1Sequence)obj); 60 } 61 62 throw new IllegalArgumentException ("unknown object in factory"); 63 } 64 65 public Holder( 66 ASN1Sequence seq) 67 { 68 for (int i = 0; i != seq.size(); i++) 69 { 70 ASN1TaggedObject tObj = (ASN1TaggedObject)seq.getObjectAt(i); 71 72 switch (tObj.getTagNo()) 73 { 74 case 0: 75 baseCertificateID = IssuerSerial.getInstance(tObj, false); 76 break; 77 case 1: 78 entityName = GeneralNames.getInstance(tObj, false); 79 break; 80 case 2: 81 objectDigestInfo = ObjectDigestInfo.getInstance(tObj, false); 82 break; 83 default: 84 throw new IllegalArgumentException ("unknown tag in Holder"); 85 } 86 } 87 } 88 89 public Holder( 90 IssuerSerial baseCertificateID) 91 { 92 this.baseCertificateID = baseCertificateID; 93 } 94 95 public Holder( 96 GeneralNames entityName) 97 { 98 this.entityName = entityName; 99 } 100 101 public IssuerSerial getBaseCertificateID() 102 { 103 return baseCertificateID; 104 } 105 106 public GeneralNames getEntityName() 107 { 108 return entityName; 109 } 110 111 public ObjectDigestInfo getObjectDigestInfo() 112 { 113 return objectDigestInfo; 114 } 115 116 public DERObject toASN1Object() 117 { 118 ASN1EncodableVector v = new ASN1EncodableVector(); 119 120 if (baseCertificateID != null) 121 { 122 v.add(new DERTaggedObject(false, 0, baseCertificateID)); 123 } 124 125 if (entityName != null) 126 { 127 v.add(new DERTaggedObject(false, 1, entityName)); 128 } 129 130 if (objectDigestInfo != null) 131 { 132 v.add(new DERTaggedObject(false, 2, objectDigestInfo)); 133 } 134 135 return new DERSequence(v); 136 } 137 } 138 | Popular Tags |