Search in sources :

Example 6 with DelegationTokenSecretManager

use of org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager in project hadoop by apache.

the class DelegationTokenFetcher method printTokensToString.

@VisibleForTesting
static String printTokensToString(final Configuration conf, final Path tokenFile, final boolean verbose) throws IOException {
    StringBuilder sbld = new StringBuilder();
    final String nl = System.getProperty("line.separator");
    DelegationTokenIdentifier id = new DelegationTokenSecretManager(0, 0, 0, 0, null).createIdentifier();
    for (Token<?> token : readTokens(tokenFile, conf)) {
        DataInputStream in = new DataInputStream(new ByteArrayInputStream(token.getIdentifier()));
        id.readFields(in);
        String idStr = (verbose ? id.toString() : id.toStringStable());
        sbld.append("Token (").append(idStr).append(") for ").append(token.getService()).append(nl);
    }
    return sbld.toString();
}
Also used : DelegationTokenSecretManager(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager) DelegationTokenIdentifier(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier) ByteArrayInputStream(java.io.ByteArrayInputStream) DataInputStream(java.io.DataInputStream) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

DelegationTokenSecretManager (org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager)6 DelegationTokenIdentifier (org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier)5 Text (org.apache.hadoop.io.Text)3 Test (org.junit.Test)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 DataInputStream (java.io.DataInputStream)2 Configuration (org.apache.hadoop.conf.Configuration)2 FSNamesystem (org.apache.hadoop.hdfs.server.namenode.FSNamesystem)2 WebHdfsFileSystem (org.apache.hadoop.hdfs.web.WebHdfsFileSystem)2 Token (org.apache.hadoop.security.token.Token)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Response (javax.ws.rs.core.Response)1 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)1