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.DERInteger; 30 import org.bouncycastle.asn1.DERObject; 31 import org.bouncycastle.asn1.DERSequence; 32 33 41 public class POPODecKeyRespContent implements DEREncodable 42 { 43 Vector integers = new Vector (); 44 45 public static POPODecKeyRespContent getInstance(ASN1TaggedObject obj, boolean explicit) 46 { 47 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 48 } 49 50 public static POPODecKeyRespContent getInstance(Object obj) 51 { 52 if (obj instanceof POPODecKeyRespContent) 53 { 54 return (POPODecKeyRespContent) obj; 55 } 56 else if (obj instanceof ASN1Sequence) 57 { 58 return new POPODecKeyRespContent((ASN1Sequence) obj); 59 } 60 61 throw new IllegalArgumentException ("unknown object in factory"); 62 } 63 64 public POPODecKeyRespContent(ASN1Sequence seq) 65 { 66 Enumeration e = seq.getObjects(); 67 68 while (e.hasMoreElements()) 69 integers.addElement( e.nextElement() ); 70 } 71 72 public POPODecKeyRespContent(DERInteger p) 73 { 74 integers.addElement(p); 75 } 76 77 public void addInteger(DERInteger p) 78 { 79 integers.addElement(p); 80 } 81 82 public DERInteger getInteger(int nr) 83 { 84 if (integers.size() > nr) 85 return (DERInteger) integers.elementAt(nr); 86 87 return null; 88 } 89 90 public DERObject getDERObject() 91 { 92 ASN1EncodableVector v = new ASN1EncodableVector(); 93 94 for (int i = 0; i < integers.size(); i++) 95 v.add((DERInteger) integers.elementAt(i)); 96 97 return new DERSequence(v); 98 } 99 100 public String toString() 101 { 102 String s = "POPODecKeyRespContent: ("; 103 104 for (int i=0;i<integers.size();i++) 105 s += integers.elementAt(i) + ", "; 106 107 s += ")"; 108 109 return s; 110 } 111 } 112 | Popular Tags |