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 SwedishEIDProfile extends EIDProfile { 29 30 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 static final int NUMBEROFCERTIFICATES = 2; 43 44 45 public static final int[] AVAILABLEMINIMUMKEYLENGTHS = {1024, 2048}; 47 48 49 51 private String [][] SUPPORTEDTOKENS = {{"TODO"}}; 52 53 54 55 public SwedishEIDProfile() { 57 super(); 58 59 data.put(TYPE, new Integer (TYPE_SWEDISHEID)); 60 61 ArrayList certprofileids = new ArrayList (NUMBEROFCERTIFICATES); 62 certprofileids.add(new Integer (SecConst.CERTPROFILE_FIXED_HARDTOKENSIGN)); 63 certprofileids.add(new Integer (SecConst.CERTPROFILE_FIXED_HARDTOKENAUTHENC)); 64 data.put(CERTIFICATEPROFILEID, certprofileids); 65 66 ArrayList certWritable = new ArrayList (NUMBEROFCERTIFICATES); 67 certWritable.add(Boolean.FALSE); 68 certWritable.add(Boolean.FALSE); 69 data.put(CERTWRITABLE, certWritable); 70 71 ArrayList caids = new ArrayList (NUMBEROFCERTIFICATES); 72 caids.add(new Integer (CAID_USEUSERDEFINED)); 73 caids.add(new Integer (CAID_USEUSERDEFINED)); 74 data.put(CAID, caids); 75 76 ArrayList pintypes = new ArrayList (NUMBEROFCERTIFICATES); 77 pintypes.add(new Integer (PINTYPE_ASCII_NUMERIC)); 78 pintypes.add(new Integer (PINTYPE_ASCII_NUMERIC)); 79 data.put(PINTYPE, pintypes); 80 81 ArrayList minpinlength = new ArrayList (NUMBEROFCERTIFICATES); 82 minpinlength.add(new Integer (4)); 83 minpinlength.add(new Integer (4)); 84 data.put(MINIMUMPINLENGTH, minpinlength); 85 86 ArrayList iskeyrecoverable = new ArrayList (NUMBEROFCERTIFICATES); 87 iskeyrecoverable.add(new Boolean (false)); 88 iskeyrecoverable.add(new Boolean (false)); 89 data.put(ISKEYRECOVERABLE, iskeyrecoverable); 90 91 92 ArrayList reuseoldcertificate = new ArrayList (NUMBEROFCERTIFICATES); 93 reuseoldcertificate.add(Boolean.FALSE); 94 reuseoldcertificate.add(Boolean.FALSE); 95 data.put(REUSEOLDCERTIFICATE, reuseoldcertificate); 96 97 ArrayList minimumkeylength = new ArrayList (NUMBEROFCERTIFICATES); 98 minimumkeylength.add(new Integer (1024)); 99 minimumkeylength.add(new Integer (1024)); 100 data.put(MINIMUMKEYLENGTH, minimumkeylength); 101 102 ArrayList keytypes = new ArrayList (NUMBEROFCERTIFICATES); 103 keytypes.add(KEYTYPE_RSA); 104 keytypes.add(KEYTYPE_RSA); 105 data.put(KEYTYPES, keytypes); 106 107 } 109 110 111 112 public int[] getAvailableMinimumKeyLengths(){ 113 return AVAILABLEMINIMUMKEYLENGTHS; 114 } 115 116 117 120 public boolean isTokenSupported(String tokenidentificationstring) { 121 return this.isTokenSupported(SUPPORTEDTOKENS, tokenidentificationstring); 122 } 123 124 125 126 129 public Object clone() throws CloneNotSupportedException { 130 SwedishEIDProfile clone = new SwedishEIDProfile(); 131 super.clone(clone); 132 133 return clone; 134 } 135 136 139 public float getLatestVersion() { 140 return LATEST_VERSION; 141 } 142 143 public void upgrade(){ 144 if(Float.compare(LATEST_VERSION, getVersion()) != 0) { 145 super.upgrade(); 147 148 if(data.get(MINIMUMPINLENGTH) == null){ 149 ArrayList minpinlength = new ArrayList (NUMBEROFCERTIFICATES); 150 minpinlength.add(new Integer (4)); 151 minpinlength.add(new Integer (4)); 152 data.put(MINIMUMPINLENGTH, minpinlength); 153 } 154 155 if(data.get(REUSEOLDCERTIFICATE) == null){ 156 ArrayList reuseoldcertificate = new ArrayList (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 certWritable = new ArrayList (NUMBEROFCERTIFICATES); 164 certWritable.add(Boolean.FALSE); 165 certWritable.add(Boolean.FALSE); 166 data.put(CERTWRITABLE, certWritable); 167 } 168 169 data.put(VERSION, new Float (LATEST_VERSION)); 170 } 171 } 172 } 173 | Popular Tags |