Colleagues, In the spring security documentation I met following notion:
If you want to secure instances which are not created by Spring (using the new operator, for example) then you need to use AspectJ.
Could anybody please show me workable example of such usage. The best case if this is done with help of static weaving.
Thank you in advance!
There is an Aspectj sample in the Spring Security codebase. It compiles against the spring-security-aspects module and then uses:
<global-method-security secured-annotations="enabled" mode="aspectj" />
to enable secured annotations. The code is very simple - it is really just a set of JUnit tests. If you take a look, you'll see that these include tests for both Spring-bean instances and instances created using the new operator.
If you want to know how spring-security-aspects works, check out the aspect source.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With