我有一个Java程序,该程序使用kerberos keytab文件安全地登录到我的hadoop服务器。我已经使用下面的代码配置了所有内容,并且在Eclipse IDE中可以正常运行,但是当我通过Maven在其中创建可执行jar并在命令行上运行时,它不起作用。我看到它能够读取keytab文件,但无法获取指定用户ID的密码,因此出现错误。有什么建议吗?
Configuration conf = new Configuration();
conf.set("hadoop.security.authentication", "kerberos");
UserGroupInformation.setConfiguration(conf);
URL file = this.getClass().getClassLoader().getResource("file.keytab");
UserGroupInformation.loginUserFromKeytab("xyzUser", file.getPath());
我的keytab文件保存在根文件夹中,并且已将其作为资源标签添加到pom.xml中。以下是我使用以下命令测试我的jar文件的命令:
java -jar myjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar
最佳答案
确保keytab文件在当前目录中,而不是在classpath中。
关于java - Kerberos:从 key 表文件javax.security.auth.login.Login.log <user>的登录失败:无法从用户获取p密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43903262/