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 */ 017 018 019 package org.apache.geronimo.util.asn1.x509; 020 021 import org.apache.geronimo.util.asn1.ASN1Encodable; 022 import org.apache.geronimo.util.asn1.ASN1EncodableVector; 023 import org.apache.geronimo.util.asn1.ASN1Sequence; 024 import org.apache.geronimo.util.asn1.ASN1TaggedObject; 025 import org.apache.geronimo.util.asn1.DERBitString; 026 import org.apache.geronimo.util.asn1.DERObject; 027 import org.apache.geronimo.util.asn1.DERSequence; 028 029 /** 030 * PKIX RFC-2459 031 * 032 * The X.509 v2 CRL syntax is as follows. For signature calculation, 033 * the data that is to be signed is ASN.1 DER encoded. 034 * 035 * <pre> 036 * CertificateList ::= SEQUENCE { 037 * tbsCertList TBSCertList, 038 * signatureAlgorithm AlgorithmIdentifier, 039 * signatureValue BIT STRING } 040 * </pre> 041 */ 042 public class CertificateList 043 extends ASN1Encodable 044 { 045 TBSCertList tbsCertList; 046 AlgorithmIdentifier sigAlgId; 047 DERBitString sig; 048 049 public static CertificateList getInstance( 050 ASN1TaggedObject obj, 051 boolean explicit) 052 { 053 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 054 } 055 056 public static CertificateList getInstance( 057 Object obj) 058 { 059 if (obj instanceof CertificateList) 060 { 061 return (CertificateList)obj; 062 } 063 else if (obj instanceof ASN1Sequence) 064 { 065 return new CertificateList((ASN1Sequence)obj); 066 } 067 068 throw new IllegalArgumentException("unknown object in factory"); 069 } 070 071 public CertificateList( 072 ASN1Sequence seq) 073 { 074 if (seq.size() == 3) 075 { 076 tbsCertList = TBSCertList.getInstance(seq.getObjectAt(0)); 077 sigAlgId = AlgorithmIdentifier.getInstance(seq.getObjectAt(1)); 078 sig = (DERBitString)seq.getObjectAt(2); 079 } 080 else 081 { 082 throw new IllegalArgumentException("sequence wrong size for CertificateList"); 083 } 084 } 085 086 public TBSCertList getTBSCertList() 087 { 088 return tbsCertList; 089 } 090 091 public TBSCertList.CRLEntry[] getRevokedCertificates() 092 { 093 return tbsCertList.getRevokedCertificates(); 094 } 095 096 public AlgorithmIdentifier getSignatureAlgorithm() 097 { 098 return sigAlgId; 099 } 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 }