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.DERInteger; 29 import org.bouncycastle.asn1.DERObject; 30 import org.bouncycastle.asn1.DERSequence; 31 32 44 public class PKIPublicationInfo implements DEREncodable 45 { 46 DERInteger action; 47 Vector pubInfos = new Vector (); 48 49 public static PKIPublicationInfo getInstance( ASN1TaggedObject obj, boolean explicit ) 50 { 51 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 52 } 53 54 public static PKIPublicationInfo getInstance( Object obj ) 55 { 56 if (obj instanceof PKIPublicationInfo) 57 { 58 return (PKIPublicationInfo)obj; 59 } 60 else if (obj instanceof ASN1Sequence) 61 { 62 return new PKIPublicationInfo((ASN1Sequence)obj); 63 } 64 65 throw new IllegalArgumentException ("unknown object in factory"); 66 } 67 68 public PKIPublicationInfo( ASN1Sequence seq ) 69 { 70 this.action = DERInteger.getInstance(seq.getObjectAt(0)); 71 if( seq.size()>1 ) 72 { 73 ASN1Sequence s = (ASN1Sequence)seq.getObjectAt(1); 74 for( int i=0; i<s.size(); i++ ) 75 pubInfos.addElement( SinglePubInfo.getInstance(s.getObjectAt(i)) ); 76 } 77 } 78 79 public PKIPublicationInfo( DERInteger action ) 80 { 81 this.action = action; 82 } 83 84 public DERInteger getAction() 85 { 86 return action; 87 } 88 89 public SinglePubInfo getPubInfo(int nr) 90 { 91 if( pubInfos.size() > nr ) 92 return (SinglePubInfo)pubInfos.elementAt(nr); 93 94 return null; 95 } 96 97 public void addPubInfo(SinglePubInfo pubInfo) 98 { 99 pubInfos.addElement( pubInfo ); 100 } 101 102 public DERObject getDERObject() 103 { 104 ASN1EncodableVector v = new ASN1EncodableVector(); 105 106 v.add( action ); 107 108 if( pubInfos.size() > 0 ) 109 { 110 ASN1EncodableVector pubiv = new ASN1EncodableVector(); 111 for (int i=0;i<pubInfos.size();i++) 112 pubiv.add( (SinglePubInfo)pubInfos.elementAt(i) ); 113 114 v.add( new DERSequence( pubiv ) ); 115 } 116 117 return new DERSequence(v); 118 } 119 120 public String toString() 121 { 122 String s = "PKIPublicationInfo: (action = " + this.getAction(); 123 124 if( pubInfos.size() > 0 ) 125 { 126 s += "pubInfos : ("; 127 128 for (int i=0;i<pubInfos.size();i++) 129 s += (SinglePubInfo)pubInfos.elementAt(i); 130 131 s += ")"; 132 } 133 134 s += ")"; 135 136 return s; 137 } 138 } 139 | Popular Tags |