From ba8647f511e1cec60a181d7e103a5b2fd314e4cc Mon Sep 17 00:00:00 2001 From: Devaraj Das Date: Sat, 30 Jan 2010 19:57:39 +0000 Subject: [PATCH] HADOOP-6520. Adds APIs to read/write Token and secret keys. Also adds the automatic loading of tokens into UserGroupInformation upon login. The tokens are read from a file specified in the environment variable. Contributed by Devaraj Das. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@904861 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 5 +++++ .../org/apache/hadoop/security/UserGroupInformation.java | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 1ec9c0626f..bb5c19cdee 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -43,6 +43,11 @@ Trunk (unreleased changes) HADOOP-6464. Write a Rackspace cloud provider. (tomwhite) + HADOOP-6520. Adds APIs to read/write Token and secret keys. Also + adds the automatic loading of tokens into UserGroupInformation + upon login. The tokens are read from a file specified in the + environment variable. (ddas) + IMPROVEMENTS HADOOP-6283. Improve the exception messages thrown by diff --git a/src/java/org/apache/hadoop/security/UserGroupInformation.java b/src/java/org/apache/hadoop/security/UserGroupInformation.java index db53b53e20..b3eab89c59 100644 --- a/src/java/org/apache/hadoop/security/UserGroupInformation.java +++ b/src/java/org/apache/hadoop/security/UserGroupInformation.java @@ -34,7 +34,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -132,6 +131,10 @@ public boolean logout() throws LoginException { /** Server-side groups fetching service */ private static Groups groups; + /**Environment variable pointing to the token cache file*/ + public static final String HADOOP_TOKEN_FILE_LOCATION = + "HADOOP_TOKEN_FILE_LOCATION"; + /** * A method to initialize the fields that depend on a configuration. * Must be called before useKerberos or groups is used. @@ -317,6 +320,10 @@ static UserGroupInformation getLoginUser() throws IOException { } login.login(); loginUser = new UserGroupInformation(login.getSubject()); + String tokenFile = System.getenv(HADOOP_TOKEN_FILE_LOCATION); + if (tokenFile != null && isSecurityEnabled()) { + TokenStorage.readTokensAndLoadInUGI(tokenFile, new Configuration(), loginUser); + } } catch (LoginException le) { throw new IOException("failure to login", le); }