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.ASN1Sequence; 22 import org.apache.geronimo.util.asn1.ASN1TaggedObject; 23 import org.apache.geronimo.util.asn1.DERBitString; 24 import org.apache.geronimo.util.asn1.DERInteger; 25 import org.apache.geronimo.util.asn1.DERObject; 26 import org.apache.geronimo.util.asn1.pkcs.PKCSObjectIdentifiers; 27 28 38 public class X509CertificateStructure 39 extends ASN1Encodable 40 implements X509ObjectIdentifiers, PKCSObjectIdentifiers 41 { 42 ASN1Sequence seq; 43 TBSCertificateStructure tbsCert; 44 AlgorithmIdentifier sigAlgId; 45 DERBitString sig; 46 47 public static X509CertificateStructure getInstance( 48 ASN1TaggedObject obj, 49 boolean explicit) 50 { 51 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 52 } 53 54 public static X509CertificateStructure getInstance( 55 Object obj) 56 { 57 if (obj instanceof X509CertificateStructure) 58 { 59 return (X509CertificateStructure)obj; 60 } 61 else if (obj instanceof ASN1Sequence) 62 { 63 return new X509CertificateStructure((ASN1Sequence)obj); 64 } 65 66 throw new IllegalArgumentException ("unknown object in factory"); 67 } 68 69 public X509CertificateStructure( 70 ASN1Sequence seq) 71 { 72 this.seq = seq; 73 74 if (seq.size() == 3) 78 { 79 tbsCert = TBSCertificateStructure.getInstance(seq.getObjectAt(0)); 80 sigAlgId = AlgorithmIdentifier.getInstance(seq.getObjectAt(1)); 81 82 sig = (DERBitString)seq.getObjectAt(2); 83 } 84 else 85 { 86 throw new IllegalArgumentException ("sequence wrong size for a certificate"); 87 } 88 } 89 90 public TBSCertificateStructure getTBSCertificate() 91 { 92 return tbsCert; 93 } 94 95 public int getVersion() 96 { 97 return tbsCert.getVersion(); 98 } 99 100 public DERInteger getSerialNumber() 101 { 102 return tbsCert.getSerialNumber(); 103 } 104 105 public X509Name getIssuer() 106 { 107 return tbsCert.getIssuer(); 108 } 109 110 public Time getStartDate() 111 { 112 return tbsCert.getStartDate(); 113 } 114 115 public Time getEndDate() 116 { 117 return tbsCert.getEndDate(); 118 } 119 120 public X509Name getSubject() 121 { 122 return tbsCert.getSubject(); 123 } 124 125 public SubjectPublicKeyInfo getSubjectPublicKeyInfo() 126 { 127 return tbsCert.getSubjectPublicKeyInfo(); 128 } 129 130 public AlgorithmIdentifier getSignatureAlgorithm() 131 { 132 return sigAlgId; 133 } 134 135 public DERBitString getSignature() 136 { 137 return sig; 138 } 139 140 public DERObject toASN1Object() 141 { 142 return seq; 143 } 144 } 145 | Popular Tags |