@Test public void testDecryptionFailure() throws InterruptedException, GeneralSecurityException { cryptoJobHandler.close(); MockCryptoService mockCryptoService = new MockCryptoService(new CryptoServiceConfig(verifiableProperties)); mockCryptoService.exceptionOnDecryption.set( new GeneralSecurityException("Exception to test", new IllegalStateException())); cryptoJobHandler = new CryptoJobHandler(DEFAULT_THREAD_COUNT); SecretKeySpec perBlobSecretKey = kms.getRandomKey(); testFailureOnDecryption(perBlobSecretKey, null, false, mockCryptoService, kms); mockCryptoService.clearStates(); cryptoJobHandler.close(); MockKeyManagementService mockKms = new MockKeyManagementService(new KMSConfig(verifiableProperties), defaultKey); cryptoJobHandler = new CryptoJobHandler(DEFAULT_THREAD_COUNT); testFailureOnDecryption(perBlobSecretKey, mockKms, true, cryptoService, mockKms); }
public void close() { if (enabled.compareAndSet(true, false)) { List<Runnable> pendingTasks = scheduler.shutdownNow(); for (Runnable task : pendingTasks) { if (task instanceof CryptoJob) { ((CryptoJob) task).closeJob(CLOSED_EXCEPTION); } else { logger.error("Unknown type of job seen : {}", task.getClass()); } } try { scheduler.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (Exception e) { logger.error("Unexpected exception while waiting for crypto jobs to terminate", e); } } }
CryptoJobHandler implements Closeable { public void close() { if (enabled.compareAndSet(true, false)) { List<Runnable> pendingTasks = scheduler.shutdownNow(); for (Runnable task : pendingTasks) { if (task instanceof CryptoJob) { ((CryptoJob) task).closeJob(CLOSED_EXCEPTION); } else { logger.error("Unknown type of job seen : {}", task.getClass()); } } try { scheduler.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (Exception e) { logger.error("Unexpected exception while waiting for crypto jobs to terminate", e); } } } }
CryptoJobHandler implements Closeable { public void close() { if (enabled.compareAndSet(true, false)) { List<Runnable> pendingTasks = scheduler.shutdownNow(); for (Runnable task : pendingTasks) { if (task instanceof CryptoJob) { ((CryptoJob) task).closeJob(CLOSED_EXCEPTION); } else { logger.error("Unknown type of job seen : {}", task.getClass()); } } try { scheduler.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (Exception e) { logger.error("Unexpected exception while waiting for crypto jobs to terminate", e); } } } CryptoJobHandler(int threadCount); }
CryptoJobHandler implements Closeable { public void close() { if (enabled.compareAndSet(true, false)) { List<Runnable> pendingTasks = scheduler.shutdownNow(); for (Runnable task : pendingTasks) { if (task instanceof CryptoJob) { ((CryptoJob) task).closeJob(CLOSED_EXCEPTION); } else { logger.error("Unknown type of job seen : {}", task.getClass()); } } try { scheduler.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (Exception e) { logger.error("Unexpected exception while waiting for crypto jobs to terminate", e); } } } CryptoJobHandler(int threadCount); void close(); }
CryptoJobHandler implements Closeable { public void close() { if (enabled.compareAndSet(true, false)) { List<Runnable> pendingTasks = scheduler.shutdownNow(); for (Runnable task : pendingTasks) { if (task instanceof CryptoJob) { ((CryptoJob) task).closeJob(CLOSED_EXCEPTION); } else { logger.error("Unknown type of job seen : {}", task.getClass()); } } try { scheduler.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (Exception e) { logger.error("Unexpected exception while waiting for crypto jobs to terminate", e); } } } CryptoJobHandler(int threadCount); void close();  }