use of org.apache.syncope.client.console.pages.Login 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));
}
Aggregations