use of org.apache.wicket.RestartResponseAtInterceptPageException in project wicket by apache.
the class SignInApplication method init.
@Override
protected void init() {
super.init();
// Register the authorization strategy
getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy.AllowAllAuthorizationStrategy() {
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
// Check if the new Page requires authentication (implements the marker interface)
if (AuthenticatedWebPage.class.isAssignableFrom(componentClass)) {
// Is user signed in?
if (((SignInSession) Session.get()).isSignedIn()) {
// okay to proceed
return true;
}
throw new RestartResponseAtInterceptPageException(SignIn.class);
}
// okay to proceed
return true;
}
});
}
use of org.apache.wicket.RestartResponseAtInterceptPageException in project wicket by apache.
the class InterceptTest method newApplication.
@Override
protected WebApplication newApplication() {
return new MockApplication() {
@Override
protected void init() {
getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy.AllowAllAuthorizationStrategy() {
private boolean block = true;
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
if (block && (componentClass == TargetPage.class || componentClass == HomePage.class)) {
block = false;
throw new RestartResponseAtInterceptPageException(InterceptPage.class);
}
return true;
}
});
super.init();
}
@Override
public Class<? extends Page> getHomePage() {
return HomePage.class;
}
};
}
use of org.apache.wicket.RestartResponseAtInterceptPageException in project wicket by apache.
the class WebSession method getClientInfo.
/**
* {@inheritDoc}
*
* <p>
* To gather the client information this implementation redirects temporarily to a special page
* ({@link BrowserInfoPage}).
* <p>
* Note: Do <strong>not</strong> call this method from your custom {@link Session} constructor
* because the temporary page needs a constructed {@link Session} to be able to work.
* <p>
* If you need to set a default client info property then better use
* {@link #setClientInfo(org.apache.wicket.core.request.ClientInfo)} directly.
*/
@Override
public WebClientInfo getClientInfo() {
if (clientInfo == null) {
RequestCycle requestCycle = RequestCycle.get();
clientInfo = new WebClientInfo(requestCycle);
if (getApplication().getRequestCycleSettings().getGatherExtendedBrowserInfo()) {
WebPage browserInfoPage = newBrowserInfoPage();
throw new RestartResponseAtInterceptPageException(browserInfoPage);
}
}
return (WebClientInfo) clientInfo;
}
use of org.apache.wicket.RestartResponseAtInterceptPageException in project wicket by apache.
the class AbstractBookmarkableMapperTest method newApplication.
@Override
protected WebApplication newApplication() {
return new MockApplication() {
@Override
protected void init() {
super.init();
getSecuritySettings().setAuthorizationStrategy(new AbstractPageAuthorizationStrategy() {
@Override
protected <T extends Page> boolean isPageAuthorized(Class<T> pageClass) {
if (pageClass == EmptyPage.class) {
throw new RestartResponseAtInterceptPageException(getHomePage());
}
return true;
}
});
}
};
}
use of org.apache.wicket.RestartResponseAtInterceptPageException in project wicket by apache.
the class SignIn2Application method init.
@Override
protected void init() {
super.init();
// Register the authorization strategy
getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy.AllowAllAuthorizationStrategy() {
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
// Check if the new Page requires authentication (implements the marker interface)
if (AuthenticatedWebPage.class.isAssignableFrom(componentClass)) {
// Is user signed in?
if (((SignIn2Session) Session.get()).isSignedIn()) {
// okay to proceed
return true;
}
// continue with the target remembered.
throw new RestartResponseAtInterceptPageException(SignIn2.class);
}
// okay to proceed
return true;
}
});
}
Aggregations