Example usage for org.apache.hadoop.mapreduce.security.token.delegation DelegationTokenIdentifier getUser

List of usage examples for org.apache.hadoop.mapreduce.security.token.delegation DelegationTokenIdentifier getUser

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce.security.token.delegation DelegationTokenIdentifier getUser.

Prototype

@Override
public UserGroupInformation getUser() 

Source Link

Document

Get the username encoded in the token identifier

Usage

From source file:org.apache.storm.hive.security.AutoHive.java

License:Apache License

private Token<DelegationTokenIdentifier> getDelegationToken(HiveConf hcatConf, String metaStoreServicePrincipal,
        String topologySubmitterUser) throws IOException {
    LOG.info("Creating delegation tokens for principal={}", metaStoreServicePrincipal);

    HCatClient hcatClient = null;// w w  w  .  j  a  v  a2  s .  c o m
    try {
        hcatClient = HCatClient.create(hcatConf);
        String delegationToken = hcatClient.getDelegationToken(topologySubmitterUser,
                metaStoreServicePrincipal);
        Token<DelegationTokenIdentifier> delegationTokenId = new Token<DelegationTokenIdentifier>();
        delegationTokenId.decodeFromUrlString(delegationToken);

        DelegationTokenIdentifier d = new DelegationTokenIdentifier();
        d.readFields(new DataInputStream(new ByteArrayInputStream(delegationTokenId.getIdentifier())));
        LOG.info("Created Delegation Token for : " + d.getUser());

        return delegationTokenId;
    } finally {
        if (hcatClient != null)
            hcatClient.close();
    }
}