Examples of UserGroupInformation


Examples of org.apache.hadoop.security.UserGroupInformation

  public static final String TOKEN = "token";
 
  @Override
  protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)
      throws ServletException, IOException {
    final UserGroupInformation ugi;
    final ServletContext context = getServletContext();
    final Configuration conf =
      (Configuration) context.getAttribute(JspHelper.CURRENT_CONF);
    try {
      ugi = getUGI(req, conf);
    } catch(IOException ioe) {
      LOG.info("Request for token received with no authentication from "
          + req.getRemoteAddr(), ioe);
      resp.sendError(HttpServletResponse.SC_FORBIDDEN,
          "Unable to identify or authenticate user");
      return;
    }
    final NameNode nn = (NameNode) context.getAttribute("name.node");
    String tokenString = req.getParameter(TOKEN);
    if (tokenString == null) {
      resp.sendError(HttpServletResponse.SC_MULTIPLE_CHOICES,
                     "Token to renew not specified");
    }
    final Token<DelegationTokenIdentifier> token =
      new Token<DelegationTokenIdentifier>();
    token.decodeFromUrlString(tokenString);
   
    try {
      long result = ugi.doAs(new PrivilegedExceptionAction<Long>() {
        public Long run() throws Exception {
          return nn.renewDelegationToken(token);
        }
      });
      PrintStream os = new PrintStream(resp.getOutputStream());
View Full Code Here

Examples of org.apache.hadoop.security.UserGroupInformation

        datanodeid.getHost() + ":" + datanodeid.getIpcPort());
    if (InterDatanodeProtocol.LOG.isDebugEnabled()) {
      InterDatanodeProtocol.LOG.info("InterDatanodeProtocol addr=" + addr);
    }

    UserGroupInformation loginUgi = UserGroupInformation.getLoginUser();
    try {
      return loginUgi
          .doAs(new PrivilegedExceptionAction<InterDatanodeProtocol>() {
            public InterDatanodeProtocol run() throws IOException {
              return (InterDatanodeProtocol) RPC.getProxy(
                  InterDatanodeProtocol.class, InterDatanodeProtocol.versionID,
                  addr, conf);
View Full Code Here

Examples of org.apache.hadoop.security.UserGroupInformation

       
        try {
          Configuration conf = new Configuration();
          DistributedFileSystem dfs = (DistributedFileSystem) FileSystem.get(conf);
          out = new DataOutputStream(new FileOutputStream(args[0]));
          UserGroupInformation ugi = UserGroupInformation.getCurrentUser();

          new DelegationTokenFetcher(dfs, out, ugi, conf).go();
         
          out.flush();
          System.out.println("Succesfully wrote token of size " +
View Full Code Here

Examples of org.apache.hadoop.security.UserGroupInformation

  public int run(final String[] argv) throws IOException, InterruptedException {
    int val = -1;
    final Configuration conf = getConf();
    UserGroupInformation.setConfiguration(conf);
    UserGroupInformation ugi = UserGroupInformation.getLoginUser();

    val = ugi.doAs(new PrivilegedExceptionAction<Integer>() {
      public Integer run() throws Exception {
        return runJob(conf,argv);
      }
    });
    return val;
View Full Code Here

Examples of org.apache.hadoop.security.UserGroupInformation

      String[] users = new String[]{"foo","bar"};
      final Configuration conf = new Configuration();
      FileSystem[] fs = new FileSystem[users.length];
 
      for(int i = 0; i < users.length; i++) {
        UserGroupInformation ugi = UserGroupInformation.createRemoteUser(users[i]);
        fs[i] = ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {
          public FileSystem run() throws IOException {
            return FileSystem.get(conf);
        }});
        for(int j = 0; j < i; j++) {
          assertFalse(fs[j] == fs[i]);
View Full Code Here

Examples of org.apache.hadoop.security.UserGroupInformation

  @SuppressWarnings("unchecked")
  public <T extends TokenIdentifier> void testCacheForUgi() throws Exception {
    final Configuration conf = new Configuration();
    conf.set("fs.cachedfile.impl", conf.get("fs.file.impl"));
    UserGroupInformation ugiA = UserGroupInformation.createRemoteUser("foo");
    UserGroupInformation ugiB = UserGroupInformation.createRemoteUser("bar");
    FileSystem fsA = ugiA.doAs(new PrivilegedExceptionAction<FileSystem>() {
      public FileSystem run() throws Exception {
        return FileSystem.get(new URI("cachedfile://a"), conf);
      }
    });
    FileSystem fsA1 = ugiA.doAs(new PrivilegedExceptionAction<FileSystem>() {
      public FileSystem run() throws Exception {
        return FileSystem.get(new URI("cachedfile://a"), conf);
      }
    });
    //Since the UGIs are the same, we should have the same filesystem for both
    assertSame(fsA, fsA1);
   
    FileSystem fsB = ugiB.doAs(new PrivilegedExceptionAction<FileSystem>() {
      public FileSystem run() throws Exception {
        return FileSystem.get(new URI("cachedfile://a"), conf);
      }
    });
    //Since the UGIs are different, we should end up with different filesystems
    //corresponding to the two UGIs
    assertNotSame(fsA, fsB);
   
    Token<T> t1 = mock(Token.class);
    UserGroupInformation ugiA2 = UserGroupInformation.createRemoteUser("foo");
   
    fsA = ugiA2.doAs(new PrivilegedExceptionAction<FileSystem>() {
      public FileSystem run() throws Exception {
        return FileSystem.get(new URI("cachedfile://a"), conf);
      }
    });
    // Although the users in the UGI are same, they have different subjects
View Full Code Here

Examples of org.apache.hadoop.security.UserGroupInformation

  }
 
  public void testCloseAllForUGI() throws Exception {
    final Configuration conf = new Configuration();
    conf.set("fs.cachedfile.impl", conf.get("fs.file.impl"));
    UserGroupInformation ugiA = UserGroupInformation.createRemoteUser("foo");
    FileSystem fsA = ugiA.doAs(new PrivilegedExceptionAction<FileSystem>() {
      public FileSystem run() throws Exception {
        return FileSystem.get(new URI("cachedfile://a"), conf);
      }
    });
    //Now we should get the cached filesystem
    FileSystem fsA1 = ugiA.doAs(new PrivilegedExceptionAction<FileSystem>() {
      public FileSystem run() throws Exception {
        return FileSystem.get(new URI("cachedfile://a"), conf);
      }
    });
    assertSame(fsA, fsA1);
   
    FileSystem.closeAllForUGI(ugiA);
   
    //Now we should get a different (newly created) filesystem
    fsA1 = ugiA.doAs(new PrivilegedExceptionAction<FileSystem>() {
      public FileSystem run() throws Exception {
        return FileSystem.get(new URI("cachedfile://a"), conf);
      }
    });
    assertNotSame(fsA, fsA1);
View Full Code Here

Examples of org.apache.hadoop.security.UserGroupInformation

    // will have permissions on the dfs
    String j = UserGroupInformation.getCurrentUser().getShortUserName();
    UserGroupInformation.createUserForTesting(j, new String [] { "myGroup"});
   
    // Create a fake user for all processes to execute within
    UserGroupInformation ugi = UserGroupInformation.createUserForTesting("Zork",
                                                 new String [] {"ZorkGroup"});
    return ugi;
  }
View Full Code Here

Examples of org.apache.hadoop.security.UserGroupInformation

  public void testAllEnabledACLForJobSubmission()
  throws IOException, InterruptedException {
    try {
      JobConf conf = setupConf(QueueManager.toFullPropertyName(
                                                               "default", submitAcl), "*");
      UserGroupInformation ugi = createNecessaryUsers();
      String[] groups = ugi.getGroupNames();
      verifyJobSubmissionToDefaultQueue(conf, true,
                                        ugi.getShortUserName() + "," + groups[groups.length-1]);
    } finally {
      tearDownCluster();
    }
  }
View Full Code Here

Examples of org.apache.hadoop.security.UserGroupInformation

      tearDownCluster();
      verifyJobSubmissionToDefaultQueue(conf, true, userName + "," + groupName);
      verifyJobSubmissionToDefaultQueue(conf, true, user2 + "," + group2);
   
      // Check if MROwner(user who started the mapreduce cluster) can submit job
      UserGroupInformation mrOwner = UserGroupInformation.getCurrentUser();
      userName = mrOwner.getShortUserName();
      String[] groups = mrOwner.getGroupNames();
      groupName = groups[groups.length - 1];
      verifyJobSubmissionToDefaultQueue(conf, true, userName + "," + groupName);
    } finally {
      tearDownCluster();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.