View Javadoc
1 /* 2 * Demosys. 3 * 4 * Terms of license - http://opensource.org/licenses/apachepl.php 5 */ 6 package org.demosys.web.login.action; 7 import javax.servlet.http.Cookie; 8 import javax.servlet.http.HttpServletRequest; 9 import javax.servlet.http.HttpServletResponse; 10 import javax.swing.*; 11 import org.apache.struts.action.Action; 12 import org.apache.struts.action.ActionForm; 13 import org.apache.struts.action.ActionForward; 14 import org.apache.struts.action.ActionMapping; 15 import org.demosys.web.ServiceLocator; 16 import org.demosys.web.iteration.CreateIterationException; 17 import org.demosys.web.iteration.IterationForm; 18 import org.demosys.web.login.LoginForm; 19 /*** 20 */ 21 public class LoginAction extends Action { 22 public ActionForward execute(ActionMapping mapping, ActionForm objForm, 23 HttpServletRequest request, HttpServletResponse response) { 24 String result = null; 25 26 // TODO : create an exception when login + password invalid 27 // try { 28 29 /* TODO : create a service locator to validate loin + password 30 ServiceLocator.getServiceLocator().getIterationService().newIteration( 31 form.toIterationView()); 32 */ 33 String login = ((LoginForm)objForm).getUserName(); 34 Cookie loginCookie = new Cookie("Login", login); 35 loginCookie.setMaxAge(365 * 24 * 60 * 60); 36 loginCookie.setPath("/"); 37 response.addCookie(loginCookie); 38 39 result = "success"; 40 /* } 41 /*catch (CreateIterationException e) { 42 e.printStackTrace(); 43 result = "failure"; 44 } 45 */ 46 return mapping.findForward(result); 47 } 48 }

This page was automatically generated by Maven