2017-02-13 131 views
1

我在使用Kerberos進行Accumulo身份驗證時遇到問題。當我嘗試創建令牌我的應用程序失敗,出現異常:Accumulo kerberos身份驗證

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 

任何幫助表示讚賞

回答

1

這樣看來,按照預期的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. 設置org.apache.hadoop.security = DEBUG在你的log4j的配置
  2. 通-Dsun.security。 krb5.debug = true(或使用System.setProperty(...))