Spring Boot 的 LDAPS 实现

问题描述

我目前正在通过 LDAPS 将 Active Directory 身份验证实施到 Spring Boot 应用程序中。 这意味着 AD Server 使用 SSL,现在似乎 Spring Boot 不提供对此的支持。 关于如何解决这个问题的任何想法?解决方案也将不胜感激。

直到现在我尝试过:

  • 将 CONTEXT.Security_PROTOCOL 设置为 SSL(没有帮助)
  • 实施临时证书库(没有帮助)
  • 哭着睡觉(没用)

这是我的 WebSecurityConfig 类:

package redacted.for.security;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider;

import javax.naming.Context;
import java.util.Hashtable;

@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                .anyRequest().fullyAuthenticated()
                .and()
                .formLogin();
    }

    @Bean
    public ActiveDirectoryLdapAuthenticationProvider activeDirectoryLdapAuthenticationProvider() {
        Hashtable<String,Object> env = new Hashtable<>();
        env.put(Context.Security_PROTOCOL,"ssl");
        ActiveDirectoryLdapAuthenticationProvider activeDirectoryLdapAuthenticationProvider = new
                ActiveDirectoryLdapAuthenticationProvider("redacted.for.security","ldaps://redacted.for.security:636/");
        return activeDirectoryLdapAuthenticationProvider;
    }

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...