1 13 14 package org.ejbca.core.ejb.hardtoken; 15 16 import javax.ejb.CreateException ; 17 import java.util.HashMap ; 18 import java.util.Date ; 19 import org.apache.log4j.Logger; 20 import org.ejbca.core.ejb.BaseEntityBean; 21 import org.ejbca.core.model.SecConst; 22 import org.ejbca.core.model.hardtoken.types.*; 23 import org.ejbca.util.StringTools; 24 25 26 81 public abstract class HardTokenDataBean extends BaseEntityBean { 82 83 84 85 private static final Logger log = Logger.getLogger(HardTokenIssuerDataBean.class); 86 87 92 public abstract String getTokenSN(); 93 94 96 public abstract void setTokenSN(String tokensn); 97 98 102 public abstract String getUsername(); 103 104 109 public abstract void setUsername(String username); 110 111 114 public abstract long getCtime(); 115 116 118 public abstract void setCtime(long createtime); 119 120 123 public abstract long getMtime(); 124 125 127 public abstract void setMtime(long modifytime); 128 129 133 public abstract int getTokenType(); 134 135 138 public abstract void setTokenType(int tokentype); 139 140 144 public abstract String getSignificantIssuerDN(); 145 146 149 public abstract void setSignificantIssuerDN(String significantissuerdn); 150 151 155 public abstract HashMap getData(); 156 157 159 public abstract void setData(HashMap data); 160 161 164 public Date getCreateTime(){ return new Date (getCtime()); } 165 166 169 public void setCreateTime(Date createtime){ setCtime(createtime.getTime()); } 170 171 174 public Date getModifyTime(){ return new Date (getCtime()); } 175 176 179 public void setModifyTime(Date modifytime){ setMtime(modifytime.getTime()); } 180 181 185 public HardToken getHardToken(){ 186 HardToken returnval = null; 187 HashMap data = getData(); 188 int tokentype = ((Integer ) data.get(HardToken.TOKENTYPE)).intValue(); 189 190 switch(tokentype){ 191 case SecConst.TOKEN_SWEDISHEID : 192 returnval = new SwedishEIDHardToken(); 193 break; 194 case SecConst.TOKEN_ENHANCEDEID : 195 returnval = new EnhancedEIDHardToken(); 196 break; 197 case SecConst.TOKEN_TURKISHEID : 198 returnval = new TurkishEIDHardToken(); 199 break; 200 case SecConst.TOKEN_EID : returnval = new EIDHardToken(); 202 break; 203 default: 204 returnval = new EIDHardToken(); 205 break; 206 } 207 208 returnval.loadData(data); 209 return returnval; 210 } 211 212 216 public void setHardToken(HardToken tokendata){ 217 setData((HashMap ) tokendata.saveData()); 218 } 219 220 221 225 226 232 public String ejbCreate(String tokensn, String username, Date createtime, Date modifytime, int tokentype, String significantissuerdn, HardToken tokendata) throws CreateException { 233 setTokenSN(tokensn); 234 setUsername(StringTools.strip(username)); 235 setCtime(createtime.getTime()); 236 setMtime(modifytime.getTime()); 237 setTokenType(tokentype); 238 setSignificantIssuerDN(significantissuerdn); 239 setHardToken(tokendata); 240 241 log.debug("Created Hard Token "+ tokensn ); 242 return tokensn; 243 } 244 245 public void ejbPostCreate(String tokensn, String username, Date createtime, Date modifytime, int tokentype, String significantissuerdn, HardToken tokendata) { 246 } 248 } 249 | Popular Tags |