spring - get method name in Pre/Post-Authorize -


I am writing my permission avilator for Spring Security and the name of the name that I am trying to do For example, for example, without the method name in the picture, I have something like:

  PostAuthorized ("Hapitation (return object, read ')" Event getEvent (int evendId) {...}   

and

  display in public boolean (authentication certification, object targetdomain Bjekt, object permission) {if (targetDomainObject inst. Event) {return Display (authentication, Lcshidomen object permission); } Return targetDiman object == zero; }   

But I need the name of the method "getEvent" which is available in that. I can pass it manually in the entry call, such as: @PostAuthorize ("Promotion (new com.example.AuthZObject (returnObject, 'getEvent'), 'Read ') ") Event getEvent (int eventId);

But is there more automated way to do this?

@ Ralph is the very right idea here is the first step to implement custom methodology of MethodSecurityExpressionOperations on that method And can use it to evaluate the expression. For example:
  Public class MyMethodSecurityExpressionRoot enhances ExpressionRoot implementation MethodSecurityExpressionOperations {Private Object Filter Object; Private object return objects; Private object target; Personal method method; Public MyMethodSecurityExpressionRoot (Authentication A) {Super (A); } // Method Allow to set public zero sethead (method i) {this.method = m; } // optionally enter the expression to expose the public method getMethod () {return method; } // Make a method that is in the public boolean for you with transparent form of the name of the // method with check. Vidyaprashan (object target, object intake) {Boolean results = false; // Your calculation method uses member variables // i.e. method.getName () and are given in logic / of course you can appoint any other object if you wish // // return is Promotion (new com .example.AuthZObject (target, method.getName ()), permission);); // You can either argue get results here; } // Apply the interface and provide the public Zero Set Filter Object (object filter object) to {this.filterObject = filterObject; } Public object getFilterObject () {return filterObject; } Public Zero Set Return Object (object return object) {this.returnObject = returnObject; } Public object getReturnObject () {return return object; } Public zero set this (object target) {this.target = target; } Public object getThis () {return target; }}   

Expand the default default method Security Expand handler and use the custom expression root.

  Public class MySecurityExpressionHandler DefaultMexicableExpressExpressHandler increases {@Override Secure MethodSecurityExpressionOperations createSecurityExpressionRoot (Authentication Authentication, Method Investment Charge) {MyMethodSecurityExpressionRoot Root = New MyMethodSecurityExpressionRoot (Authentication); Root.setThis (invocation.getThis ()); Root.setPermissionEvaluator (getPermissionEvaluator ()); Root.setTrustResolver (new AuthenticationTrustResolverImpl ()); Root.setRoleHierarchy (getRoleHierarchy ()); root.setMethod (invocation.getMethod ()); Return route; Once you have configured MySecurityExpressionHandler, you should be able to use the following:  
  @PostAuthorize ("hasMethodPermission" (return objects, 'read') ") Event getEvent (event) Event);    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -