1 20 package com.novosec.pkix.asn1.cmp; 21 22 import org.bouncycastle.asn1.ASN1EncodableVector; 23 import org.bouncycastle.asn1.ASN1OctetString; 24 import org.bouncycastle.asn1.ASN1Sequence; 25 import org.bouncycastle.asn1.ASN1TaggedObject; 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 45 public class CertConfirmContent implements DEREncodable 46 { 47 ASN1OctetString certHash; 48 DERInteger certReqId; 49 PKIStatusInfo statusInfo; 50 51 public static CertConfirmContent getInstance( ASN1TaggedObject obj, boolean explicit ) 52 { 53 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 54 } 55 56 public static CertConfirmContent getInstance( Object obj ) 57 { 58 if (obj instanceof CertConfirmContent) 59 { 60 return (CertConfirmContent)obj; 61 } 62 else if (obj instanceof ASN1Sequence) 63 { 64 return new CertConfirmContent((ASN1Sequence)obj); 65 } 66 67 throw new IllegalArgumentException ("unknown object in factory"); 68 } 69 70 public CertConfirmContent( ASN1Sequence seq ) 71 { 72 ASN1Sequence s = ASN1Sequence.getInstance(seq.getObjectAt(0)); 73 74 this.certHash = ASN1OctetString.getInstance( s.getObjectAt(0) ); 75 this.certReqId = DERInteger.getInstance( s.getObjectAt(1) ); 76 this.statusInfo = null; 77 78 if( s.size() > 2 ) 79 { 80 this.statusInfo = PKIStatusInfo.getInstance( s.getObjectAt(2) ); 81 } 82 } 83 84 public CertConfirmContent( ASN1OctetString certHash, DERInteger certReqId) 85 { 86 this.certHash = certHash; 87 this.certReqId = certReqId; 88 this.statusInfo = null; 89 } 90 91 public DERInteger getCertReqId() 92 { 93 return certReqId; 94 } 95 96 public ASN1OctetString getCertHash() 97 { 98 return certHash; 99 } 100 101 public PKIStatusInfo getPKIStatus() 102 { 103 return statusInfo; 104 } 105 106 public void setPKIStatus(PKIStatusInfo status) 107 { 108 this.statusInfo = status; 109 } 110 111 public DERObject getDERObject() 112 { 113 ASN1EncodableVector outer = new ASN1EncodableVector(); 114 ASN1EncodableVector v = new ASN1EncodableVector(); 115 116 v.add( certHash ); 117 v.add( certReqId ); 118 119 if ( statusInfo != null ) 120 v.add( statusInfo); 121 122 outer.add( new DERSequence(v) ); 123 124 return new DERSequence(outer); 125 } 126 127 public String toString() 128 { 129 String s = "CertConfirmContent: (certHash = " + this.getCertHash() + 130 ", certReqId = " + this.getCertReqId(); 131 132 if( this.getPKIStatus() != null ) 133 s += "pkiStatus = " + this.getPKIStatus(); 134 135 s += ")"; 136 137 return s; 138 } 139 } 140 | Popular Tags |