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

📄 signinhandler.java

📁 J2EE & Tomcat books published by hope
💻 JAVA
字号:
/* */package com.sun.j2ee.workflow.control.actions;import java.util.HashMap;import java.util.ArrayList;import java.util.Locale;import java.util.Enumeration;import javax.servlet.http.HttpSession;import com.sun.j2ee.workflow.util.WebKeys;import com.sun.j2ee.workflow.util.JSPUtil;import javax.servlet.http.HttpServletRequest;import com.sun.j2ee.workflow.util.Debug;import com.sun.j2ee.workflow.control.web.UserBean;import com.sun.j2ee.workflow.control.exceptions.WorkflowActionException;import com.sun.j2ee.workflow.control.exceptions.SigninFailedException;import com.sun.j2ee.workflow.user.model.UserModel;import com.sun.j2ee.workflow.user.dao.UserDAOImpl;import com.sun.j2ee.workflow.user.exceptions.UserDAOSysException;import com.sun.j2ee.workflow.user.exceptions.UserDAOAppException;import com.sun.j2ee.workflow.user.exceptions.UserDAODBUpdateException;import com.sun.j2ee.workflow.user.exceptions.UserDAOFinderException;import com.sun.j2ee.workflow.user.exceptions.UserDAODupKeyException;/** SigninHandler * @author Jian (James) Cai * */public class SigninHandler extends ActionHandlerSupport {        public void perform(HashMap signinevent) throws WorkflowActionException{        Debug.println("Signin Handler: perform()");        //session of the request are passed as partof the event        HttpSession session = (HttpSession)signinevent.get("session");        Locale currentLocale = JSPUtil.getLocale(session);        String username =  (String)signinevent.get("j_username");        Debug.println("j_username" + username);        //if (currentLocale.equals(Locale.JAPAN)) userName = JSPUtil.convertJISEncoding(userName);        String password =  (String)signinevent.get("j_password");        Debug.println("j_password" + password);                //if (currentLocale.equals(Locale.JAPAN)) password = JSPUtil.convertJISEncoding(password);        //String targetScreen =  (String)signinevent.get("target_screen");        // set the userId in the UserBean                UserBean userbean = (UserBean)getUserBean(session);        userbean.setUserId(username);              // validate that the password matches the  one in the user account       UserModel useraccount = null;       try {           UserDAOImpl userDa = new UserDAOImpl();                   Debug.println("SigininHandler: userDa.findByPrimaryKey");           String user_id = userDa.findByPrimaryKey(username);           Debug.println("found user id: "+user_id);           useraccount = userDa.load(user_id);           //account = cust.getDetails();       } catch (UserDAOFinderException fe) {           throw new SigninFailedException("Unable to find the password details for user " );       } catch (UserDAOSysException se) {           Debug.println("found UserDAOSysException se" + se.toString());       }       if ((useraccount != null) & useraccount.getPassword().equals(password)) {           Debug.println("Password valid for =" + username);           userbean.setLoggedIn(true);           userbean.setUserModel(useraccount);       } else {           Debug.println("Invalide password: for =" + username);              throw new SigninFailedException("password is wrong");       }            }        public void doEnd() {        }           public UserBean getUserBean(HttpSession session) {        UserBean user = (UserBean)        session.getAttribute(WebKeys.UserBeanKey);        if (user == null) {            user = new UserBean();            session.setAttribute(WebKeys.UserBeanKey, user);        }        return user;    }}

⌨️ 快捷键说明

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