You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by sunilmanu <su...@gmail.com> on 2011/06/14 22:07:17 UTC

Tapestry Remembers which page to navigate after User Logs in ?

Hello Everyone,

After the user is kicked out of a session and they try to login back,
Tapestry tries to take the user back to the last requested Page or tries to
execute the last requested Action ? Why does it behave like that ?

Is there a way I can configure it to go to a "PAGE-123" always after the
user logs in successfully ALL the time ? Right now because of this issue,
lot of users are complaining and they are getting Stale Link Exception
because after logging in it tries to take them to a page and lot of
information might be missing and it breaks.

So plzzzz help or point me to right direction... !! Is there any particular
Cookie I need to delete when the redirect happens ? 

thanks in advance for all the help...

thanks,
Sunil

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-Remembers-which-page-to-navigate-after-User-Logs-in-tp4489125p4489125.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Tapestry Remembers which page to navigate after User Logs in ?

Posted by sunilmanu <su...@gmail.com>.
Hi Chris,

Thanks a bunch for the help !! that worked !! you just made my day....

regards,
Sunil

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-Remembers-which-page-to-navigate-after-User-Logs-in-tp4489125p4491525.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Tapestry Remembers which page to navigate after User Logs in ?

Posted by Chris Poulsen <ma...@nesluop.dk>.
Hi,

If I'm not mistaken its an acegi feature you are experiencing, not a
tapestry issue.

It has been years since we have used acegi security where i work, but if my
memory serves me correctly, you have to set a property called something like
"alwaysUseDefaultTargetUrl" to true on your authentication processing filter
and then your "/LoginRedirectDispatcher.html" page (page-123?) should of
course do the right thing.

Hope this helps.

-- 
Regards Chris


On Tue, Jun 14, 2011 at 11:23 PM, sunilmanu <su...@gmail.com>wrote:

> Hi,
>
> its Tapestry 4.0.2. We use ACEGI for the authentication. Below is how its
> configured in
>
> /***** hivemodule.xml *****
> ***********************/
>
>
>        <service-point id="FormProcessingFilter"
> interface="web.filters.FormProcessor">
>        <invoke-factory>
>            <construct class="web.filters.FormProcessingFilter"
> initialize-method="afterPropertiesSet">
>                <set property="authenticationFailureUrl"
> value="/HomePage.html"
> />
>                <set property="defaultTargetUrl"
> value="/LoginRedirectDispatcher.html" />
>                <set property="filterProcessesUrl"
> value="/j_acegi_security_check" />
>                <set property="continueChainBeforeSuccessfulAuthentication"
> value="false" />
>            </construct>
>        </invoke-factory>
>    </service-point>
>
>    <service-point id="FormAuthenticationEntryPoint"
> interface="org.acegisecurity.ui.AuthenticationEntryPoint">
>        <invoke-factory>
>            <construct class="web.filters.FormAuthenticationEntryPoint">
>                <set property="loginFormUrl" value="/HomeDispatcher.html" />
>                <set property="forceHttps" value="false" />
>            </construct>
>        </invoke-factory>
>    </service-point>
>
>
>
> /***** FormProcessingFilter.java *****
> ******************************/
> public class FormProcessingFilter extends AuthenticationProcessingFilter
> implements FormProcessor  {
> ........
> ........
>
>        public boolean attemptAuthentication( String username, String
> password ) {
>                UsernamePasswordAuthenticationToken authRequest = new
> UsernamePasswordAuthenticationToken( username, password );
>                authRequest.setDetails(
> authenticationDetailsSource.buildDetails( request
> ) );
>
>                Authentication authResult;
>
>                try {
>                        authResult =
> getAuthenticationManager().authenticate( authRequest );
>                } catch( AuthenticationException failed ) {
>                        failed.printStackTrace();
>
>  SecurityContextHolder.getContext().setAuthentication( null );
>                        return false;
>                }
>
>                try {
>                        successfulAuthentication( request, response,
> authResult );
>                } catch( IOException e ) {
>                        log.error("--(authentication )IOException--: " +
> e.getMessage() );
>                        return false;
>                }
>
>                return true;
>        }
>
>        @Override
>    protected void onSuccessfulAuthentication(HttpServletRequest request,
> HttpServletResponse response,Authentication authResult) throws IOException{
>
> //          System.out.println("in successfull authentation
> method.........");
>          GrantedAuthority[] authArray = authResult.getAuthorities();
>          for (int i = 0; i < authArray.length; i++) {
> //                System.out.println("The Role "+ i+" = " +authArray[i] + "
> : " + authResult.getName());
>          }
>          HttpSession session = request.getSession();
>          SecurityContext sc = SecurityContextHolder.getContext();
>          sc.setAuthentication(authResult);
>          session.setAttribute("ACEGI_SECURITY_CONTEXT", sc);
>    }
>
>
>
>
> /***** FormProcessingFilter.java *****
> ******************************/
> public class FormAuthenticationEntryPoint extends
> AuthenticationProcessingFilterEntryPoint {
>        public void commence(ServletRequest request, ServletResponse
> response,
>                        AuthenticationException authException) throws
> IOException,
> ServletException {
>                ((HttpServletResponse) response).addHeader("Connection",
> "close");
>                super.commence(request, response, authException);
>        }
> }
>
>
> Thanks,
> Sunil
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Tapestry-Remembers-which-page-to-navigate-after-User-Logs-in-tp4489125p4489354.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Tapestry Remembers which page to navigate after User Logs in ?

Posted by sunilmanu <su...@gmail.com>.
Hi,

its Tapestry 4.0.2. We use ACEGI for the authentication. Below is how its
configured in

/***** hivemodule.xml *****
***********************/

	
	<service-point id="FormProcessingFilter"
interface="web.filters.FormProcessor">
        <invoke-factory>
            <construct class="web.filters.FormProcessingFilter"
initialize-method="afterPropertiesSet">
            	<set property="authenticationFailureUrl" value="/HomePage.html"
/>
            	<set property="defaultTargetUrl"
value="/LoginRedirectDispatcher.html" />
            	<set property="filterProcessesUrl"
value="/j_acegi_security_check" />
            	<set property="continueChainBeforeSuccessfulAuthentication"
value="false" />
            </construct>
        </invoke-factory>
    </service-point>
    
    <service-point id="FormAuthenticationEntryPoint"
interface="org.acegisecurity.ui.AuthenticationEntryPoint">
        <invoke-factory>
            <construct class="web.filters.FormAuthenticationEntryPoint">
            	<set property="loginFormUrl" value="/HomeDispatcher.html" />
            	<set property="forceHttps" value="false" />
            </construct>
        </invoke-factory>
    </service-point>



/***** FormProcessingFilter.java *****
******************************/
public class FormProcessingFilter extends AuthenticationProcessingFilter
implements FormProcessor  {
........
........

	public boolean attemptAuthentication( String username, String password ) {
		UsernamePasswordAuthenticationToken authRequest = new
UsernamePasswordAuthenticationToken( username, password );
		authRequest.setDetails( authenticationDetailsSource.buildDetails( request
) );
		
		Authentication authResult;
		
		try {	
			authResult = getAuthenticationManager().authenticate( authRequest );			
		} catch( AuthenticationException failed ) {
			failed.printStackTrace();
			SecurityContextHolder.getContext().setAuthentication( null );
			return false;
		}
		
		try {			
			successfulAuthentication( request, response, authResult );
		} catch( IOException e ) {
			log.error("--(authentication )IOException--: " + e.getMessage() );
			return false;
		}
		
		return true;
	}
	
	@Override
    protected void onSuccessfulAuthentication(HttpServletRequest request,
HttpServletResponse response,Authentication authResult) throws IOException{

//          System.out.println("in successfull authentation
method.........");
          GrantedAuthority[] authArray = authResult.getAuthorities();
          for (int i = 0; i < authArray.length; i++) {
//                System.out.println("The Role "+ i+" = " +authArray[i] + "
: " + authResult.getName());
          }
          HttpSession session = request.getSession();
          SecurityContext sc = SecurityContextHolder.getContext();
          sc.setAuthentication(authResult);
          session.setAttribute("ACEGI_SECURITY_CONTEXT", sc);
    }




/***** FormProcessingFilter.java *****
******************************/
public class FormAuthenticationEntryPoint extends
AuthenticationProcessingFilterEntryPoint {
	public void commence(ServletRequest request, ServletResponse response,
			AuthenticationException authException) throws IOException,
ServletException {
		((HttpServletResponse) response).addHeader("Connection", "close");
		super.commence(request, response, authException);
	}
}


Thanks,
Sunil


--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-Remembers-which-page-to-navigate-after-User-Logs-in-tp4489125p4489354.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Tapestry Remembers which page to navigate after User Logs in ?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Hi, Rich!

He's talking about Tapestry 4, not 5. The only hint about it was the  
reference to StaleLinkException.

On Tue, 14 Jun 2011 17:20:27 -0300, Rich M <ri...@moremagic.com> wrote:

> It might help to know the structure by which you control login and  
> navigation inside the authorized portion of your application.
>
> In my case, all the login forms explicitly return the Overview page :
>
> public onSuccessFromForm(){
>      // Login validation
>      return overview;
> }
>
> @InjectPage
> private Overview overview;
>
> Is there some structure to your application that prevents this from  
> being a usable pattern?
>
> On 06/14/2011 04:07 PM, sunilmanu wrote:
>> Hello Everyone,
>>
>> After the user is kicked out of a session and they try to login back,
>> Tapestry tries to take the user back to the last requested Page or  
>> tries to
>> execute the last requested Action ? Why does it behave like that ?
>>
>> Is there a way I can configure it to go to a "PAGE-123" always after the
>> user logs in successfully ALL the time ? Right now because of this  
>> issue,
>> lot of users are complaining and they are getting Stale Link Exception
>> because after logging in it tries to take them to a page and lot of
>> information might be missing and it breaks.
>>
>> So plzzzz help or point me to right direction... !! Is there any  
>> particular
>> Cookie I need to delete when the redirect happens ?
>>
>> thanks in advance for all the help...
>>
>> thanks,
>> Sunil
>>
>> --
>> View this message in context:  
>> http://tapestry.1045711.n5.nabble.com/Tapestry-Remembers-which-page-to-navigate-after-User-Logs-in-tp4489125p4489125.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Tapestry Remembers which page to navigate after User Logs in ?

Posted by Rich M <ri...@moremagic.com>.
It might help to know the structure by which you control login and 
navigation inside the authorized portion of your application.

In my case, all the login forms explicitly return the Overview page :

public onSuccessFromForm(){
     // Login validation
     return overview;
}

@InjectPage
private Overview overview;

Is there some structure to your application that prevents this from 
being a usable pattern?

On 06/14/2011 04:07 PM, sunilmanu wrote:
> Hello Everyone,
>
> After the user is kicked out of a session and they try to login back,
> Tapestry tries to take the user back to the last requested Page or tries to
> execute the last requested Action ? Why does it behave like that ?
>
> Is there a way I can configure it to go to a "PAGE-123" always after the
> user logs in successfully ALL the time ? Right now because of this issue,
> lot of users are complaining and they are getting Stale Link Exception
> because after logging in it tries to take them to a page and lot of
> information might be missing and it breaks.
>
> So plzzzz help or point me to right direction... !! Is there any particular
> Cookie I need to delete when the redirect happens ?
>
> thanks in advance for all the help...
>
> thanks,
> Sunil
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-Remembers-which-page-to-navigate-after-User-Logs-in-tp4489125p4489125.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org