public static String getTokenStrForm(String tokenSignature) throws IOException {
    UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
    TokenSelector<? extends TokenIdentifier> tokenSelector = new DelegationTokenSelector();

    Token<? extends TokenIdentifier> token = tokenSelector.selectToken(
        tokenSignature == null ? new Text() : new Text(tokenSignature), ugi.getTokens());
    return token != null ? token.encodeToUrlString() : null;
  }
Get the string form of the token given a token signature. The signature is used as the value of
the "service" field in the token for lookup. Ref: AbstractDelegationTokenSelector in Hadoop. If
there exists such a token in the token cache (credential store) of the job, the lookup returns
that. This is relevant only when running against a "secure" hadoop release The method gets hold
of the tokens if they are set up by hadoop - this should happen on the map/reduce tasks if the
client added the tokens into hadoop's credential store in the front end during job submission.
The method will select the hive delegation token among the set of tokens and return the string
form of it

@param tokenSignature
@return the string form of the token found
@throws IOException
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/SecurityUtils.java