1 20 package com.novosec.pkix.asn1.cmp; 21 22 import org.bouncycastle.asn1.ASN1EncodableVector; 23 import org.bouncycastle.asn1.ASN1Sequence; 24 import org.bouncycastle.asn1.ASN1TaggedObject; 25 import org.bouncycastle.asn1.DERBitString; 26 import org.bouncycastle.asn1.DEREncodable; 27 import org.bouncycastle.asn1.DERInteger; 28 import org.bouncycastle.asn1.DERObject; 29 import org.bouncycastle.asn1.DERSequence; 30 31 64 public class PKIStatusInfo implements DEREncodable 65 { 66 DERInteger status; 67 PKIFreeText statusString; 68 DERBitString failInfo; 69 70 public static PKIStatusInfo getInstance( ASN1TaggedObject obj, boolean explicit ) 71 { 72 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 73 } 74 75 public static PKIStatusInfo getInstance( Object obj ) 76 { 77 if (obj instanceof PKIStatusInfo) 78 { 79 return (PKIStatusInfo)obj; 80 } 81 else if (obj instanceof ASN1Sequence) 82 { 83 return new PKIStatusInfo((ASN1Sequence)obj); 84 } 85 86 throw new IllegalArgumentException ("unknown object in factory"); 87 } 88 89 public PKIStatusInfo( ASN1Sequence seq ) 90 { 91 this.status = DERInteger.getInstance(seq.getObjectAt(0)); 92 93 this.statusString = null; 94 this.failInfo = null; 95 96 if (seq.size() > 2) 97 { 98 this.statusString = PKIFreeText.getInstance(seq.getObjectAt(1)); 99 this.failInfo = DERBitString.getInstance(seq.getObjectAt(2)); 100 } 101 else 102 if (seq.size() > 1) 103 { 104 Object obj = seq.getObjectAt(1); 105 106 if( obj instanceof ASN1Sequence ) 107 this.statusString = PKIFreeText.getInstance(obj); 108 else 109 this.failInfo = DERBitString.getInstance(obj); 110 } 111 } 112 113 public PKIStatusInfo( DERInteger status ) 114 { 115 this.status = status; 116 } 117 118 public DERInteger getStatus() 119 { 120 return status; 121 } 122 123 public PKIFreeText getStatusString() 124 { 125 return statusString; 126 } 127 128 public void setStatusString(PKIFreeText statusString) 129 { 130 this.statusString = statusString; 131 } 132 133 134 public DERBitString getFailInfo() 135 { 136 return failInfo; 137 } 138 139 public void setFailInfo(DERBitString failInfo) 140 { 141 this.failInfo = failInfo; 142 } 143 144 public DERObject getDERObject() 145 { 146 ASN1EncodableVector v = new ASN1EncodableVector(); 147 148 v.add( status ); 149 150 if ( statusString != null ) 151 v.add( statusString ); 152 153 if ( failInfo!= null ) 154 v.add( failInfo ); 155 156 return new DERSequence(v); 157 } 158 159 public String toString() 160 { 161 String s = "PKIStatusInfo: (status = " + this.getStatus(); 162 163 if( this.getStatusString() != null ) 164 s += ", statusString: " + this.getStatusString(); 165 166 if( this.getFailInfo() != null ) 167 s += ", failInfo: " + this.getFailInfo(); 168 169 s += ")"; 170 171 return s; 172 } 173 } 174 | Popular Tags |