Repository: hive Updated Branches: refs/heads/branch-2 6189dbdea -> 10f5554e9
HIVE-16708 : Exception while renewing a Delegation Token (Vihang Karajgaonkar, reviewed by Aihua Xu) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/10f5554e Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/10f5554e Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/10f5554e Branch: refs/heads/branch-2 Commit: 10f5554e9dd4e9aef62167b0d76656af44d496ea Parents: 6189dbd Author: Vihang Karajgaonkar <vih...@cloudera.com> Authored: Wed Nov 29 14:01:23 2017 -0800 Committer: Vihang Karajgaonkar <vih...@cloudera.com> Committed: Wed Nov 29 14:01:23 2017 -0800 ---------------------------------------------------------------------- .../apache/hive/minikdc/TestJdbcWithMiniKdc.java | 16 ++++++++++++++++ .../hive/thrift/DelegationTokenSecretManager.java | 8 +++++++- 2 files changed, 23 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/10f5554e/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithMiniKdc.java ---------------------------------------------------------------------- diff --git a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithMiniKdc.java b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithMiniKdc.java index bd66d15..089c359 100644 --- a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithMiniKdc.java +++ b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithMiniKdc.java @@ -174,6 +174,22 @@ public class TestJdbcWithMiniKdc { } @Test + public void testRenewDelegationToken() throws Exception { + UserGroupInformation currentUGI = miniHiveKdc.loginUser(MiniHiveKdc.HIVE_TEST_SUPER_USER); + hs2Conn = DriverManager.getConnection(miniHS2.getJdbcURL()); + String currentUser = currentUGI.getUserName(); + // retrieve token and store in the cache + String token = ((HiveConnection) hs2Conn) + .getDelegationToken(MiniHiveKdc.HIVE_TEST_USER_1, + miniHiveKdc.getFullyQualifiedServicePrincipal(MiniHiveKdc.HIVE_TEST_SUPER_USER)); + assertTrue(token != null && !token.isEmpty()); + + ((HiveConnection) hs2Conn).renewDelegationToken(token); + + hs2Conn.close(); + } + + @Test public void testCancelRenewTokenFlow() throws Exception { miniHiveKdc.loginUser(MiniHiveKdc.HIVE_TEST_SUPER_USER); hs2Conn = DriverManager.getConnection(miniHS2.getJdbcURL()); http://git-wip-us.apache.org/repos/asf/hive/blob/10f5554e/shims/common/src/main/java/org/apache/hadoop/hive/thrift/DelegationTokenSecretManager.java ---------------------------------------------------------------------- diff --git a/shims/common/src/main/java/org/apache/hadoop/hive/thrift/DelegationTokenSecretManager.java b/shims/common/src/main/java/org/apache/hadoop/hive/thrift/DelegationTokenSecretManager.java index 6a863d8..f39c5c9 100644 --- a/shims/common/src/main/java/org/apache/hadoop/hive/thrift/DelegationTokenSecretManager.java +++ b/shims/common/src/main/java/org/apache/hadoop/hive/thrift/DelegationTokenSecretManager.java @@ -93,7 +93,13 @@ public class DelegationTokenSecretManager public synchronized long renewDelegationToken(String tokenStrForm) throws IOException { Token<DelegationTokenIdentifier> t= new Token<DelegationTokenIdentifier>(); t.decodeFromUrlString(tokenStrForm); - String user = UserGroupInformation.getCurrentUser().getUserName(); + //when a token is created the renewer of the token is stored + //as shortName in AbstractDelegationTokenIdentifier.setRenewer() + //this seems like an inconsistency because while cancelling the token + //it uses the shortname to compare the renewer while it does not use + //shortname during token renewal. Use getShortUserName() until its fixed + //in HADOOP-15068 + String user = UserGroupInformation.getCurrentUser().getShortUserName(); return renewToken(t, user); }