use of org.apache.wicket.authorization.IAuthorizationStrategy in project wicket by apache.
the class AjaxBehaviorEnabledTest method before.
/**
*/
@Before
public void before() {
final IAuthorizationStrategy strategy = new CustomStrategy();
tester = new WicketTester(new MockApplication() {
@Override
public Session newSession(Request request, Response response) {
return new WebSession(request) {
private static final long serialVersionUID = 1L;
@Override
public IAuthorizationStrategy getAuthorizationStrategy() {
return strategy;
}
};
}
});
}
use of org.apache.wicket.authorization.IAuthorizationStrategy in project wicket by apache.
the class Test method testRedirect.
/**
*/
@org.junit.Test
public void testRedirect() {
final IAuthorizationStrategy authorizationStrategy = new SimplePageAuthorizationStrategy(RedirectPage.class, LoginPage.class) {
@Override
protected boolean isAuthorized() {
return false;
}
};
tester.getApplication().getSecuritySettings().setAuthorizationStrategy(authorizationStrategy);
tester.startPage(RedirectPage.class);
tester.assertRenderedPage(LoginPage.class);
}
use of org.apache.wicket.authorization.IAuthorizationStrategy in project wicket by apache.
the class LibraryApplication method init.
@Override
protected void init() {
super.init();
getResourceSettings().setThrowExceptionOnMissingResource(false);
getRequestCycleSettings().setRenderStrategy(RequestCycleSettings.RenderStrategy.REDIRECT_TO_RENDER);
// Install a simple page authorization strategy, that checks all pages
// of type AuthenticatedWebPage.
IAuthorizationStrategy authorizationStrategy = new SimplePageAuthorizationStrategy(AuthenticatedWebPage.class, SignIn.class) {
@Override
protected boolean isAuthorized() {
// check whether the user is logged on
return (((LibrarySession) Session.get()).isSignedIn());
}
};
getSecuritySettings().setAuthorizationStrategy(authorizationStrategy);
}
Aggregations