⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 localcertificatestoresessionbean.java

📁 一个免费的CA,基于EJB平台的,老师叫我们测试,现把之共享出来让大家参考
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/************************************************************************* *                                                                       * *  EJBCA: The OpenSource Certificate Authority                          * *                                                                       * *  This software is free software; you can redistribute it and/or       * *  modify it under the terms of the GNU Lesser General Public           * *  License as published by the Free Software Foundation; either         * *  version 2.1 of the License, or any later version.                    * *                                                                       * *  See terms of license at gnu.org.                                     * *                                                                       * *************************************************************************/package org.ejbca.core.ejb.ca.store;import java.math.BigInteger;import java.security.cert.Certificate;import java.security.cert.X509CRL;import java.security.cert.X509Certificate;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.util.ArrayList;import java.util.Collection;import java.util.Date;import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Random;import javax.ejb.CreateException;import javax.ejb.EJBException;import javax.ejb.FinderException;import org.apache.commons.lang.StringUtils;import org.apache.log4j.Logger;import org.ejbca.core.ejb.BaseSessionBean;import org.ejbca.core.ejb.JNDINames;import org.ejbca.core.ejb.authorization.IAuthorizationSessionLocal;import org.ejbca.core.ejb.authorization.IAuthorizationSessionLocalHome;import org.ejbca.core.ejb.ca.publisher.IPublisherSessionLocal;import org.ejbca.core.ejb.ca.publisher.IPublisherSessionLocalHome;import org.ejbca.core.ejb.log.ILogSessionLocal;import org.ejbca.core.ejb.log.ILogSessionLocalHome;import org.ejbca.core.ejb.protect.TableProtectSessionLocal;import org.ejbca.core.ejb.protect.TableProtectSessionLocalHome;import org.ejbca.core.model.InternalResources;import org.ejbca.core.model.SecConst;import org.ejbca.core.model.authorization.AuthorizationDeniedException;import org.ejbca.core.model.ca.certificateprofiles.CACertificateProfile;import org.ejbca.core.model.ca.certificateprofiles.CertificateProfile;import org.ejbca.core.model.ca.certificateprofiles.CertificateProfileExistsException;import org.ejbca.core.model.ca.certificateprofiles.EndUserCertificateProfile;import org.ejbca.core.model.ca.certificateprofiles.HardTokenAuthCertificateProfile;import org.ejbca.core.model.ca.certificateprofiles.HardTokenAuthEncCertificateProfile;import org.ejbca.core.model.ca.certificateprofiles.HardTokenEncCertificateProfile;import org.ejbca.core.model.ca.certificateprofiles.HardTokenSignCertificateProfile;import org.ejbca.core.model.ca.certificateprofiles.OCSPSignerCertificateProfile;import org.ejbca.core.model.ca.certificateprofiles.RootCACertificateProfile;import org.ejbca.core.model.ca.crl.RevokedCertInfo;import org.ejbca.core.model.ca.store.CRLInfo;import org.ejbca.core.model.ca.store.CertReqHistory;import org.ejbca.core.model.ca.store.CertificateInfo;import org.ejbca.core.model.log.Admin;import org.ejbca.core.model.log.LogConstants;import org.ejbca.core.model.log.LogEntry;import org.ejbca.core.model.protect.TableVerifyResult;import org.ejbca.core.model.ra.UserDataVO;import org.ejbca.util.CertTools;import org.ejbca.util.JDBCUtil;import org.ejbca.util.StringTools;/** * Stores certificate and CRL in the local database using Certificate and CRL Entity Beans. * Uses JNDI name for datasource as defined in env 'Datasource' in ejb-jar.xml. * * @ejb.bean display-name="CertificateStoreSB" * name="CertificateStoreSession" * jndi-name="CertificateStoreSession" * view-type="both" * type="Stateless" * transaction-type="Container" * * @ejb.transaction type="Supports" * * @weblogic.enable-call-by-reference True * * @ejb.env-entry description="JDBC datasource to be used" * name="DataSource" * type="java.lang.String" * value="${datasource.jndi-name-prefix}${datasource.jndi-name}" * * @ejb.env-entry description="Enable or disable protection of database entrys" *   name="certSigning" *   type="java.lang.String" *   value="${protection.certprotect}" *    * @ejb.ejb-external-ref description="The Certificate entity bean used to store and fetch certificates" * view-type="local" * ref-name="ejb/CertificateDataLocal" * type="Entity" * home="org.ejbca.core.ejb.ca.store.CertificateDataLocalHome" * business="org.ejbca.core.ejb.ca.store.CertificateDataLocal" * link="CertificateData" * * @ejb.ejb-external-ref description="The CRL entity bean used to store and fetch CRLs" * view-type="local" * ref-name="ejb/CRLDataLocal" * type="Entity" * home="org.ejbca.core.ejb.ca.store.CRLDataLocalHome" * business="org.ejbca.core.ejb.ca.store.CRLDataLocal" * link="CRLData" * * @ejb.ejb-external-ref description="The CertReqHistoryData Entity bean" * view-type="local" * ref-name="ejb/CertReqHistoryDataLocal" * type="Entity" * home="org.ejbca.core.ejb.ca.store.CertReqHistoryDataLocalHome" * business="org.ejbca.core.ejb.ca.store.CertReqHistoryDataLocal" * link="CertReqHistoryData" * * @ejb.ejb-external-ref description="The CertificateProfileData Entity bean" * view-type="local" * ref-name="ejb/CertificateProfileDataLocal" * type="Entity" * home="org.ejbca.core.ejb.ca.store.CertificateProfileDataLocalHome" * business="org.ejbca.core.ejb.ca.store.CertificateProfileDataLocal" * link="CertificateProfileData" *  * @ejb.ejb-external-ref description="The Log session bean" * view-type="local" * ref-name="ejb/LogSessionLocal" * type="Session" * home="org.ejbca.core.ejb.log.ILogSessionLocalHome" * business="org.ejbca.core.ejb.log.ILogSessionLocal" * link="LogSession" * * @ejb.ejb-external-ref description="The Authorization session bean" * view-type="local" * ref-name="ejb/AuthorizationSessionLocal" * type="Session" * home="org.ejbca.core.ejb.authorization.IAuthorizationSessionLocalHome" * business="org.ejbca.core.ejb.authorization.IAuthorizationSessionLocal" * link="AuthorizationSession" * * @ejb.ejb-external-ref description="Publishers are configured to store certificates and CRLs in additional places from the main database. * Publishers runs as local beans" * view-type="local" * ref-name="ejb/PublisherSessionLocal" * type="Session" * home="org.ejbca.core.ejb.ca.publisher.IPublisherSessionLocalHome" * business="org.ejbca.core.ejb.ca.publisher.IPublisherSessionLocal" * link="PublisherSession" * * @ejb.ejb-external-ref *   description="The table protection session bean" *   view-type="local" *   ref-name="ejb/TableProtectSessionLocal" *   type="Session" *   home="org.ejbca.core.ejb.protect.TableProtectSessionLocalHome" *   business="org.ejbca.core.ejb.protect.TableProtectSessionLocal" *   link="TableProtectSession" *    * @ejb.home extends="javax.ejb.EJBHome" * local-extends="javax.ejb.EJBLocalHome" * local-class="org.ejbca.core.ejb.ca.store.ICertificateStoreSessionLocalHome" * remote-class="org.ejbca.core.ejb.ca.store.ICertificateStoreSessionHome" * * @ejb.interface extends="javax.ejb.EJBObject" * local-extends="javax.ejb.EJBLocalObject" * local-class="org.ejbca.core.ejb.ca.store.ICertificateStoreSessionLocal" * remote-class="org.ejbca.core.ejb.ca.store.ICertificateStoreSessionRemote" *  * @version $Id: LocalCertificateStoreSessionBean.java,v 1.28.2.2 2007/03/01 16:16:06 anatom Exp $ *  */public class LocalCertificateStoreSessionBean extends BaseSessionBean {    /** Internal localization of logs and errors */    private static final InternalResources intres = InternalResources.getInstance();        /**     * The home interface of Certificate entity bean     */    private CertificateDataLocalHome certHome = null;    /**     * The home interface of Certificate Type entity bean     */    private CertificateProfileDataLocalHome certprofilehome = null;    /**     * The home interface of CRL entity bean     */    private CRLDataLocalHome crlHome = null;        /**     * The home interface of CertReqHistory entity bean     */    private CertReqHistoryDataLocalHome certReqHistoryHome = null;        /**     * The local interface of the log session bean     */    private ILogSessionLocal logsession = null;    /**     * The local interface of the authorization session bean     */    private IAuthorizationSessionLocal authorizationsession = null;    /** The come interface of the protection session bean */    private TableProtectSessionLocalHome protecthome = null;        /** If protection of database entries are enabled of not, default not */    private boolean protect = false;        /**     * The local interface of the publisher session bean     */    private IPublisherSessionLocal publishersession = null;    final private CertificateDataUtil.Adapter adapter;        public LocalCertificateStoreSessionBean() {        super();        adapter = new MyAdapter();    }        /**     * Default create for SessionBean without any creation Arguments.     *     * @throws CreateException if bean instance can't be created     */    public void ejbCreate() throws CreateException {        crlHome = (CRLDataLocalHome) getLocator().getLocalHome(CRLDataLocalHome.COMP_NAME);        certHome = (CertificateDataLocalHome) getLocator().getLocalHome(CertificateDataLocalHome.COMP_NAME);        certReqHistoryHome = (CertReqHistoryDataLocalHome) getLocator().getLocalHome(CertReqHistoryDataLocalHome.COMP_NAME);        certprofilehome = (CertificateProfileDataLocalHome) getLocator().getLocalHome(CertificateProfileDataLocalHome.COMP_NAME);        String sign = getLocator().getString("java:comp/env/certSigning");        if (StringUtils.equalsIgnoreCase(sign, "true")) {        	protect = true;        	protecthome = (TableProtectSessionLocalHome) getLocator().getLocalHome(TableProtectSessionLocalHome.COMP_NAME);        }    }    /**     * Gets connection to log session bean     */    protected ILogSessionLocal getLogSession() {        if (logsession == null) {            try {                ILogSessionLocalHome home = (ILogSessionLocalHome) getLocator().getLocalHome(ILogSessionLocalHome.COMP_NAME);                logsession = home.create();            } catch (Exception e) {                throw new EJBException(e);            }        }        return logsession;    } //getLogSession    /**     * Gets connection to authorization session bean     *     * @return Connection     */    private IAuthorizationSessionLocal getAuthorizationSession() {        if (authorizationsession == null) {            try {                IAuthorizationSessionLocalHome home = (IAuthorizationSessionLocalHome) getLocator().getLocalHome(IAuthorizationSessionLocalHome.COMP_NAME);                authorizationsession = home.create();            } catch (Exception e) {                throw new EJBException(e);            }        }        return authorizationsession;    } //getAuthorizationSession    /**     * Gets connection to publisher session bean     *     * @return Connection     */    private IPublisherSessionLocal getPublisherSession() {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -