public static KeyProvider createKeyProviderFromUri(final Configuration conf, final URI providerUri) throws IOException { KeyProvider keyProvider = KeyProviderFactory.get(providerUri, conf); if (keyProvider == null) { throw new IOException("Could not instantiate KeyProvider for uri: " + providerUri); } if (keyProvider.isTransient()) { throw new IOException("KeyProvider " + keyProvider.toString() + " was found but it is a transient provider."); } return keyProvider; }
protected KeyProvider getKeyProvider() { KeyProvider prov = null; List<KeyProvider> providers; try { providers = KeyProviderFactory.getProviders(getConf()); if (userSuppliedProvider) { prov = providers.get(0); } else { for (KeyProvider p : providers) { if (!p.isTransient()) { prov = p; break; } } } } catch (IOException e) { e.printStackTrace(getErr()); } if (prov == null) { getOut().println(NO_VALID_PROVIDERS); } return prov; }
/** * Create a KeyProvider based on a provided URI. * * @param uri key provider URI * @param conf configuration to initialize the key provider * @return the key provider for the specified URI, or <code>NULL</code> if * a provider for the specified URI scheme could not be found. * @throws IOException thrown if the provider failed to initialize. */ public static KeyProvider get(URI uri, Configuration conf) throws IOException { KeyProvider kp = null; for (KeyProviderFactory factory : serviceLoader) { kp = factory.createProvider(uri, conf); if (kp != null) { break; } } return kp; }
public static List<KeyProvider> getProviders(Configuration conf ) throws IOException { List<KeyProvider> result = new ArrayList<KeyProvider>(); for(String path: conf.getStringCollection(KEY_PROVIDER_PATH)) { try { URI uri = new URI(path); KeyProvider kp = get(uri, conf); if (kp != null) { result.add(kp); } else { throw new IOException("No KeyProviderFactory for " + uri + " in " + KEY_PROVIDER_PATH); } } catch (URISyntaxException error) { throw new IOException("Bad configuration of " + KEY_PROVIDER_PATH + " at " + path, error); } } return result; }
static KeyProvider createKeyProvider(Configuration conf, Random random) throws IOException { List<org.apache.hadoop.crypto.key.KeyProvider> result = KeyProviderFactory.getProviders(conf); if (result.size() == 0) { LOG.info("Can't get KeyProvider for ORC encryption from" + " hadoop.security.key.provider.path."); return new HadoopShimsPre2_3.NullKeyProvider(); } else { return new KeyProviderImpl(result.get(0), random); } }
/** * Create a KeyProvider based on a provided URI. * * @param uri key provider URI * @param conf configuration to initialize the key provider * @return the key provider for the specified URI, or <code>NULL</code> if * a provider for the specified URI scheme could not be found. * @throws IOException thrown if the provider failed to initialize. */ public static KeyProvider get(URI uri, Configuration conf) throws IOException { KeyProvider kp = null; for (KeyProviderFactory factory : serviceLoader) { kp = factory.createProvider(uri, conf); if (kp != null) { break; } } return kp; }
private static void setUpKeyProvider(Configuration conf) throws Exception { URI keyProviderUri = new URI("jceks://file" + TEST_UTIL.getDataTestDir("test.jks").toUri().toString()); conf.set("dfs.encryption.key.provider.uri", keyProviderUri.toString()); KeyProvider keyProvider = KeyProviderFactory.get(keyProviderUri, conf); keyProvider.createKey(TEST_KEY_NAME, KeyProvider.options(conf)); keyProvider.flush(); keyProvider.close(); }
protected KeyProvider getKeyProvider() { KeyProvider provider = null; List<KeyProvider> providers; try { providers = KeyProviderFactory.getProviders(getConf()); if (userSuppliedProvider) { provider = providers.get(0); } else { for (KeyProvider p : providers) { if (!p.isTransient()) { provider = p; break; } } } } catch (IOException e) { e.printStackTrace(err); } return provider; }
/** * Create a KeyProvider based on a provided URI. * * @param uri key provider URI * @param conf configuration to initialize the key provider * @return the key provider for the specified URI, or <code>NULL</code> if * a provider for the specified URI scheme could not be found. * @throws IOException thrown if the provider failed to initialize. */ public static KeyProvider get(URI uri, Configuration conf) throws IOException { KeyProvider kp = null; for (KeyProviderFactory factory : serviceLoader) { kp = factory.createProvider(uri, conf); if (kp != null) { break; } } return kp; }
public static KeyProvider createKeyProviderFromUri(final Configuration conf, final URI providerUri) throws IOException { KeyProvider keyProvider = KeyProviderFactory.get(providerUri, conf); if (keyProvider == null) { throw new IOException("Could not instantiate KeyProvider for uri: " + providerUri); } if (keyProvider.isTransient()) { throw new IOException("KeyProvider " + keyProvider.toString() + " was found but it is a transient provider."); } return keyProvider; } }
protected KeyProvider getKeyProvider() { KeyProvider prov = null; List<KeyProvider> providers; try { providers = KeyProviderFactory.getProviders(getConf()); if (userSuppliedProvider) { prov = providers.get(0); } else { for (KeyProvider p : providers) { if (!p.isTransient()) { prov = p; break; } } } } catch (IOException e) { e.printStackTrace(err); } if (prov == null) { out.println(NO_VALID_PROVIDERS); } return prov; }
/** * Create a KeyProvider based on a provided URI. * * @param uri key provider URI * @param conf configuration to initialize the key provider * @return the key provider for the specified URI, or <code>NULL</code> if * a provider for the specified URI scheme could not be found. * @throws IOException thrown if the provider failed to initialize. */ public static KeyProvider get(URI uri, Configuration conf) throws IOException { KeyProvider kp = null; for (KeyProviderFactory factory : serviceLoader) { kp = factory.createProvider(uri, conf); if (kp != null) { break; } } return kp; }
public static List<KeyProvider> getProviders(Configuration conf ) throws IOException { List<KeyProvider> result = new ArrayList<KeyProvider>(); for(String path: conf.getStringCollection(KEY_PROVIDER_PATH)) { try { URI uri = new URI(path); KeyProvider kp = get(uri, conf); if (kp != null) { result.add(kp); } else { throw new IOException("No KeyProviderFactory for " + uri + " in " + KEY_PROVIDER_PATH); } } catch (URISyntaxException error) { throw new IOException("Bad configuration of " + KEY_PROVIDER_PATH + " at " + path, error); } } return result; }
protected KeyProvider getKeyProvider() { KeyProvider provider = null; List<KeyProvider> providers; try { providers = KeyProviderFactory.getProviders(getConf()); if (userSuppliedProvider) { provider = providers.get(0); } else { for (KeyProvider p : providers) { if (!p.isTransient()) { provider = p; break; } } } } catch (IOException e) { e.printStackTrace(err); } return provider; }
/** * Create a KeyProvider based on a provided URI. * * @param uri key provider URI * @param conf configuration to initialize the key provider * @return the key provider for the specified URI, or <code>NULL</code> if * a provider for the specified URI scheme could not be found. * @throws IOException thrown if the provider failed to initialize. */ public static KeyProvider get(URI uri, Configuration conf) throws IOException { KeyProvider kp = null; for (KeyProviderFactory factory : serviceLoader) { kp = factory.createProvider(uri, conf); if (kp != null) { break; } } return kp; }
public static List<KeyProvider> getProviders(Configuration conf ) throws IOException { List<KeyProvider> result = new ArrayList<KeyProvider>(); for(String path: conf.getStringCollection(KEY_PROVIDER_PATH)) { try { URI uri = new URI(path); KeyProvider kp = get(uri, conf); if (kp != null) { result.add(kp); } else { throw new IOException("No KeyProviderFactory for " + uri + " in " + KEY_PROVIDER_PATH); } } catch (URISyntaxException error) { throw new IOException("Bad configuration of " + KEY_PROVIDER_PATH + " at " + path, error); } } return result; }
protected KeyProvider getKeyProvider() { KeyProvider provider = null; List<KeyProvider> providers; try { providers = KeyProviderFactory.getProviders(getConf()); if (userSuppliedProvider) { provider = providers.get(0); } else { for (KeyProvider p : providers) { if (!p.isTransient()) { provider = p; break; } } } } catch (IOException e) { e.printStackTrace(err); } return provider; }
public static List<KeyProvider> getProviders(Configuration conf ) throws IOException { List<KeyProvider> result = new ArrayList<KeyProvider>(); for(String path: conf.getStringCollection(KEY_PROVIDER_PATH)) { try { URI uri = new URI(path); KeyProvider kp = get(uri, conf); if (kp != null) { result.add(kp); } else { throw new IOException("No KeyProviderFactory for " + uri + " in " + KEY_PROVIDER_PATH); } } catch (URISyntaxException error) { throw new IOException("Bad configuration of " + KEY_PROVIDER_PATH + " at " + path, error); } } return result; }
@Test public void testFactoryErrors() throws Exception { Configuration conf = new Configuration(); conf.set(KeyProviderFactory.KEY_PROVIDER_PATH, "unknown:///"); try { List<KeyProvider> providers = KeyProviderFactory.getProviders(conf); assertTrue("should throw!", false); } catch (IOException e) { assertEquals("No KeyProviderFactory for unknown:/// in " + KeyProviderFactory.KEY_PROVIDER_PATH, e.getMessage()); } }
public static List<KeyProvider> getProviders(Configuration conf ) throws IOException { List<KeyProvider> result = new ArrayList<KeyProvider>(); for(String path: conf.getStringCollection(KEY_PROVIDER_PATH)) { try { URI uri = new URI(path); KeyProvider kp = get(uri, conf); if (kp != null) { result.add(kp); } else { throw new IOException("No KeyProviderFactory for " + uri + " in " + KEY_PROVIDER_PATH); } } catch (URISyntaxException error) { throw new IOException("Bad configuration of " + KEY_PROVIDER_PATH + " at " + path, error); } } return result; }