Example usage for org.apache.hadoop.crypto.key KeyProviderDelegationTokenExtension createKeyProviderDelegationTokenExtension

List of usage examples for org.apache.hadoop.crypto.key KeyProviderDelegationTokenExtension createKeyProviderDelegationTokenExtension

Introduction

In this page you can find the example usage for org.apache.hadoop.crypto.key KeyProviderDelegationTokenExtension createKeyProviderDelegationTokenExtension.

Prototype

public static KeyProviderDelegationTokenExtension createKeyProviderDelegationTokenExtension(
        KeyProvider keyProvider) 

Source Link

Document

Creates a KeyProviderDelegationTokenExtension using a given KeyProvider .

Usage

From source file:co.cask.cdap.security.store.KMSSecureStore.java

License:Apache License

/**
 * Uses the KeyProviderDelegationTokenExtension to get the delegation token for KMS.
 * @param renewer User used to renew the delegation tokens
 * @param credentials Credentials in which to add new delegation tokens
 * @return credentials with KMS delegation token added if it was successfully retrieved.
 *//*from www .j  a v a2 s  .  c  o m*/
@Override
public Credentials addDelegationTokens(String renewer, Credentials credentials) {
    KeyProviderDelegationTokenExtension tokenExtension = KeyProviderDelegationTokenExtension
            .createKeyProviderDelegationTokenExtension(provider);
    try {
        tokenExtension.addDelegationTokens(renewer, credentials);
    } catch (IOException e) {
        LOG.debug("KMS delegation token not updated.");
    }
    return credentials;
}

From source file:com.mellanox.r4h.DistributedFileSystem.java

License:Apache License

@Override
public Token<?>[] addDelegationTokens(final String renewer, Credentials credentials) throws IOException {
    Token<?>[] tokens = super.addDelegationTokens(renewer, credentials);
    if (dfs.isHDFSEncryptionEnabled()) {
        KeyProviderDelegationTokenExtension keyProviderDelegationTokenExtension = KeyProviderDelegationTokenExtension
                .createKeyProviderDelegationTokenExtension(dfs.getKeyProvider());
        Token<?>[] kpTokens = keyProviderDelegationTokenExtension.addDelegationTokens(renewer, credentials);
        if (tokens != null && kpTokens != null) {
            Token<?>[] all = new Token<?>[tokens.length + kpTokens.length];
            System.arraycopy(tokens, 0, all, 0, tokens.length);
            System.arraycopy(kpTokens, 0, all, tokens.length, kpTokens.length);
            tokens = all;//from w  w  w.ja va 2s .co  m
        } else {
            tokens = (tokens != null) ? tokens : kpTokens;
        }
    }
    return tokens;
}