KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > model > hardtoken > types > HardToken


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.hardtoken.types;
15
16 import java.io.Serializable JavaDoc;
17
18 import org.ejbca.core.model.UpgradeableDataHashMap;
19
20
21
22 /**
23  * HardToken is a base class that all HardToken classes is supposed to inherit. It function is to
24  * define the data the token is supposed contain.
25  *
26  * @author TomSelleck
27  * @version $Id: HardToken.java,v 1.1 2006/01/17 20:31:52 anatom Exp $
28  */

29 public abstract class HardToken extends UpgradeableDataHashMap implements Serializable JavaDoc, Cloneable JavaDoc {
30     // Default Values
31
public static final float LATEST_VERSION = 0;
32     public static final String JavaDoc TOKENTYPE = "TOKENTYPE";
33
34     
35     public static final String JavaDoc TOKENPROFILE = "TOKENPROFILE";
36     // Protexted Constants, must be overloaded by all deriving classes.
37
public String JavaDoc[] FIELDS;
38     public int[] DATATYPES;
39     public String JavaDoc[] FIELDTEXTS;
40
41     // Public Constants.
42

43     /* Constants used to define how the stored data should be represented in the web-gui.*/
44     public static final int INTEGER = 0;
45     public static final int LONG = 1;
46     public static final int STRING = 2;
47     public static final int BOOLEAN = 3;
48     public static final int DATE = 4;
49     public static final int EMPTYROW = 5;
50     public static final String JavaDoc EMPTYROW_FIELD = "EMTPYROW";
51
52
53
54     
55     // Public Methods
56
public Object JavaDoc getField(String JavaDoc field) {
57         return data.get(field);
58     }
59         
60     public abstract int getNumberOfFields() ;
61
62     public abstract String JavaDoc getFieldText(int index);
63
64     public abstract String JavaDoc getFieldPointer(int index);
65
66     public abstract int getFieldDataType(int index);
67
68     public void setField(String JavaDoc field, Object JavaDoc value) {
69         data.put(field, value);
70     }
71
72     
73     public int getTokenProfileId() {
74         if(data.get(HardToken.TOKENPROFILE) == null)
75             return 0;
76         
77         return ((Integer JavaDoc) data.get(HardToken.TOKENPROFILE)).intValue();
78     }
79     
80     public void setTokenProfileId(int hardtokenprofileid) {
81       data.put(HardToken.TOKENPROFILE, new Integer JavaDoc(hardtokenprofileid));
82     }
83
84
85     /**
86      * Implemtation of UpgradableDataHashMap function getLatestVersion
87      *
88      */

89     public float getLatestVersion() {
90         return LATEST_VERSION;
91     }
92
93     /**
94      * Implemtation of UpgradableDataHashMap function upgrade.
95      */

96     public void upgrade() {
97     }
98 }
99
Popular Tags