KeyLoader { public static KeyLoader fromKeyStore(final Vertx vertx, final String keyStorePath, final char[] password) { Objects.requireNonNull(vertx); Objects.requireNonNull(keyStorePath); if (!vertx.fileSystem().existsBlocking(Objects.requireNonNull(keyStorePath))) { throw new IllegalArgumentException("key store does not exist"); } final FileFormat format = FileFormat.detect(keyStorePath); final String type; switch (format) { case JKS: type = "JKS"; break; case PKCS12: type = "PKCS12"; break; default: throw new IllegalArgumentException("key store must be JKS or PKCS format but is: " + format); } return loadKeysFromStore(vertx, type, keyStorePath, password); } private  KeyLoader(final PrivateKey privateKey, final List<Certificate> certs); PrivateKey getPrivateKey(); Certificate[] getCertificateChain(); PublicKey getPublicKey(); static KeyLoader fromKeyStore(final Vertx vertx, final String keyStorePath, final char[] password); static KeyLoader fromFiles(final Vertx vertx, final String keyPath, final String certPath);  }
@Test public void testLoaderFailsForNonExistingKeyStore() { assertThatThrownBy(() -> KeyLoader.fromKeyStore(vertx, "non-existing.p12", "secret".toCharArray())) .isInstanceOf(IllegalArgumentException.class); }