KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > novosec > pkix > asn1 > cmp > RevAnnContent


1 // CMP implementation copyright (c) 2003 NOVOSEC AG (http://www.novosec.com)
2
//
3
// Author: Maik Stohn
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
6
// software and associated documentation files (the "Software"), to deal in the Software
7
// without restriction, including without limitation the rights to use, copy, modify, merge,
8
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
9
// to whom the Software is furnished to do so, subject to the following conditions:
10
//
11
// The above copyright notice and this permission notice shall be included in all copies or
12
// substantial portions of the Software.
13
//
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
15
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19

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 /**
35  * ASN.1 structure DER En/DeCoder.
36  *
37  * <pre>
38  * RevAnnContent ::= SEQUENCE {
39  * status PKIStatus,
40  * certId CertId,
41  * willBeRevokedAt DERGeneralizedTime,
42  * badSinceDate DERGeneralizedTime,
43  * crlDetails Extensions OPTIONAL
44  *
45  * }
46  *
47  * </pre>
48  */

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 JavaDoc 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 JavaDoc("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 JavaDoc toString()
143     {
144       String JavaDoc 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