CryptoPrimitives implements CryptoSuite { private void setTrustStore(KeyStore keyStore) throws InvalidArgumentException { if (keyStore == null) { throw new InvalidArgumentException("Need to specify a java.security.KeyStore input parameter"); } trustStore = keyStore; } 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 testSetTrustStore() throws Throwable { try { CryptoPrimitives myCrypto = new CryptoPrimitives(); KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); keyStore.load(null, null); TestUtils.invokeMethod(myCrypto, "setTrustStore", keyStore); assertSame(keyStore, myCrypto.getTrustStore()); } catch (CryptoException | KeyStoreException | NoSuchAlgorithmException | CertificateException | IOException e) { fail("testSetTrustStore() should not have thrown Exception. Error: " + e.getMessage()); } }