📄 caadminsessionbean.java
字号:
/************************************************************************* * * * 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 se.anatom.ejbca.ca.caadmin;import java.io.UnsupportedEncodingException;import java.security.KeyStore;import java.security.PrivateKey;import java.security.PublicKey;import java.security.cert.CertPath;import java.security.cert.CertPathValidator;import java.security.cert.CertPathValidatorException;import java.security.cert.CertPathValidatorResult;import java.security.cert.Certificate;import java.security.cert.CertificateExpiredException;import java.security.cert.CertificateFactory;import java.security.cert.CertificateNotYetValidException;import java.security.cert.PKIXCertPathValidatorResult;import java.security.cert.PKIXParameters;import java.security.cert.TrustAnchor;import java.security.cert.X509Certificate;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 javax.ejb.CreateException;import javax.ejb.EJBException;import org.bouncycastle.asn1.ASN1Set;import se.anatom.ejbca.BaseSessionBean;import se.anatom.ejbca.SecConst;import se.anatom.ejbca.authorization.AuthorizationDeniedException;import se.anatom.ejbca.authorization.AvailableAccessRules;import se.anatom.ejbca.authorization.IAuthorizationSessionLocal;import se.anatom.ejbca.authorization.IAuthorizationSessionLocalHome;import se.anatom.ejbca.ca.caadmin.extendedcaservices.ExtendedCAServiceInfo;import se.anatom.ejbca.ca.caadmin.extendedcaservices.OCSPCAService;import se.anatom.ejbca.ca.caadmin.extendedcaservices.OCSPCAServiceInfo;import se.anatom.ejbca.ca.caadmin.hardcatokens.HardCATokenManager;import se.anatom.ejbca.ca.crl.ICreateCRLSessionLocal;import se.anatom.ejbca.ca.crl.ICreateCRLSessionLocalHome;import se.anatom.ejbca.ca.crl.RevokedCertInfo;import se.anatom.ejbca.ca.exception.CADoesntExistsException;import se.anatom.ejbca.ca.exception.CAExistsException;import se.anatom.ejbca.ca.exception.CATokenAuthenticationFailedException;import se.anatom.ejbca.ca.exception.CATokenOfflineException;import se.anatom.ejbca.ca.exception.IllegalKeyStoreException;import se.anatom.ejbca.ca.sign.ISignSessionLocal;import se.anatom.ejbca.ca.sign.ISignSessionLocalHome;import se.anatom.ejbca.ca.store.CertificateDataBean;import se.anatom.ejbca.ca.store.ICertificateStoreSessionLocal;import se.anatom.ejbca.ca.store.ICertificateStoreSessionLocalHome;import se.anatom.ejbca.ca.store.certificateprofiles.CertificateProfile;import se.anatom.ejbca.common.ExtendedPKCS10CertificationRequest;import se.anatom.ejbca.common.UserDataVO;import se.anatom.ejbca.exception.EjbcaException;import se.anatom.ejbca.log.Admin;import se.anatom.ejbca.log.ILogSessionLocal;import se.anatom.ejbca.log.ILogSessionLocalHome;import se.anatom.ejbca.log.LogEntry;import se.anatom.ejbca.protocol.IRequestMessage;import se.anatom.ejbca.protocol.IResponseMessage;import se.anatom.ejbca.protocol.PKCS10RequestMessage;import se.anatom.ejbca.protocol.X509ResponseMessage;import se.anatom.ejbca.util.CertTools;import se.anatom.ejbca.util.KeyTools;/** * Administrates and manages CAs in EJBCA system. * * @version $Id: CAAdminSessionBean.java,v 1.42.2.3 2005/11/24 21:16:37 herrvendil Exp $ * * @ejb.bean description="Session bean handling core CA function,signing certificates" * display-name="CAAdminSB" * name="CAAdminSession" * jndi-name="CAAdminSession" * local-jndi-name="CAAdminSessionLocal" * view-type="both" * type="Stateless" * transaction-type="Container" * * @ejb.transaction type="Required" * * @ejb.permission role-name="InternalUser" * * @ejb.env-entry description="Used internally to keystores in database" * name="keyStorePass" * type="java.lang.String" * value="${ca.keystorepass}" * @ejb.env-entry description="Password for OCSP keystores" * name="OCSPKeyStorePass" * type="java.lang.String" * value="${ca.ocspkeystorepass}" * * @ejb.ejb-external-ref description="The CA entity bean" * view-type="local" * ejb-name="CADataLocal" * type="Entity" * home="se.anatom.ejbca.ca.caadmin.ICADataLocalHome" * business="se.anatom.ejbca.ca.caadmin.ICADataLocal" * link="CAData" * * @ejb.ejb-external-ref description="The log session bean" * view-type="local" * ejb-name="LogSessionLocal" * type="Session" * home="se.anatom.ejbca.log.ILogSessionLocalHome" * business="se.anatom.ejbca.log.ILogSessionLocal" * link="LogSession" * * @ejb.ejb-external-ref description="The Authorization Session Bean" * view-type="local" * ejb-name="AuthorizationSessionLocal" * type="Session" * home="se.anatom.ejbca.authorization.IAuthorizationSessionLocalHome" * business="se.anatom.ejbca.authorization.IAuthorizationSessionLocal" * link="AuthorizationSession" * * @ejb.ejb-external-ref description="The Certificate store used to store and fetch certificates" * view-type="local" * ejb-name="CertificateStoreSessionLocal" * type="Session" * home="se.anatom.ejbca.ca.store.ICertificateStoreSessionLocalHome" * business="se.anatom.ejbca.ca.store.ICertificateStoreSessionLocal" * link="CertificateStoreSession" * * @ejb.ejb-external-ref description="The Sign Session Bean" * view-type="local" * ejb-name="RSASignSessionLocal" * type="Session" * home="se.anatom.ejbca.ca.sign.ISignSessionLocalHome" * business="se.anatom.ejbca.ca.store.ISignSessionLocal" * link="RSASignSession" * * @ejb.ejb-external-ref description="The CRL Create bean" * view-type="local" * ejb-name="CreateCRLSessionLocal" * type="Session" * home="se.anatom.ejbca.ca.crl.ICreateCRLSessionLocalHome" * business="se.anatom.ejbca.ca.crl.ICreateCRLSessionLocal" * link="CreateCRLSession" * * @ejb.home * extends="javax.ejb.EJBHome" * remote-class="se.anatom.ejbca.ca.caadmin.ICAAdminSessionHome" * local-extends="javax.ejb.EJBLocalHome" * local-class="se.anatom.ejbca.ca.caadmin.ICAAdminSessionLocalHome" * * @ejb.interface * extends="javax.ejb.EJBObject" * remote-class="se.anatom.ejbca.ca.caadmin.ICAAdminSessionRemote" * local-extends="javax.ejb.EJBLocalObject" * local-class="se.anatom.ejbca.ca.caadmin.ICAAdminSessionLocal" * * @ejb.security-identity * run-as="InternalUser" */public class CAAdminSessionBean extends BaseSessionBean { /** The local home interface of CAData.*/ private CADataLocalHome cadatahome; /** The local interface of the log session bean */ private ILogSessionLocal logsession; /** The local interface of the authorization session bean */ private IAuthorizationSessionLocal authorizationsession; /** The local interface of the certificate store session bean */ private ICertificateStoreSessionLocal certificatestoresession; /** The local interface of the sign session bean */ private ISignSessionLocal signsession; /** The local interface of the job runner session bean used to create crls.*/ private ICreateCRLSessionLocal jobrunner; /** * Default create for SessionBean without any creation Arguments. * @throws CreateException if bean instance can't be created */ public void ejbCreate() throws CreateException { cadatahome = (CADataLocalHome)getLocator().getLocalHome(CADataLocalHome.COMP_NAME); // Install BouncyCastle provider CertTools.installBCProvider(); } /** Gets connection to log session bean */ private 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 crl create session bean * @return Connection */ private ICreateCRLSessionLocal getCRLCreateSession() { if(jobrunner == null){ try{ ICreateCRLSessionLocalHome home = (ICreateCRLSessionLocalHome) getLocator().getLocalHome(ICreateCRLSessionLocalHome.COMP_NAME); jobrunner = home.create(); }catch(Exception e){ throw new EJBException(e); } } return jobrunner; } /** Gets connection to certificate store session bean * @return Connection */ private ICertificateStoreSessionLocal getCertificateStoreSession() { if(certificatestoresession == null){ try{ ICertificateStoreSessionLocalHome home = (ICertificateStoreSessionLocalHome) getLocator().getLocalHome(ICertificateStoreSessionLocalHome.COMP_NAME); certificatestoresession = home.create(); }catch(Exception e){ throw new EJBException(e); } } return certificatestoresession; } //getCertificateStoreSession /** Gets connection to sign session bean * @return Connection */ private ISignSessionLocal getSignSession() { if(signsession == null){ try{ ISignSessionLocalHome signsessionhome = (ISignSessionLocalHome) getLocator().getLocalHome(ISignSessionLocalHome.COMP_NAME); signsession = signsessionhome.create();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -