1 20 package com.novosec.pkix.asn1.cmp; 21 22 import java.util.Enumeration ; 23 import java.util.Vector ; 24 25 import org.bouncycastle.asn1.ASN1EncodableVector; 26 import org.bouncycastle.asn1.ASN1Sequence; 27 import org.bouncycastle.asn1.ASN1TaggedObject; 28 import org.bouncycastle.asn1.DEREncodable; 29 import org.bouncycastle.asn1.DERObject; 30 import org.bouncycastle.asn1.DERSequence; 31 import org.bouncycastle.asn1.x509.CertificateList; 32 33 41 public class CRLAnnContent implements DEREncodable 42 { 43 Vector certificateLists = new Vector (); 44 45 public static CRLAnnContent getInstance( ASN1TaggedObject obj, boolean explicit ) 46 { 47 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 48 } 49 50 public static CRLAnnContent getInstance( Object obj ) 51 { 52 if (obj instanceof CRLAnnContent) 53 { 54 return (CRLAnnContent)obj; 55 } 56 else if (obj instanceof ASN1Sequence) 57 { 58 return new CRLAnnContent((ASN1Sequence)obj); 59 } 60 61 throw new IllegalArgumentException ("unknown object in factory"); 62 } 63 64 public CRLAnnContent( ASN1Sequence seq ) 65 { 66 Enumeration e = seq.getObjects(); 67 while (e.hasMoreElements()) 68 { 69 CertificateList s = CertificateList.getInstance(e.nextElement()); 70 certificateLists.addElement(s); 71 } 72 } 73 74 public CRLAnnContent( CertificateList certificateList ) 75 { 76 certificateLists.addElement( certificateList ); 77 } 78 79 public void addCertificateList( CertificateList certificateList ) 80 { 81 certificateLists.addElement( certificateList ); 82 } 83 84 public CertificateList getCertificateList(int nr) 85 { 86 if (certificateLists.size() > nr) 87 return (CertificateList)certificateLists.elementAt(nr); 88 89 return null; 90 } 91 92 public DERObject getDERObject() 93 { 94 ASN1EncodableVector v = new ASN1EncodableVector(); 95 96 for (int i=0;i<certificateLists.size();i++) 97 { 98 v.add((CertificateList)certificateLists.elementAt(i)); 99 } 100 101 return new DERSequence(v); 102 } 103 104 public String toString() 105 { 106 String p = null; 107 for (int i=0;i<certificateLists.size();i++) 108 { 109 if( p == null ) 110 p = ((CertificateList)certificateLists.elementAt(i)).toString(); 111 else 112 p += (CertificateList)certificateLists.elementAt(i); 113 } 114 return "CRLAnnContent: "+p; 115 } 116 } 117 | Popular Tags |