开发者

AspectJ Advice on Spring Security ProviderManager throws exception on startup

Does anyone know why when I try to create an advice around the "doAuthentication" method of the Spring Security (v3.0) ProviderManager my application throws an exception on startup?

I am autowiring an instance of my spring authentication-manager bean into a controller and when the autowire is attempted my app fails to deploy.

Here is what my security context xml looks like...

...<auth开发者_如何学运维entication-manager alias="authenticationManager"> ...

Here is the pertinent part of my controller...

@Autowired
private ProviderManager authenticationManager;

and here is my advice declaration:

@After("execution(* org.springframework.security.authentication.ProviderManager.doAuthentication(..)) && args(authentication)")

Any help will be greatly appreciated!


I'm not sure from the available information, but I'm guessing that you're using Spring AOP, which uses JDK dynamic proxies by default, so you are coming across the usual problem that the proxy does not retain the type of the original class (ProviderManager). The proxy will implement the interface AuthenticationManager, however. Try autowiring using this type and see if it works. Either that or you can enable class proxying which uses cglib instead of dynamic proxies. If you're using the Spring AOP namespace, you can set the proxy-target-class attribute to true.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜