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

📄 localuseradminsessionbean.java

📁 JAVA做的J2EE下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 se.anatom.ejbca.ra;import java.math.BigInteger;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.text.DateFormat;import java.util.ArrayList;import java.util.Collection;import java.util.Date;import java.util.HashMap;import java.util.Iterator;import javax.ejb.CreateException;import javax.ejb.DuplicateKeyException;import javax.ejb.EJBException;import javax.ejb.FinderException;import javax.ejb.ObjectNotFoundException;import javax.ejb.RemoveException;import javax.mail.Message;import javax.mail.Session;import javax.mail.Transport;import javax.mail.internet.InternetAddress;import se.anatom.ejbca.BaseSessionBean;import se.anatom.ejbca.JNDINames;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.store.ICertificateStoreSessionLocal;import se.anatom.ejbca.ca.store.ICertificateStoreSessionLocalHome;import se.anatom.ejbca.common.UserDataVO;import se.anatom.ejbca.keyrecovery.IKeyRecoverySessionLocal;import se.anatom.ejbca.keyrecovery.IKeyRecoverySessionLocalHome;import se.anatom.ejbca.log.Admin;import se.anatom.ejbca.log.ILogSessionLocal;import se.anatom.ejbca.log.ILogSessionLocalHome;import se.anatom.ejbca.log.LogConstants;import se.anatom.ejbca.log.LogEntry;import se.anatom.ejbca.ra.exception.NotFoundException;import se.anatom.ejbca.ra.raadmin.DNFieldExtractor;import se.anatom.ejbca.ra.raadmin.EndEntityProfile;import se.anatom.ejbca.ra.raadmin.GlobalConfiguration;import se.anatom.ejbca.ra.raadmin.IRaAdminSessionLocal;import se.anatom.ejbca.ra.raadmin.IRaAdminSessionLocalHome;import se.anatom.ejbca.ra.raadmin.UserDoesntFullfillEndEntityProfile;import se.anatom.ejbca.util.CertTools;import se.anatom.ejbca.util.JDBCUtil;import se.anatom.ejbca.util.StringTools;import se.anatom.ejbca.util.TemplateMimeMessage;import se.anatom.ejbca.util.query.BasicMatch;import se.anatom.ejbca.util.query.IllegalQueryException;import se.anatom.ejbca.util.query.Query;import se.anatom.ejbca.util.query.UserMatch;/** * Administrates users in the database using UserData Entity Bean. * Uses JNDI name for datasource as defined in env 'Datasource' in ejb-jar.xml. * * @version $Id: LocalUserAdminSessionBean.java,v 1.100.2.1 2005/09/17 14:36:40 anatom Exp $ * @ejb.bean *   display-name="UserAdminSB" *   name="UserAdminSession" *   view-type="both" *   type="Stateless" *   transaction-type="Container" * * @ejb.transaction type="Required" * * @ejb.permission role-name="InternalUser" * * @ejb.env-entry *  name="DataSource" *  type="java.lang.String" *  value="java:/${datasource.jndi-name}" * * @ejb.env-entry *   description="Factory class can dynamically link to external implementation class" *   name="RMIFactory" *   type="java.lang.String" *   value="se.walter.cardPersonalization.ra.ejbca.RMIFactoryImpl" * * @ejb.env-entry *   description="Defines the JNDI name of the mail service used" *   name="MailJNDIName" *   type="java.lang.String" *   value="${mail.jndi-name}" *  * @ejb.env-entry *   description="Defines the sender of the notification message" *   name="sender" *   type="java.lang.String" *   value="${mail.from}" * * @ejb.env-entry *   description="Defines the subject used in the notification message" *   name="subject" *   type="java.lang.String" *   value="${mail.subject}" * * @ejb.env-entry *   description="Defines the actual message of the notification. Use the values $Username, $Password, $CN, $O, $OU, $C, $DATE to indicate which texts that should be replaced (Case insensitive), $NL stands for newline." *   name="message" *   type="java.lang.String" *   value="${mail.message}" * * @ejb.ejb-external-ref *   description="The Certificate Store session bean" *   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 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 Ra Admin session bean" *   view-type="local" *   ejb-name="RaAdminSessionLocal" *   type="Session" *   home="se.anatom.ejbca.ra.raadmin.IRaAdminSessionLocalHome" *   business="se.anatom.ejbca.ra.raadmin.IRaAdminSessionLocal" *   link="RaAdminSession" * * @ejb.ejb-external-ref *   description="The Key Recovery session bean" *   view-type="local" *   ejb-name="KeyRecoverySessionLocal" *   type="Session" *   home="se.anatom.ejbca.keyrecovery.IKeyRecoverySessionLocalHome" *   business="se.anatom.ejbca.keyrecovery.IKeyRecoverySessionLocal" *   link="KeyRecoverySession" * * @ejb.ejb-external-ref *   description="The User entity bean" *   view-type="local" *   ejb-name="UserDataLocal" *   type="Entity" *   home="se.anatom.ejbca.ra.UserDataLocalHome" *   business="se.anatom.ejbca.ra.UserDataLocal" *   link="UserData" * * @ejb.resource-ref *   res-ref-name="mail/DefaultMail" *   res-type="javax.mail.Session" *   res-auth="Container" * * @ejb.home *   extends="javax.ejb.EJBHome" *   local-extends="javax.ejb.EJBLocalHome" *   local-class="se.anatom.ejbca.ra.IUserAdminSessionLocalHome" *   remote-class="se.anatom.ejbca.ra.IUserAdminSessionHome" * * @ejb.interface *   extends="javax.ejb.EJBObject,UserAdminConstants" *   local-extends="javax.ejb.EJBLocalObject,UserAdminConstants" *   local-class="se.anatom.ejbca.ra.IUserAdminSessionLocal" *   remote-class="se.anatom.ejbca.ra.IUserAdminSessionRemote" */public class LocalUserAdminSessionBean extends BaseSessionBean {    /**     * The local interface of RaAdmin Session Bean.     */    private IRaAdminSessionLocal raadminsession;    /**     * The local interface of the certificate store session bean     */    private ICertificateStoreSessionLocal certificatesession;    /**     * The local interface of the authorization session bean     */    private IAuthorizationSessionLocal authorizationsession;    /**     * The local interface of the authorization session bean     */    private IKeyRecoverySessionLocal keyrecoverysession;    /**     * The remote interface of the log session bean     */    private ILogSessionLocal logsession;    private UserDataLocalHome home = null;    /**     * Columns in the database used in select     */    private static final String USERDATA_COL = "username, subjectDN, subjectAltName, subjectEmail, status, type, clearpassword, timeCreated, timeModified, endEntityprofileId, certificateProfileId, tokenType, hardTokenIssuerId, cAId";    /**     * Default create for SessionBean.     *     * @throws CreateException if bean instance can't be created     * @see se.anatom.ejbca.log.Admin     */    public void ejbCreate() throws CreateException {        debug(">ejbCreate()");        try {            home = (UserDataLocalHome) getLocator().getLocalHome(UserDataLocalHome.COMP_NAME);            ILogSessionLocalHome logsessionhome = (ILogSessionLocalHome) getLocator().getLocalHome(ILogSessionLocalHome.COMP_NAME);            logsession = logsessionhome.create();            IAuthorizationSessionLocalHome authorizationsessionhome = (IAuthorizationSessionLocalHome) getLocator().getLocalHome(IAuthorizationSessionLocalHome.COMP_NAME);            authorizationsession = authorizationsessionhome.create();            IRaAdminSessionLocalHome raadminsessionhome = (IRaAdminSessionLocalHome) getLocator().getLocalHome(IRaAdminSessionLocalHome.COMP_NAME);            raadminsession = raadminsessionhome.create();            ICertificateStoreSessionLocalHome certificatesessionhome = (ICertificateStoreSessionLocalHome) getLocator().getLocalHome(ICertificateStoreSessionLocalHome.COMP_NAME);            certificatesession = certificatesessionhome.create();                        IKeyRecoverySessionLocalHome keyrecoverysessionhome = (IKeyRecoverySessionLocalHome) getLocator().getLocalHome(IKeyRecoverySessionLocalHome.COMP_NAME);            keyrecoverysession = keyrecoverysessionhome.create();        } catch (Exception e) {            error("Error creating session bean:", e);            throw new EJBException(e);        }    }    /**     * Gets the Global Configuration from ra admin session bean-     */    private GlobalConfiguration getGlobalConfiguration(Admin admin) {        return raadminsession.loadGlobalConfiguration(admin);    }    private boolean authorizedToCA(Admin admin, int caid) {        boolean returnval = false;        try {            returnval = authorizationsession.isAuthorizedNoLog(admin, AvailableAccessRules.CAPREFIX + caid);        } catch (AuthorizationDeniedException e) {        }        return returnval;    }    private boolean authorizedToEndEntityProfile(Admin admin, int profileid, String rights) {        boolean returnval = false;

⌨️ 快捷键说明

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