KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > util > asn1 > x509 > CertificateList


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18
19 package org.apache.geronimo.util.asn1.x509;
20
21 import org.apache.geronimo.util.asn1.ASN1Encodable;
22 import org.apache.geronimo.util.asn1.ASN1EncodableVector;
23 import org.apache.geronimo.util.asn1.ASN1Sequence;
24 import org.apache.geronimo.util.asn1.ASN1TaggedObject;
25 import org.apache.geronimo.util.asn1.DERBitString;
26 import org.apache.geronimo.util.asn1.DERObject;
27 import org.apache.geronimo.util.asn1.DERSequence;
28
29 /**
30  * PKIX RFC-2459
31  *
32  * The X.509 v2 CRL syntax is as follows. For signature calculation,
33  * the data that is to be signed is ASN.1 DER encoded.
34  *
35  * <pre>
36  * CertificateList ::= SEQUENCE {
37  * tbsCertList TBSCertList,
38  * signatureAlgorithm AlgorithmIdentifier,
39  * signatureValue BIT STRING }
40  * </pre>
41  */

42 public class CertificateList
43     extends ASN1Encodable
44 {
45     TBSCertList tbsCertList;
46     AlgorithmIdentifier sigAlgId;
47     DERBitString sig;
48
49     public static CertificateList getInstance(
50         ASN1TaggedObject obj,
51         boolean explicit)
52     {
53         return getInstance(ASN1Sequence.getInstance(obj, explicit));
54     }
55
56     public static CertificateList getInstance(
57         Object JavaDoc obj)
58     {
59         if (obj instanceof CertificateList)
60         {
61             return (CertificateList)obj;
62         }
63         else if (obj instanceof ASN1Sequence)
64         {
65             return new CertificateList((ASN1Sequence)obj);
66         }
67
68         throw new IllegalArgumentException JavaDoc("unknown object in factory");
69     }
70
71     public CertificateList(
72         ASN1Sequence seq)
73     {
74         if (seq.size() == 3)
75         {
76             tbsCertList = TBSCertList.getInstance(seq.getObjectAt(0));
77             sigAlgId = AlgorithmIdentifier.getInstance(seq.getObjectAt(1));
78             sig = (DERBitString)seq.getObjectAt(2);
79         }
80         else
81         {
82             throw new IllegalArgumentException JavaDoc("sequence wrong size for CertificateList");
83         }
84     }
85
86     public TBSCertList getTBSCertList()
87     {
88         return tbsCertList;
89     }
90
91     public TBSCertList.CRLEntry[] getRevokedCertificates()
92     {
93         return tbsCertList.getRevokedCertificates();
94     }
95
96     public AlgorithmIdentifier getSignatureAlgorithm()
97     {
98         return sigAlgId;
99     }
100
101     public DERBitString getSignature()
102     {
103         return sig;
104     }
105
106     public int getVersion()
107     {
108         return tbsCertList.getVersion();
109     }
110
111     public X509Name getIssuer()
112     {
113         return tbsCertList.getIssuer();
114     }
115
116     public Time getThisUpdate()
117     {
118         return tbsCertList.getThisUpdate();
119     }
120
121     public Time getNextUpdate()
122     {
123         return tbsCertList.getNextUpdate();
124     }
125
126     public DERObject toASN1Object()
127     {
128         ASN1EncodableVector v = new ASN1EncodableVector();
129
130         v.add(tbsCertList);
131         v.add(sigAlgId);
132         v.add(sig);
133
134         return new DERSequence(v);
135     }
136 }
137
Popular Tags