我正在使用SQLJDBC通过JavaKerberos身份验证连接到MS-SQL。不幸的是,当我设置以下值时,SQLJDBC并不在src/main/resources中查找文件,而是希望文件位于root目录中(这在cloudhub/stand中失败,但在studio中运行良好)
需要System.setProperty("sun.security.krb5.debug", "true"); System.setProperty("java.security.auth.login.config", "sqlserverJDBC.conf"); System.setProperty("java.security.krb5.conf", "krb5.conf");帮助!!
感谢纳维恩·H
发布于 2017-07-04 10:57:36
您需要设置conf文件的路径(相对路径或绝对路径)。
System.setProperty("java.security.krb5.conf","src/main/resources/krb5.conf");
https://docs.oracle.com/javase/8/docs/technotes/guides/security/jgss/tutorials/KerberosReq.html
发布于 2017-07-11 16:48:05
感谢你的回复,这在anypoint studio中是有效的。如果我在cloudHub或独立环境中部署相同的应用程序,这将不起作用。
通过以下更改,我使其正常工作。
File jaasFile = new File(classLoader.getResource(obj.getAppPropertyFile("sqlserverJDBC.conf.file")).getFile());
String jaasConfigFilePath = jaasFile.getPath();
System.out.println("sqlserverJDBC path : " + jaasConfigFilePath);
obj.write(jaasConfigFilePath,strBuilder);
System.setProperty("java.security.auth.login.config", jaasConfigFilePath);https://stackoverflow.com/questions/44879319
复制相似问题