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 AttributeCertificateInfo 30 extends ASN1Encodable 31 { 32 private DERInteger version; 33 private Holder holder; 34 private AttCertIssuer issuer; 35 private AlgorithmIdentifier signature; 36 private DERInteger serialNumber; 37 private AttCertValidityPeriod attrCertValidityPeriod; 38 private ASN1Sequence attributes; 39 private DERBitString issuerUniqueID; 40 private X509Extensions extensions; 41 42 public static AttributeCertificateInfo getInstance( 43 ASN1TaggedObject obj, 44 boolean explicit) 45 { 46 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 47 } 48 49 public static AttributeCertificateInfo getInstance( 50 Object obj) 51 { 52 if (obj instanceof AttributeCertificateInfo) 53 { 54 return (AttributeCertificateInfo)obj; 55 } 56 else if (obj instanceof ASN1Sequence) 57 { 58 return new AttributeCertificateInfo((ASN1Sequence)obj); 59 } 60 61 throw new IllegalArgumentException ("unknown object in factory"); 62 } 63 64 public AttributeCertificateInfo( 65 ASN1Sequence seq) 66 { 67 this.version = DERInteger.getInstance(seq.getObjectAt(0)); 68 this.holder = Holder.getInstance(seq.getObjectAt(1)); 69 this.issuer = AttCertIssuer.getInstance(seq.getObjectAt(2)); 70 this.signature = AlgorithmIdentifier.getInstance(seq.getObjectAt(3)); 71 this.serialNumber = DERInteger.getInstance(seq.getObjectAt(4)); 72 this.attrCertValidityPeriod = AttCertValidityPeriod.getInstance(seq.getObjectAt(5)); 73 this.attributes = ASN1Sequence.getInstance(seq.getObjectAt(6)); 74 75 for (int i = 7; i < seq.size(); i++) 76 { 77 ASN1Encodable obj = (ASN1Encodable)seq.getObjectAt(i); 78 79 if (obj instanceof DERBitString) 80 { 81 this.issuerUniqueID = DERBitString.getInstance(seq.getObjectAt(i)); 82 } 83 else if (obj instanceof ASN1Sequence || obj instanceof X509Extensions) 84 { 85 this.extensions = X509Extensions.getInstance(seq.getObjectAt(i)); 86 } 87 } 88 } 89 90 public DERInteger getVersion() 91 { 92 return version; 93 } 94 95 public Holder getHolder() 96 { 97 return holder; 98 } 99 100 public AttCertIssuer getIssuer() 101 { 102 return issuer; 103 } 104 105 public AlgorithmIdentifier getSignature() 106 { 107 return signature; 108 } 109 110 public DERInteger getSerialNumber() 111 { 112 return serialNumber; 113 } 114 115 public AttCertValidityPeriod getAttrCertValidityPeriod() 116 { 117 return attrCertValidityPeriod; 118 } 119 120 public ASN1Sequence getAttributes() 121 { 122 return attributes; 123 } 124 125 public DERBitString getIssuerUniqueID() 126 { 127 return issuerUniqueID; 128 } 129 130 public X509Extensions getExtensions() 131 { 132 return extensions; 133 } 134 135 153 public DERObject toASN1Object() 154 { 155 ASN1EncodableVector v = new ASN1EncodableVector(); 156 157 v.add(version); 158 v.add(holder); 159 v.add(issuer); 160 v.add(signature); 161 v.add(serialNumber); 162 v.add(attrCertValidityPeriod); 163 v.add(attributes); 164 165 if (issuerUniqueID != null) 166 { 167 v.add(issuerUniqueID); 168 } 169 170 if (extensions != null) 171 { 172 v.add(extensions); 173 } 174 175 return new DERSequence(v); 176 } 177 } 178 | Popular Tags |