throw (RuntimeException)e; } else { throw new WrapperException(e);
@Override public KeyVersion rollNewVersion(final String name) throws NoSuchAlgorithmException, IOException { try { final KeyVersion newVersion = doOp(new ProviderCallable<KeyVersion>() { @Override public KeyVersion call(KMSClientProvider provider) throws IOException, NoSuchAlgorithmException { return provider.rollNewVersion(name); } }, nextIdx(), false); invalidateCache(name); return newVersion; } catch (WrapperException e) { if (e.getCause() instanceof GeneralSecurityException) { throw (NoSuchAlgorithmException) e.getCause(); } throw new IOException(e.getCause()); } }
private <T> T doOp(ProviderCallable<T> op, int currPos) throws IOException { IOException ex = null; for (int i = 0; i < providers.length; i++) { KMSClientProvider provider = providers[(currPos + i) % providers.length]; try { return op.call(provider); } catch (IOException ioe) { LOG.warn("KMS provider at [{}] threw an IOException [{}]!!", provider.getKMSUrl(), ioe.getMessage()); ex = ioe; } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException)e; } else { throw new WrapperException(e); } } } if (ex != null) { LOG.warn("Aborting since the Request has failed with all KMS" + " providers in the group. !!"); throw ex; } throw new IOException("No providers configured !!"); }
private <T> T doOp(ProviderCallable<T> op, int currPos) throws IOException { IOException ex = null; for (int i = 0; i < providers.length; i++) { KMSClientProvider provider = providers[(currPos + i) % providers.length]; try { return op.call(provider); } catch (IOException ioe) { LOG.warn("KMS provider at [{}] threw an IOException [{}]!!", provider.getKMSUrl(), ioe.getMessage()); ex = ioe; } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException)e; } else { throw new WrapperException(e); } } } if (ex != null) { LOG.warn("Aborting since the Request has failed with all KMS" + " providers in the group. !!"); throw ex; } throw new IOException("No providers configured !!"); }
private <T> T doOp(ProviderCallable<T> op, int currPos) throws IOException { IOException ex = null; for (int i = 0; i < providers.length; i++) { KMSClientProvider provider = providers[(currPos + i) % providers.length]; try { return op.call(provider); } catch (IOException ioe) { LOG.warn("KMS provider at [{}] threw an IOException [{}]!!", provider.getKMSUrl(), ioe.getMessage()); ex = ioe; } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException)e; } else { throw new WrapperException(e); } } } if (ex != null) { LOG.warn("Aborting since the Request has failed with all KMS" + " providers in the group. !!"); throw ex; } throw new IOException("No providers configured !!"); }
private <T> T doOp(ProviderCallable<T> op, int currPos) throws IOException { IOException ex = null; for (int i = 0; i < providers.length; i++) { KMSClientProvider provider = providers[(currPos + i) % providers.length]; try { return op.call(provider); } catch (IOException ioe) { LOG.warn("KMS provider at [{}] threw an IOException [{}]!!", provider.getKMSUrl(), ioe.getMessage()); ex = ioe; } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException)e; } else { throw new WrapperException(e); } } } if (ex != null) { LOG.warn("Aborting since the Request has failed with all KMS" + " providers in the group. !!"); throw ex; } throw new IOException("No providers configured !!"); }
@Override public KeyVersion decryptEncryptedKey(final EncryptedKeyVersion encryptedKeyVersion) throws IOException, GeneralSecurityException { try { return doOp(new ProviderCallable<KeyVersion>() { @Override public KeyVersion call(KMSClientProvider provider) throws IOException, GeneralSecurityException { return provider.decryptEncryptedKey(encryptedKeyVersion); } }, nextIdx()); } catch (WrapperException we) { if (we.getCause() instanceof GeneralSecurityException) { throw (GeneralSecurityException) we.getCause(); } throw new IOException(we.getCause()); } }
@Override public EncryptedKeyVersion generateEncryptedKey(final String encryptionKeyName) throws IOException, GeneralSecurityException { try { return doOp(new ProviderCallable<EncryptedKeyVersion>() { @Override public EncryptedKeyVersion call(KMSClientProvider provider) throws IOException, GeneralSecurityException { return provider.generateEncryptedKey(encryptionKeyName); } }, nextIdx()); } catch (WrapperException we) { if (we.getCause() instanceof GeneralSecurityException) { throw (GeneralSecurityException) we.getCause(); } throw new IOException(we.getCause()); } }
@Override public KeyVersion createKey(final String name, final Options options) throws NoSuchAlgorithmException, IOException { try { return doOp(new ProviderCallable<KeyVersion>() { @Override public KeyVersion call(KMSClientProvider provider) throws IOException, NoSuchAlgorithmException { return provider.createKey(name, options); } }, nextIdx()); } catch (WrapperException e) { if (e.getCause() instanceof GeneralSecurityException) { throw (NoSuchAlgorithmException) e.getCause(); } throw new IOException(e.getCause()); } } @Override
@Override public KeyVersion rollNewVersion(final String name) throws NoSuchAlgorithmException, IOException { try { return doOp(new ProviderCallable<KeyVersion>() { @Override public KeyVersion call(KMSClientProvider provider) throws IOException, NoSuchAlgorithmException { return provider.rollNewVersion(name); } }, nextIdx()); } catch (WrapperException e) { if (e.getCause() instanceof GeneralSecurityException) { throw (NoSuchAlgorithmException) e.getCause(); } throw new IOException(e.getCause()); } }
@Override public EncryptedKeyVersion generateEncryptedKey(final String encryptionKeyName) throws IOException, GeneralSecurityException { try { return doOp(new ProviderCallable<EncryptedKeyVersion>() { @Override public EncryptedKeyVersion call(KMSClientProvider provider) throws IOException, GeneralSecurityException { return provider.generateEncryptedKey(encryptionKeyName); } }, nextIdx()); } catch (WrapperException we) { throw (GeneralSecurityException) we.getCause(); } }
@Override public KeyVersion decryptEncryptedKey(final EncryptedKeyVersion encryptedKeyVersion) throws IOException, GeneralSecurityException { try { return doOp(new ProviderCallable<KeyVersion>() { @Override public KeyVersion call(KMSClientProvider provider) throws IOException, GeneralSecurityException { return provider.decryptEncryptedKey(encryptedKeyVersion); } }, nextIdx()); } catch (WrapperException we) { throw (GeneralSecurityException)we.getCause(); } }
@Override public KeyVersion createKey(final String name, final Options options) throws NoSuchAlgorithmException, IOException { try { return doOp(new ProviderCallable<KeyVersion>() { @Override public KeyVersion call(KMSClientProvider provider) throws IOException, NoSuchAlgorithmException { return provider.createKey(name, options); } }, nextIdx()); } catch (WrapperException e) { throw (NoSuchAlgorithmException)e.getCause(); } } @Override
@Override public KeyVersion decryptEncryptedKey(final EncryptedKeyVersion encryptedKeyVersion) throws IOException, GeneralSecurityException { try { return doOp(new ProviderCallable<KeyVersion>() { @Override public KeyVersion call(KMSClientProvider provider) throws IOException, GeneralSecurityException { return provider.decryptEncryptedKey(encryptedKeyVersion); } }, nextIdx()); } catch (WrapperException we) { throw (GeneralSecurityException)we.getCause(); } }
@Override public KeyVersion createKey(final String name, final Options options) throws NoSuchAlgorithmException, IOException { try { return doOp(new ProviderCallable<KeyVersion>() { @Override public KeyVersion call(KMSClientProvider provider) throws IOException, NoSuchAlgorithmException { return provider.createKey(name, options); } }, nextIdx()); } catch (WrapperException e) { throw (NoSuchAlgorithmException)e.getCause(); } } @Override
@Override public EncryptedKeyVersion generateEncryptedKey(final String encryptionKeyName) throws IOException, GeneralSecurityException { try { return doOp(new ProviderCallable<EncryptedKeyVersion>() { @Override public EncryptedKeyVersion call(KMSClientProvider provider) throws IOException, GeneralSecurityException { return provider.generateEncryptedKey(encryptionKeyName); } }, nextIdx()); } catch (WrapperException we) { throw (GeneralSecurityException) we.getCause(); } }
@Override public KeyVersion rollNewVersion(final String name) throws NoSuchAlgorithmException, IOException { try { return doOp(new ProviderCallable<KeyVersion>() { @Override public KeyVersion call(KMSClientProvider provider) throws IOException, NoSuchAlgorithmException { return provider.rollNewVersion(name); } }, nextIdx()); } catch (WrapperException e) { throw (NoSuchAlgorithmException)e.getCause(); } }
@Override public KeyVersion rollNewVersion(final String name) throws NoSuchAlgorithmException, IOException { try { return doOp(new ProviderCallable<KeyVersion>() { @Override public KeyVersion call(KMSClientProvider provider) throws IOException, NoSuchAlgorithmException { return provider.rollNewVersion(name); } }, nextIdx()); } catch (WrapperException e) { throw (NoSuchAlgorithmException)e.getCause(); } }
@Override public KeyVersion createKey(final String name, final Options options) throws NoSuchAlgorithmException, IOException { try { return doOp(new ProviderCallable<KeyVersion>() { @Override public KeyVersion call(KMSClientProvider provider) throws IOException, NoSuchAlgorithmException { return provider.createKey(name, options); } }, nextIdx()); } catch (WrapperException e) { throw (NoSuchAlgorithmException)e.getCause(); } } @Override
@Override public KeyVersion rollNewVersion(final String name) throws NoSuchAlgorithmException, IOException { try { return doOp(new ProviderCallable<KeyVersion>() { @Override public KeyVersion call(KMSClientProvider provider) throws IOException, NoSuchAlgorithmException { return provider.rollNewVersion(name); } }, nextIdx()); } catch (WrapperException e) { throw (NoSuchAlgorithmException)e.getCause(); } }