Spring Security - Prevent AccessDeniedException from stopping application normal flow -
i'm using spring secuirty 3 acl module. i'm securing methods @preauthentication annotations using custom permissionevaluator. working fine, every time permissionevaluator returns access_denied accessdeniedexception thrown @ point , stops application execution. desired behaivore when permissionevaluator returns , access_denied, secured method call prevented (skipped) , rest of application keeps running normally. have idea on how achieve this?
if wrap each call want happen in try...catch
, can behavior. basically, since it's exception, normal exception handling apply it. if application can handle exception , continue normally, that!
here's example of mean:
// 1st method denied want continue execution after try { // call method throw exception } catch (/*the exception expect thrown , want continue after*/){} // 2nd method denied want continue execution after try { // call method b throw exception } catch (/*the exception expect thrown , want continue after*/){} etc.
yes, add lot of overhead calling methods, simple way of allowing execution continue after exception raised.
i argue more correct, since calling code does know how deal exceptions. doesn't require additional spring configuration, means code behavior remains closer default , not rely on external configurations determine it's behavior.
Comments
Post a Comment