You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Stateri <se...@globo.com> on 2010/03/01 22:33:11 UTC

What's the page that cause the redirect to the login page ?

Hi,

I'm using Tapestry 5 over Spring 2.0 with Acegi Security. I'd like that, if
the user call an url that's protected, then this user will be redirect to
the login page and, after a successfully login, then he will be automaticly
redirectly to the page that he has called firstly.
But, when I configure the property acegi.accessDenied.url to "/Start" and
call a protect url, I'm automaticly redirect to the "/Start", that's my
login page (it's correct), but in this page I can see any way to get the
original page, the page that use has type firstly to be redirect to my login
page.
Is there any way to get the "original" page, or the page that has caused the
redirect to the login page at login page ?

thanks in advance,

Sergio Stateri Jr.
sergio.stateri@globo.com 
-- 
View this message in context: http://old.nabble.com/What%27s-the-page-that-cause-the-redirect-to-the-login-page---tp27749346p27749346.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: What's the page that cause the redirect to the login page ?

Posted by Jonathan Barker <jo...@gmail.com>.
Try something like this in your Start page that uses the SavedRequest that
gets put in the session by Acegi. Note that I use Spring Security so you
will need to adjust the constant naming accordingly. (I think you should
 add a line to clear the
AbstractProcessingFilter.SPRING_SECURITY_SAVED_REQUEST_KEY
 once you've used it, and I'm sure it can be improved... ):


@Inject

private Logger logger;

 @Inject

private RequestGlobals _requestGlobals;

 @Inject

private AuthenticationManager _authenticationManager;


 @Persist

@Property

private String _username;

 @Persist("flash")

@Property

private String _password;


 private Authentication authResult;


  @Component(id="password")

private PasswordField _passwordField;

 @Component(id="LoginForm")

private Form _form;


public void onValidateFormFromLoginForm(){

UsernamePasswordAuthenticationToken authRequest =

new UsernamePasswordAuthenticationToken(_username,_password);

 try {

authResult = _authenticationManager.authenticate(authRequest);

} catch (BadCredentialsException failed) {

_form.recordError(_passwordField, "Invalid username or password");

} catch (AuthenticationException failed) {

_form.recordError(_passwordField, "Invalid username or password");

}


 }

public Object onSuccessFromLoginForm(){

 SavedRequest savedRequest =

            (SavedRequest) _requestGlobals
.getHTTPServletRequest().getSession().getAttribute(AbstractProcessingFilter.
SPRING_SECURITY_SAVED_REQUEST_KEY);


 SecurityContextHolder.getContext().setAuthentication(authResult);


 if(savedRequest != null){

         java.net.URL url = null;

        try {

        url = new URL(savedRequest.getRequestURL());

        } catch (MalformedURLException e){

        logger.error("malformed url:" + savedRequest.getRequestURI());

                        return Dashboard.class;


        }

        return url;

        }

        return Dashboard.class;




 }


On Mon, Mar 1, 2010 at 4:33 PM, Stateri <se...@globo.com> wrote:

>
> Hi,
>
> I'm using Tapestry 5 over Spring 2.0 with Acegi Security. I'd like that, if
> the user call an url that's protected, then this user will be redirect to
> the login page and, after a successfully login, then he will be automaticly
> redirectly to the page that he has called firstly.
> But, when I configure the property acegi.accessDenied.url to "/Start" and
> call a protect url, I'm automaticly redirect to the "/Start", that's my
> login page (it's correct), but in this page I can see any way to get the
> original page, the page that use has type firstly to be redirect to my
> login
> page.
> Is there any way to get the "original" page, or the page that has caused
> the
> redirect to the login page at login page ?
>
> thanks in advance,
>
> Sergio Stateri Jr.
> sergio.stateri@globo.com
> --
> View this message in context:
> http://old.nabble.com/What%27s-the-page-that-cause-the-redirect-to-the-login-page---tp27749346p27749346.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
>
>


-- 
Jonathan Barker
ITStrategic