【发布时间】:2020-03-25 20:59:37
【问题描述】:
所以我正在研究 Spring Security 的实现。我遇到了一段我无法理解的代码。因此,根据文档,当我们想要自定义 Spring 使用的 AuthenticationManager 时,需要重写以下方法。
protected void configure(AuthenticationManagerBuilder auth) throws java.lang.Exception
我的问题是谁在调用此方法并在此处传递 AuthenticationManagerBuilder 实例。 我看到的工作示例不会创建/公开任何 AuthenticationManagerBuilder bean。
另外,我在文档中看到以下内容,
受保护的 AuthenticationManager authenticationManager() throws java.lang.Exception 获取要使用的 AuthenticationManager。
默认 策略是如果 configure(AuthenticationManagerBuilder) 方法是 重写以使用传入的 AuthenticationManagerBuilder。 否则,按类型自动装配 AuthenticationManager。
被覆盖的方法是一个 void 方法,可能这就是为什么我对它正在做什么/应该做什么感到困惑的原因。
任何帮助/指针都非常感谢。我知道它有效我似乎无法弄清楚如何。 非常感谢。
【问题讨论】:
标签: java spring spring-mvc spring-security