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]