OadrPKISecurity { public static TrustManagerFactory createTrustManagerFactory(List<String> trustedCertificateFilePath) throws OadrSecurityException { TrustManagerFactory tmf = null; try { KeyStore ts = KeyStore.getInstance(KeyStore.getDefaultType()); ts.load(null, null); for (String certPath : trustedCertificateFilePath) { X509Certificate cert = OadrPKISecurity.parseCertificate(certPath); File file = new File(certPath); ts.setCertificateEntry(file.getName(), cert); } tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(ts); } catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | IOException e) { throw new OadrSecurityException(e); } return tmf; } private  OadrPKISecurity(); static PrivateKey parsePrivateKey(String privateKeyFilePath); static PrivateKey parsePrivateKey(FileReader fileReader); static X509Certificate parseCertificate(String certificateFilePath); static X509Certificate parseCertificate(FileReader fileReader); static KeyStore createKeyStore(String privateKeyFilePath, String clientCertificatefilePath, String password); static KeyManagerFactory createKeyManagerFactory(String clientPrivateKeyPemFilePath,
			String clientCertificatePemFilePath, String password); static KeyStore createTrustStore(List<String> certificates); static TrustManagerFactory createTrustManagerFactory(List<String> trustedCertificateFilePath); static SSLContext createSSLContext(String clientPrivateKeyPemFilePath, String clientCertificatePemFilePath,
			List<String> trustCertificates, String password); static String md5Hex(String data); static KeyPair generateRsaKeyPair(); static KeyPair generateEccKeyPair(); static OadrUserX509Credential generateCredentials(KeyPair caKeyPair, X509Certificate caCert,
			String commonName, OadrPKIAlgorithm algo);  }
@Test public void createTrustManagerFactoryTest() throws OadrSecurityException, KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { List<String> certificates = new ArrayList<>(); certificates.add(TestUtils.TEST_CRT); TrustManagerFactory createTrustManagerFactory = OadrPKISecurity.createTrustManagerFactory(certificates); assertNotNull(createTrustManagerFactory); createTrustManagerFactory = OadrPKISecurity.createTrustManagerFactory(Lists.newArrayList()); assertNotNull(createTrustManagerFactory); certificates = new ArrayList<>(); certificates.add(TestUtils.TEST_KEY); boolean exception = false; try { createTrustManagerFactory = OadrPKISecurity.createTrustManagerFactory(certificates); } catch (OadrSecurityException e) { exception = true; } assertTrue(exception); }