CryptoPrimitives implements CryptoSuite { @Override public void loadCACertificates(Collection<Certificate> certificates) throws CryptoException { if (certificates == null || certificates.size() == 0) { throw new CryptoException("Unable to load CA certificates. List is empty"); } try { for (Certificate cert : certificates) { addCACertificateToTrustStore(cert, Integer.toString(cert.hashCode())); } } catch (InvalidArgumentException e) { throw new CryptoException("Unable to add certificate to trust store. Error: " + e.getMessage(), e); } } 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 (expected = CryptoException.class) public void testLoadCACertsBadInput() throws CryptoException { crypto.loadCACertificates(null); }