Selaa lähdekoodia

HDFS-1039. Service should be set in the token in JspHelper.getUGI

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@950231 13f79535-47bb-0310-9956-ffa450edef68
Boris Shkolnik 15 vuotta sitten
vanhempi
commit
2ab5caf035
2 muutettua tiedostoa jossa 12 lisäystä ja 2 poistoa
  1. 2 0
      CHANGES.txt
  2. 10 2
      src/java/org/apache/hadoop/hdfs/server/common/JspHelper.java

+ 2 - 0
CHANGES.txt

@@ -28,6 +28,8 @@ Trunk (unreleased changes)
     HDFS-1119. Introduce a GSet interface to BlocksMap.  (szetszwo)
     HDFS-1119. Introduce a GSet interface to BlocksMap.  (szetszwo)
 
 
   BUG FIXES
   BUG FIXES
+    HDFS-1039.  Service should be set in the token in JspHelper.getUGI(jnp via boryas)
+
     HDFS-1038. FIX. A test missed in a previous commit for this JIRA. (boryas)
     HDFS-1038. FIX. A test missed in a previous commit for this JIRA. (boryas)
 
 
     HDFS-1038. In nn_browsedfscontent.jsp fetch delegation token only 
     HDFS-1038. In nn_browsedfscontent.jsp fetch delegation token only 

+ 10 - 2
src/java/org/apache/hadoop/hdfs/server/common/JspHelper.java

@@ -45,8 +45,10 @@ import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier;
 import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier;
 import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier;
 import org.apache.hadoop.hdfs.server.datanode.DatanodeJspHelper;
 import org.apache.hadoop.hdfs.server.datanode.DatanodeJspHelper;
 import org.apache.hadoop.hdfs.server.namenode.DatanodeDescriptor;
 import org.apache.hadoop.hdfs.server.namenode.DatanodeDescriptor;
+import org.apache.hadoop.hdfs.server.namenode.NameNode;
 import org.apache.hadoop.http.HtmlQuoting;
 import org.apache.hadoop.http.HtmlQuoting;
 import org.apache.hadoop.io.WritableUtils;
 import org.apache.hadoop.io.WritableUtils;
+import org.apache.hadoop.io.Text;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.security.AccessControlException;
 import org.apache.hadoop.security.AccessControlException;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.UserGroupInformation;
@@ -280,8 +282,8 @@ public class JspHelper {
       String[] parts = dir.split(Path.SEPARATOR);
       String[] parts = dir.split(Path.SEPARATOR);
       StringBuilder tempPath = new StringBuilder(dir.length());
       StringBuilder tempPath = new StringBuilder(dir.length());
       out.print("<a href=\"browseDirectory.jsp" + "?dir="+ Path.SEPARATOR
       out.print("<a href=\"browseDirectory.jsp" + "?dir="+ Path.SEPARATOR
-          + "&namenodeInfoPort=" + namenodeInfoPort
-          + "\">" + Path.SEPARATOR + "</a>");
+          + "&namenodeInfoPort=" + namenodeInfoPort + SET_DELEGATION
+          + tokenString + "\">" + Path.SEPARATOR + "</a>");
       tempPath.append(Path.SEPARATOR);
       tempPath.append(Path.SEPARATOR);
       for (int i = 0; i < parts.length-1; i++) {
       for (int i = 0; i < parts.length-1; i++) {
         if (!parts[i].equals("")) {
         if (!parts[i].equals("")) {
@@ -405,6 +407,12 @@ public class JspHelper {
         Token<DelegationTokenIdentifier> token = 
         Token<DelegationTokenIdentifier> token = 
           new Token<DelegationTokenIdentifier>();
           new Token<DelegationTokenIdentifier>();
         token.decodeFromUrlString(tokenString);
         token.decodeFromUrlString(tokenString);
+        InetSocketAddress serviceAddr = NameNode.getAddress(conf);
+        LOG.info("Setting service in token: "
+            + new Text(serviceAddr.getAddress().getHostAddress() + ":"
+                + serviceAddr.getPort()));
+        token.setService(new Text(serviceAddr.getAddress().getHostAddress()
+            + ":" + serviceAddr.getPort()));
         ugi = UserGroupInformation.createRemoteUser(user);
         ugi = UserGroupInformation.createRemoteUser(user);
         ugi.addToken(token);
         ugi.addToken(token);
         ugi.setAuthenticationMethod(AuthenticationMethod.TOKEN);
         ugi.setAuthenticationMethod(AuthenticationMethod.TOKEN);