Search in sources :

Example 26 with TrustBundle

use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.

the class DefaultBundleRefreshProcessorImpl_convertRawBundleToAnchorCollectionTest method testConvertRawBundleToAnchorCollection_invalidBundle_assertNoAnchors.

public void testConvertRawBundleToAnchorCollection_invalidBundle_assertNoAnchors() throws Exception {
    TrustBundleDao dao = mock(TrustBundleDao.class);
    final byte[] rawBundle = TestUtils.loadBundle("invalidBundle.der");
    final DefaultBundleRefreshProcessorImpl processor = new DefaultBundleRefreshProcessorImpl();
    processor.setDao(dao);
    final TrustBundle existingBundle = new TrustBundle();
    final Calendar processAttempStart = Calendar.getInstance(Locale.getDefault());
    Collection<X509Certificate> anchors = processor.convertRawBundleToAnchorCollection(rawBundle, existingBundle, processAttempStart);
    assertNull(anchors);
}
Also used : Calendar(java.util.Calendar) TrustBundle(org.nhindirect.config.store.TrustBundle) TrustBundleDao(org.nhindirect.config.store.dao.TrustBundleDao) X509Certificate(java.security.cert.X509Certificate)

Example 27 with TrustBundle

use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.

the class DefaultBundleRefreshProcessorImpl_convertRawBundleToAnchorCollectionTest method testConvertRawBundleToAnchorCollection_getFromP7B_assertAnchors.

public void testConvertRawBundleToAnchorCollection_getFromP7B_assertAnchors() throws Exception {
    final byte[] rawBundle = TestUtils.loadBundle("signedbundle.p7b");
    final DefaultBundleRefreshProcessorImpl processor = new DefaultBundleRefreshProcessorImpl();
    final TrustBundle existingBundle = new TrustBundle();
    final Calendar processAttempStart = Calendar.getInstance(Locale.getDefault());
    Collection<X509Certificate> anchors = processor.convertRawBundleToAnchorCollection(rawBundle, existingBundle, processAttempStart);
    assertNotNull(anchors);
    assertEquals(1, anchors.size());
}
Also used : Calendar(java.util.Calendar) TrustBundle(org.nhindirect.config.store.TrustBundle) X509Certificate(java.security.cert.X509Certificate)

Example 28 with TrustBundle

use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.

the class DefaultBundleRefreshProcessorImpl_convertRawBundleToAnchorCollectionTest method testConvertRawBundleToAnchorCollection_getFromSignedBundle_noVerification_assertAnchors.

public void testConvertRawBundleToAnchorCollection_getFromSignedBundle_noVerification_assertAnchors() throws Exception {
    final byte[] rawBundle = TestUtils.loadBundle("signedbundle.p7m");
    final DefaultBundleRefreshProcessorImpl processor = new DefaultBundleRefreshProcessorImpl();
    final TrustBundle existingBundle = new TrustBundle();
    final Calendar processAttempStart = Calendar.getInstance(Locale.getDefault());
    Collection<X509Certificate> anchors = processor.convertRawBundleToAnchorCollection(rawBundle, existingBundle, processAttempStart);
    assertNotNull(anchors);
    assertEquals(1, anchors.size());
}
Also used : Calendar(java.util.Calendar) TrustBundle(org.nhindirect.config.store.TrustBundle) X509Certificate(java.security.cert.X509Certificate)

Example 29 with TrustBundle

use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.

the class DefaultBundleRefreshProcessorImpl_refreshBundleTest method testRefreshBundle_invalidBundle_assertUpdateNotCalled.

@SuppressWarnings("unchecked")
public void testRefreshBundle_invalidBundle_assertUpdateNotCalled() throws Exception {
    DefaultBundleRefreshProcessorImpl processor = new DefaultBundleRefreshProcessorImpl();
    processor.setDao(dao);
    final TrustBundle bundle = new TrustBundle();
    bundle.setBundleName("Junit Bundle");
    File fl = new File("src/test/resources/bundles/invalidBundle.der");
    bundle.setBundleURL(filePrefix + fl.getAbsolutePath());
    processor.refreshBundle(bundle);
    verify(dao, times(0)).updateTrustBundleAnchors(eq(bundle.getId()), (Calendar) any(), (Collection<TrustBundleAnchor>) any(), (String) any());
}
Also used : TrustBundle(org.nhindirect.config.store.TrustBundle) File(java.io.File) TrustBundleAnchor(org.nhindirect.config.store.TrustBundleAnchor)

Example 30 with TrustBundle

use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.

the class DefaultBundleRefreshProcessorImpl_refreshBundleTest method testRefreshBundle_bundleNotFound_assertUpdateNotCalled.

@SuppressWarnings("unchecked")
public void testRefreshBundle_bundleNotFound_assertUpdateNotCalled() throws Exception {
    DefaultBundleRefreshProcessorImpl processor = new DefaultBundleRefreshProcessorImpl();
    processor.setDao(dao);
    final TrustBundle bundle = new TrustBundle();
    bundle.setBundleName("Junit Bundle");
    File fl = new File("src/test/resources/bundles/signedbundle.p7b2122");
    bundle.setBundleURL(filePrefix + fl.getAbsolutePath());
    processor.refreshBundle(bundle);
    verify(dao, times(0)).updateTrustBundleAnchors(eq(bundle.getId()), (Calendar) any(), (Collection<TrustBundleAnchor>) any(), (String) any());
}
Also used : TrustBundle(org.nhindirect.config.store.TrustBundle) File(java.io.File) TrustBundleAnchor(org.nhindirect.config.store.TrustBundleAnchor)

Aggregations

TrustBundle (org.nhindirect.config.store.TrustBundle)44 File (java.io.File)16 ConfigurationStoreException (org.nhindirect.config.store.ConfigurationStoreException)15 ApplicationContext (org.springframework.context.ApplicationContext)12 Transactional (org.springframework.transaction.annotation.Transactional)12 NoResultException (javax.persistence.NoResultException)11 TrustBundleAnchor (org.nhindirect.config.store.TrustBundleAnchor)10 Domain (org.nhindirect.config.store.Domain)9 Calendar (java.util.Calendar)8 TrustBundleDomainReltn (org.nhindirect.config.store.TrustBundleDomainReltn)7 X509Certificate (java.security.cert.X509Certificate)6 Query (javax.persistence.Query)6 TrustBundleDao (org.nhindirect.config.store.dao.TrustBundleDao)4 TrustBundleService (org.nhindirect.config.service.TrustBundleService)3 ArrayList (java.util.ArrayList)2 Address (org.nhindirect.config.store.Address)2 Anchor (org.nhindirect.config.store.Anchor)2 CertPolicy (org.nhindirect.config.store.CertPolicy)2 CertPolicyGroup (org.nhindirect.config.store.CertPolicyGroup)2 Certificate (org.nhindirect.config.store.Certificate)2