Package org.nemesis.forum.webapp.admin.action

Source Code of org.nemesis.forum.webapp.admin.action.LogonAction

package org.nemesis.forum.webapp.admin.action;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.nemesis.forum.util.CookieManager;





/**
* controller de Login
*
* @author dlaurent
* 15:06:28
* <p>there is a compile-time dependencies on the
* <code>java.util.Locale</code> class, which changed between JDK 1.3 and
* JDK 1.4.</p>
*/
public class LogonAction extends BaseAction {

  public ActionForward execute(ActionMapping mapping,
         ActionForm form,
         HttpServletRequest request,
         HttpServletResponse response)
  throws Exception {

   
    ActionErrors errors = new ActionErrors();
    String username = (String)PropertyUtils.getSimpleProperty(form, "username");
        String password = (String)PropertyUtils.getSimpleProperty(form, "password");
    String language = (String)PropertyUtils.getSimpleProperty(form, "language");
   
    Locale l=new Locale(language);//ICI Locale l=new Locale(language,"");
    setLocale(request,l);
    request.getSession().setAttribute(Globals.LOCALE_KEY, l);
    CookieManager.setCookie(response,"language",language,CookieManager.MAX_COOKIE_AGE);

   
    // check
    try {
     
        super.authenticate(request,username,password);

    } catch (Exception e) {
     
      errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("logon.error.badLogin"));
      saveErrors(request, errors);
      return (mapping.getInputForward());
     
    }  
   
   
   
    // Remove the obsolete form bean
    /*if (mapping.getAttribute() != null) {
            if ("request".equals(mapping.getScope()))
                request.removeAttribute(mapping.getAttribute());
            else
                request.getSession().removeAttribute(mapping.getAttribute());
        }*/

    // Forward control to the specified success URI
    return (mapping.findForward("success"));
   

  }

}
TOP

Related Classes of org.nemesis.forum.webapp.admin.action.LogonAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.