struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerardo Corro <rob_gar_...@hotmail.com>
Subject RE: Struts+Acegi not working
Date Wed, 01 Aug 2007 15:16:08 GMT

After changing the login page avoiding the html tag lib like this:    <body>       
<html:messages id="message" message="true">            <bean:write name="message"
/>            <br />        </html:messages>                <form method="post"
action="j_acegi_security_check.do" name="userLoginForm">            username : <input
type="text" name="j_username" size="25" maxlength="20" />            <br />     
              password : <input type="password" name="j_password" size="25" maxlength="20"
 />            <br />            <html:submit />        </form>     
      </body>The login page is finally displayed, the html tag libs caused the problem
(A bug?); however, when trying to get authenticated it appears this DEBUG level message :2007-08-01
17:08:19,134-34313   DEBUG [http-8080-Processor25] Returning cached instance of singleton
bean 'httpSessionContextIntegrationFilter' DefaultListableBeanFactory.getBean (lu00EDnea:197
)  2007-08-01 17:08:19,134-34313   DEBUG [http-8080-Processor25] Returning cached instance
of singleton bean 'authenticationProcessingFilter' DefaultListableBeanFactory.getBean (lu00EDnea:197
)  2007-08-01 17:08:19,134-34313   DEBUG [http-8080-Processor25] Returning cached instance
of singleton bean 'exceptionTranslationFilter' DefaultListableBeanFactory.getBean (lu00EDnea:197
)  2007-08-01 17:08:19,134-34313   DEBUG [http-8080-Processor25] Returning cached instance
of singleton bean 'filterInvocationInterceptor' DefaultListableBeanFactory.getBean (lu00EDnea:197
)  2007-08-01 17:08:19,134-34313   DEBUG [http-8080-Processor25] Publishing event in context
[Root WebApplicationContext]: org.acegisecurity.event.authorization.AuthenticationCredentialsNotFoundEvent[source=FilterInvocation:
URL: /j_acegi_security_check.do] XmlWebApplicationContext.publishEvent (lu00EDnea:241 )  And
the user is never authenticated.By the way, the security file was also changed to this:  
 <bean id="authenticationProcessingFilter" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter">
       <property name="authenticationManager">            <ref local="authenticationManager"
/>        </property>        <property name="authenticationFailureUrl">   
        <value>/userLogin.jsp?login_error=errors.credenciales.novalidos</value>
       </property>        <property name="defaultTargetUrl">            <value>/WEB-INF/page/userLoginSuccess.jsp</value>
       </property>        <property name="filterProcessesUrl">            <value>*j_acegi_security_check.do</value>
       </property>    </bean>Please assist.> Date: Tue, 31 Jul 2007 10:41:58
-0700> From: thechrispratt@gmail.com> To: user@struts.apache.org> Subject: Re: Struts+Acegi
not working> > It's because now your login page is considered a secure page and it's>
not allowing you to display it.  Try changing your filters to:> >          <filter-mapping>>
                 <filter-name>FiltroFilterChainProxy</filter-name>>       
          <url-pattern>*.do</url-pattern>>          </filter-mapping>>
         <filter-mapping>>                  <filter-name>FiltroFilterChainProxy</filter-name>>
                 <url-pattern>/j_acegi_security_filter</url-pattern>>     
    </filter-mapping>> > I believe you could also change some of the settings
in your security> context and achieve the same effect, but this should get you going.>
(*Chris*)> > On 7/31/07, Gerardo Corro <rob_gar_esp@hotmail.com> wrote:> >>
> Thanks, but not working yet; when invoking the page http://localhost:8080/login_demo/
the same error appear time after time, even trying to invoke directly the page http://localhost:8080/login_demo/userLogin.jsp
shows the same error.these are the settings right now:#############web.xml############   
<filter>        <filter-name>FiltroFilterChainProxy</filter-name>      
 <filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>       
<init-param>            <param-name>targetClass</param-name>           
<param-value>org.acegisecurity.util.FilterChainProxy</param-value>        </init-param>
   </filter>        <filter-mapping>      <filter-name>FiltroFilterChainProxy</filter-name>
     <url-pattern>/*</url-pattern>    </filter-mapping>    <servlet>
       <servlet-name>action</servlet-name>        <servlet-class>      
     org.apache.struts.action.ActionServlet        </servlet-class>        <init-param>
           <param-name>config</param-name>            <param-value>/WEB-INF/struts-config.xml</param-value>
       </init-param>        <init-param>            <param-name>debug</param-name>
           <param-value>2</param-value>        </init-param>        <init-param>
           <param-name>detail</param-name>            <param-value>2</param-value>
       </init-param>        <init-param>            <param-name>validate</param-name>
           <param-value>true</param-value>        </init-param>        <load-on-startup>2</load-on-startup>
   </servlet>    <welcome-file-list>        <welcome-file>userLogin.jsp</welcome-file>
   </welcome-file-list>################struts-config.xml###############<?xml version="1.0"
encoding="UTF-8"?><!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD
Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"><struts-config>
 <data-sources />  <form-beans >    <form-bean name="userLoginForm" type="com.xxx.yyy.struts.form.UserLoginForm"
/>  </form-beans>        <!-- Global Exception Definitions -->    <global-exceptions>
           <exception key="errors.acegi.accesoDenegado" type="org.acegisecurity.AccessDeniedException"
handler="com.xxx.yyy.struts.exceptions.AcegiExceptionHandler" />        </global-exceptions>
   <!-- Global Forward Definitions -->    <global-forwards>        <forward
name="error" path="/WEB-INF/page/error.jsp"/>        <forward name="errorAcegi" path="/WEB-INF/page/errorAcegi.jsp"
/>                  </global-forwards>      <action-mappings >    <action
     attribute="userLoginForm"      input="/userLogin.jsp"      name="userLoginForm"     
path="/userLogin"      scope="request"      type="com.xxx.yyy.struts.action.UserLoginAction">
     <forward name="success" path="/WEB-INF/page/userLoginSuccess.jsp" />      <forward
name="failure" path="/userLogin.jsp" />    </action>  </action-mappings>#############userLogin.jsp############
       <html:form action="/j_acegi_security_check" name="userLoginForm">           
username : <html:text property="j_username" name="j_username" />            <html:errors
property="j_username" />            <br />                    password : <html:password
property="j_password" name="j_password" />            <html:errors property="j_password"
/>            <br />            <html:submit />        </html:form>#############securitycontext############
   <bean id="authenticationProcessingFilter" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter">
       <property name="authenticationManager">            <ref local="authenticationManager"
/>        </property>        <property name="authenticationFailureUrl">   
        <value>/userLogin.jsp?login_error=errors.credenciales.novalidos</value>
       </property>        <property name="defaultTargetUrl">            <value>/</value>
       </property>        <property name="filterProcessesUrl">            <value>/j_acegi_security_check</value>
       </property>    </bean>################UserLoginAction.java###############
   public ActionForward execute(            ActionMapping mapping,            ActionForm form,
           HttpServletRequest request,            HttpServletResponse response) {        
                      ActionMessages messages = new ActionMessages();        ActionMessage
message = new ActionMessage("");                      Authentication authentication = ((SecurityContext)request.getSession().getAttribute("ACEGI_SECURITY_CONTEXT")).getAuthentication();
       UsuariosDao usuarios = (UsuariosDao)SpringFactory.getBean("usuariosDaoHbn");      
 Usuarios usuario;        try {            usuario = usuarios.findWhereUsuarioEquals(authentication.getName());
       } catch (UsuariosDaoException e) {            log.error( e);            usuario=null;
       }               if (usuario != null){                   request.getSession().setAttribute("usuario",usuario);
             return mapping.findForward("success");                 }else{            message
= new ActionMessage("error.validar.usuario");               messages.add("validarUsuario",message);
           saveMessages(request,messages);            return mapping.findForward("failure");
       }                }Thanks for your help!!!!> Date: Tue, 31 Jul 2007 09:25:17 -0700>
From: thechrispratt@gmail.com> To: user@struts.apache.org> Subject: Re: Struts+Acegi
not working> > >         <filter-mapping>> >                 <filter-name>FiltroFilterChainProxy</filter-name>>
>                 <url-pattern>*.do</url-pattern>> >         </filter-mapping>>
> You have the Acegi Filter mapped to *.do, so it's not going to be> called when the
request for j_acegi_security_check comes in.  It's> being passed straight on to struts,
and since you don't have an action> mapped to j_acegi_security_check either, you're getting
that> exception.> > > javax.servlet.ServletException: Cannot retrieve mapping
for action /j_acegi_security_check> >  Try changing your filter-mapping to /*>  
(*Chris*)> > --------------------------------------------------------------------->
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org> For additional commands, e-mail:
user-help@struts.apache.org>> > _________________________________________________________________>
> Make every IM count. Download Windows Live Messenger and join the i'm Initiative now.
It's free.> > http://im.live.com/messenger/im/home/?source=TAGWL_June07> > --------------------------------------------------------------------->
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org> For additional commands, e-mail:
user-help@struts.apache.org> 
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message