Java 类org.apache.hadoop.hdfs.server.namenode.NameNodeHttpServer 实例源码

项目:hadoop    文件:JspHelper.java   
private static InetSocketAddress getNNServiceAddress(ServletContext context,
    HttpServletRequest request) {
  String namenodeAddressInUrl = request.getParameter(NAMENODE_ADDRESS);
  InetSocketAddress namenodeAddress = null;
  if (namenodeAddressInUrl != null) {
    namenodeAddress = NetUtils.createSocketAddr(namenodeAddressInUrl);
  } else if (context != null) {
    namenodeAddress = NameNodeHttpServer.getNameNodeAddressFromContext(
        context); 
  }
  if (namenodeAddress != null) {
    return namenodeAddress;
  }
  return null;
}
项目:hadoop    文件:JspHelper.java   
private static UserGroupInformation getTokenUGI(ServletContext context,
                                                HttpServletRequest request,
                                                String tokenString,
                                                Configuration conf)
                                                    throws IOException {
  final Token<DelegationTokenIdentifier> token =
      new Token<DelegationTokenIdentifier>();
  token.decodeFromUrlString(tokenString);
  InetSocketAddress serviceAddress = getNNServiceAddress(context, request);
  if (serviceAddress != null) {
    SecurityUtil.setTokenService(token, serviceAddress);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
  }

  ByteArrayInputStream buf =
      new ByteArrayInputStream(token.getIdentifier());
  DataInputStream in = new DataInputStream(buf);
  DelegationTokenIdentifier id = new DelegationTokenIdentifier();
  id.readFields(in);
  if (context != null) {
    final NameNode nn = NameNodeHttpServer.getNameNodeFromContext(context);
    if (nn != null) {
      // Verify the token.
      nn.getNamesystem().verifyToken(id, token.getPassword());
    }
  }
  UserGroupInformation ugi = id.getUser();
  ugi.addToken(token);
  return ugi;
}
项目:aliyun-oss-hadoop-fs    文件:JspHelper.java   
private static InetSocketAddress getNNServiceAddress(ServletContext context,
    HttpServletRequest request) {
  String namenodeAddressInUrl = request.getParameter(NAMENODE_ADDRESS);
  InetSocketAddress namenodeAddress = null;
  if (namenodeAddressInUrl != null) {
    namenodeAddress = NetUtils.createSocketAddr(namenodeAddressInUrl);
  } else if (context != null) {
    namenodeAddress = NameNodeHttpServer.getNameNodeAddressFromContext(
        context); 
  }
  if (namenodeAddress != null) {
    return namenodeAddress;
  }
  return null;
}
项目:aliyun-oss-hadoop-fs    文件:JspHelper.java   
private static UserGroupInformation getTokenUGI(ServletContext context,
                                                HttpServletRequest request,
                                                String tokenString,
                                                Configuration conf)
                                                    throws IOException {
  final Token<DelegationTokenIdentifier> token =
      new Token<DelegationTokenIdentifier>();
  token.decodeFromUrlString(tokenString);
  InetSocketAddress serviceAddress = getNNServiceAddress(context, request);
  if (serviceAddress != null) {
    SecurityUtil.setTokenService(token, serviceAddress);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
  }

  ByteArrayInputStream buf =
      new ByteArrayInputStream(token.getIdentifier());
  DataInputStream in = new DataInputStream(buf);
  DelegationTokenIdentifier id = new DelegationTokenIdentifier();
  id.readFields(in);
  if (context != null) {
    final NameNode nn = NameNodeHttpServer.getNameNodeFromContext(context);
    if (nn != null) {
      // Verify the token.
      nn.getNamesystem().verifyToken(id, token.getPassword());
    }
  }
  UserGroupInformation ugi = id.getUser();
  ugi.addToken(token);
  return ugi;
}
项目:big-c    文件:JspHelper.java   
private static InetSocketAddress getNNServiceAddress(ServletContext context,
    HttpServletRequest request) {
  String namenodeAddressInUrl = request.getParameter(NAMENODE_ADDRESS);
  InetSocketAddress namenodeAddress = null;
  if (namenodeAddressInUrl != null) {
    namenodeAddress = NetUtils.createSocketAddr(namenodeAddressInUrl);
  } else if (context != null) {
    namenodeAddress = NameNodeHttpServer.getNameNodeAddressFromContext(
        context); 
  }
  if (namenodeAddress != null) {
    return namenodeAddress;
  }
  return null;
}
项目:big-c    文件:JspHelper.java   
private static UserGroupInformation getTokenUGI(ServletContext context,
                                                HttpServletRequest request,
                                                String tokenString,
                                                Configuration conf)
                                                    throws IOException {
  final Token<DelegationTokenIdentifier> token =
      new Token<DelegationTokenIdentifier>();
  token.decodeFromUrlString(tokenString);
  InetSocketAddress serviceAddress = getNNServiceAddress(context, request);
  if (serviceAddress != null) {
    SecurityUtil.setTokenService(token, serviceAddress);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
  }

  ByteArrayInputStream buf =
      new ByteArrayInputStream(token.getIdentifier());
  DataInputStream in = new DataInputStream(buf);
  DelegationTokenIdentifier id = new DelegationTokenIdentifier();
  id.readFields(in);
  if (context != null) {
    final NameNode nn = NameNodeHttpServer.getNameNodeFromContext(context);
    if (nn != null) {
      // Verify the token.
      nn.getNamesystem().verifyToken(id, token.getPassword());
    }
  }
  UserGroupInformation ugi = id.getUser();
  ugi.addToken(token);
  return ugi;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:JspHelper.java   
private static InetSocketAddress getNNServiceAddress(ServletContext context,
    HttpServletRequest request) {
  String namenodeAddressInUrl = request.getParameter(NAMENODE_ADDRESS);
  InetSocketAddress namenodeAddress = null;
  if (namenodeAddressInUrl != null) {
    namenodeAddress = NetUtils.createSocketAddr(namenodeAddressInUrl);
  } else if (context != null) {
    namenodeAddress = NameNodeHttpServer.getNameNodeAddressFromContext(
        context); 
  }
  if (namenodeAddress != null) {
    return namenodeAddress;
  }
  return null;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:JspHelper.java   
private static UserGroupInformation getTokenUGI(ServletContext context,
                                                HttpServletRequest request,
                                                String tokenString,
                                                Configuration conf)
                                                    throws IOException {
  final Token<DelegationTokenIdentifier> token =
      new Token<DelegationTokenIdentifier>();
  token.decodeFromUrlString(tokenString);
  InetSocketAddress serviceAddress = getNNServiceAddress(context, request);
  if (serviceAddress != null) {
    SecurityUtil.setTokenService(token, serviceAddress);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
  }

  ByteArrayInputStream buf =
      new ByteArrayInputStream(token.getIdentifier());
  DataInputStream in = new DataInputStream(buf);
  DelegationTokenIdentifier id = new DelegationTokenIdentifier();
  id.readFields(in);
  if (context != null) {
    final NameNode nn = NameNodeHttpServer.getNameNodeFromContext(context);
    if (nn != null) {
      // Verify the token.
      nn.getNamesystem().verifyToken(id, token.getPassword());
    }
  }
  UserGroupInformation ugi = id.getUser();
  ugi.addToken(token);
  return ugi;
}
项目:hadoop-plus    文件:JspHelper.java   
private static InetSocketAddress getNNServiceAddress(ServletContext context,
    HttpServletRequest request) {
  String namenodeAddressInUrl = request.getParameter(NAMENODE_ADDRESS);
  InetSocketAddress namenodeAddress = null;
  if (namenodeAddressInUrl != null) {
    namenodeAddress = NetUtils.createSocketAddr(namenodeAddressInUrl);
  } else if (context != null) {
    namenodeAddress = NameNodeHttpServer.getNameNodeAddressFromContext(
        context); 
  }
  if (namenodeAddress != null) {
    return namenodeAddress;
  }
  return null;
}
项目:hadoop-plus    文件:JspHelper.java   
private static UserGroupInformation getTokenUGI(ServletContext context,
                                                HttpServletRequest request,
                                                String tokenString,
                                                Configuration conf)
                                                    throws IOException {
  final Token<DelegationTokenIdentifier> token =
      new Token<DelegationTokenIdentifier>();
  token.decodeFromUrlString(tokenString);
  InetSocketAddress serviceAddress = getNNServiceAddress(context, request);
  if (serviceAddress != null) {
    SecurityUtil.setTokenService(token, serviceAddress);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
  }

  ByteArrayInputStream buf =
      new ByteArrayInputStream(token.getIdentifier());
  DataInputStream in = new DataInputStream(buf);
  DelegationTokenIdentifier id = new DelegationTokenIdentifier();
  id.readFields(in);
  if (context != null) {
    final NameNode nn = NameNodeHttpServer.getNameNodeFromContext(context);
    if (nn != null) {
      // Verify the token.
      nn.getNamesystem().verifyToken(id, token.getPassword());
    }
  }
  UserGroupInformation ugi = id.getUser();
  ugi.addToken(token);
  return ugi;
}
项目:FlexMap    文件:JspHelper.java   
private static InetSocketAddress getNNServiceAddress(ServletContext context,
    HttpServletRequest request) {
  String namenodeAddressInUrl = request.getParameter(NAMENODE_ADDRESS);
  InetSocketAddress namenodeAddress = null;
  if (namenodeAddressInUrl != null) {
    namenodeAddress = NetUtils.createSocketAddr(namenodeAddressInUrl);
  } else if (context != null) {
    namenodeAddress = NameNodeHttpServer.getNameNodeAddressFromContext(
        context); 
  }
  if (namenodeAddress != null) {
    return namenodeAddress;
  }
  return null;
}
项目:FlexMap    文件:JspHelper.java   
private static UserGroupInformation getTokenUGI(ServletContext context,
                                                HttpServletRequest request,
                                                String tokenString,
                                                Configuration conf)
                                                    throws IOException {
  final Token<DelegationTokenIdentifier> token =
      new Token<DelegationTokenIdentifier>();
  token.decodeFromUrlString(tokenString);
  InetSocketAddress serviceAddress = getNNServiceAddress(context, request);
  if (serviceAddress != null) {
    SecurityUtil.setTokenService(token, serviceAddress);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
  }

  ByteArrayInputStream buf =
      new ByteArrayInputStream(token.getIdentifier());
  DataInputStream in = new DataInputStream(buf);
  DelegationTokenIdentifier id = new DelegationTokenIdentifier();
  id.readFields(in);
  if (context != null) {
    final NameNode nn = NameNodeHttpServer.getNameNodeFromContext(context);
    if (nn != null) {
      // Verify the token.
      nn.getNamesystem().verifyToken(id, token.getPassword());
    }
  }
  UserGroupInformation ugi = id.getUser();
  ugi.addToken(token);
  return ugi;
}
项目:hops    文件:JspHelper.java   
private static InetSocketAddress getNNServiceAddress(ServletContext context,
    HttpServletRequest request) {
  String namenodeAddressInUrl = request.getParameter(NAMENODE_ADDRESS);
  InetSocketAddress namenodeAddress = null;
  if (namenodeAddressInUrl != null) {
    namenodeAddress = NetUtils.createSocketAddr(namenodeAddressInUrl);
  } else if (context != null) {
    namenodeAddress =
        NameNodeHttpServer.getNameNodeAddressFromContext(context);
  }
  if (namenodeAddress != null) {
    return namenodeAddress;
  }
  return null;
}
项目:hops    文件:JspHelper.java   
private static UserGroupInformation getTokenUGI(ServletContext context,
    HttpServletRequest request, String tokenString, Configuration conf)
    throws IOException {
  final Token<DelegationTokenIdentifier> token =
      new Token<>();
  token.decodeFromUrlString(tokenString);
  InetSocketAddress serviceAddress = getNNServiceAddress(context, request);
  if (serviceAddress != null) {
    SecurityUtil.setTokenService(token, serviceAddress);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
  }

  ByteArrayInputStream buf = new ByteArrayInputStream(token.getIdentifier());
  DataInputStream in = new DataInputStream(buf);
  DelegationTokenIdentifier id = new DelegationTokenIdentifier();
  id.readFields(in);
  if (context != null) {
    final NameNode nn = NameNodeHttpServer.getNameNodeFromContext(context);
    if (nn != null) {
      // Verify the token.
      nn.getNamesystem().verifyToken(id, token.getPassword());
    }
  }
  UserGroupInformation ugi = id.getUser();
  ugi.addToken(token);
  return ugi;
}
项目:hadoop-TCP    文件:JspHelper.java   
private static InetSocketAddress getNNServiceAddress(ServletContext context,
    HttpServletRequest request) {
  String namenodeAddressInUrl = request.getParameter(NAMENODE_ADDRESS);
  InetSocketAddress namenodeAddress = null;
  if (namenodeAddressInUrl != null) {
    namenodeAddress = NetUtils.createSocketAddr(namenodeAddressInUrl);
  } else if (context != null) {
    namenodeAddress = NameNodeHttpServer.getNameNodeAddressFromContext(
        context); 
  }
  if (namenodeAddress != null) {
    return namenodeAddress;
  }
  return null;
}
项目:hadoop-TCP    文件:JspHelper.java   
private static UserGroupInformation getTokenUGI(ServletContext context,
                                                HttpServletRequest request,
                                                String tokenString,
                                                Configuration conf)
                                                    throws IOException {
  final Token<DelegationTokenIdentifier> token =
      new Token<DelegationTokenIdentifier>();
  token.decodeFromUrlString(tokenString);
  InetSocketAddress serviceAddress = getNNServiceAddress(context, request);
  if (serviceAddress != null) {
    SecurityUtil.setTokenService(token, serviceAddress);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
  }

  ByteArrayInputStream buf =
      new ByteArrayInputStream(token.getIdentifier());
  DataInputStream in = new DataInputStream(buf);
  DelegationTokenIdentifier id = new DelegationTokenIdentifier();
  id.readFields(in);
  if (context != null) {
    final NameNode nn = NameNodeHttpServer.getNameNodeFromContext(context);
    if (nn != null) {
      // Verify the token.
      nn.getNamesystem().verifyToken(id, token.getPassword());
    }
  }
  UserGroupInformation ugi = id.getUser();
  ugi.addToken(token);
  return ugi;
}
项目:hardfs    文件:JspHelper.java   
private static InetSocketAddress getNNServiceAddress(ServletContext context,
    HttpServletRequest request) {
  String namenodeAddressInUrl = request.getParameter(NAMENODE_ADDRESS);
  InetSocketAddress namenodeAddress = null;
  if (namenodeAddressInUrl != null) {
    namenodeAddress = NetUtils.createSocketAddr(namenodeAddressInUrl);
  } else if (context != null) {
    namenodeAddress = NameNodeHttpServer.getNameNodeAddressFromContext(
        context); 
  }
  if (namenodeAddress != null) {
    return namenodeAddress;
  }
  return null;
}
项目:hardfs    文件:JspHelper.java   
private static UserGroupInformation getTokenUGI(ServletContext context,
                                                HttpServletRequest request,
                                                String tokenString,
                                                Configuration conf)
                                                    throws IOException {
  final Token<DelegationTokenIdentifier> token =
      new Token<DelegationTokenIdentifier>();
  token.decodeFromUrlString(tokenString);
  InetSocketAddress serviceAddress = getNNServiceAddress(context, request);
  if (serviceAddress != null) {
    SecurityUtil.setTokenService(token, serviceAddress);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
  }

  ByteArrayInputStream buf =
      new ByteArrayInputStream(token.getIdentifier());
  DataInputStream in = new DataInputStream(buf);
  DelegationTokenIdentifier id = new DelegationTokenIdentifier();
  id.readFields(in);
  if (context != null) {
    final NameNode nn = NameNodeHttpServer.getNameNodeFromContext(context);
    if (nn != null) {
      // Verify the token.
      nn.getNamesystem().verifyToken(id, token.getPassword());
    }
  }
  UserGroupInformation ugi = id.getUser();
  ugi.addToken(token);
  return ugi;
}
项目:hadoop-on-lustre2    文件:JspHelper.java   
private static InetSocketAddress getNNServiceAddress(ServletContext context,
    HttpServletRequest request) {
  String namenodeAddressInUrl = request.getParameter(NAMENODE_ADDRESS);
  InetSocketAddress namenodeAddress = null;
  if (namenodeAddressInUrl != null) {
    namenodeAddress = NetUtils.createSocketAddr(namenodeAddressInUrl);
  } else if (context != null) {
    namenodeAddress = NameNodeHttpServer.getNameNodeAddressFromContext(
        context); 
  }
  if (namenodeAddress != null) {
    return namenodeAddress;
  }
  return null;
}
项目:hadoop-on-lustre2    文件:JspHelper.java   
private static UserGroupInformation getTokenUGI(ServletContext context,
                                                HttpServletRequest request,
                                                String tokenString,
                                                Configuration conf)
                                                    throws IOException {
  final Token<DelegationTokenIdentifier> token =
      new Token<DelegationTokenIdentifier>();
  token.decodeFromUrlString(tokenString);
  InetSocketAddress serviceAddress = getNNServiceAddress(context, request);
  if (serviceAddress != null) {
    SecurityUtil.setTokenService(token, serviceAddress);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
  }

  ByteArrayInputStream buf =
      new ByteArrayInputStream(token.getIdentifier());
  DataInputStream in = new DataInputStream(buf);
  DelegationTokenIdentifier id = new DelegationTokenIdentifier();
  id.readFields(in);
  if (context != null) {
    final NameNode nn = NameNodeHttpServer.getNameNodeFromContext(context);
    if (nn != null) {
      // Verify the token.
      nn.getNamesystem().verifyToken(id, token.getPassword());
    }
  }
  UserGroupInformation ugi = id.getUser();
  ugi.addToken(token);
  return ugi;
}
项目:hadoop    文件:TestJspHelper.java   
@Test
public void testGetUgi() throws IOException {
  conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "hdfs://localhost:4321/");
  HttpServletRequest request = mock(HttpServletRequest.class);
  ServletContext context = mock(ServletContext.class);
  String user = "TheDoctor";
  Text userText = new Text(user);
  DelegationTokenIdentifier dtId = new DelegationTokenIdentifier(userText,
      userText, null);
  Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>(
      dtId, new DummySecretManager(0, 0, 0, 0));
  String tokenString = token.encodeToUrlString();
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  when(request.getRemoteUser()).thenReturn(user);

  //Test attribute in the url to be used as service in the token.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(
      "1.1.1.1:1111");

  conf.set(DFSConfigKeys.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
  UserGroupInformation.setConfiguration(conf);

  verifyServiceInToken(context, request, "1.1.1.1:1111");

  //Test attribute name.node.address 
  //Set the nnaddr url parameter to null.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(null);
  InetSocketAddress addr = new InetSocketAddress("localhost", 2222);
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(addr);
  verifyServiceInToken(context, request, addr.getAddress().getHostAddress()
      + ":2222");

  //Test service already set in the token
  token.setService(new Text("3.3.3.3:3333"));
  tokenString = token.encodeToUrlString();
  //Set the name.node.address attribute in Servlet context to null
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(null);
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  verifyServiceInToken(context, request, "3.3.3.3:3333");
}
项目:aliyun-oss-hadoop-fs    文件:TestJspHelper.java   
@Test
public void testGetUgi() throws IOException {
  conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "hdfs://localhost:4321/");
  HttpServletRequest request = mock(HttpServletRequest.class);
  ServletContext context = mock(ServletContext.class);
  String user = "TheDoctor";
  Text userText = new Text(user);
  DelegationTokenIdentifier dtId = new DelegationTokenIdentifier(userText,
      userText, null);
  Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>(
      dtId, new DummySecretManager(0, 0, 0, 0));
  String tokenString = token.encodeToUrlString();
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  when(request.getRemoteUser()).thenReturn(user);

  //Test attribute in the url to be used as service in the token.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(
      "1.1.1.1:1111");

  conf.set(DFSConfigKeys.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
  UserGroupInformation.setConfiguration(conf);

  verifyServiceInToken(context, request, "1.1.1.1:1111");

  //Test attribute name.node.address 
  //Set the nnaddr url parameter to null.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(null);
  InetSocketAddress addr = new InetSocketAddress("localhost", 2222);
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(addr);
  verifyServiceInToken(context, request, addr.getAddress().getHostAddress()
      + ":2222");

  //Test service already set in the token
  token.setService(new Text("3.3.3.3:3333"));
  tokenString = token.encodeToUrlString();
  //Set the name.node.address attribute in Servlet context to null
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(null);
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  verifyServiceInToken(context, request, "3.3.3.3:3333");
}
项目:big-c    文件:TestJspHelper.java   
@Test
public void testGetUgi() throws IOException {
  conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "hdfs://localhost:4321/");
  HttpServletRequest request = mock(HttpServletRequest.class);
  ServletContext context = mock(ServletContext.class);
  String user = "TheDoctor";
  Text userText = new Text(user);
  DelegationTokenIdentifier dtId = new DelegationTokenIdentifier(userText,
      userText, null);
  Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>(
      dtId, new DummySecretManager(0, 0, 0, 0));
  String tokenString = token.encodeToUrlString();
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  when(request.getRemoteUser()).thenReturn(user);

  //Test attribute in the url to be used as service in the token.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(
      "1.1.1.1:1111");

  conf.set(DFSConfigKeys.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
  UserGroupInformation.setConfiguration(conf);

  verifyServiceInToken(context, request, "1.1.1.1:1111");

  //Test attribute name.node.address 
  //Set the nnaddr url parameter to null.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(null);
  InetSocketAddress addr = new InetSocketAddress("localhost", 2222);
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(addr);
  verifyServiceInToken(context, request, addr.getAddress().getHostAddress()
      + ":2222");

  //Test service already set in the token
  token.setService(new Text("3.3.3.3:3333"));
  tokenString = token.encodeToUrlString();
  //Set the name.node.address attribute in Servlet context to null
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(null);
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  verifyServiceInToken(context, request, "3.3.3.3:3333");
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestJspHelper.java   
@Test
public void testGetUgi() throws IOException {
  conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "hdfs://localhost:4321/");
  HttpServletRequest request = mock(HttpServletRequest.class);
  ServletContext context = mock(ServletContext.class);
  String user = "TheDoctor";
  Text userText = new Text(user);
  DelegationTokenIdentifier dtId = new DelegationTokenIdentifier(userText,
      userText, null);
  Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>(
      dtId, new DummySecretManager(0, 0, 0, 0));
  String tokenString = token.encodeToUrlString();
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  when(request.getRemoteUser()).thenReturn(user);

  //Test attribute in the url to be used as service in the token.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(
      "1.1.1.1:1111");

  conf.set(DFSConfigKeys.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
  UserGroupInformation.setConfiguration(conf);

  verifyServiceInToken(context, request, "1.1.1.1:1111");

  //Test attribute name.node.address 
  //Set the nnaddr url parameter to null.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(null);
  InetSocketAddress addr = new InetSocketAddress("localhost", 2222);
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(addr);
  verifyServiceInToken(context, request, addr.getAddress().getHostAddress()
      + ":2222");

  //Test service already set in the token
  token.setService(new Text("3.3.3.3:3333"));
  tokenString = token.encodeToUrlString();
  //Set the name.node.address attribute in Servlet context to null
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(null);
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  verifyServiceInToken(context, request, "3.3.3.3:3333");
}
项目:hadoop-plus    文件:TestJspHelper.java   
@Test
public void testGetUgi() throws IOException {
  conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "hdfs://localhost:4321/");
  HttpServletRequest request = mock(HttpServletRequest.class);
  ServletContext context = mock(ServletContext.class);
  String user = "TheDoctor";
  Text userText = new Text(user);
  DelegationTokenIdentifier dtId = new DelegationTokenIdentifier(userText,
      userText, null);
  Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>(
      dtId, new DummySecretManager(0, 0, 0, 0));
  String tokenString = token.encodeToUrlString();
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  when(request.getRemoteUser()).thenReturn(user);

  //Test attribute in the url to be used as service in the token.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(
      "1.1.1.1:1111");

  conf.set(DFSConfigKeys.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
  UserGroupInformation.setConfiguration(conf);

  verifyServiceInToken(context, request, "1.1.1.1:1111");

  //Test attribute name.node.address 
  //Set the nnaddr url parameter to null.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(null);
  InetSocketAddress addr = new InetSocketAddress("localhost", 2222);
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(addr);
  verifyServiceInToken(context, request, addr.getAddress().getHostAddress()
      + ":2222");

  //Test service already set in the token
  token.setService(new Text("3.3.3.3:3333"));
  tokenString = token.encodeToUrlString();
  //Set the name.node.address attribute in Servlet context to null
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(null);
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  verifyServiceInToken(context, request, "3.3.3.3:3333");
}
项目:FlexMap    文件:TestJspHelper.java   
@Test
public void testGetUgi() throws IOException {
  conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "hdfs://localhost:4321/");
  HttpServletRequest request = mock(HttpServletRequest.class);
  ServletContext context = mock(ServletContext.class);
  String user = "TheDoctor";
  Text userText = new Text(user);
  DelegationTokenIdentifier dtId = new DelegationTokenIdentifier(userText,
      userText, null);
  Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>(
      dtId, new DummySecretManager(0, 0, 0, 0));
  String tokenString = token.encodeToUrlString();
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  when(request.getRemoteUser()).thenReturn(user);

  //Test attribute in the url to be used as service in the token.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(
      "1.1.1.1:1111");

  conf.set(DFSConfigKeys.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
  UserGroupInformation.setConfiguration(conf);

  verifyServiceInToken(context, request, "1.1.1.1:1111");

  //Test attribute name.node.address 
  //Set the nnaddr url parameter to null.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(null);
  InetSocketAddress addr = new InetSocketAddress("localhost", 2222);
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(addr);
  verifyServiceInToken(context, request, addr.getAddress().getHostAddress()
      + ":2222");

  //Test service already set in the token
  token.setService(new Text("3.3.3.3:3333"));
  tokenString = token.encodeToUrlString();
  //Set the name.node.address attribute in Servlet context to null
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(null);
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  verifyServiceInToken(context, request, "3.3.3.3:3333");
}
项目:hops    文件:TestJspHelper.java   
@Test
public void testGetUgi() throws IOException {
  conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "hdfs://localhost:4321/");
  HttpServletRequest request = mock(HttpServletRequest.class);
  ServletContext context = mock(ServletContext.class);
  String user = "TheDoctor";
  Text userText = new Text(user);
  DelegationTokenIdentifier dtId =
      new DelegationTokenIdentifier(userText, userText, null);
  Token<DelegationTokenIdentifier> token =
      new Token<>(dtId,
          new DummySecretManager(0, 0, 0, 0));
  String tokenString = token.encodeToUrlString();
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME))
      .thenReturn(tokenString);
  when(request.getRemoteUser()).thenReturn(user);

  //Test attribute in the url to be used as service in the token.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS))
      .thenReturn("1.1.1.1:1111");

  conf.set(DFSConfigKeys.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
  UserGroupInformation.setConfiguration(conf);

  verifyServiceInToken(context, request, "1.1.1.1:1111");

  //Test attribute name.node.address 
  //Set the nnaddr url parameter to null.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(null);
  InetSocketAddress addr = new InetSocketAddress("localhost", 2222);
  when(
      context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(addr);
  verifyServiceInToken(context, request,
      addr.getAddress().getHostAddress() + ":2222");

  //Test service already set in the token
  token.setService(new Text("3.3.3.3:3333"));
  tokenString = token.encodeToUrlString();
  //Set the name.node.address attribute in Servlet context to null
  when(
      context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(null);
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME))
      .thenReturn(tokenString);
  verifyServiceInToken(context, request, "3.3.3.3:3333");
}
项目:hadoop-TCP    文件:TestJspHelper.java   
@Test
public void testGetUgi() throws IOException {
  conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "hdfs://localhost:4321/");
  HttpServletRequest request = mock(HttpServletRequest.class);
  ServletContext context = mock(ServletContext.class);
  String user = "TheDoctor";
  Text userText = new Text(user);
  DelegationTokenIdentifier dtId = new DelegationTokenIdentifier(userText,
      userText, null);
  Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>(
      dtId, new DummySecretManager(0, 0, 0, 0));
  String tokenString = token.encodeToUrlString();
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  when(request.getRemoteUser()).thenReturn(user);

  //Test attribute in the url to be used as service in the token.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(
      "1.1.1.1:1111");

  conf.set(DFSConfigKeys.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
  UserGroupInformation.setConfiguration(conf);

  verifyServiceInToken(context, request, "1.1.1.1:1111");

  //Test attribute name.node.address 
  //Set the nnaddr url parameter to null.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(null);
  InetSocketAddress addr = new InetSocketAddress("localhost", 2222);
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(addr);
  verifyServiceInToken(context, request, addr.getAddress().getHostAddress()
      + ":2222");

  //Test service already set in the token
  token.setService(new Text("3.3.3.3:3333"));
  tokenString = token.encodeToUrlString();
  //Set the name.node.address attribute in Servlet context to null
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(null);
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  verifyServiceInToken(context, request, "3.3.3.3:3333");
}
项目:hardfs    文件:TestJspHelper.java   
@Test
public void testGetUgi() throws IOException {
  conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "hdfs://localhost:4321/");
  HttpServletRequest request = mock(HttpServletRequest.class);
  ServletContext context = mock(ServletContext.class);
  String user = "TheDoctor";
  Text userText = new Text(user);
  DelegationTokenIdentifier dtId = new DelegationTokenIdentifier(userText,
      userText, null);
  Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>(
      dtId, new DummySecretManager(0, 0, 0, 0));
  String tokenString = token.encodeToUrlString();
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  when(request.getRemoteUser()).thenReturn(user);

  //Test attribute in the url to be used as service in the token.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(
      "1.1.1.1:1111");

  conf.set(DFSConfigKeys.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
  UserGroupInformation.setConfiguration(conf);

  verifyServiceInToken(context, request, "1.1.1.1:1111");

  //Test attribute name.node.address 
  //Set the nnaddr url parameter to null.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(null);
  InetSocketAddress addr = new InetSocketAddress("localhost", 2222);
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(addr);
  verifyServiceInToken(context, request, addr.getAddress().getHostAddress()
      + ":2222");

  //Test service already set in the token
  token.setService(new Text("3.3.3.3:3333"));
  tokenString = token.encodeToUrlString();
  //Set the name.node.address attribute in Servlet context to null
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(null);
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  verifyServiceInToken(context, request, "3.3.3.3:3333");
}
项目:hadoop-on-lustre2    文件:TestJspHelper.java   
@Test
public void testGetUgi() throws IOException {
  conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "hdfs://localhost:4321/");
  HttpServletRequest request = mock(HttpServletRequest.class);
  ServletContext context = mock(ServletContext.class);
  String user = "TheDoctor";
  Text userText = new Text(user);
  DelegationTokenIdentifier dtId = new DelegationTokenIdentifier(userText,
      userText, null);
  Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>(
      dtId, new DummySecretManager(0, 0, 0, 0));
  String tokenString = token.encodeToUrlString();
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  when(request.getRemoteUser()).thenReturn(user);

  //Test attribute in the url to be used as service in the token.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(
      "1.1.1.1:1111");

  conf.set(DFSConfigKeys.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
  UserGroupInformation.setConfiguration(conf);

  verifyServiceInToken(context, request, "1.1.1.1:1111");

  //Test attribute name.node.address 
  //Set the nnaddr url parameter to null.
  when(request.getParameter(JspHelper.NAMENODE_ADDRESS)).thenReturn(null);
  InetSocketAddress addr = new InetSocketAddress("localhost", 2222);
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(addr);
  verifyServiceInToken(context, request, addr.getAddress().getHostAddress()
      + ":2222");

  //Test service already set in the token
  token.setService(new Text("3.3.3.3:3333"));
  tokenString = token.encodeToUrlString();
  //Set the name.node.address attribute in Servlet context to null
  when(context.getAttribute(NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY))
      .thenReturn(null);
  when(request.getParameter(JspHelper.DELEGATION_PARAMETER_NAME)).thenReturn(
      tokenString);
  verifyServiceInToken(context, request, "3.3.3.3:3333");
}