CryptoPrimitives implements CryptoSuite { public KeyStore getTrustStore() throws CryptoException { if (trustStore == null) { createTrustStore(); } return trustStore; } CryptoPrimitives(); Certificate bytesToCertificate(byte[] certBytes); PrivateKey bytesToPrivateKey(byte[] pemKey); @Override boolean verify(byte[] pemCertificate, String signatureAlgorithm, byte[] signature, byte[] plainText); KeyStore getTrustStore(); void addCACertificateToTrustStore(File caCertPem, String alias); void addCACertificateToTrustStore(byte[] bytes, String alias); @Override void loadCACertificates(Collection<Certificate> certificates); @Override void loadCACertificatesAsBytes(Collection<byte[]> certificatesBytes); @Override KeyPair keyGen(); @Override byte[] sign(PrivateKey key, byte[] data); String generateCertificationRequest(String subject, KeyPair pair); @Override byte[] hash(byte[] input); @Override CryptoSuiteFactory getCryptoSuiteFactory(); void init(); @Override Properties getProperties(); byte[] certificateToDER(String certificatePEM);  }
@Test public void testGetTrustStore() throws IllegalAccessException, InstantiationException, ClassNotFoundException { try { CryptoPrimitives myCrypto = new CryptoPrimitives(); assertNotNull(myCrypto.getTrustStore()); } catch (CryptoException e) { fail("getTrustStore() fails with : " + e.getMessage()); } }
@Test public void testGetTrustStoreEntries() { try { assertNotNull(crypto.getTrustStore().getCertificateAlias(testCACert)); assertNull(crypto.getTrustStore().getCertificate("testtesttest")); } catch (KeyStoreException | CryptoException e) { fail("testGetTrustStoreEntries should not have thrown exception. Error: " + e.getMessage()); } }