KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > protocol > cmp > CmpConfirmResponseMessage


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13 package org.ejbca.core.protocol.cmp;
14
15 import java.io.IOException JavaDoc;
16 import java.security.InvalidKeyException JavaDoc;
17 import java.security.NoSuchAlgorithmException JavaDoc;
18 import java.security.NoSuchProviderException JavaDoc;
19 import java.security.PrivateKey JavaDoc;
20 import java.security.cert.CRL JavaDoc;
21 import java.security.cert.Certificate JavaDoc;
22 import java.security.cert.CertificateEncodingException JavaDoc;
23 import java.security.cert.X509Certificate JavaDoc;
24
25 import org.bouncycastle.asn1.DERNull;
26 import org.bouncycastle.asn1.x509.X509Name;
27 import org.ejbca.core.model.ca.SignRequestException;
28 import org.ejbca.core.model.ra.NotFoundException;
29 import org.ejbca.core.protocol.FailInfo;
30 import org.ejbca.core.protocol.IRequestMessage;
31 import org.ejbca.core.protocol.IResponseMessage;
32 import org.ejbca.core.protocol.ResponseStatus;
33
34 import com.novosec.pkix.asn1.cmp.PKIBody;
35 import com.novosec.pkix.asn1.cmp.PKIHeader;
36 import com.novosec.pkix.asn1.cmp.PKIMessage;
37
38
39 /**
40  * A very simple confirmation message, no protection and a nullbody
41  * @author tomas
42  * @version $Id: CmpConfirmResponseMessage.java,v 1.5 2006/11/09 18:26:43 anatom Exp $
43  */

44 public class CmpConfirmResponseMessage extends BaseCmpMessage implements IResponseMessage {
45
46     /**
47      * Determines if a de-serialized file is compatible with this class.
48      *
49      * Maintainers must change this value if and only if the new version
50      * of this class is not compatible with old versions. See Sun docs
51      * for <a HREF=http://java.sun.com/products/jdk/1.1/docs/guide
52      * /serialization/spec/version.doc.html> details. </a>
53      *
54      */

55     static final long serialVersionUID = 10002L;
56
57     /** The encoded response message */
58     private byte[] responseMessage = null;
59
60     public void setCertificate(Certificate JavaDoc cert) {
61     }
62
63     public void setCrl(CRL JavaDoc crl) {
64     }
65
66     public void setIncludeCACert(boolean incCACert) {
67     }
68
69     public byte[] getResponseMessage() throws IOException JavaDoc,
70             CertificateEncodingException JavaDoc {
71         return responseMessage;
72     }
73
74     public void setStatus(ResponseStatus status) {
75     }
76
77     public ResponseStatus getStatus() {
78         return ResponseStatus.SUCCESS;
79     }
80
81     public void setFailInfo(FailInfo failInfo) {
82     }
83
84     public FailInfo getFailInfo() {
85         return null;
86     }
87
88     public void setFailText(String JavaDoc failText) {
89     }
90
91     public String JavaDoc getFailText() {
92         return null;
93     }
94
95     public boolean create() throws IOException JavaDoc, InvalidKeyException JavaDoc,
96             NoSuchAlgorithmException JavaDoc, NoSuchProviderException JavaDoc,
97             SignRequestException, NotFoundException {
98
99         X509Name sender = X509Name.getInstance(getSender().getName());
100         X509Name recipient = X509Name.getInstance(getRecipient().getName());
101         PKIHeader myPKIHeader = CmpMessageHelper.createPKIHeader(sender, recipient, getSenderNonce(), getRecipientNonce(), getTransactionId());
102         PKIBody myPKIBody = new PKIBody(new DERNull(), 19);
103         PKIMessage myPKIMessage = new PKIMessage(myPKIHeader, myPKIBody);
104
105         if ((getPbeDigestAlg() != null) && (getPbeMacAlg() != null) && (getPbeKeyId() != null) && (getPbeKey() != null) ) {
106             responseMessage = CmpMessageHelper.protectPKIMessageWithPBE(myPKIMessage, getPbeKeyId(), getPbeKey(), getPbeDigestAlg(), getPbeMacAlg(), getPbeIterationCount());
107         } else {
108             responseMessage = CmpMessageHelper.pkiMessageToByteArray(myPKIMessage);
109         }
110         return true;
111     }
112
113     public boolean requireSignKeyInfo() {
114         return false;
115     }
116
117     public boolean requireEncKeyInfo() {
118         return false;
119     }
120
121     public void setSignKeyInfo(X509Certificate JavaDoc cert, PrivateKey JavaDoc key,
122             String JavaDoc provider) {
123     }
124
125     public void setEncKeyInfo(X509Certificate JavaDoc cert, PrivateKey JavaDoc key,
126             String JavaDoc provider) {
127     }
128
129     public void setSenderNonce(String JavaDoc senderNonce) {
130         super.setSenderNonce(senderNonce);
131     }
132
133     public void setRecipientNonce(String JavaDoc recipientNonce) {
134         super.setRecipientNonce(recipientNonce);
135     }
136
137     public void setTransactionId(String JavaDoc transactionId) {
138         super.setTransactionId(transactionId);
139     }
140
141     public void setRecipientKeyInfo(byte[] recipientKeyInfo) {
142     }
143
144     public void setPreferredDigestAlg(String JavaDoc digest) {
145     }
146
147     public void setRequestType(int reqtype) {
148     }
149
150     public void setRequestId(int reqid) {
151     }
152
153     /** @see org.ejca.core.protocol.IResponseMessage
154      */

155     public void setProtectionParamsFromRequest(IRequestMessage reqMsg) {
156     }
157 }
158
Popular Tags