📄 rsasignsessionbean.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 org.ejbca.core.ejb.ca.sign;import java.io.IOException;import java.io.UnsupportedEncodingException;import java.math.BigInteger;import java.security.InvalidKeyException;import java.security.NoSuchAlgorithmException;import java.security.NoSuchProviderException;import java.security.PublicKey;import java.security.SecureRandom;import java.security.cert.CRLException;import java.security.cert.Certificate;import java.security.cert.CertificateExpiredException;import java.security.cert.CertificateNotYetValidException;import java.security.cert.X509CRL;import java.security.cert.X509Certificate;import java.util.Arrays;import java.util.Collection;import java.util.Date;import java.util.Iterator;import java.util.Vector;import javax.ejb.CreateException;import javax.ejb.EJBException;import javax.ejb.ObjectNotFoundException;import org.ejbca.core.ejb.BaseSessionBean;import org.ejbca.core.ejb.ca.auth.IAuthenticationSessionLocal;import org.ejbca.core.ejb.ca.auth.IAuthenticationSessionLocalHome;import org.ejbca.core.ejb.ca.caadmin.CADataLocal;import org.ejbca.core.ejb.ca.caadmin.CADataLocalHome;import org.ejbca.core.ejb.ca.publisher.IPublisherSessionLocal;import org.ejbca.core.ejb.ca.publisher.IPublisherSessionLocalHome;import org.ejbca.core.ejb.ca.store.CertificateDataBean;import org.ejbca.core.ejb.ca.store.ICertificateStoreSessionLocal;import org.ejbca.core.ejb.ca.store.ICertificateStoreSessionLocalHome;import org.ejbca.core.ejb.log.ILogSessionLocal;import org.ejbca.core.ejb.log.ILogSessionLocalHome;import org.ejbca.core.model.InternalResources;import org.ejbca.core.model.SecConst;import org.ejbca.core.model.ca.AuthLoginException;import org.ejbca.core.model.ca.AuthStatusException;import org.ejbca.core.model.ca.IllegalKeyException;import org.ejbca.core.model.ca.SignRequestException;import org.ejbca.core.model.ca.SignRequestSignatureException;import org.ejbca.core.model.ca.caadmin.CA;import org.ejbca.core.model.ca.caadmin.CADoesntExistsException;import org.ejbca.core.model.ca.caadmin.IllegalKeyStoreException;import org.ejbca.core.model.ca.caadmin.extendedcaservices.ExtendedCAServiceNotActiveException;import org.ejbca.core.model.ca.caadmin.extendedcaservices.ExtendedCAServiceRequest;import org.ejbca.core.model.ca.caadmin.extendedcaservices.ExtendedCAServiceRequestException;import org.ejbca.core.model.ca.caadmin.extendedcaservices.ExtendedCAServiceResponse;import org.ejbca.core.model.ca.caadmin.extendedcaservices.IllegalExtendedCAServiceRequestException;import org.ejbca.core.model.ca.catoken.CAToken;import org.ejbca.core.model.ca.catoken.CATokenOfflineException;import org.ejbca.core.model.ca.certificateprofiles.CertificateProfile;import org.ejbca.core.model.ca.crl.RevokedCertInfo;import org.ejbca.core.model.log.Admin;import org.ejbca.core.model.log.LogEntry;import org.ejbca.core.model.ra.NotFoundException;import org.ejbca.core.model.ra.UserDataVO;import org.ejbca.core.protocol.FailInfo;import org.ejbca.core.protocol.IRequestMessage;import org.ejbca.core.protocol.IResponseMessage;import org.ejbca.core.protocol.ResponseStatus;import org.ejbca.util.CertTools;import org.ejbca.util.KeyTools;/** * Creates and signs certificates. * * @ejb.bean description="Session bean handling core CA function,signing certificates" * display-name="RSASignSessionSB" * name="RSASignSession" * jndi-name="RSASignSession" * local-jndi-name="SignSessionLocal" * view-type="both" * type="Stateless" * transaction-type="Container" * * @ejb.transaction type="Required" * * @weblogic.enable-call-by-reference True * * @ejb.env-entry description="Name of PRNG algorithm used for random source - refer to Appendix A in the * Java Cryptography Architecture API Specification And Reference for * information about standard PRNG algorithm names" * name="randomAlgorithm" * type="java.lang.String" * value="SHA1PRNG" * * @ejb.ejb-external-ref description="The CA entity bean" * view-type="local" * ref-name="ejb/CADataLocal" * type="Entity" * home="org.ejbca.core.ejb.ca.caadmin.CADataLocalHome" * business="org.ejbca.core.ejb.ca.caadmin.CADataLocal" * link="CAData" * * @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 Certificate store used to store and fetch certificates" * view-type="local" * ref-name="ejb/CertificateStoreSessionLocal" * type="Session" * home="org.ejbca.core.ejb.ca.store.ICertificateStoreSessionLocalHome" * business="org.ejbca.core.ejb.ca.store.ICertificateStoreSessionLocal" * link="CertificateStoreSession" * * @ejb.ejb-external-ref description="The Authentication session used to authenticate users when issuing certificates. * Alter this to enable a custom made authentication session implementing the * IAuthenticationSessionLocal interface" * view-type="local" * ref-name="ejb/AuthenticationSessionLocal" * type="Session" * home="org.ejbca.core.ejb.ca.auth.IAuthenticationSessionLocalHome" * business="org.ejbca.core.ejb.ca.auth.IAuthenticationSessionLocal" * link="AuthenticationSession" * * @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.home * extends="javax.ejb.EJBHome" * remote-class="org.ejbca.core.ejb.ca.sign.ISignSessionHome" * local-extends="javax.ejb.EJBLocalHome" * local-class="org.ejbca.core.ejb.ca.sign.ISignSessionLocalHome" * * @ejb.interface * extends="javax.ejb.EJBObject" * remote-class="org.ejbca.core.ejb.ca.sign.ISignSessionRemote" * local-extends="javax.ejb.EJBLocalObject" * local-class="org.ejbca.core.ejb.ca.sign.ISignSessionLocal" * * @version $Id: RSASignSessionBean.java,v 1.37.2.2 2007/06/05 13:36:33 anatom Exp $ */public class RSASignSessionBean extends BaseSessionBean { /** * Local interfacte to ca admin store */ private CADataLocalHome cadatahome; /** * Home interface to certificate store */ private ICertificateStoreSessionLocalHome storeHome = null; /* Home interface to Authentication session */ private IAuthenticationSessionLocalHome authHome = null; /* Home interface to Publisher session */ private IPublisherSessionLocalHome publishHome = null; /** * The local interface of the log session bean */ private ILogSessionLocal logsession; /** Internal localization of logs and errors */ private static final InternalResources intres = InternalResources.getInstance(); /** * Source of good random data */ SecureRandom randomSource = null; /** * Default create for SessionBean without any creation Arguments. * * @throws CreateException if bean instance can't be created * @ejb.create-method */ public void ejbCreate() throws CreateException { debug(">ejbCreate()"); try { // Install BouncyCastle provider CertTools.installBCProvider(); // get home interfaces to other session beans used storeHome = (ICertificateStoreSessionLocalHome) getLocator().getLocalHome(ICertificateStoreSessionLocalHome.COMP_NAME); authHome = (IAuthenticationSessionLocalHome) getLocator().getLocalHome(IAuthenticationSessionLocalHome.COMP_NAME); cadatahome = (CADataLocalHome) getLocator().getLocalHome(CADataLocalHome.COMP_NAME); publishHome = (IPublisherSessionLocalHome) getLocator().getLocalHome(IPublisherSessionLocalHome.COMP_NAME); // Get a decent source of random data String randomAlgorithm = getLocator().getString("java:comp/env/randomAlgorithm"); randomSource = SecureRandom.getInstance(randomAlgorithm); SernoGenerator.setAlgorithm(randomAlgorithm); } catch (Exception e) { debug("Caught exception in ejbCreate(): ", e); throw new EJBException(e); } debug("<ejbCreate()"); } /** * Gets connection to log session bean */ private ILogSessionLocal getLogSession() { if (logsession == null) { try { ILogSessionLocalHome logsessionhome = (ILogSessionLocalHome) getLocator().getLocalHome(ILogSessionLocalHome.COMP_NAME); logsession = logsessionhome.create(); } catch (Exception e) { throw new EJBException(e); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -