1 13 14 package org.ejbca.core.model.hardtoken.profiles; 15 16 17 import java.util.ArrayList ; 18 19 import org.ejbca.core.model.SecConst; 20 21 22 23 28 public class EnhancedEIDProfile extends EIDProfile { 29 30 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 static final int NUMBEROFCERTIFICATES = 3; 45 46 47 public static final int[] AVAILABLEMINIMUMKEYLENGTHS = {1024, 2048}; 49 50 52 private String [][] SUPPORTEDTOKENS = {{"TODO"}}; 53 54 55 public EnhancedEIDProfile() { 57 super(); 58 59 data.put(TYPE, new Integer (TYPE_ENHANCEDEID)); 60 61 ArrayList certprofileids = new ArrayList (NUMBEROFCERTIFICATES); 62 certprofileids.add(new Integer (SecConst.CERTPROFILE_FIXED_HARDTOKENSIGN)); 63 certprofileids.add(new Integer (SecConst.CERTPROFILE_FIXED_HARDTOKENAUTH)); 64 certprofileids.add(new Integer (SecConst.CERTPROFILE_FIXED_HARDTOKENENC)); 65 data.put(CERTIFICATEPROFILEID, certprofileids); 66 67 ArrayList certWritable = new ArrayList (NUMBEROFCERTIFICATES); 68 certWritable.add(Boolean.FALSE); 69 certWritable.add(Boolean.FALSE); 70 certWritable.add(Boolean.FALSE); 71 data.put(CERTWRITABLE, certWritable); 72 73 ArrayList caids = new ArrayList (NUMBEROFCERTIFICATES); 74 caids.add(new Integer (CAID_USEUSERDEFINED)); 75 caids.add(new Integer (CAID_USEUSERDEFINED)); 76 caids.add(new Integer (CAID_USEUSERDEFINED)); 77 data.put(CAID, caids); 78 79 ArrayList pintypes = new ArrayList (NUMBEROFCERTIFICATES); 80 pintypes.add(new Integer (PINTYPE_ASCII_NUMERIC)); 81 pintypes.add(new Integer (PINTYPE_ASCII_NUMERIC)); 82 pintypes.add(new Integer (PINTYPE_ENC_SAME_AS_AUTH)); 83 data.put(PINTYPE, pintypes); 84 85 ArrayList minpinlength = new ArrayList (NUMBEROFCERTIFICATES); 86 minpinlength.add(new Integer (4)); 87 minpinlength.add(new Integer (4)); 88 minpinlength.add(new Integer (0)); 89 data.put(MINIMUMPINLENGTH, minpinlength); 90 91 ArrayList iskeyrecoverable = new ArrayList (NUMBEROFCERTIFICATES); 92 iskeyrecoverable.add(Boolean.FALSE); 93 iskeyrecoverable.add(Boolean.FALSE); 94 iskeyrecoverable.add(Boolean.TRUE); 95 data.put(ISKEYRECOVERABLE, iskeyrecoverable); 96 97 ArrayList reuseoldcertificate = new ArrayList (NUMBEROFCERTIFICATES); 98 reuseoldcertificate.add(Boolean.FALSE); 99 reuseoldcertificate.add(Boolean.FALSE); 100 reuseoldcertificate.add(Boolean.FALSE); 101 data.put(REUSEOLDCERTIFICATE, reuseoldcertificate); 102 103 ArrayList minimumkeylength = new ArrayList (NUMBEROFCERTIFICATES); 104 minimumkeylength.add(new Integer (2048)); 105 minimumkeylength.add(new Integer (2048)); 106 minimumkeylength.add(new Integer (2048)); 107 data.put(MINIMUMKEYLENGTH, minimumkeylength); 108 109 ArrayList keytypes = new ArrayList (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 127 public boolean isTokenSupported(String tokenidentificationstring) { 128 return this.isTokenSupported(SUPPORTEDTOKENS, tokenidentificationstring); 129 } 130 131 132 135 public Object clone() throws CloneNotSupportedException { 136 EnhancedEIDProfile clone = new EnhancedEIDProfile(); 137 138 super.clone(clone); 139 140 return clone; 141 } 142 143 146 public float getLatestVersion() { 147 return LATEST_VERSION; 148 } 149 150 public void upgrade(){ 151 if(Float.compare(LATEST_VERSION, getVersion()) != 0) { 152 super.upgrade(); 154 155 if(data.get(MINIMUMPINLENGTH) == null){ 156 ArrayList minpinlength = new ArrayList (NUMBEROFCERTIFICATES); 157 minpinlength.add(new Integer (4)); 158 minpinlength.add(new Integer (4)); 159 minpinlength.add(new Integer (0)); 160 data.put(MINIMUMPINLENGTH, minpinlength); 161 } 162 163 if(data.get(REUSEOLDCERTIFICATE) == null){ 164 ArrayList reuseoldcertificate = new ArrayList (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 certWritable = new ArrayList (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 (LATEST_VERSION)); 180 } 181 } 182 } 183 | Popular Tags |