FileDocCategorySizeDatePackage
LoginAction.javaAPI DocJBoss 4.2.12232Fri Jul 13 20:56:06 BST 2007xpetstore.web.struts.action.signon

LoginAction

public class LoginAction extends xpetstore.web.struts.action.BaseAction
author
Herve Tchepannou
struts.action
name="signonForm" path="/login" input="/login.jsp" scope="request" validate="true"
struts.action-forward
name="success" path="/index.jsp"
struts.action-forward
name="error" path="/signon.jsp"

Fields Summary
Constructors Summary
Methods Summary
public org.apache.struts.action.ActionForwarddoExecute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

        SignonForm    frm = ( SignonForm ) form;
        Account  account = frm.getAccount(  );
        String        redirectUri = frm.getRedirectUri(  );
        Petstore petstore = getPetstore(  );

        if ( petstore.authenticate( account.getUserId(  ), account.getPassword(  ) ) )
        {
            Customer cust = petstore.getCustomer( account.getUserId(  ) );
            initSession( cust, request );

            if ( ( redirectUri == null ) || ( redirectUri.length(  ) == 0 ) )
            {
                return mapping.findForward( SUCCESS );
            }
            else
            {
                _log.info( "...redirecting to: " + redirectUri );
                response.sendRedirect( redirectUri );
                return null;
            }
        }
        else
        {
            request.setAttribute( MESSAGE_KEY, getString( "authentication_failed" ) );

            return mapping.findForward( ERROR );
        }