001: // CMP implementation copyright (c) 2003 NOVOSEC AG (http://www.novosec.com)
002: //
003: // Author: Maik Stohn
004: //
005: // Permission is hereby granted, free of charge, to any person obtaining a copy of this
006: // software and associated documentation files (the "Software"), to deal in the Software
007: // without restriction, including without limitation the rights to use, copy, modify, merge,
008: // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
009: // to whom the Software is furnished to do so, subject to the following conditions:
010: //
011: // The above copyright notice and this permission notice shall be included in all copies or
012: // substantial portions of the Software.
013: //
014: // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
015: // BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
016: // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
017: // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
018: // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
019:
020: package com.novosec.pkix.asn1.cmp;
021:
022: import org.bouncycastle.asn1.ASN1EncodableVector;
023: import org.bouncycastle.asn1.ASN1Sequence;
024: import org.bouncycastle.asn1.ASN1TaggedObject;
025: import org.bouncycastle.asn1.DEREncodable;
026: import org.bouncycastle.asn1.DERGeneralizedTime;
027: import org.bouncycastle.asn1.DERInteger;
028: import org.bouncycastle.asn1.DERObject;
029: import org.bouncycastle.asn1.DERSequence;
030: import org.bouncycastle.asn1.x509.X509Extensions;
031:
032: import com.novosec.pkix.asn1.crmf.CertId;
033:
034: /**
035: * ASN.1 structure DER En/DeCoder.
036: *
037: * <pre>
038: * RevAnnContent ::= SEQUENCE {
039: * status PKIStatus,
040: * certId CertId,
041: * willBeRevokedAt DERGeneralizedTime,
042: * badSinceDate DERGeneralizedTime,
043: * crlDetails Extensions OPTIONAL
044: *
045: * }
046: *
047: * </pre>
048: */
049: public class RevAnnContent implements DEREncodable {
050: DERInteger status;
051: CertId certId;
052: DERGeneralizedTime willBeRevokedAt;
053: DERGeneralizedTime badSinceDate;
054: X509Extensions crlDetails;
055:
056: public static RevAnnContent getInstance(ASN1TaggedObject obj,
057: boolean explicit) {
058: return getInstance(ASN1Sequence.getInstance(obj, explicit));
059: }
060:
061: public static RevAnnContent getInstance(Object obj) {
062: if (obj instanceof RevAnnContent) {
063: return (RevAnnContent) obj;
064: } else if (obj instanceof ASN1Sequence) {
065: return new RevAnnContent((ASN1Sequence) obj);
066: }
067:
068: throw new IllegalArgumentException("unknown object in factory");
069: }
070:
071: public RevAnnContent(ASN1Sequence seq) {
072: this .status = DERInteger.getInstance(seq.getObjectAt(0));
073: this .certId = CertId.getInstance(seq.getObjectAt(1));
074: this .willBeRevokedAt = DERGeneralizedTime.getInstance(seq
075: .getObjectAt(2));
076: this .badSinceDate = DERGeneralizedTime.getInstance(seq
077: .getObjectAt(3));
078:
079: if (seq.size() > 4)
080: this .crlDetails = X509Extensions.getInstance(seq
081: .getObjectAt(4));
082: }
083:
084: public RevAnnContent(DERInteger status, CertId certId,
085: DERGeneralizedTime willBeRevokedAt,
086: DERGeneralizedTime badSinceDate) {
087: this .status = status;
088: this .certId = certId;
089: this .willBeRevokedAt = willBeRevokedAt;
090: this .badSinceDate = badSinceDate;
091: }
092:
093: public DERInteger getStatus() {
094: return status;
095: }
096:
097: public CertId getCertId() {
098: return certId;
099: }
100:
101: public DERGeneralizedTime getWillBeRevokedAt() {
102: return willBeRevokedAt;
103: }
104:
105: public DERGeneralizedTime getBadSinceDate() {
106: return badSinceDate;
107: }
108:
109: public X509Extensions getCrlDetails() {
110: return crlDetails;
111: }
112:
113: public void setCrlDetails(X509Extensions crlDetails) {
114: this .crlDetails = crlDetails;
115: }
116:
117: public DERObject getDERObject() {
118: ASN1EncodableVector v = new ASN1EncodableVector();
119:
120: v.add(status);
121: v.add(certId);
122: v.add(willBeRevokedAt);
123: v.add(badSinceDate);
124:
125: if (crlDetails != null)
126: v.add(crlDetails);
127:
128: return new DERSequence(v);
129: }
130:
131: public String toString() {
132: String s = "RevAnnContent: (status = " + this .getStatus()
133: + ", " + "certId = " + this .getCertId() + ", "
134: + "willBeRevokedAt = " + this .getWillBeRevokedAt()
135: + ", " + "badSinceDate = " + this .getBadSinceDate();
136:
137: if (this .getCrlDetails() != null)
138: s += ", crlDetails = " + this .getCrlDetails();
139:
140: s += ")";
141:
142: return s;
143: }
144: }
|