hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bor...@apache.org
Subject svn commit: r965556 - in /hadoop/common/trunk: CHANGES.txt src/java/org/apache/hadoop/security/SecurityUtil.java
Date Mon, 19 Jul 2010 16:51:16 GMT
Author: boryas
Date: Mon Jul 19 16:51:16 2010
New Revision: 965556

URL: http://svn.apache.org/viewvc?rev=965556&view=rev
Log:
HADOOP-6805. add buildDTServiceName method to SecurityUtil (as part of MAPREDUCE-1718)

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/java/org/apache/hadoop/security/SecurityUtil.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=965556&r1=965555&r2=965556&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Mon Jul 19 16:51:16 2010
@@ -71,6 +71,9 @@ Trunk (unreleased changes)
     HADOOP-6826. FileStatus needs unit tests. (Rodrigo Schmidt via Eli
     Collins)
 
+    HADOOP-6905. add buildDTServiceName method to SecurityUtil 
+    (as part of MAPREDUCE-1718)  (boryas)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/security/SecurityUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/security/SecurityUtil.java?rev=965556&r1=965555&r2=965556&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/security/SecurityUtil.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/security/SecurityUtil.java Mon Jul 19 16:51:16
2010
@@ -17,6 +17,7 @@
 package org.apache.hadoop.security;
 
 import java.io.IOException;
+import java.net.URI;
 import java.net.URL;
 import java.security.AccessController;
 import java.util.Set;
@@ -28,7 +29,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.net.NetUtils;
 
 import sun.security.jgss.krb5.Krb5Util;
 import sun.security.krb5.Credentials;
@@ -106,4 +107,23 @@ public class SecurityUtil {
     Subject.getSubject(AccessController.getContext()).getPrivateCredentials()
         .add(Krb5Util.credsToTicket(serviceCred));
   }
+
+  /**
+   * create service name for Delegation token ip:port
+   * @param uri
+   * @param defPort
+   * @return "ip:port"
+   */
+  public static String buildDTServiceName(URI uri, int defPort) {
+    int port = uri.getPort();
+    if(port == -1) 
+      port = defPort;
+
+    // build the service name string "/ip:port"
+    // for whatever reason using NetUtils.createSocketAddr(target).toString()
+    // returns "localhost/ip:port"
+    StringBuffer sb = new StringBuffer();
+    sb.append(NetUtils.normalizeHostName(uri.getHost())).append(":").append(port);
+    return sb.toString();
+  }
 }



Mime
View raw message