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