1 package org.bouncycastle.asn1.x509;
2
3 import org.bouncycastle.asn1.*;
4 import org.bouncycastle.asn1.pkcs.*;
5
6
16 public class X509CertificateStructure
17 implements DEREncodable, X509ObjectIdentifiers, PKCSObjectIdentifiers
18 {
19 ASN1Sequence seq;
20 TBSCertificateStructure tbsCert;
21 AlgorithmIdentifier sigAlgId;
22 DERBitString sig;
23
24 public static X509CertificateStructure getInstance(
25 ASN1TaggedObject obj,
26 boolean explicit)
27 {
28 return getInstance(ASN1Sequence.getInstance(obj, explicit));
29 }
30
31 public static X509CertificateStructure getInstance(
32 Object obj)
33 {
34 if (obj instanceof X509CertificateStructure)
35 {
36 return (X509CertificateStructure)obj;
37 }
38 else if (obj instanceof ASN1Sequence)
39 {
40 return new X509CertificateStructure((ASN1Sequence)obj);
41 }
42
43 throw new IllegalArgumentException("unknown object in factory");
44 }
45
46 public X509CertificateStructure(
47 ASN1Sequence seq)
48 {
49 this.seq = seq;
50
51
52
53
54 if (seq.size() == 3)
55 {
56 tbsCert = TBSCertificateStructure.getInstance(seq.getObjectAt(0));
57 sigAlgId = AlgorithmIdentifier.getInstance(seq.getObjectAt(1));
58
59 sig = (DERBitString)seq.getObjectAt(2);
60 }
61 }
62
63 public TBSCertificateStructure getTBSCertificate()
64 {
65 return tbsCert;
66 }
67
68 public int getVersion()
69 {
70 return tbsCert.getVersion();
71 }
72
73 public DERInteger getSerialNumber()
74 {
75 return tbsCert.getSerialNumber();
76 }
77
78 public X509Name getIssuer()
79 {
80 return tbsCert.getIssuer();
81 }
82
83 public Time getStartDate()
84 {
85 return tbsCert.getStartDate();
86 }
87
88 public Time getEndDate()
89 {
90 return tbsCert.getEndDate();
91 }
92
93 public X509Name getSubject()
94 {
95 return tbsCert.getSubject();
96 }
97
98 public SubjectPublicKeyInfo getSubjectPublicKeyInfo()
99 {
100 return tbsCert.getSubjectPublicKeyInfo();
101 }
102
103 public AlgorithmIdentifier getSignatureAlgorithm()
104 {
105 return sigAlgId;
106 }
107
108 public DERBitString getSignature()
109 {
110 return sig;
111 }
112
113 public DERObject getDERObject()
114 {
115 return seq;
116 }
117 }
118