Accumulo kerberos 身份验证

Accumulo kerberos authentication

我在使用 Kerberos 进行 Accumulo 身份验证时遇到问题。当我尝试创建令牌时,我的应用程序失败并出现异常:

Exception in thread "main" java.lang.IllegalArgumentException: Subject is not logged in via Kerberos
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:92)
    at org.apache.accumulo.core.client.security.tokens.KerberosToken.<init>(KerberosToken.java:56)

我的连接码:

UserGroupInformation.loginUserFromKeytab("user", "keytab"); // ok
KerberosToken token = new KerberosToken(); // Exception goes here

感谢任何帮助

您的 Kerberos 登录似乎没有按预期运行。该构造函数正在执行以下操作:

  public KerberosToken(String principal) throws IOException {
    requireNonNull(principal);
    final UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
    checkArgument(ugi.hasKerberosCredentials(), "Subject is not logged in via Kerberos");
    checkArgument(principal.equals(ugi.getUserName()), "Provided principal does not match currently logged-in user");
    this.principal = ugi.getUserName();
  }

不知何故,您的 UGI 调用导致当前用户没有 Kerberos 凭据。你应该能够自己检查这个。我没有适合你的简单解决方案,但你可以尝试以下方法来调试它:

  1. 在您的 log4j 配置中设置 org.apache.hadoop.security=DEBUG
  2. 将 -Dsun.security.krb5.debug=true 传递给您的 JVM(或使用 System.setProperty(...))