1 13 14 package org.ejbca.core.ejb.keyrecovery; 15 16 import org.apache.log4j.Logger; 17 import org.ejbca.core.ejb.BaseEntityBean; 18 import org.ejbca.util.Base64; 19 import org.ejbca.util.StringTools; 20 21 22 23 import javax.ejb.CreateException ; 24 import java.math.BigInteger ; 25 26 27 89 public abstract class KeyRecoveryDataBean extends BaseEntityBean { 90 private static final Logger log = Logger.getLogger(KeyRecoveryDataBean.class); 91 92 96 public abstract String getCertSN(); 97 98 100 public abstract void setCertSN(String certificatesn); 101 102 107 public abstract String getIssuerDN(); 108 109 111 public abstract void setIssuerDN(String issuerdn); 112 113 117 public abstract String getUsername(); 118 119 125 public abstract void setUsername(String username); 126 127 131 public abstract boolean getMarkedAsRecoverable(); 132 133 136 public abstract void setMarkedAsRecoverable(boolean markedasrecoverable); 137 138 141 public abstract String getKeyData(); 142 143 145 public abstract void setKeyData(String keydata); 146 147 150 public BigInteger getCertificateSN() { 151 return new BigInteger (getCertSN(), 16); 152 } 153 154 157 public void setCertificateSN(BigInteger certificatesn) { 158 setCertSN(certificatesn.toString(16)); 159 } 160 161 164 public byte[] getKeyDataAsByteArray() { 165 return Base64.decode(this.getKeyData().getBytes()); 166 } 167 168 171 public void setKeyDataFromByteArray(byte[] keydata) { 172 setKeyData(new String (Base64.encode(keydata))); 173 } 174 175 179 191 public KeyRecoveryDataPK ejbCreate(BigInteger certificatesn, String issuerdn, String username, 192 byte[] keydata) throws CreateException { 193 setCertificateSN(certificatesn); 194 setIssuerDN(issuerdn); 195 setUsername(StringTools.strip(username)); 196 setMarkedAsRecoverable(false); 197 setKeyDataFromByteArray(keydata); 198 KeyRecoveryDataPK pk = new KeyRecoveryDataPK(getCertSN(), issuerdn); 199 log.debug("Created Key Recoverydata for user " + username); 200 return pk; 201 } 202 203 public void ejbPostCreate(BigInteger certificatesn, String issuerdn, String username, 204 byte[] keydata) { 205 } 207 208 } 209 | Popular Tags |