FileDocCategorySizeDatePackage
LoginAction.javaAPI DocJBoss 4.2.12770Fri Jul 13 20:55:42 BST 2007xpetstore.web.webwork.action.signon

LoginAction

public class LoginAction extends xpetstore.web.webwork.action.BaseAction implements webwork.action.ServletResponseAware
author
Herve Tchepannou
webwork.action
name="login" success="index.action" error="signon.vm"

Fields Summary
private String
_password
private HttpServletResponse
_response
private String
_userId
Constructors Summary
Methods Summary
protected java.lang.StringdoExecute()

see
webwork.action.ActionSupport#doExecute()

        Session s = getHibernateSession(  );

        try
        {
            Customer c = ( Customer ) s.load( Customer.class, _userId );

            if ( c.getAccount(  ).matchPassword( _password ) )
            {
                initSession( c );

                /* Redirect */
                if ( ( _redirectUri != null ) && ( _redirectUri.length(  ) > 0 ) )
                {
                    _response.sendRedirect( _redirectUri );
                    return NONE;
                }

                /* Normal flow */
                return SUCCESS;
            }
            else
            {
                addError( "login", getText( "authentication_failed" ) );
                return ERROR;
            }
        }
        catch ( ObjectNotFoundException o )
        {
            addError( "login", getText( "authentication_failed" ) );

            return ERROR;
        }
        finally
        {
            s.close(  );
        }
    
public java.lang.StringgetPassword()

return
String

        return _password;
    
public java.lang.StringgetUserId()

return
String

        return _userId;
    
public voidsetPassword(java.lang.String password)
Sets the password.

param
password The password to set

        _password = password;
    
public voidsetServletResponse(javax.servlet.http.HttpServletResponse response)

see
webwork.action.ServletRequestAware#setServletRequest(javax.servlet.http.HttpServletRequest)

        _response = response;
    
public voidsetUserId(java.lang.String login)
Sets the login.

param
login The login to set

        _userId = login;