use of org.apache.wicket.core.request.handler.PageProvider in project syncope by apache.
the class SyncopeConsoleRequestCycleListener method onException.
@Override
public IRequestHandler onException(final RequestCycle cycle, final Exception e) {
LOG.error("Exception found", e);
PageParameters errorParameters = new PageParameters();
IRequestablePage errorPage = null;
if (instanceOf(e, UnauthorizedInstantiationException.class) != null) {
errorParameters.add("errorMessage", MISSING_AUTHORIZATION);
errorPage = new Login(errorParameters);
} else if (instanceOf(e, AccessControlException.class) != null) {
if (instanceOf(e, AccessControlException.class).getMessage().contains("expired")) {
errorParameters.add("errorMessage", PAGE_EXPIRED);
} else {
errorParameters.add("errorMessage", MISSING_AUTHORIZATION_CORE);
}
errorPage = new Login(errorParameters);
} else if (instanceOf(e, PageExpiredException.class) != null || !SyncopeConsoleSession.get().isSignedIn()) {
errorParameters.add("errorMessage", PAGE_EXPIRED);
errorPage = new Login(errorParameters);
} else if (instanceOf(e, BadRequestException.class) != null || instanceOf(e, WebServiceException.class) != null || instanceOf(e, SyncopeClientException.class) != null) {
errorParameters.add("errorMessage", REST);
errorPage = new Login(errorParameters);
} else {
Throwable cause = instanceOf(e, ForbiddenException.class);
if (cause == null) {
// redirect to default Wicket error page
errorPage = new ExceptionErrorPage(e, null);
} else {
errorParameters.add("errorMessage", cause.getMessage());
errorPage = new Login(errorParameters);
}
}
if (errorPage instanceof Login) {
try {
SyncopeConsoleSession.get().cleanup();
SyncopeConsoleSession.get().invalidateNow();
} catch (Throwable t) {
// ignore
LOG.debug("Unexpected error while forcing logout after error", t);
}
}
return new RenderPageRequestHandler(new PageProvider(errorPage));
}
use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.
the class AbstractBookmarkableMapper method processHybrid.
/**
* Creates a {@code IRequestHandler} that processes a hybrid request. When the page identified
* by {@code pageInfo} was not available, the request should be treated as a bookmarkable
* request.
*
* @param pageInfo
* @param pageClass
* @param pageParameters
* @param renderCount
* @return a {@code IRequestHandler} capable of processing the hybrid request.
*/
protected IRequestHandler processHybrid(PageInfo pageInfo, Class<? extends IRequestablePage> pageClass, PageParameters pageParameters, Integer renderCount) {
PageProvider provider = new PageProvider(pageInfo.getPageId(), pageClass, pageParameters, renderCount);
provider.setPageSource(getContext());
checkExpiration(provider, pageInfo);
/**
* https://issues.apache.org/jira/browse/WICKET-5734
*/
PageParameters constructionPageParameters = provider.hasPageInstance() ? provider.getPageInstance().getPageParameters() : new PageParameters();
if (PageParameters.equals(constructionPageParameters, pageParameters) == false) {
// when the resolved page by id has been created
return new RenderPageRequestHandler(new PageProvider(pageClass, pageParameters));
}
return new RenderPageRequestHandler(provider);
}
use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.
the class BookmarkableMapperTest method encode4.
/**
*/
@Test
public void encode4() {
MockPage page = new MockPage(15);
page.getPageParameters().set(0, "i1");
page.getPageParameters().set(1, "i2");
page.getPageParameters().set("a", "b", INamedParameters.Type.QUERY_STRING);
page.getPageParameters().set("b", "c", INamedParameters.Type.QUERY_STRING);
page.setCreatedBookmarkable(true);
IPageProvider provider = new PageProvider(page);
IRequestHandler handler = new RenderPageRequestHandler(provider);
Url url = encoder.mapHandler(handler);
assertEquals("wicket/bookmarkable/" + PAGE_CLASS_NAME + "/i1/i2?15&a=b&b=c", url.toString());
}
use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.
the class CryptoMapperTest method pageInstanceEncrypt.
/**
* Tests that URLs for page instances are encrypted (/wicket/page?5)
*/
@Test
public void pageInstanceEncrypt() {
MockPage page = new MockPage(5);
IRequestHandler requestHandler = new RenderPageRequestHandler(new PageProvider(page));
assertEquals(PLAIN_PAGE_INSTANCE_URL, mapper.getDelegateMapper().mapHandler(requestHandler).toString());
assertEquals(ENCRYPTED_PAGE_INSTANCE_URL, mapper.mapHandler(requestHandler).toString());
}
use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.
the class MountedMapperTest method placeholderEncode4.
/**
* WICKET-5247 page instantiated without required parameters won't be mapped
*/
@Test
public void placeholderEncode4() {
PageProvider provider = new PageProvider(MockPage.class) {
@Override
public boolean isNewPageInstance() {
return false;
}
};
provider.setPageSource(context);
IRequestHandler handler = new RenderPageRequestHandler(provider);
Url url = placeholderEncoder.mapHandler(handler);
assertNull(url);
}
Aggregations