Example usage for org.apache.hadoop.hdfs.security.token.block BlockTokenIdentifier setExpiryDate

List of usage examples for org.apache.hadoop.hdfs.security.token.block BlockTokenIdentifier setExpiryDate

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.security.token.block BlockTokenIdentifier setExpiryDate.

Prototype

public void setExpiryDate(long expiryDate) 

Source Link

Usage

From source file:io.hops.metadata.security.token.block.NameNodeBlockTokenSecretManager.java

License:Apache License

@Override
protected byte[] createPassword(BlockTokenIdentifier identifier) {
    BlockKey key;//  w w  w.  j a  v  a2 s . co m
    try {
        key = getBlockKeyByType(BlockKey.KeyType.CurrKey);
    } catch (IOException ex) {
        throw new IllegalStateException("currentKey hasn't been initialized. [" + ex.getMessage() + "]");
    }
    if (key == null) {
        throw new IllegalStateException("currentKey hasn't been initialized.");
    }
    identifier.setExpiryDate(Time.now() + tokenLifetime);
    identifier.setKeyId(key.getKeyId());
    if (LOG.isDebugEnabled()) {
        LOG.debug("Generating block token for " + identifier.toString());
    }
    return createPassword(identifier.getBytes(), key.getKey());
}