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