Re: know the last page user comes from
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 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:thomas.kapp...@isb-sib.ch] > Sent: Thursday, January 28, 2010 11:16 AM > To: users@wicket.apache.org > 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:thomas.kapp...@isb-sib.ch] > > Sent: Thursday, January 28, 2010 10:47 AM > > To: users@wicket.apache.org > > 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 Kapplerthomas.kapp...@isb-sib.ch > 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: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
RE: know the last page user comes from
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:thomas.kapp...@isb-sib.ch] Sent: Thursday, January 28, 2010 11:16 AM To: users@wicket.apache.org 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:thomas.kapp...@isb-sib.ch] > Sent: Thursday, January 28, 2010 10:47 AM > To: users@wicket.apache.org > 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 Kapplerthomas.kapp...@isb-sib.ch 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: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
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:thomas.kapp...@isb-sib.ch] Sent: Thursday, January 28, 2010 10:47 AM To: users@wicket.apache.org 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 Kapplerthomas.kapp...@isb-sib.ch 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: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: know the last page user comes from
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? Thanks Thomas! BR, Martin -Original Message- From: Thomas Kappler [mailto:thomas.kapp...@isb-sib.ch] Sent: Thursday, January 28, 2010 10:47 AM To: users@wicket.apache.org 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 Kapplerthomas.kapp...@isb-sib.ch 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: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
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 Kapplerthomas.kapp...@isb-sib.ch 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: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: know the last page user comes from
Hi, Andrew! I was saying that if I set up access denied page that way: getApplicationSettings().setAccessDeniedPage(MyAccessDeniedPage.class); there is no possibility to pass prev page in the constructor. Regards, Martin -Original Message- From: Andrew Lombardi [mailto:and...@mysticcoders.com] Sent: Thursday, January 28, 2010 10:39 AM To: users@wicket.apache.org Subject: Re: know the last page user comes from Pass the previous Page in the constructor. On Jan 28, 2010, at 12:36 AM, 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. > > Thank you ! > > Best regards, > Martin > To our success! Mystic Coders, LLC | Code Magic | www.mysticcoders.com ANDREW LOMBARDI | and...@mysticcoders.com 2321 E 4th St. Ste C-128, Santa Ana CA 92705 ofc: 714-816-4488 fax: 714-782-6024 cell: 714-697-8046 linked-in: http://www.linkedin.com/in/andrewlombardi twitter: http://www.twitter.com/kinabalu Eco-Tip: Printing e-mails is usually a waste. This message is for the named person's use only. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: know the last page user comes from
Pass the previous Page in the constructor. On Jan 28, 2010, at 12:36 AM, 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. > > Thank you ! > > Best regards, > Martin > To our success! Mystic Coders, LLC | Code Magic | www.mysticcoders.com ANDREW LOMBARDI | and...@mysticcoders.com 2321 E 4th St. Ste C-128, Santa Ana CA 92705 ofc: 714-816-4488 fax: 714-782-6024 cell: 714-697-8046 linked-in: http://www.linkedin.com/in/andrewlombardi twitter: http://www.twitter.com/kinabalu Eco-Tip: Printing e-mails is usually a waste. This message is for the named person's use only. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient.
know the last page user comes from
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. Thank you ! Best regards, Martin