KickJava   Java API By Example, From Geeks To Geeks.

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


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.HashMap JavaDoc;
19
20
21 /** Handles maintenance of the soft devices producing signatures and handling the private key
22  * and stored in database.
23  *
24  * @version $Id: NullCAToken.java,v 1.2 2006/05/28 14:21:11 anatom Exp $
25  */

26 public class NullCAToken extends CAToken implements java.io.Serializable JavaDoc{
27
28     public static final float LATEST_VERSION = 1;
29
30     
31     public NullCAToken(){
32       data = new HashMap JavaDoc();
33       data.put(CATOKENTYPE, new Integer JavaDoc(CATokenInfo.CATOKENTYPE_NULL));
34       data.put(VERSION, new Float JavaDoc(LATEST_VERSION));
35     }
36     
37     public NullCAToken(HashMap JavaDoc data) {
38     
39    }
40     
41    /**
42     * Method that generates the keys that will be used by the CAToken.
43     */

44    public void generateKeys(CATokenInfo catokeninfo) throws Exception JavaDoc{
45       // Do Nothing
46
}
47    
48
49    
50    public CATokenInfo getCATokenInfo(){
51      return new NullCATokenInfo();
52    }
53    
54    /**
55     * Updates the CAToken data saved in database.
56     */

57     public void updateCATokenInfo(CATokenInfo catokeninfo){
58     }
59    
60    /** Returns null
61     *
62     * @return PrivateKey object
63     */

64     public PrivateKey JavaDoc getPrivateKey(int purpose){
65       return null;
66     }
67
68     /** Returns null
69     *
70     * @return PublicKey object
71     */

72     public PublicKey JavaDoc getPublicKey(int purpose){
73       return null;
74     }
75     
76
77     /** Returns the signature Provider that should be used to sign things with
78      * the PrivateKey object returned by this signingdevice implementation.
79      * @return String the name of the Provider
80      */

81     public String JavaDoc getProvider(){
82       return "BC";
83     }
84
85     /** Implemtation of UpgradableDataHashMap function getLatestVersion */
86     public float getLatestVersion(){
87        return LATEST_VERSION;
88     }
89
90     /** Implemtation of UpgradableDataHashMap function upgrade. */
91
92     public void upgrade(){
93         if(Float.compare(LATEST_VERSION, getVersion()) != 0) {
94             // New version of the class, upgrade
95

96             data.put(VERSION, new Float JavaDoc(LATEST_VERSION));
97         }
98     }
99
100     /**
101      * @see org.ejbca.core.model.ca.catoken.CAToken#activate(java.lang.String)
102      */

103     public void activate(String JavaDoc authenticationcode) throws CATokenAuthenticationFailedException, CATokenOfflineException {
104         // Do Nothing
105
}
106
107     /**
108      * @see org.ejbca.core.model.ca.catoken.CAToken#deactivate()
109      */

110     public boolean deactivate() {
111        // Do Nothing
112
return true;
113     }
114     
115     
116 }
117
118
Popular Tags