signincontroller.java

来自「<Java网络程序设计 J2EE>随书源码」· Java 代码 · 共 60 行

JAVA
60
字号
/**/package org.impact.stars.control.ejb;import java.rmi.RemoteException;import javax.ejb.CreateException;import javax.ejb.EJBException;import javax.ejb.FinderException;import org.impact.stars.util.Debug;import org.impact.stars.util.EJBKeys;import org.impact.stars.util.JNDINames;//import org.impact.stars.customer.customer.ejb.Customer;import org.impact.stars.util.EJBUtil;//import org.impact.stars.customer.customer.ejb.CustomerHome;//import org.impact.stars.customer.account.model.AccountModel;import org.impact.stars.control.event.SigninEvent;import org.impact.stars.control.event.StarsEvent;import org.impact.stars.signon.ejb.SignOnLocal;import org.impact.stars.signon.ejb.SignOnLocalHome;import org.impact.stars.signon.exceptions.SignOnAppException;import org.impact.stars.signon.model.SignOnModel;import org.impact.stars.control.exceptions.GeneralFailureException;import org.impact.stars.control.exceptions.SigninFailedException;import org.impact.stars.control.exceptions.StarsEventException;public class SigninController extends StateControllerSupport {  public void perform(StarsEvent event) throws StarsEventException {      SigninEvent se = (SigninEvent)event;      Debug.println("SigninEvent: " + se);      // validate that the password matches the  one in the account       SignOnModel account = null;       try {           SignOnLocalHome home = EJBUtil.getSignOnLocalHome();           SignOnLocal cust = home.findByPrimaryKey(se.getUserName());           account = cust.getDetails();       } catch (FinderException ce) {           throw new SigninFailedException("Unable to find the password details for user " + se.getUserName());       } catch (javax.naming.NamingException ne) {           throw new GeneralFailureException("Irrecoverable error while trying to verify the the user while signin : " + ne);       }       if ((account != null) & account.getPassWord().equals(se.getPassword())) {           Debug.println("Password valid for =" + se.getUserName());           machine.setAttribute(EJBKeys.USERNAME,se.getUserName());           machine.setAttribute(EJBKeys.PASSWORD,se.getPassword());       } else {           Debug.println("Invalide password: for =" + se.getUserName());              throw new SigninFailedException("password is wrong");       }  }}

⌨️ 快捷键说明

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