1 13 14 package org.ejbca.core.model.hardtoken.profiles; 15 16 import java.io.Serializable ; 17 import java.util.List ; 18 19 import org.ejbca.core.model.UpgradeableDataHashMap; 20 21 22 32 public abstract class HardTokenProfile extends UpgradeableDataHashMap implements Serializable , Cloneable { 33 35 36 public static final String TRUE = "true"; 37 public static final String FALSE = "false"; 38 39 public static final int PINTYPE_ASCII_NUMERIC = 1; 40 public static final int PINTYPE_UTF8 = 2; 41 public static final int PINTYPE_ISO9564_1 = 4; 42 43 public static final String TYPE = "type"; 45 46 protected static final String NUMBEROFCOPIES = "numberofcopies"; 47 protected static final String EREASABLETOKEN = "ereasabletoken"; 48 protected static final String HARDTOKENPREFIX = "hardtokenprefix"; 49 protected static final String PINTYPE = "pintype"; 50 protected static final String MINIMUMPINLENGTH = "minimumpinlength"; 51 protected static final String GENERATEIDENTICALPINFORCOPIES = "generateidenticalpinforcopies"; 52 54 57 public HardTokenProfile() { 58 setNumberOfCopies(1); 59 setEreasableToken(true); 60 setHardTokenSNPrefix("000000"); 61 setGenerateIdenticalPINForCopies(true); 62 } 63 64 70 public int getNumberOfCopies(){return ((Integer )data.get(NUMBEROFCOPIES)).intValue();} 71 72 76 77 public boolean getGenerateIdenticalPINForCopies(){return ((Boolean ) data.get(GENERATEIDENTICALPINFORCOPIES)).booleanValue();} 78 79 84 public boolean getEreasableToken(){ return ((Boolean )data.get(EREASABLETOKEN)).booleanValue(); } 85 86 92 93 public String getHardTokenSNPrefix(){ return (String ) data.get(HARDTOKENPREFIX); } 94 95 96 97 103 public abstract boolean isTokenSupported(String tokenidentificationstring); 104 106 public void setNumberOfCopies(int numberofcopies) { data.put(NUMBEROFCOPIES,new Integer (numberofcopies));} 107 108 public void setEreasableToken(boolean ereasabletoken) {data.put(EREASABLETOKEN, Boolean.valueOf(ereasabletoken));} 109 110 public void setHardTokenSNPrefix(String hardtokensnprefix){ data.put(HARDTOKENPREFIX,hardtokensnprefix); } 111 112 public void setGenerateIdenticalPINForCopies(boolean generate){ data.put(GENERATEIDENTICALPINFORCOPIES, Boolean.valueOf(generate));} 113 114 121 public int getPINType(int certusage){ 122 return ((Integer ) ((List ) data.get(PINTYPE)).get(certusage)).intValue(); 123 } 124 125 public void setPINType(int certusage, int pintype){ 126 ((List ) data.get(PINTYPE)).set(certusage, new Integer (pintype)); 127 } 128 129 136 public int getMinimumPINLength(int certusage){ 137 return ((Integer ) ((List ) data.get(MINIMUMPINLENGTH)).get(certusage)).intValue(); 138 } 139 140 public void setMinimumPINLength(int certusage, int length){ 141 ((List ) data.get(MINIMUMPINLENGTH)).set(certusage, new Integer (length)); 142 } 143 144 public abstract Object clone() throws CloneNotSupportedException ; 145 146 147 public abstract float getLatestVersion(); 148 149 150 public void upgrade(){ 151 } 153 154 protected boolean isTokenSupported(String [] supportedtokens, String tokenidentificationstring){ 156 boolean returnval = false; 157 for(int i=0; i<supportedtokens.length; i++){ 158 if(supportedtokens[i].equals(tokenidentificationstring)) 159 returnval=true; 160 } 161 162 return returnval; 163 } 164 165 166 167 } 168 | Popular Tags |