KickJava   Java API By Example, From Geeks To Geeks.

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


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  * EnhancedEIDProfile with three certificates and key recovery functionallity
25  *
26  * @version $Id: EnhancedEIDProfile.java,v 1.3 2006/07/11 13:03:04 herrvendil Exp $
27  */

28 public class EnhancedEIDProfile extends EIDProfile {
29                         
30     // Public Constants
31

32     public static final int TYPE_ENHANCEDEID = 2;
33     
34     public static final float LATEST_VERSION = 4;
35
36     public static final int CERTUSAGE_SIGN = 0;
37     public static final int CERTUSAGE_AUTH = 1;
38     public static final int CERTUSAGE_ENC = 2;
39     
40     public static final int PINTYPE_AUTH_SAME_AS_SIGN = SwedishEIDProfile.PINTYPE_AUTHENC_SAME_AS_SIGN;
41     public static final int PINTYPE_ENC_SAME_AS_AUTH = 101;
42     
43     // Protected Constants
44
protected static final int NUMBEROFCERTIFICATES = 3;
45     
46     
47     // Private Constants
48
public static final int[] AVAILABLEMINIMUMKEYLENGTHS = {1024, 2048};
49     
50     // Protected Fields
51

52     private String JavaDoc[][] SUPPORTEDTOKENS = {{"TODO"}};
53         
54     
55     // Default Values
56
public EnhancedEIDProfile() {
57       super();
58                
59       data.put(TYPE, new Integer JavaDoc(TYPE_ENHANCEDEID));
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_HARDTOKENAUTH));
64       certprofileids.add(new Integer JavaDoc(SecConst.CERTPROFILE_FIXED_HARDTOKENENC));
65       data.put(CERTIFICATEPROFILEID, certprofileids);
66       
67       ArrayList JavaDoc certWritable = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
68       certWritable.add(Boolean.FALSE);
69       certWritable.add(Boolean.FALSE);
70       certWritable.add(Boolean.FALSE);
71       data.put(CERTWRITABLE, certWritable);
72           
73       ArrayList JavaDoc caids = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
74       caids.add(new Integer JavaDoc(CAID_USEUSERDEFINED));
75       caids.add(new Integer JavaDoc(CAID_USEUSERDEFINED));
76       caids.add(new Integer JavaDoc(CAID_USEUSERDEFINED));
77       data.put(CAID, caids);
78       
79       ArrayList JavaDoc pintypes = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
80       pintypes.add(new Integer JavaDoc(PINTYPE_ASCII_NUMERIC));
81       pintypes.add(new Integer JavaDoc(PINTYPE_ASCII_NUMERIC));
82       pintypes.add(new Integer JavaDoc(PINTYPE_ENC_SAME_AS_AUTH));
83       data.put(PINTYPE, pintypes);
84       
85       ArrayList JavaDoc minpinlength = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
86       minpinlength.add(new Integer JavaDoc(4));
87       minpinlength.add(new Integer JavaDoc(4));
88       minpinlength.add(new Integer JavaDoc(0));
89       data.put(MINIMUMPINLENGTH, minpinlength);
90       
91       ArrayList JavaDoc iskeyrecoverable = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
92       iskeyrecoverable.add(Boolean.FALSE);
93       iskeyrecoverable.add(Boolean.FALSE);
94       iskeyrecoverable.add(Boolean.TRUE);
95       data.put(ISKEYRECOVERABLE, iskeyrecoverable);
96       
97       ArrayList JavaDoc reuseoldcertificate = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
98       reuseoldcertificate.add(Boolean.FALSE);
99       reuseoldcertificate.add(Boolean.FALSE);
100       reuseoldcertificate.add(Boolean.FALSE);
101       data.put(REUSEOLDCERTIFICATE, reuseoldcertificate);
102
103       ArrayList JavaDoc minimumkeylength = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
104       minimumkeylength.add(new Integer JavaDoc(2048));
105       minimumkeylength.add(new Integer JavaDoc(2048));
106       minimumkeylength.add(new Integer JavaDoc(2048));
107       data.put(MINIMUMKEYLENGTH, minimumkeylength);
108
109       ArrayList JavaDoc keytypes = new ArrayList JavaDoc(NUMBEROFCERTIFICATES);
110       keytypes.add(KEYTYPE_RSA);
111       keytypes.add(KEYTYPE_RSA);
112       keytypes.add(KEYTYPE_RSA);
113       data.put(KEYTYPES, keytypes);
114          
115     }
116
117
118     
119     public int[] getAvailableMinimumKeyLengths(){
120         return AVAILABLEMINIMUMKEYLENGTHS;
121     }
122                             
123
124     /**
125      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.HardTokenProfile#isTokenSupported(java.lang.String)
126      */

127     public boolean isTokenSupported(String JavaDoc tokenidentificationstring) {
128         return this.isTokenSupported(SUPPORTEDTOKENS, tokenidentificationstring);
129     }
130
131
132     /*
133      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.HardTokenProfile#clone()
134      */

135     public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
136         EnhancedEIDProfile clone = new EnhancedEIDProfile();
137         
138         super.clone(clone);
139
140         return clone;
141     }
142
143     /*
144      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.HardTokenProfile#getLatestVersion()
145      */

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