BouncyCastleKeyFactoryProvider extends Provider implements ConfigurableProvider { public static void call(Runnable task) { call(() -> { task.run(); return true; }); } @SuppressWarnings("deprecation") // Not deprecated in Java 8. private  BouncyCastleKeyFactoryProvider(); static void call(Runnable task); static synchronized T call(Supplier<T> task); @Override void setParameter(String parameterName, Object parameter); @Override boolean hasAlgorithm(String type, String name); @Override void addAlgorithm(String key, String value); @Override void addAlgorithm(String type, ASN1ObjectIdentifier oid, String className); @Override void addKeyInfoConverter(ASN1ObjectIdentifier oid, AsymmetricKeyInfoConverter keyInfoConverter); @Override void addAttributes(String key, Map<String, String> attributeMap);  }
@Test void pkcs5() { BouncyCastleKeyFactoryProvider.call(this::loadPkcs5); }
@Test void pkcs8() { BouncyCastleKeyFactoryProvider.call(this::loadPkcs8); }
@Test void bouncyCastlePreInstalled() { Assumptions.assumeTrue(Arrays.stream(Security.getProviders()) .noneMatch(p -> BouncyCastleProvider.PROVIDER_NAME.equals(p.getName()))); Security.addProvider(new BouncyCastleProvider()); try { BouncyCastleKeyFactoryProvider.call(this::loadPkcs5); BouncyCastleKeyFactoryProvider.call(this::loadPkcs8); } finally { Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME); } }
@Test void nestedInvocation() { BouncyCastleKeyFactoryProvider.call(() -> BouncyCastleKeyFactoryProvider.call(this::loadPkcs5)); }