KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > model > ca > catoken > DummyHardCAToken


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.catoken;
15
16 import java.security.PrivateKey JavaDoc;
17 import java.security.PublicKey JavaDoc;
18 import java.util.Properties JavaDoc;
19
20 import org.apache.log4j.Logger;
21
22
23 /**
24  *
25  * Class used as test and demonstrationclass when writing HardCAToken plug-ins as HSMs.
26  *
27  * Observe: Remember to add a loadClass("thisclass") row to the HardCATokenManager.init() method when adding new plug-ins.
28
29  * @author herrvendil
30  * @version $Id: DummyHardCAToken.java,v 1.1 2006/01/17 20:31:51 anatom Exp $
31  *
32  */

33 public class DummyHardCAToken implements IHardCAToken {
34     /** Log4j instance */
35     private static final Logger log = Logger.getLogger(DummyHardCAToken.class);
36     
37     /** The constructor of HardCAToken should throw an InstantiationException is the token can not
38      * be created, if for example depending jar files for the particular HSM is not available.
39      */

40     public DummyHardCAToken(){
41         log.debug("Creating DummyHardCAToken");
42         AvailableHardCAToken token = HardCATokenManager.instance().getAvailableHardCAToken("org.ejbca.core.ejb.ca.catoken.DummyHardCAToken");
43         if (token != null) {
44             log.debug("Registered DummyHardCAToken succesfully.");
45         }
46     }
47     
48     /**
49      * This method should initalize this plug-in with the properties configured in the adminweb-GUI.
50      *
51      */

52     public void init(Properties JavaDoc properties, String JavaDoc signaturealgorithm) {
53         log.debug("Init()");
54           // Implement this.
55
}
56     
57
58     /**
59      * Method used to activate HardCATokens when connected after being offline.
60      *
61      * @param authenticationcode used to unlock catoken, i.e PIN for smartcard HSMs
62      * @throws CATokenOfflineException if CAToken is not available or connected.
63      * @throws CATokenAuthenticationFailedException with error message if authentication to HardCATokens fail.
64      */

65     public void activate(String JavaDoc authenticationcode) throws CATokenAuthenticationFailedException, CATokenOfflineException {
66         log.debug("activate(" + authenticationcode +")");
67         // Implement this.
68
}
69     
70     /**
71      * Method used to deactivate HardCATokens.
72      * Should reset the HSMs or smartcard.
73      *
74      * @return true if deactivation was successful.
75      */

76     public boolean deactivate(){
77       log.debug("deactivate()");
78       // Implement this.
79
return true;
80     }
81     
82     
83     /**
84      * Should return a reference to the private key used with the given purpose.
85      *
86      * Purpose can have one of the following values: CAKEYPURPOSE_CERTSIGN, CAKEYPURPOSE_CRLSIGN or CAKEYPURPOSE_KEYENCRYPT
87      */

88     public PrivateKey JavaDoc getPrivateKey(int purpose) {
89         log.debug("getPrivateKey(" + purpose + ")");
90         // Implement this.
91
return null;
92     }
93     
94     /**
95      * Should return a reference to the public key used with the given purpose.
96      *
97      * Purpose can have one of the following values: CAKEYPURPOSE_CERTSIGN, CAKEYPURPOSE_CRLSIGN or CAKEYPURPOSE_KEYENCRYPT
98      */

99     public PublicKey JavaDoc getPublicKey(int purpose) {
100         log.debug("getPublicKey(" + purpose + ")");
101         // Implement this.
102
return null;
103     }
104
105     
106     
107     /** Should return the signature Provider that should be used to sign things with
108      * the PrivateKey object returned by this signingdevice implementation.
109      * @return String the name of the Provider
110      */

111     public String JavaDoc getProvider() {
112         log.debug("getProvider()");
113         // Implement this.
114
return null;
115     }
116
117     /**
118      * Method that returns the current status of the catoken.
119      *
120      * Should return one of the IHardCAToken.STATUS_.. values
121      */

122     public int getCATokenStatus() {
123         log.debug("getCATokenStatus()");
124         // Implements this
125
return 0;
126     }
127
128
129 }
130
Popular Tags