Posts

Showing posts from July, 2014

Spring Security - Annotation Based Method level Security Handler - Part2

Now lets explore the code a little deeper to get a better understanding of how Spring in a best way performs all the Task. So from the above configuration it is quite evident that at the heart lies the CustomMethodSecurityExpressionHandler , which incorporates a permissionEvaluator i.e. DefaultPermissionEvaluator and priviledgeEvaluator i.e. CustomPriviledgeEvaluator The code for permissionEvaluator is: public class DefaultPermissionEvaluator implements PermissionEvaluator { @Override public boolean hasPermission(Authentication auth, Object arg1, Object arg2) { // TODO Auto-generated method stub System.out.println(" *******1) The Authentication is:"+auth+"\n"+arg1+"\n"+arg2); return true; } @Override public boolean hasPermission(Authentication auth, Serializable arg1, String arg2, Object arg3) { // TODO Auto-generated method stub System.out.println(" ******* 2) The Authentication is:"+auth+":"

Spring Security - Annotation Based Method level Security Handler

Introduction Spring Security 3, apart from securing URL’s based on priviledge i.e. roles (The basic authorization process), also provides the ample scope of implementing method level security with annotations at the business layer, and thus ensuring no unauthorized calls would be made at the methods at the corresponding layer. The implementation of method level security is being accomplished with the help of Spring managed AOP approach to recognize, evaluate and secure method invocations. The basic flow can be described as follows: • Spring AOP runtime intercept calls to the methods of interest by implemeting aspects with the help of MethodSecurityInterceptor. • The MethodSecurityInterceptor with the help of AccessDecisionManager, and the corresponding AccessDecisionVoters of the AccessDecisionManager makes the authorization decision. Generic Configuration Details The AOP proxying is not invoked for all Spring Mannaged Beans by default. Declaring in Spring Security