throw new IllegalArgumentException("Cannot get TLS specification from: " + specification);
}
- /**
- * Using private keys and trusted certificates to create a new JDK <code>KeyStore</code> which
- * will be used by TLS clients to create <code>SSLEngine</code>. The private keys are essential
- * to create JDK <code>KeyStore</code> while the trusted certificates are optional.
- *
- * @return A JDK KeyStore object
- * @throws GeneralSecurityException If any security exception occurred
- * @throws IOException If there is an I/O problem with the keystore data
- */
- KeyStore getJavaKeyStore() throws GeneralSecurityException, IOException {
- return getJavaKeyStore(Set.of());
- }
-
/**
* Using private keys and trusted certificates to create a new JDK <code>KeyStore</code> which
* will be used by TLS clients to create <code>SSLEngine</code>. The private keys are essential
import java.security.KeyStoreException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@Test
void testKeystoreAdapterInit() throws Exception {
try (var keystoreAdapter = new DefaultSslHandlerFactoryProvider(dataBroker)) {
- final var ex = assertThrows(KeyStoreException.class, keystoreAdapter::getJavaKeyStore);
+ final var ex = assertThrows(KeyStoreException.class, () -> keystoreAdapter.getJavaKeyStore(Set.of()));
assertThat(ex.getMessage(), startsWith("No keystore private key found"));
}
}
try (var keystoreAdapter = new DefaultSslHandlerFactoryProvider(dataBroker)) {
listener.onDataTreeChanged(List.of(dataTreeModification1));
- final var keyStore = keystoreAdapter.getJavaKeyStore();
+ final var keyStore = keystoreAdapter.getJavaKeyStore(Set.of());
assertTrue(keyStore.containsAlias(privateKey.getName()));
}
}
listener.onDataTreeChanged(List.of(dataTreeModification1, dataTreeModification2));
// Check result
- final var keyStore = keystoreAdapter.getJavaKeyStore();
+ final var keyStore = keystoreAdapter.getJavaKeyStore(Set.of());
assertTrue(keyStore.containsAlias(privateKey.getName()));
assertTrue(keyStore.containsAlias(trustedCertificate.getName()));
}