KickJava   Java API By Example, From Geeks To Geeks.

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


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
21
22
23 /** Handles maintenance of the hardware device producing signatures and handling the private key.
24  * All HardCAToken plug-ins must implement this interface.
25  *
26  *
27  * @version $Id: IHardCAToken.java,v 1.1 2006/01/17 20:31:51 anatom Exp $
28  */

29 public interface IHardCAToken {
30
31     public static final int STATUS_ACTIVE = 1;
32     public static final int STATUS_OFFLINE = 2;
33     
34    /**
35     * Method called after creation of instance. Gives the object it's properties.
36     *
37     */

38     public abstract void init(Properties JavaDoc properties, String JavaDoc signaturealgorithm);
39     
40     /**
41      * Method that returns the current status of the catoken.
42      *
43      * Should return one of the IHardCAToken.STATUS_.. values
44      */

45     public abstract int getCATokenStatus();
46     
47     /**
48      * Method used to activate HardCATokens when connected after being offline.
49      *
50      * @param authenticationcode used to unlock catoken, i.e PIN for smartcard HSMs
51      * @throws CATokenOfflineException if CAToken is not available or connected.
52      * @throws CATokenAuthenticationFailedException with error message if authentication to HardCATokens fail.
53      */

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

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

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

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

85     public abstract String JavaDoc getProvider();
86
87     
88 }
89
Popular Tags