List of usage examples for org.apache.hadoop.hdfs.security.token.block BlockTokenIdentifier toString
@Override
public String toString()
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. jav a 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()); }
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 ww . j a va2s .co 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()); }