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.DEREncodable; 26 import org.bouncycastle.asn1.DERGeneralizedTime; 27 import org.bouncycastle.asn1.DERInteger; 28 import org.bouncycastle.asn1.DERObject; 29 import org.bouncycastle.asn1.DERSequence; 30 import org.bouncycastle.asn1.x509.X509Extensions; 31 32 import com.novosec.pkix.asn1.crmf.CertId; 33 34 49 public class RevAnnContent implements DEREncodable 50 { 51 DERInteger status; 52 CertId certId; 53 DERGeneralizedTime willBeRevokedAt; 54 DERGeneralizedTime badSinceDate; 55 X509Extensions crlDetails; 56 57 public static RevAnnContent getInstance( ASN1TaggedObject obj, boolean explicit ) 58 { 59 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 60 } 61 62 public static RevAnnContent getInstance( Object obj ) 63 { 64 if (obj instanceof RevAnnContent) 65 { 66 return (RevAnnContent)obj; 67 } 68 else if (obj instanceof ASN1Sequence) 69 { 70 return new RevAnnContent((ASN1Sequence)obj); 71 } 72 73 throw new IllegalArgumentException ("unknown object in factory"); 74 } 75 76 public RevAnnContent( ASN1Sequence seq ) 77 { 78 this.status = DERInteger.getInstance( seq.getObjectAt(0) ); 79 this.certId = CertId.getInstance( seq.getObjectAt(1) ); 80 this.willBeRevokedAt = DERGeneralizedTime.getInstance( seq.getObjectAt(2) ); 81 this.badSinceDate = DERGeneralizedTime.getInstance( seq.getObjectAt(3) ); 82 83 if( seq.size() > 4 ) 84 this.crlDetails = X509Extensions.getInstance( seq.getObjectAt(4) ); 85 } 86 87 public RevAnnContent( DERInteger status, CertId certId, DERGeneralizedTime willBeRevokedAt, 88 DERGeneralizedTime badSinceDate ) 89 { 90 this.status = status; 91 this.certId = certId; 92 this.willBeRevokedAt = willBeRevokedAt; 93 this.badSinceDate = badSinceDate; 94 } 95 96 public DERInteger getStatus() 97 { 98 return status; 99 } 100 101 public CertId getCertId() 102 { 103 return certId; 104 } 105 106 public DERGeneralizedTime getWillBeRevokedAt() 107 { 108 return willBeRevokedAt; 109 } 110 111 public DERGeneralizedTime getBadSinceDate() 112 { 113 return badSinceDate; 114 } 115 116 public X509Extensions getCrlDetails() 117 { 118 return crlDetails; 119 } 120 121 public void setCrlDetails( X509Extensions crlDetails ) 122 { 123 this.crlDetails = crlDetails; 124 } 125 126 127 public DERObject getDERObject() 128 { 129 ASN1EncodableVector v = new ASN1EncodableVector(); 130 131 v.add( status ); 132 v.add( certId ); 133 v.add( willBeRevokedAt ); 134 v.add( badSinceDate ); 135 136 if( crlDetails != null ) 137 v.add( crlDetails ); 138 139 return new DERSequence(v); 140 } 141 142 public String toString() 143 { 144 String s = "RevAnnContent: (status = " + this.getStatus() + ", " + 145 "certId = " + this.getCertId() + ", " + 146 "willBeRevokedAt = " + this.getWillBeRevokedAt() + ", " + 147 "badSinceDate = " + this.getBadSinceDate(); 148 149 if( this.getCrlDetails() != null ) 150 s += ", crlDetails = " + this.getCrlDetails(); 151 152 s += ")"; 153 154 return s; 155 } 156 } 157 | Popular Tags |