Example usage for org.apache.hadoop.security.token.delegation AbstractDelegationTokenIdentifier getIssueDate

List of usage examples for org.apache.hadoop.security.token.delegation AbstractDelegationTokenIdentifier getIssueDate

Introduction

In this page you can find the example usage for org.apache.hadoop.security.token.delegation AbstractDelegationTokenIdentifier getIssueDate.

Prototype

public long getIssueDate() 

Source Link

Usage

From source file:org.apache.slider.core.launch.CredentialUtils.java

License:Apache License

/**
 * Create a string for people to look at
 * @param token token to convert to a string form
 * @return a printable view of the token
 *//*from  w w  w. j  a v  a2s.  c om*/
public static String tokenToString(Token<? extends TokenIdentifier> token) {
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    StringBuilder buffer = new StringBuilder(128);
    buffer.append(token.toString());
    try {
        TokenIdentifier ti = token.decodeIdentifier();
        buffer.append("; ").append(ti);
        if (ti instanceof AbstractDelegationTokenIdentifier) {
            // details in human readable form, and compensate for information HDFS DT omits
            AbstractDelegationTokenIdentifier dt = (AbstractDelegationTokenIdentifier) ti;
            buffer.append("; Renewer: ").append(dt.getRenewer());
            buffer.append("; Issued: ").append(df.format(new Date(dt.getIssueDate())));
            buffer.append("; Max Date: ").append(df.format(new Date(dt.getMaxDate())));
        }
    } catch (IOException e) {
        //marshall problem; not ours
        LOG.debug("Failed to decode {}: {}", token, e, e);
    }
    return buffer.toString();
}