001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.crypto.asn1.x509;
017:
018: import org.apache.geronimo.crypto.asn1.ASN1Encodable;
019: import org.apache.geronimo.crypto.asn1.ASN1EncodableVector;
020: import org.apache.geronimo.crypto.asn1.ASN1Sequence;
021: import org.apache.geronimo.crypto.asn1.ASN1TaggedObject;
022: import org.apache.geronimo.crypto.asn1.DERBitString;
023: import org.apache.geronimo.crypto.asn1.DERObject;
024: import org.apache.geronimo.crypto.asn1.DERSequence;
025:
026: /**
027: * PKIX RFC-2459
028: *
029: * The X.509 v2 CRL syntax is as follows. For signature calculation,
030: * the data that is to be signed is ASN.1 DER encoded.
031: *
032: * <pre>
033: * CertificateList ::= SEQUENCE {
034: * tbsCertList TBSCertList,
035: * signatureAlgorithm AlgorithmIdentifier,
036: * signatureValue BIT STRING }
037: * </pre>
038: */
039: public class CertificateList extends ASN1Encodable {
040: TBSCertList tbsCertList;
041: AlgorithmIdentifier sigAlgId;
042: DERBitString sig;
043:
044: public static CertificateList getInstance(ASN1TaggedObject obj,
045: boolean explicit) {
046: return getInstance(ASN1Sequence.getInstance(obj, explicit));
047: }
048:
049: public static CertificateList getInstance(Object obj) {
050: if (obj instanceof CertificateList) {
051: return (CertificateList) obj;
052: } else if (obj instanceof ASN1Sequence) {
053: return new CertificateList((ASN1Sequence) obj);
054: }
055:
056: throw new IllegalArgumentException("unknown object in factory");
057: }
058:
059: public CertificateList(ASN1Sequence seq) {
060: if (seq.size() == 3) {
061: tbsCertList = TBSCertList.getInstance(seq.getObjectAt(0));
062: sigAlgId = AlgorithmIdentifier.getInstance(seq
063: .getObjectAt(1));
064: sig = (DERBitString) seq.getObjectAt(2);
065: } else {
066: throw new IllegalArgumentException(
067: "sequence wrong size for CertificateList");
068: }
069: }
070:
071: public TBSCertList getTBSCertList() {
072: return tbsCertList;
073: }
074:
075: public TBSCertList.CRLEntry[] getRevokedCertificates() {
076: return tbsCertList.getRevokedCertificates();
077: }
078:
079: public AlgorithmIdentifier getSignatureAlgorithm() {
080: return sigAlgId;
081: }
082:
083: public DERBitString getSignature() {
084: return sig;
085: }
086:
087: public int getVersion() {
088: return tbsCertList.getVersion();
089: }
090:
091: public X509Name getIssuer() {
092: return tbsCertList.getIssuer();
093: }
094:
095: public Time getThisUpdate() {
096: return tbsCertList.getThisUpdate();
097: }
098:
099: public Time getNextUpdate() {
100: return tbsCertList.getNextUpdate();
101: }
102:
103: public DERObject toASN1Object() {
104: ASN1EncodableVector v = new ASN1EncodableVector();
105:
106: v.add(tbsCertList);
107: v.add(sigAlgId);
108: v.add(sig);
109:
110: return new DERSequence(v);
111: }
112: }
|