Spring security Spring Security自定义ldapAuthenticationProvider+;自定义ldapAuthoritiesPopulator

Spring security Spring Security自定义ldapAuthenticationProvider+;自定义ldapAuthoritiesPopulator,spring-security,spring-security-ldap,Spring Security,Spring Security Ldap,是否可以将自定义ldap身份验证提供程序与自定义ldap权限填充器一起使用 我不希望每次ldap服务器在短时间内无法访问时都重新启动我的应用程序(因此我需要自定义提供程序,以便在每次登录时创建新的上下文并覆盖authenticate方法) 另一方面,我需要为ldap用户的每个成员创建自定义角色(需要覆盖GetGrantedAuthority)要实现自定义ldap身份验证提供程序,需要创建从AbstractLdapAuthenticator扩展的类 公共类BindPasswordAuthentic

是否可以将自定义ldap身份验证提供程序与自定义ldap权限填充器一起使用

我不希望每次ldap服务器在短时间内无法访问时都重新启动我的应用程序(因此我需要自定义提供程序,以便在每次登录时创建新的上下文并覆盖authenticate方法)


另一方面,我需要为ldap用户的每个成员创建自定义角色(需要覆盖GetGrantedAuthority)

要实现自定义ldap身份验证提供程序,需要创建从
AbstractLdapAuthenticator扩展的类

公共类BindPasswordAuthenticator扩展了AbstractLdapAuthenticator{
public BindPasswordAuthentificator(BaseLdapPathContextSource contextSource){
超级(contextSource);
}
@凌驾
公共DirContextOperations身份验证(身份验证){
DirContextOperations用户;
字符串username=authentication.getName();
字符串密码=(字符串)身份验证。getCredentials();
user=authenticateByLdap(用户名、密码);//在此处验证用户
if(user==null){
抛出新的BadCredentialsException(
messages.getMessage(“BindAuthenticator.badCredentials”、“坏凭证”);
}
返回用户;
}
}
为了实现ldap权限填充器,您需要创建从
ldaAuthoritiesPopulator

公共类CustomLdapAuthoritiesPopulator实现了LdapAuthoritiesPopulator{
@凌驾

公共集合要实现自定义ldap身份验证提供程序,您需要创建从
AbstractLdapAuthenticator

公共类BindPasswordAuthenticator扩展了AbstractLdapAuthenticator{
public BindPasswordAuthentificator(BaseLdapPathContextSource contextSource){
超级(contextSource);
}
@凌驾
公共DirContextOperations身份验证(身份验证){
DirContextOperations用户;
字符串username=authentication.getName();
字符串密码=(字符串)身份验证。getCredentials();
user=authenticateByLdap(用户名、密码);//在此处验证用户
if(user==null){
抛出新的BadCredentialsException(
messages.getMessage(“BindAuthenticator.badCredentials”、“坏凭证”);
}
返回用户;
}
}
为了实现ldap权限填充器,您需要创建从
ldaAuthoritiesPopulator

公共类CustomLdapAuthoritiesPopulator实现了LdapAuthoritiesPopulator{
@凌驾

公共集合你能提供一些解释吗?一个人如何实现
authenticateByLdap(用户名、密码);
。如何设置
ldap url
userdn
&
groupSearchBase(“ou=groups”)
谢谢你能提供一些解释。一个人如何实现
authenticateByLdap(用户名、密码);
。如何设置
ldap url
userdn
&
groupSearchBase(“ou=groups”)
谢谢