You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by dd...@apache.org on 2010/06/11 22:32:27 UTC

svn commit: r953863 - in /hadoop/common/trunk: CHANGES.txt src/java/org/apache/hadoop/security/UserGroupInformation.java src/test/core/org/apache/hadoop/security/TestUserGroupInformation.java

Author: ddas
Date: Fri Jun 11 20:32:26 2010
New Revision: 953863

URL: http://svn.apache.org/viewvc?rev=953863&view=rev
Log:
HADOOP-6814. Adds an API in UserGroupInformation to get the real authentication method of a passed UGI. Contributed by Jitendra Pandey.

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/java/org/apache/hadoop/security/UserGroupInformation.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/security/TestUserGroupInformation.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=953863&r1=953862&r2=953863&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Fri Jun 11 20:32:26 2010
@@ -50,6 +50,9 @@ Trunk (unreleased changes)
     HADOOP-6526. Need mapping from long principal names to local OS 
     user names. (boryas)
 
+    HADOOP-6814. Adds an API in UserGroupInformation to get the real
+    authentication method of a passed UGI. (Jitendra Pandey via ddas)
+
   BUG FIXES
     HADOOP-6638. try to relogin in a case of failed RPC connection (expired tgt) 
     only in case the subject is loginUser or proxyUgi.realUser. (boryas)

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/security/UserGroupInformation.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/security/UserGroupInformation.java?rev=953863&r1=953862&r2=953863&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/security/UserGroupInformation.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/security/UserGroupInformation.java Fri Jun 11 20:32:26 2010
@@ -735,6 +735,22 @@ public class UserGroupInformation {
     }
     return null;
   }
+  
+  /**
+   * Returns the authentication method of a ugi. If the authentication method is
+   * PROXY, returns the authentication method of the real user.
+   * 
+   * @param ugi
+   * @return AuthenticationMethod
+   */
+  public static AuthenticationMethod getRealAuthenticationMethod(
+      UserGroupInformation ugi) {
+    AuthenticationMethod authMethod = ugi.getAuthenticationMethod();
+    if (authMethod == AuthenticationMethod.PROXY) {
+      authMethod = ugi.getRealUser().getAuthenticationMethod();
+    }
+    return authMethod;
+  }
 
   /**
    * Compare the subjects to see if they are equal to each other.

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/security/TestUserGroupInformation.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/security/TestUserGroupInformation.java?rev=953863&r1=953862&r2=953863&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/security/TestUserGroupInformation.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/security/TestUserGroupInformation.java Fri Jun 11 20:32:26 2010
@@ -277,6 +277,8 @@ public class TestUserGroupInformation {
     Assert.assertEquals(am, ugi.getAuthenticationMethod());
     Assert.assertEquals(null, proxyUgi.getAuthenticationMethod());
     proxyUgi.setAuthenticationMethod(AuthenticationMethod.PROXY);
+    Assert.assertEquals(am, UserGroupInformation
+        .getRealAuthenticationMethod(proxyUgi));
     proxyUgi.doAs(new PrivilegedExceptionAction<Object>() {
       public Object run() throws IOException {
         Assert.assertEquals(AuthenticationMethod.PROXY, UserGroupInformation