List of usage examples for org.apache.hadoop.security Credentials Credentials
public Credentials()
From source file:yarnkit.client.YarnClientService.java
License:Apache License
@Nullable private static ByteBuffer getSecurityToken(@Nonnull Configuration conf) throws IOException { if (!UserGroupInformation.isSecurityEnabled()) { return null; }/*from ww w . j a v a 2 s . c o m*/ FileSystem fs = FileSystem.get(conf); Credentials credentials = new Credentials(); String tokenRenewer = conf.get(YarnConfiguration.RM_PRINCIPAL); if (tokenRenewer == null || tokenRenewer.length() == 0) { throw new IOException("Can't get Master Kerberos principal for the RM to use as renewer"); } // For now, only getting tokens for the default file-system. final Token<?> tokens[] = fs.addDelegationTokens(tokenRenewer, credentials); if (tokens != null) { for (Token<?> token : tokens) { LOG.info("Got delegation token for " + fs.getUri() + ": " + token); } } DataOutputBuffer dob = new DataOutputBuffer(); credentials.writeTokenStorageToStream(dob); return ByteBuffer.wrap(dob.getData(), 0, dob.getLength()); }