KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > model > ca > caadmin > extendedcaservices > KeyRecoveryCAServiceResponse


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  
14 package org.ejbca.core.model.ca.caadmin.extendedcaservices;
15
16 import java.io.Serializable JavaDoc;
17 import java.security.KeyPair JavaDoc;
18
19
20 /**
21  * Class used when delevering key recovery service response from a CA.
22  *
23  * @version $Id: KeyRecoveryCAServiceResponse.java,v 1.1 2006/01/17 20:30:56 anatom Exp $
24  */

25 public class KeyRecoveryCAServiceResponse extends ExtendedCAServiceResponse implements Serializable JavaDoc {
26              
27     public static final int TYPE_ENCRYPTKEYSRESPONSE = 1;
28     public static final int TYPE_DECRYPTKEYSRESPONSE = 1;
29     
30     private int type;
31     private byte[] keydata;
32     private KeyPair JavaDoc keypair;
33     
34     public KeyRecoveryCAServiceResponse(int type, byte[] keydata) {
35        this.type=type;
36        this.keydata=keydata;
37     }
38     
39     public KeyRecoveryCAServiceResponse(int type, KeyPair JavaDoc keypair) {
40         this.type=type;
41         this.keypair=keypair;
42     }
43            
44     /**
45      * @return type of response, one of the TYPE_ constants.
46      */

47     public int getType(){
48         return type;
49     }
50     
51     /**
52      * Method returning the encrypted key data if the type of response
53      * is TYPE_ENCRYPTRESPONSE, null otherwise.
54      */

55     
56     public byte[] getKeyData(){
57         if(type != TYPE_ENCRYPTKEYSRESPONSE)
58             return null;
59         return keydata;
60     }
61
62     /**
63      * Method returning the decrypted keypair if the type of response
64      * is TYPE_DECRYPTRESPONSE, null otherwise.
65      */

66     public KeyPair JavaDoc getKeyPair(){
67         if(type != TYPE_DECRYPTKEYSRESPONSE)
68             return null;
69         return keypair;
70     }
71         
72 }
73
Popular Tags