1 20 package com.novosec.pkix.asn1.cmp; 21 22 import org.bouncycastle.asn1.ASN1TaggedObject; 23 import org.bouncycastle.asn1.DEREncodable; 24 import org.bouncycastle.asn1.DERNull; 25 import org.bouncycastle.asn1.DERObject; 26 import org.bouncycastle.asn1.DERTaggedObject; 27 import org.bouncycastle.asn1.pkcs.CertificationRequest; 28 import org.bouncycastle.asn1.x509.X509CertificateStructure; 29 30 import com.novosec.pkix.asn1.crmf.CertReqMessages; 31 32 66 public class PKIBody implements DEREncodable 67 { 68 DEREncodable obj; 69 int tag; 70 71 public PKIBody( DEREncodable obj, int tag ) 72 { 73 this.obj = obj; 74 this.tag = tag; 75 } 76 77 public int getTagNo() 78 { 79 return tag; 80 } 81 82 public CertReqMessages getIr() 83 { 84 if( this.tag != 0 ) 85 return null; 86 return (CertReqMessages)this.obj; 87 } 88 89 public CertRepMessage getIp() 90 { 91 if( this.tag != 1 ) 92 return null; 93 return (CertRepMessage)this.obj; 94 } 95 96 public CertReqMessages getCr() 97 { 98 if( this.tag != 2 ) 99 return null; 100 return (CertReqMessages)this.obj; 101 } 102 103 public CertRepMessage getCp() 104 { 105 if( this.tag != 3 ) 106 return null; 107 return (CertRepMessage)this.obj; 108 } 109 110 public CertificationRequest getP10cr() 111 { 112 if( this.tag != 4 ) 113 return null; 114 return (CertificationRequest)this.obj; 115 } 116 117 public POPODecKeyChallContent getPopdecc() 118 { 119 if( this.tag != 5 ) 120 return null; 121 return (POPODecKeyChallContent)this.obj; 122 } 123 124 public POPODecKeyRespContent getPopdecr() 125 { 126 if( this.tag != 6 ) 127 return null; 128 return (POPODecKeyRespContent)this.obj; 129 } 130 131 public CertReqMessages getKur() 132 { 133 if( this.tag != 7 ) 134 return null; 135 return (CertReqMessages)this.obj; 136 } 137 138 public CertRepMessage getKup() 139 { 140 if( this.tag != 8 ) 141 return null; 142 return (CertRepMessage)this.obj; 143 } 144 145 public CertReqMessages getKrr() 146 { 147 if( this.tag != 9 ) 148 return null; 149 return (CertReqMessages)this.obj; 150 } 151 152 public KeyRecRepContent getKrp() 153 { 154 if( this.tag != 10 ) 155 return null; 156 return (KeyRecRepContent)this.obj; 157 } 158 159 public RevReqContent getRr() 160 { 161 if( this.tag != 11 ) 162 return null; 163 return (RevReqContent)this.obj; 164 } 165 166 public RevRepContent getRp() 167 { 168 if( this.tag != 12 ) 169 return null; 170 return (RevRepContent)this.obj; 171 } 172 173 public CertReqMessages getCcr() 174 { 175 if( this.tag != 13 ) 176 return null; 177 return (CertReqMessages)this.obj; 178 } 179 180 public CertRepMessage getCcp() 181 { 182 if( this.tag != 14 ) 183 return null; 184 return (CertRepMessage)this.obj; 185 } 186 187 public CAKeyUpdAnnContent getCkuann() 188 { 189 if( this.tag != 15 ) 190 return null; 191 return (CAKeyUpdAnnContent)this.obj; 192 } 193 194 public X509CertificateStructure getCann() 195 { 196 if( this.tag != 16 ) 197 return null; 198 return (X509CertificateStructure)this.obj; 199 } 200 201 public RevAnnContent getRann() 202 { 203 if( this.tag != 17 ) 204 return null; 205 return (RevAnnContent)this.obj; 206 } 207 208 public CRLAnnContent getCrlann() 209 { 210 if( this.tag != 18 ) 211 return null; 212 return (CRLAnnContent)this.obj; 213 } 214 215 public DERNull getConf() 216 { 217 if( this.tag != 19 ) 218 return null; 219 return (DERNull)this.obj; 220 } 221 222 public PKIMessage getNested() 223 { 224 if( this.tag != 20 ) 225 return null; 226 return (PKIMessage)this.obj; 227 } 228 229 public GenMsgContent getGenm() 230 { 231 if( this.tag != 21 ) 232 return null; 233 return (GenMsgContent)this.obj; 234 } 235 236 public GenRepContent getGenp() 237 { 238 if( this.tag != 22 ) 239 return null; 240 return (GenRepContent)this.obj; 241 } 242 243 public ErrorMsgContent getError() 244 { 245 if( this.tag != 23 ) 246 return null; 247 return (ErrorMsgContent)this.obj; 248 } 249 250 public CertConfirmContent getCertConf() { 251 if (this.tag != 24 ) 252 return null; 253 return (CertConfirmContent)this.obj; 254 } 255 256 public static PKIBody getInstance( DERObject obj ) 257 { 258 return getInstance( (ASN1TaggedObject)obj, true ); 259 } 260 261 public static PKIBody getInstance( ASN1TaggedObject tagObj, boolean explicit ) 262 { 263 int tag = tagObj.getTagNo(); 264 265 switch (tag) 266 { 267 case 0: return new PKIBody(CertReqMessages.getInstance(tagObj.getObject()), 0); 268 case 1: return new PKIBody(CertRepMessage.getInstance(tagObj.getObject()), 1); 269 case 2: return new PKIBody(CertReqMessages.getInstance(tagObj.getObject()), 2); 270 case 3: return new PKIBody(CertRepMessage.getInstance(tagObj.getObject()), 3); 271 case 4: return new PKIBody(tagObj.getObject(), 4); 272 case 5: return new PKIBody(POPODecKeyChallContent.getInstance(tagObj.getObject()), 5); 273 case 6: return new PKIBody(POPODecKeyRespContent.getInstance(tagObj.getObject()), 6); 274 case 7: return new PKIBody(CertReqMessages.getInstance(tagObj.getObject()), 7); 275 case 8: return new PKIBody(CertRepMessage.getInstance(tagObj.getObject()), 8); 276 case 9: return new PKIBody(CertReqMessages.getInstance(tagObj.getObject()), 9); 277 case 10: return new PKIBody(KeyRecRepContent.getInstance(tagObj.getObject()), 10); 278 case 11: return new PKIBody(RevReqContent.getInstance(tagObj.getObject()), 11); 279 case 12: return new PKIBody(RevRepContent.getInstance(tagObj.getObject()), 12); 280 case 13: return new PKIBody(CertReqMessages.getInstance(tagObj.getObject()), 13); 281 case 14: return new PKIBody(CertRepMessage.getInstance(tagObj.getObject()), 14); 282 case 15: return new PKIBody(CAKeyUpdAnnContent.getInstance(tagObj.getObject()), 15); 283 case 16: return new PKIBody(X509CertificateStructure.getInstance(tagObj.getObject()),16); 284 case 17: return new PKIBody(RevAnnContent.getInstance(tagObj.getObject()), 17); 285 case 18: return new PKIBody(CRLAnnContent.getInstance(tagObj.getObject()), 18); 286 case 19: return new PKIBody(tagObj.getObject(), 19); 287 case 20: return new PKIBody(PKIMessage.getInstance(tagObj.getObject()), 20); 288 case 21: return new PKIBody(GenMsgContent.getInstance(tagObj.getObject()), 21); 289 case 22: return new PKIBody(GenRepContent.getInstance(tagObj.getObject()), 22); 290 case 23: return new PKIBody(ErrorMsgContent.getInstance(tagObj.getObject()), 23); 291 case 24: return new PKIBody(CertConfirmContent.getInstance(tagObj.getObject()), 24); 292 } 293 294 throw new IllegalArgumentException ("unknown tag: " + tag); 295 } 296 297 public DERObject getDERObject() 298 { 299 return new DERTaggedObject(true, tag, obj); 300 } 301 302 public String toString() 303 { 304 return "PKIBody: (" + obj + ")"; 305 } 306 } 307 | Popular Tags |