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

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

Introduction

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

Prototype

public int getKeyId() 

Source Link

Usage

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

License:Apache License

@Override
public byte[] retrievePassword(BlockTokenIdentifier identifier) throws InvalidToken {
    if (isExpired(identifier.getExpiryDate())) {
        throw new InvalidToken("Block token with " + identifier.toString() + " is expired.");
    }//from   w w w .j  a va 2 s  .c o m
    BlockKey key = null;
    try {
        key = getBlockKeyById(identifier.getKeyId());
    } catch (IOException ex) {
    }

    if (key == null) {
        throw new InvalidToken("Can't re-compute password for " + identifier.toString()
                + ", since the required block key (keyID=" + identifier.getKeyId() + ") doesn't exist.");
    }
    return createPassword(identifier.getBytes(), key.getKey());
}