use of fi.otavanopisto.security.AuthorizationException in project muikku by otavanopisto.
the class ExceptionHandler method handle.
@Override
public void handle() throws FacesException {
for (final Iterator<ExceptionQueuedEvent> queuedEventIterator = getUnhandledExceptionQueuedEvents().iterator(); queuedEventIterator.hasNext(); ) {
ExceptionQueuedEvent queuedEvent = queuedEventIterator.next();
ExceptionQueuedEventContext queuedEventContext = queuedEvent.getContext();
Throwable exception = queuedEventContext.getException();
while ((exception instanceof FacesException || exception instanceof EJBException || exception instanceof ELException || exception instanceof RewriteException || exception instanceof CreationException || exception instanceof IllegalStateException) && exception.getCause() != null) {
exception = exception.getCause();
}
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
try {
if (exception instanceof AuthorizationException) {
externalContext.setResponseStatus(HttpServletResponse.SC_FORBIDDEN);
renderView("/error/access-denied.jsf");
} else if (exception instanceof FileNotFoundException) {
externalContext.setResponseStatus(HttpServletResponse.SC_NOT_FOUND);
renderView("/error/not-found.jsf");
} else {
throw new FacesException(exception);
}
} finally {
queuedEventIterator.remove();
}
}
getWrapped().handle();
}
Aggregations