KickJava   Java API By Example, From Geeks To Geeks.

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


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.DERObject;
27 import org.bouncycastle.asn1.DERSequence;
28 import org.bouncycastle.asn1.x509.X509CertificateStructure;
29
30 /**
31  * ASN.1 structure DER En/DeCoder.
32  *
33  * <pre>
34  * CAKeyUpdAnnContent ::= SEQUENCE {
35  * oldWithNew Certificate, -- old pub signed with new priv (X509CertificateStructure)
36  * newWithOld Certificate, -- new pub signed with old priv (X509CertificateStructure)
37  * newWithNew Certificate -- new pub signed with new priv (X509CertificateStructure)
38  * }
39  *
40  * </pre>
41  */

42 public class CAKeyUpdAnnContent implements DEREncodable
43 {
44   X509CertificateStructure oldWithNew;
45   X509CertificateStructure newWithOld;
46   X509CertificateStructure newWithNew;
47
48   public static CAKeyUpdAnnContent getInstance(ASN1TaggedObject obj, boolean explicit)
49   {
50     return getInstance(ASN1Sequence.getInstance(obj, explicit));
51   }
52
53   public static CAKeyUpdAnnContent getInstance(Object JavaDoc obj)
54   {
55     if (obj instanceof CAKeyUpdAnnContent)
56     {
57       return (CAKeyUpdAnnContent) obj;
58     }
59     else if (obj instanceof ASN1Sequence)
60     {
61       return new CAKeyUpdAnnContent((ASN1Sequence) obj);
62     }
63
64     throw new IllegalArgumentException JavaDoc("unknown object in factory");
65   }
66
67   public CAKeyUpdAnnContent(ASN1Sequence seq)
68   {
69     this.oldWithNew = X509CertificateStructure.getInstance(seq.getObjectAt(0));
70     this.newWithOld = X509CertificateStructure.getInstance(seq.getObjectAt(1));
71     this.newWithNew = X509CertificateStructure.getInstance(seq.getObjectAt(2));
72   }
73
74   public CAKeyUpdAnnContent(
75     X509CertificateStructure oldWithNew,
76     X509CertificateStructure newWithOld,
77     X509CertificateStructure newWithNew)
78   {
79     this.oldWithNew = oldWithNew;
80     this.newWithOld = newWithOld;
81     this.newWithNew = newWithNew;
82   }
83
84   public X509CertificateStructure getOldWithNew()
85   {
86     return oldWithNew;
87   }
88
89   public X509CertificateStructure getNewWithOld()
90   {
91     return newWithOld;
92   }
93
94   public X509CertificateStructure getNewWithNew()
95   {
96     return newWithNew;
97   }
98
99   public DERObject getDERObject()
100   {
101     ASN1EncodableVector v = new ASN1EncodableVector();
102
103     v.add(oldWithNew);
104     v.add(newWithOld);
105     v.add(newWithNew);
106
107     return new DERSequence(v);
108   }
109
110   public String JavaDoc toString()
111   {
112     return "CAKeyUpdAnnContent: oldWithNew = " + this.getOldWithNew() + ", " +
113                                 "newWithOld = " + this.getNewWithOld() + ", " +
114                                 "newWithNew = " + this.getNewWithNew() + ")";
115   }
116 }
117
Popular Tags