我正在尝试在Spring Boot中使用LDAP对用户进行身份验证。这是我的Web安全配置:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.anyRequest().fullyAuthenticated()
.and()
.formLogin();
}
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.ldapAuthentication()
.userDnPatterns("uid={0},ou=people")
.groupSearchBase("ou=groups")
.contextSource()
.url("ldap://my.ldap.url/dc=mysite,dc=com")
.and()
.passwordCompare()
.passwordEncoder(new LdapShaPasswordEncoder())
.passwordAttribute("userPassword");
}
使用Apache Directory Studio,我可以看到密码加密方法是
CRYPT-MD5
java.lang.NullPointerException: null
尝试登录时出错。
我想我选错了编码器。有人知道我应该用哪个编码器吗?