java - Kerberos:从 key 表文件javax.security.auth.login.Login.log <user>的登录失败:无法从用户获取p密码

标签 java eclipse maven hadoop kerberos

我有一个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/

相关文章:

java - 在 Java 中使用 block 的 Groovy

eclipse - 为什么 Eclipse 看不到我的 Samsung Galaxy 手机,即使我可以使用驱动器盘符传输文件?

java - 如何在 Java 项目中添加/使用嵌入式 SQLite?

java - 有没有办法将 mywebapp-1.0-SNAPSHOT-classes.jar 从 maven-war-plugin 中的 attachClasses 配置更改为 mywebapp-1.0-SNAPSHOT.jar?

java - 使用maven和Jetty时的Web应用程序路径

java - 如何在数据库中保存复选框状态?

java - 仅使用字符串方法 split 验证来自 (xxx) xxx-xxxx 的电话号码

java - 尝试更新映射键和值时出现 ConcurrentModificationException

java - Eclipse:期间发生内部错误: "Update Hierarchy"

SpringSource 包存储库更改