Package org.apache.hadoop.security

Examples of org.apache.hadoop.security.Credentials.writeTokenStorageToStream()


          for (Token<?> token : tokens) {
            log.info("Got delegation token for " + fs.getUri() + "; " + token);
          }
        }
        DataOutputBuffer dob = new DataOutputBuffer();
        credentials.writeTokenStorageToStream(dob);
        ByteBuffer containerToken  = ByteBuffer.wrap(dob.getData(), 0, dob.getLength());
        context.setTokens(containerToken);
      }
    } catch (IOException e) {
      log.error("Error setting tokens for appmaster launch context", e);
View Full Code Here


   */
  protected void setupLaunchContextTokens(ContainerLaunchContext ctx) {
    try {
      Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials();
      DataOutputBuffer dob = new DataOutputBuffer();
      credentials.writeTokenStorageToStream(dob);
      // remove the AM-RM token containers should not access
      Iterator<Token<?>> iterator = credentials.getAllTokens().iterator();
      while (iterator.hasNext()) {
        Token<?> token = iterator.next();
        log.info("Token " + token);
View Full Code Here

    LOG.info("Starting ApplicationMaster");

    Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials();
    LOG.info("Credentials: " + credentials);
    DataOutputBuffer dob = new DataOutputBuffer();
    credentials.writeTokenStorageToStream(dob);
    // Now remove the AM->RM token so that containers cannot access it.
    Iterator<Token<?>> iter = credentials.getAllTokens().iterator();
    while (iter.hasNext()) {
      Token<?> token = iter.next();
      LOG.info("Processing token: " + token);
View Full Code Here

        for (Token<?> token : tokens) {
          LOG.info("Got dt for " + fs.getUri() + "; " + token);
        }
      }
      DataOutputBuffer dob = new DataOutputBuffer();
      credentials.writeTokenStorageToStream(dob);
      ByteBuffer fsTokens = ByteBuffer.wrap(dob.getData(), 0, dob.getLength());
      amContainer.setTokens(fsTokens);
    }

    appContext.setAMContainerSpec(amContainer);
View Full Code Here

      TokenCache.setJobToken(jobToken, taskCredentials);

      DataOutputBuffer containerTokens_dob = new DataOutputBuffer();
      LOG.info("Size of containertokens_dob is "
          + taskCredentials.numberOfTokens());
      taskCredentials.writeTokenStorageToStream(containerTokens_dob);
      tokens =
          ByteBuffer.wrap(containerTokens_dob.getData(), 0,
              containerTokens_dob.getLength());

      // Add shuffle token
View Full Code Here

          for (Token<? extends TokenIdentifier> tk : credentials
              .getAllTokens()) {
            LOG.debug(tk.getService() + " : " + tk.encodeToUrlString());
          }
        }
        credentials.writeTokenStorageToStream(tokenOut);
      } finally {
        if (tokenOut != null) {
          tokenOut.close();
        }
      }
View Full Code Here

      alias.set("token" + i);
      Token token = new Token(identifier, password, kind, service);
      creds.addToken(alias, token);
    }
    DataOutputBuffer buf = new DataOutputBuffer();
    creds.writeTokenStorageToStream(buf);
    DataInputBuffer ret = new DataInputBuffer();
    ret.reset(buf.getData(), 0, buf.getLength());
    return ret;
  }
View Full Code Here

      TokenCache.setJobToken(jobToken, taskCredentials);

      DataOutputBuffer containerTokens_dob = new DataOutputBuffer();
      LOG.info("Size of containertokens_dob is "
          + taskCredentials.numberOfTokens());
      taskCredentials.writeTokenStorageToStream(containerTokens_dob);
      taskCredentialsBuffer =
          ByteBuffer.wrap(containerTokens_dob.getData(), 0,
              containerTokens_dob.getLength());

      // Add shuffle token
View Full Code Here

      InetAddress.getByName(uri.getHost()).getHostAddress() + ":" + uri.getPort();
    token.setService(new Text(nnAddress));
   
    Credentials ts = new Credentials();
    ts.addToken(new Text(shortName), token);
    ts.writeTokenStorageToStream(out);
  }

  /**
   * Utility method to obtain a delegation token over http
   * @param nnHttpAddr Namenode http addr, such as http://namenode:50070
View Full Code Here

  static private void getDTfromRemoteIntoFile(String nnAddr, String filename)
  throws IOException {
    Credentials ts = getDTfromRemote(nnAddr, null);

    DataOutputStream file = new DataOutputStream(new FileOutputStream(filename));
    ts.writeTokenStorageToStream(file);
    file.flush();
    System.out.println("Successfully wrote token of " + file.size()
        + " bytes  to " + filename);
  }
}
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.