I look like this may be not be approriate form for my exception.
Whenever OptimisticLockException happens, the application gets directed to error.xhtml.
<exception class="javax.persistence.OptimisticLockException">
<end-conversation />
<redirect view-id="/error.xhtml">
<message severity="warn">Another user changed the same data,
please try again really</message>
</redirect>
</exception>
Incase of AuthorizationException, the seam debug page opens which shows the stack trace. But i want, it should direct to error.xhtml.
<exception class="org.jboss.seam.security.AuthorizationException">
<redirect view-id="/error.xhtml">
<message severity="warn">You don't have permission to access this
resource</message>
</redirect>
</exception>
Also please not that I have defined my custom hasPermisson method.
public boolean hasPermission(Object target, String action) {
Identity identity = Identity.instance();
if (identity == null || !identity.isLoggedIn()) {
return false;
}
Entitlements entitlements = Entitlements.instance();
if ("FUNCTION".equals(target) && entitlements.isFunctionAvailable(action)) {
return true;
}
if ("FUNCTION_ID".equals(target) && entitlements.isFunctionAvailableBySurrogateId(action)) {
return true;
}
if(action.contains("VIEW")){
Events.instance().raiseEvent("org.jboss.seam.security.notAuthorized");
throw new AuthorizationException(String.format(
"Authorization check failed for permission [%s]", action));
}
return false;
}
Any suggestions.