Search in sources :

Example 1 with AbstractPageAuthorizationStrategy

use of org.apache.wicket.authorization.strategies.page.AbstractPageAuthorizationStrategy 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;
                }
            });
        }
    };
}
Also used : EmptyPage(org.apache.wicket.util.tester.WicketTesterLazyIsPageStatelessRedirectToBufferTest.EmptyPage) MockApplication(org.apache.wicket.mock.MockApplication) AbstractPageAuthorizationStrategy(org.apache.wicket.authorization.strategies.page.AbstractPageAuthorizationStrategy) RestartResponseAtInterceptPageException(org.apache.wicket.RestartResponseAtInterceptPageException)

Example 2 with AbstractPageAuthorizationStrategy

use of org.apache.wicket.authorization.strategies.page.AbstractPageAuthorizationStrategy in project wicket by apache.

the class RestartResponseAtInterceptPageExceptionTest 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 != RedirectPage.class) {
                        RedirectPage intercept = new RedirectPage("http://example.com/path");
                        throw new RestartResponseAtInterceptPageException(intercept);
                    }
                    return true;
                }
            });
        }
    };
}
Also used : MockApplication(org.apache.wicket.mock.MockApplication) AbstractPageAuthorizationStrategy(org.apache.wicket.authorization.strategies.page.AbstractPageAuthorizationStrategy) RedirectPage(org.apache.wicket.markup.html.pages.RedirectPage)

Aggregations

AbstractPageAuthorizationStrategy (org.apache.wicket.authorization.strategies.page.AbstractPageAuthorizationStrategy)2 MockApplication (org.apache.wicket.mock.MockApplication)2 RestartResponseAtInterceptPageException (org.apache.wicket.RestartResponseAtInterceptPageException)1 RedirectPage (org.apache.wicket.markup.html.pages.RedirectPage)1 EmptyPage (org.apache.wicket.util.tester.WicketTesterLazyIsPageStatelessRedirectToBufferTest.EmptyPage)1