I have good Spring MVC app I am trying to get @ illustrated annotations and Spekg auto-Proksiing with the spring, but it appears are you near me to identify my @ precise annotations such a controller:
@ administrator @ request mailing ( "/") public class ApplicationController {private ApplicationFactory applicationFactory; @Public ApplicationController (ApplicationFactory applicationFactory) {super (); This.applicationFactory = applicationFactory; } @Secured ("ROLE_USER") @ResponseBody @RequestMapping (method = GET) public application getApplicationInfo () {Return Application Factory.buildApplication (this); }} and a spring security XML looks something like this:
Code:
& lt; Security: GlobalType - Security Safe-annotation = "enabled" mode = "aspectj" proxy-target-square = "true" /> & Lt; Security: http auto-config = "true" use-expression = "true" & gt; & Lt; Security: http-basic / & gt; & Lt; / Security: http & gt; The above is thus being loaded by a no-xml Spring @ configuration components:
@ configuration @ComponentScan (basePackages = { "com .example "}) @EnableWebMvc @ImportResource (" classpath: security.xml ") public class ApplicationConfiguration WebMvcConfigurerAdapter {} Extended does are loaded using a Servlet 3.0 WebApplicationInitializer instead Is: Implementation of the public class SpringMvcInitializer WebApplicationInitializer {Private Final Entatation Config Web Applications Contact Context = new Antateshn Config Web Applications of Contaks (); Removes Public Zero (universalcontent servletcontact) servlet exception on startup {context.register (ApplicationConfiguration.class); ServletContext.addListener (new ContextLoaderListener (reference)); ServletContext.addListener (New Log4jConfigListener ()); Final Hand FILTERProxy Proxy = New DelegatingFilterProxy ("springSecurityFilterChain", reference); FilterRegistration.Dynamic filter = servletContext.addFilter ("security filter", proxy); Filter.addMappingForUrlPatterns (EnumSet.of (Request), Incorrect, "/ *"); Last Dispatcher Servlet Servlet = New Dispatcher Service (Reference); Servicelet registration. Dynamic Dispatcher = Sarlatcontex Adservelet ("sender", servlet); Dispatcher.setLoadOnStartup (1); Dispatcher.addMapping ("/ *"); Although} Spring Security is not detecting annotations and I can still enable without a secure endpoint without authorization. According to this, it is possible because & lt; Global-method-security & gt; Element is loading in the wrong application context, but I do not know whether it is up to the N-XML Spring Configuration. Am I missing something? I've tried adding @EnableApectpectJAutoProxy (proxyTargetClass = true) in your application configuration, but he or knitting so do not help knit long run anyway or do I enable annotation-based security to your application Time to compile?
When you are using Spring with AOP, you can choose between two implementations of AOP can:
-
Spring AOP implementation is not required to weave, but it is only controlled by beans Spiapi AOP implementation no limitations can work for all objects and Spring AOP , But requires compile-time or load-time knitting
-
mode = "optional" App tells spring to use aspect for APP, so the security aspect will not work in your case without knitting. APPS does not have to do anything to use the APPJSE auto-proxying term as a AOP implementation - this is a feature that allows you to use the Aptech API (instead of implementation) with Spring AOP
Therefore, in your case you can use Spring AOP implementation, because the controller is a spring bean, so you should remove the mode = "aspectj" . Also keep in mind that your controller should not have any-arguments constructor - this is a limit of Spring AOP.
Comments
Post a Comment