use of org.nhindirect.config.store.dao.impl.CertificateDaoImpl in project nhin-d by DirectProject.
the class CertificateDaoImp_saveWithProtectionMgr method testStripP12ProtectionTest_NoP12ProtectionWithManager_assertP12Returned.
@Test
public void testStripP12ProtectionTest_NoP12ProtectionWithManager_assertP12Returned() throws Exception {
final EntityManager manager = mock(EntityManager.class);
doAnswer(new Answer<Object>() {
public Object answer(InvocationOnMock invocation) {
persistedCert = (Certificate) invocation.getArguments()[0];
return "";
}
}).when(manager).persist(any());
final BootstrappedKeyStoreProtectionManager mgr = new BootstrappedKeyStoreProtectionManager();
mgr.setKeyStoreProtectionKey("12345");
mgr.setPrivateKeyProtectionKey("67890");
CertificateDaoImpl daoImpl = new CertificateDaoImpl();
daoImpl.setKeyStoreProtectionManager(mgr);
daoImpl.setEntityManager(manager);
daoImpl.save(populateCert("gm2552.der", "gm2552Key.der"));
assert (persistedCert.getData() != null);
// make sure we can't access the P12 without a passphrase
boolean exceptionOccured = false;
try {
CertUtils.toCertContainer(persistedCert.getData());
} catch (CertificateConversionException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
Aggregations