| 1 5 6 package com.raptus.owxv3.eadmin; 7 8 import java.io.IOException ; 9 10 import javax.servlet.ServletException ; 11 import javax.servlet.http.*; 12 13 import org.apache.struts.action.*; 14 15 import com.raptus.owxv3.*; 16 import com.raptus.owxv3.api.LoginAction; 17 18 41 public class EALoginAction extends LoginAction 42 { 43 45 60 public ActionForward perform(ActionMapping mapping, 61 ActionForm form, 62 HttpServletRequest request, 63 HttpServletResponse response) 64 throws IOException , ServletException  65 { 66 EALoginForm owaf = (EALoginForm) form; 67 String element = request.getParameter(Constants.HTTPGET_PARAM_ELEMENT); 68 if(element == null || element.length() == 0) 69 element = owaf.getElement(); 70 71 if(element != null && element.length() > 0) 72 { 73 if(element.compareToIgnoreCase("login") == 0) { 75 return performLogin(mapping, owaf, request, response); 76 } 77 else if(element.compareToIgnoreCase("logout") == 0) { 79 return performLogout(mapping, owaf, request, response); 80 } 81 } 82 else 83 LoggingManager.log("Unkown element " + element + " requested", this); 84 85 return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNELEMENT); 86 } 87 88 91 public ActionForward performLogin(ActionMapping mapping, 92 EALoginForm form, 93 HttpServletRequest request, 94 HttpServletResponse response) 95 throws IOException , ServletException  96 { 97 ActionErrors errors = new ActionErrors(); 98 99 String username = form.getUsername(); 100 String password = form.getPassword(); 101 102 LoggingManager.log("A user <" + username + "> tries to log in.", this); 103 104 String nextView = Constants.SCREEN_LOGIN; 105 if(username != null && password != null) 106 { 107 if(loginUser(request, username, password)) 108 nextView = Constants.SCREEN_SUCCESS; 109 else 110 errors.add("loginerrors", new ActionError(Constants.MESSAGE_I18N_LOGINFAILED)); 111 } 112 else 113 errors.add("loginerrors", new ActionError(Constants.MESSAGE_I18N_LOGINWELCOME)); 114 115 saveErrors(request, errors); 116 LoggingManager.log("Forwarding user to struts screen <" + nextView + ">", this); 117 LoggingManager.log(errors.size() + " errors during login phase.", this); 118 return mapping.findForward(nextView); 119 } 120 121 124 public ActionForward performLogout(ActionMapping mapping, 125 EALoginForm form, 126 HttpServletRequest request, 127 HttpServletResponse response) 128 throws IOException , ServletException  129 { 130 XMLConfigManager cm=XMLConfigManager.getInstance(); 134 form.setWebsiteURL( cm.getPropertyByTree("virtualhost","hostname") ); 135 136 HttpSession session = request.getSession(); 137 logoutUser(session); 138 139 return mapping.findForward(Constants.SCREEN_LOGOUT); 140 } 141 142 } 143 144 | Popular Tags |