以下代码用于使用 Java+Kerberos 向 Windows AD 服务器进行身份验证,并且工作正常-
public class KerberosAuthenticator {
public static void main(String[] args) {
String jaasConfigFilePath = "/myDir/jaas.conf";
System.setProperty("java.security.auth.login.config", jaasConfigFilePath);
String krb5ConfigFilePath = "/etc/krb5/krb5.conf";
System.setProperty("java.security.krb5.conf", krb5ConfigFilePath);
boolean success = auth.KerberosAuthenticator.authenticate("testprincipal", "testpass");
System.out.println(success);
}
}
以上只是一个测试程序。实际代码将在 tomcat webapp 中运行。我面临的问题是,如果 krb5.conf 文件更改,tomcat 中不会反射(reflect)同样的情况,如果使用早期版本的 krb5.conf 已经成功验证一次。新更改仅反射(reflect)在 tomcat 的重新启动上。
我想知道是否有一种方法可以指定 JVM 重新加载 krb5.conf,以便它在不重新启动 JVM 的情况下获取最新的更改。
最佳答案
refreshKrb5Config=true
应该在 jaas.conf 中为 KRB5LoginModule 设置。
关于java - 在不重启 JVM 的情况下在 JAVA 中重新加载 Kerberos 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1437281/