Example usage for org.apache.hadoop.crypto.key KeyProviderFactory getProviders

List of usage examples for org.apache.hadoop.crypto.key KeyProviderFactory getProviders

Introduction

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

Prototype

public static List<KeyProvider> getProviders(Configuration conf) throws IOException 

Source Link

Usage

From source file:org.trustedanalytics.cfbroker.store.hdfs.service.SimpleHdfsClient.java

License:Apache License

void createEncryptionZoneKey(String key) throws NoSuchAlgorithmException, IOException {
    final KeyProvider.Options options = KeyProvider.options(fs.getConf());
    options.setDescription(key);/*from w w w  .  jav  a2  s.  c  o m*/
    options.setBitLength(256);

    List<KeyProvider> providers = KeyProviderFactory.getProviders(fs.getConf());
    Preconditions.checkArgument(!providers.isEmpty(),
            "KMS configuration required for creating encryption zones");

    KeyProvider keyProvider = providers.get(0);
    keyProvider.createKey(key, options);
}