KickJava   Java API By Example, From Geeks To Geeks.

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


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
19 import org.ejbca.core.model.UpgradeableDataHashMap;
20
21
22
23 /** Handles maintenance of the device producing signatures and handling the private key.
24  *
25  * @version $Id: CAToken.java,v 1.2 2006/10/31 08:19:41 anatom Exp $
26  */

27 public abstract class CAToken extends UpgradeableDataHashMap implements java.io.Serializable JavaDoc{
28     
29     public static final String JavaDoc CATOKENTYPE = "catokentype";
30     
31     protected static final String JavaDoc SIGNATUREALGORITHM = "signaturealgorithm";
32     protected static final String JavaDoc ENCRYPTIONALGORITHM = "encryptionalgorithm";
33    /**
34     * Returns information about this CAToken.
35     */

36     public abstract CATokenInfo getCATokenInfo();
37     
38    /**
39     * Updates the CAToken data saved in database.
40     */

41     public abstract void updateCATokenInfo(CATokenInfo catokeninfo);
42
43     /**
44      * Method used to activate HardCATokens when connected after being offline.
45      *
46      * @param authenticationcode used to unlock catoken, i.e PIN for smartcard HSMs
47      * @throws CATokenOfflineException if CAToken is not available or connected.
48      * @throws CATokenAuthenticationFailedException with error message if authentication to HardCATokens fail.
49      */

50     public abstract void activate(String JavaDoc authenticationcode) throws CATokenAuthenticationFailedException, CATokenOfflineException;
51
52     /**
53      * Method used to deactivate HardCATokens.
54      * Used to set a CAToken too offline status and to reset the HSMs authorization code.
55      *
56      * @return true if deactivation was successful.
57      */

58     public abstract boolean deactivate();
59    
60     
61    /** Returns the private key (if possible) of token.
62     *
63     * @param purpose should be SecConst.CAKEYPURPOSE_CERTSIGN, SecConst.CAKEYPURPOSE_CRLSIGN or SecConst.CAKEYPURPOSE_KEYENCRYPT
64     * @throws CATokenOfflineException if CAToken is not available or connected.
65     * @return PrivateKey object
66     */

67     public abstract PrivateKey JavaDoc getPrivateKey(int purpose) throws CATokenOfflineException;
68
69    /** Returns the public key (if possible) of token.
70     *
71     * @param purpose should be SecConst.CAKEYPURPOSE_CERTSIGN, SecConst.CAKEYPURPOSE_CRLSIGN or SecConst.CAKEYPURPOSE_KEYENCRYPT
72     * @throws CATokenOfflineException if CAToken is not available or connected.
73     * @return PublicKey object
74     */

75     public abstract PublicKey JavaDoc getPublicKey(int purpose) throws CATokenOfflineException;
76
77     
78     
79     /** Returns the signature Provider that should be used to sign things with
80      * the PrivateKey object returned by this signingdevice implementation.
81      * @return String the name of the Provider
82      */

83     public abstract String JavaDoc getProvider();
84
85     
86 }
87
Popular Tags