Martin,

It looks like you are trying to implement the flow for authorization
manually (User tries to go from PageA to PageB, but they require
authorization, so you temporarily send them to PageC -- if they fail, send
them back to PageA, if they succeed, send them to PageB).

The good news is that Wicket has nice support for denoting pages as
requiring authorization and then automatically walking users through an
auth-page and handling moving them forward or back for you if necessary.

Also you can checkout the wicket signin example:
http://wicketstuff.org/wicket14/signin/;jsessionid=1FF7784E87DBECFF9CF8624411BA0FA8?wicket:bookmarkablePage=:org.apache.wicket.examples.signin.SignIn

<http://wicketstuff.org/wicket14/signin/;jsessionid=1FF7784E87DBECFF9CF8624411BA0FA8?wicket:bookmarkablePage=:org.apache.wicket.examples.signin.SignIn>
-R

On Thu, Jan 28, 2010 at 3:08 AM, Martin Asenov <[email protected]> wrote:

> Thank you, Thomas, for your time!
>
> Most likely this will help me solve the problem.
>
> Have a nice day!
>
> -----Original Message-----
> From: Thomas Kappler [mailto:[email protected]]
> Sent: Thursday, January 28, 2010 11:16 AM
> To: [email protected]
> Subject: Re: know the last page user comes from
>
> On 01/28/10 10:01, Martin Asenov wrote:
> > Yes I know about it, but never used it, is it suitable in the case I
> mentioned above? Would you give me some hints on how to implement it?
>
> Sure, here's some code from a small internal app I wrote recently. I got
> most of it from either the wiki or the list archive, but I can't find it
> right now.
>
>
> If a page needs authentication and the user is not signed in, I throw a
> RestartResponseAtInterceptPageException. This IAuthorizationStrategy is
> set in WebApplication.init(), via
> getSecuritySettings().setAuthorizationStrategy(...). Code:
>
>
> public class SimpleAuthorizationStrategy implements IAuthorizationStrategy
> {
>
>        public boolean isActionAuthorized(Component arg0, Action arg1)
>        {
>                return true;
>        }
>
>        @SuppressWarnings("unchecked")
>        public boolean isInstantiationAuthorized(Class componentClass)
>        {
>                // Does this page need authentication?
>                if
> (AuthenticatedBasePage.class.isAssignableFrom(componentClass))
>                {
>                        if (NewtSession.get().isSignedIn())
>                                return true;
>                        else
>                                throw new
> RestartResponseAtInterceptPageException(SignInPage.class);
>                }
>                return true;
>        }
> }
>
> Then in my sign-in page, I can just say
>
> if (NewtSession.get().authenticate(username.value(), password.value()))
> {
>     if (!continueToOriginalDestination())
>         setResponsePage(getApplication().getHomePage());
> ...
>
> The continueToOriginalDestination() gets the user to where the
> RestartResponseAtInterceptPageException was thrown.
>
> HTH,
> Thomas
>
>
> >
> > -----Original Message-----
> > From: Thomas Kappler [mailto:[email protected]]
> > Sent: Thursday, January 28, 2010 10:47 AM
> > To: [email protected]
> > Subject: Re: know the last page user comes from
> >
> > On 01/28/10 09:36, Martin Asenov wrote:
> >> Hello, everyone, I was just wondering how could I know what's the page
> the user comes from, when he comes into a new page. In need that in order to
> redirect to previous page in my access denied page.
> >
> > Do you know about Component.continueToOriginalDestination() ?
> >
> > -- Thomas
>
>
> --
> -------------------------------------------------------------------
>   Thomas Kappler                        [email protected]
>   Swiss Institute of Bioinformatics         Tel: +41 22 379 51 89
>   CMU, rue Michel Servet 1
>   1211 Geneve 4
>   Switzerland                              http://www.uniprot.org
> -------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to