createProviders(conf, origUrl, port, hostsPart); return new LoadBalancingKMSClientProvider(providerUri, providers, conf);
return createProvider(providerUri, conf, origUrl, port, hostsPart);
return createProvider(providerUri, conf, origUrl, port, hostsPart);
return createProvider(providerUri, conf, origUrl, port, hostsPart);
return createProvider(providerUri, conf, origUrl, port, hostsPart);
/** * 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. */ @Inject KMSSecureStoreService(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."); }
@Test public void testCreation() throws Exception { Configuration conf = new Configuration(); KeyProvider kp = new KMSClientProvider.Factory().createProvider(new URI( "kms://http@host1/kms/foo"), conf); assertTrue(kp instanceof KMSClientProvider); ((KMSClientProvider) kp).getKMSUrl()); kp = new KMSClientProvider.Factory().createProvider(new URI( "kms://http@host1;host2;host3/kms/foo"), conf); assertTrue(kp instanceof LoadBalancingKMSClientProvider); providers[2].getKMSUrl())); kp = new KMSClientProvider.Factory().createProvider(new URI( "kms://http@host1;host2;host3:16000/kms/foo"), conf); assertTrue(kp instanceof LoadBalancingKMSClientProvider);
@Test public void testCreation() throws Exception { Configuration conf = new Configuration(); KeyProvider kp = new KMSClientProvider.Factory().createProvider(new URI( "kms://http@host1/kms/foo"), conf); assertTrue(kp instanceof KMSClientProvider); ((KMSClientProvider) kp).getKMSUrl()); kp = new KMSClientProvider.Factory().createProvider(new URI( "kms://http@host1;host2;host3/kms/foo"), conf); assertTrue(kp instanceof LoadBalancingKMSClientProvider); providers[2].getKMSUrl())); kp = new KMSClientProvider.Factory().createProvider(new URI( "kms://http@host1;host2;host3:16000/kms/foo"), conf); assertTrue(kp instanceof LoadBalancingKMSClientProvider);