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.DERObject;
027: import org.bouncycastle.asn1.DERSequence;
028: import org.bouncycastle.asn1.x509.X509CertificateStructure;
029:
030: /**
031: * ASN.1 structure DER En/DeCoder.
032: *
033: * <pre>
034: * CAKeyUpdAnnContent ::= SEQUENCE {
035: * oldWithNew Certificate, -- old pub signed with new priv (X509CertificateStructure)
036: * newWithOld Certificate, -- new pub signed with old priv (X509CertificateStructure)
037: * newWithNew Certificate -- new pub signed with new priv (X509CertificateStructure)
038: * }
039: *
040: * </pre>
041: */
042: public class CAKeyUpdAnnContent implements DEREncodable {
043: X509CertificateStructure oldWithNew;
044: X509CertificateStructure newWithOld;
045: X509CertificateStructure newWithNew;
046:
047: public static CAKeyUpdAnnContent getInstance(ASN1TaggedObject obj,
048: boolean explicit) {
049: return getInstance(ASN1Sequence.getInstance(obj, explicit));
050: }
051:
052: public static CAKeyUpdAnnContent getInstance(Object obj) {
053: if (obj instanceof CAKeyUpdAnnContent) {
054: return (CAKeyUpdAnnContent) obj;
055: } else if (obj instanceof ASN1Sequence) {
056: return new CAKeyUpdAnnContent((ASN1Sequence) obj);
057: }
058:
059: throw new IllegalArgumentException("unknown object in factory");
060: }
061:
062: public CAKeyUpdAnnContent(ASN1Sequence seq) {
063: this .oldWithNew = X509CertificateStructure.getInstance(seq
064: .getObjectAt(0));
065: this .newWithOld = X509CertificateStructure.getInstance(seq
066: .getObjectAt(1));
067: this .newWithNew = X509CertificateStructure.getInstance(seq
068: .getObjectAt(2));
069: }
070:
071: public CAKeyUpdAnnContent(X509CertificateStructure oldWithNew,
072: X509CertificateStructure newWithOld,
073: X509CertificateStructure newWithNew) {
074: this .oldWithNew = oldWithNew;
075: this .newWithOld = newWithOld;
076: this .newWithNew = newWithNew;
077: }
078:
079: public X509CertificateStructure getOldWithNew() {
080: return oldWithNew;
081: }
082:
083: public X509CertificateStructure getNewWithOld() {
084: return newWithOld;
085: }
086:
087: public X509CertificateStructure getNewWithNew() {
088: return newWithNew;
089: }
090:
091: public DERObject getDERObject() {
092: ASN1EncodableVector v = new ASN1EncodableVector();
093:
094: v.add(oldWithNew);
095: v.add(newWithOld);
096: v.add(newWithNew);
097:
098: return new DERSequence(v);
099: }
100:
101: public String toString() {
102: return "CAKeyUpdAnnContent: oldWithNew = "
103: + this .getOldWithNew() + ", " + "newWithOld = "
104: + this .getNewWithOld() + ", " + "newWithNew = "
105: + this .getNewWithNew() + ")";
106: }
107: }
|