List of usage examples for org.apache.hadoop.crypto.key KeyProviderFactory KEY_PROVIDER_PATH
String KEY_PROVIDER_PATH
To view the source code for org.apache.hadoop.crypto.key KeyProviderFactory KEY_PROVIDER_PATH.
Click Source Link
From source file:co.cask.cdap.security.store.KMSSecureStore.java
License:Apache License
/** * Sets up the key provider. It reads the KMS URI from Hadoop conf to initialize the provider. * @param conf Hadoop configuration. core-site.xml contains the key provider URI. * @param namespaceQueryAdmin For querying namespace. * @throws IllegalArgumentException If the key provider URI is not set. * @throws URISyntaxException If the key provider path is not a valid URI. * @throws IOException If the authority or the port could not be read from the provider URI. *///from w w w. ja v a 2s .c o m @Inject KMSSecureStore(Configuration conf, NamespaceQueryAdmin namespaceQueryAdmin) throws IOException, URISyntaxException { this.conf = conf; this.namespaceQueryAdmin = namespaceQueryAdmin; try { String keyProviderPath = conf.get(KeyProviderFactory.KEY_PROVIDER_PATH); if (Strings.isNullOrEmpty(keyProviderPath)) { throw new IllegalArgumentException("Could not find the key provider URI. Please make sure that " + "hadoop.security.key.provider.path is set to the KMS URI in your " + "core-site.xml."); } URI providerUri = new URI(keyProviderPath); provider = KMSClientProvider.Factory.get(providerUri, conf); } catch (URISyntaxException e) { throw new URISyntaxException( "Secure store could not be loaded. The value for hadoop.security.key.provider.path" + "in core-site.xml is not a valid URI.", e.getReason()); } catch (IOException e) { throw new IOException("Secure store could not be loaded. KMS KeyProvider failed to initialize", e); } LOG.debug("KMS backed secure store initialized successfully."); }