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

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

Introduction

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

Prototype

public void setKeyId(int keyId) 

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.  ja  va  2 s. c o 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());
}