1 13 14 package org.ejbca.core.ejb.ca.store; 15 16 import java.math.BigInteger ; 17 import java.security.cert.Certificate ; 18 import java.security.cert.X509Certificate ; 19 import java.util.Collection ; 20 import java.util.Date ; 21 22 import javax.ejb.CreateException ; 23 24 import org.apache.commons.lang.StringUtils; 25 import org.apache.log4j.Logger; 26 import org.ejbca.core.ejb.BaseSessionBean; 27 import org.ejbca.core.ejb.protect.TableProtectSessionLocalHome; 28 import org.ejbca.core.model.ca.crl.RevokedCertInfo; 29 import org.ejbca.core.model.log.Admin; 30 import org.ejbca.util.CertTools; 31 32 86 public class LocalCertificateStoreOnlyDataSessionBean extends BaseSessionBean { 87 88 91 private CertificateDataLocalHome certHome = null; 92 private final CertificateDataUtil.Adapter adapter; 93 94 95 private TableProtectSessionLocalHome protecthome = null; 96 97 public LocalCertificateStoreOnlyDataSessionBean() { 98 super(); 99 CertTools.installBCProvider(); 100 adapter = new MyAdapter(); 101 } 102 103 112 public RevokedCertInfo isRevoked(Admin admin, String issuerDN, BigInteger serno) { 113 return CertificateDataUtil.isRevoked(admin, issuerDN, serno, certHome, protecthome, adapter); 114 } 116 125 public Certificate findCertificateByIssuerAndSerno(Admin admin, String issuerDN, BigInteger serno) { 126 return CertificateDataUtil.findCertificateByIssuerAndSerno(admin, issuerDN, serno, certHome, adapter); 127 } 129 197 public Collection findCertificatesByType(Admin admin, int type, String issuerDN) { 198 return CertificateDataUtil.findCertificatesByType(admin, type, issuerDN, certHome, adapter); 199 } 201 private class MyAdapter implements CertificateDataUtil.Adapter { 202 205 public Logger getLogger() { 206 return log; 207 } 208 211 public void log(Admin admin, int caid, int module, Date time, String username, X509Certificate certificate, int event, String comment) { 212 } 214 217 public void debug(String s) { 218 LocalCertificateStoreOnlyDataSessionBean.this.debug(s); 219 } 220 223 public void error(String s) { 224 LocalCertificateStoreOnlyDataSessionBean.this.error(s); 225 } 226 229 public void error(String s, Exception e) { 230 LocalCertificateStoreOnlyDataSessionBean.this.error(s, e); 231 } 232 } 233 234 239 public void ejbCreate() { 240 certHome = (CertificateDataLocalHome) getLocator().getLocalHome(CertificateDataLocalHome.COMP_NAME); 241 String sign = getLocator().getString("java:comp/env/certSigning"); 242 if (StringUtils.equalsIgnoreCase(sign, "true")) { 243 protecthome = (TableProtectSessionLocalHome) getLocator().getLocalHome(TableProtectSessionLocalHome.COMP_NAME); 244 } 245 } 246 247 } 248 | Popular Tags |