KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > model > hardtoken > profiles > SwedishEIDProfile


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.profiles;
15
16
17 import java.util.ArrayList JavaDoc;
18
19 import org.ejbca.core.model.SecConst;
20
21
22
23 /**
24  * Hard token profile with a goal to fulfill Swedish EID standard.
25  *
26  * @version $Id: SwedishEIDProfile.java,v 1.3 2006/07/11 13:03:04 herrvendil Exp $
27  */

28 public class SwedishEIDProfile extends EIDProfile {
29         
30     // Public Constants
31
public static final int TYPE_SWEDISHEID = 1;
32     
33     public static final float LATEST_VERSION = 4;
34
35     public static final int CERTUSAGE_SIGN = 0;
36     public static final int CERTUSAGE_AUTHENC = 1;
37     
38     public static final int PINTYPE_AUTHENC_SAME_AS_SIGN = 100;
39             
40     
41     // Protected Constants
42
protected static final int NUMBEROFCERTIFICATES = 2;
43     
44     
45     // Private Constants
46
public static final int[] AVAILABLEMINIMUMKEYLENGTHS = {1024, 2048};
47         
48     
49     // Protected Fields
50

51     private String JavaDoc[][] SUPPORTEDTOKENS = {{"TODO"}};
52     
53     
54     
55     // Default Values
56
public SwedishEIDProfile() {
57       super();
58       
59       data.put(TYPE, new Integer JavaDoc(TYPE_SWEDISHEID));
60       
61       ArrayList JavaDoc certprofileids = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
62       certprofileids.add(new Integer JavaDoc(SecConst.CERTPROFILE_FIXED_HARDTOKENSIGN));
63       certprofileids.add(new Integer JavaDoc(SecConst.CERTPROFILE_FIXED_HARDTOKENAUTHENC));
64       data.put(CERTIFICATEPROFILEID, certprofileids);
65       
66       ArrayList JavaDoc certWritable = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
67       certWritable.add(Boolean.FALSE);
68       certWritable.add(Boolean.FALSE);
69       data.put(CERTWRITABLE, certWritable);
70       
71       ArrayList JavaDoc caids = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
72       caids.add(new Integer JavaDoc(CAID_USEUSERDEFINED));
73       caids.add(new Integer JavaDoc(CAID_USEUSERDEFINED));
74       data.put(CAID, caids);
75       
76       ArrayList JavaDoc pintypes = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
77       pintypes.add(new Integer JavaDoc(PINTYPE_ASCII_NUMERIC));
78       pintypes.add(new Integer JavaDoc(PINTYPE_ASCII_NUMERIC));
79       data.put(PINTYPE, pintypes);
80
81       ArrayList JavaDoc minpinlength = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
82       minpinlength.add(new Integer JavaDoc(4));
83       minpinlength.add(new Integer JavaDoc(4));
84       data.put(MINIMUMPINLENGTH, minpinlength);
85       
86       ArrayList JavaDoc iskeyrecoverable = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
87       iskeyrecoverable.add(new Boolean JavaDoc(false));
88       iskeyrecoverable.add(new Boolean JavaDoc(false));
89       data.put(ISKEYRECOVERABLE, iskeyrecoverable);
90       
91         
92       ArrayList JavaDoc reuseoldcertificate = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
93       reuseoldcertificate.add(Boolean.FALSE);
94       reuseoldcertificate.add(Boolean.FALSE);
95       data.put(REUSEOLDCERTIFICATE, reuseoldcertificate);
96
97       ArrayList JavaDoc minimumkeylength = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
98       minimumkeylength.add(new Integer JavaDoc(1024));
99       minimumkeylength.add(new Integer JavaDoc(1024));
100       data.put(MINIMUMKEYLENGTH, minimumkeylength);
101
102       ArrayList JavaDoc keytypes = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
103       keytypes.add(KEYTYPE_RSA);
104       keytypes.add(KEYTYPE_RSA);
105       data.put(KEYTYPES, keytypes);
106       
107       // HERE
108
}
109
110
111     
112     public int[] getAvailableMinimumKeyLengths(){
113         return AVAILABLEMINIMUMKEYLENGTHS;
114     }
115                             
116
117     /**
118      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.HardTokenProfile#isTokenSupported(java.lang.String)
119      */

120     public boolean isTokenSupported(String JavaDoc tokenidentificationstring) {
121         return this.isTokenSupported(SUPPORTEDTOKENS, tokenidentificationstring);
122     }
123
124
125
126     /*
127      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.HardTokenProfile#clone()
128      */

129     public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
130         SwedishEIDProfile clone = new SwedishEIDProfile();
131         super.clone(clone);
132
133         return clone;
134     }
135
136     /*
137      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.HardTokenProfile#getLatestVersion()
138      */

139     public float getLatestVersion() {
140       return LATEST_VERSION;
141     }
142
143     public void upgrade(){
144         if(Float.compare(LATEST_VERSION, getVersion()) != 0) {
145             // New version of the class, upgrade
146
super.upgrade();
147             
148             if(data.get(MINIMUMPINLENGTH) == null){
149                 ArrayList JavaDoc minpinlength = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
150                 minpinlength.add(new Integer JavaDoc(4));
151                 minpinlength.add(new Integer JavaDoc(4));
152                 data.put(MINIMUMPINLENGTH, minpinlength);
153             }
154             
155             if(data.get(REUSEOLDCERTIFICATE) == null){
156                 ArrayList JavaDoc reuseoldcertificate = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
157                 reuseoldcertificate.add(Boolean.FALSE);
158                 reuseoldcertificate.add(Boolean.FALSE);
159                 data.put(REUSEOLDCERTIFICATE, reuseoldcertificate);
160             }
161             
162             if(data.get(CERTWRITABLE) == null){
163                 ArrayList JavaDoc certWritable = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
164                 certWritable.add(Boolean.FALSE);
165                 certWritable.add(Boolean.FALSE);
166                 data.put(CERTWRITABLE, certWritable);
167             }
168             
169             data.put(VERSION, new Float JavaDoc(LATEST_VERSION));
170         }
171     }
172 }
173
Popular Tags