use of org.nhindirect.stagent.cert.CertificateResolver in project nhin-d by DirectProject.
the class NHINDAgentTest method testIncomingDSN_incomingNotTrusted_outgoingTrusted_useIncomingSettingFalse_assertMDNMessageNotTrusted.
public void testIncomingDSN_incomingNotTrusted_outgoingTrusted_useIncomingSettingFalse_assertMDNMessageNotTrusted() throws Exception {
OptionsManager.getInstance().setOptionsParameter(new OptionsParameter(OptionsParameter.USE_OUTGOING_POLICY_FOR_INCOMING_NOTIFICATIONS, "false"));
// first create the encyrpted message
DefaultNHINDAgent agent = TestUtils.getStockAgent(Arrays.asList(new String[] { "starugh-stateline.com" }));
String testMessage = TestUtils.readResource("DSNMessage.txt");
final OutgoingMessage SMIMEenvMessage = agent.processOutgoing(testMessage);
;
assertNotNull(SMIMEenvMessage);
// now send received the MDN
agent = TestUtils.getStockAgent(Arrays.asList(new String[] { "Cerner.com" }));
DefaultTrustAnchorResolver resolver = (DefaultTrustAnchorResolver) agent.getTrustAnchors();
CertificateResolver mockResolver = mock(CertificateResolver.class);
DefaultTrustAnchorResolver newResolver = new DefaultTrustAnchorResolver(resolver.getOutgoingAnchors(), mockResolver);
agent.setTrustAnchorResolver(newResolver);
IncomingMessage incomingMessage = null;
try {
incomingMessage = agent.processIncoming(SMIMEenvMessage.getMessage());
} catch (NHINDException e) {
assertEquals(TrustError.NoTrustedRecipients, e.getError());
}
assertNull(incomingMessage);
}
use of org.nhindirect.stagent.cert.CertificateResolver in project nhin-d by DirectProject.
the class NHINDAgentTest method testIncomingMDN_incomingNotTrusted_outgoingTrusted_useIncomingSettingFalse_assertMDNMessageNotTrusted.
public void testIncomingMDN_incomingNotTrusted_outgoingTrusted_useIncomingSettingFalse_assertMDNMessageNotTrusted() throws Exception {
OptionsManager.getInstance().setOptionsParameter(new OptionsParameter(OptionsParameter.USE_OUTGOING_POLICY_FOR_INCOMING_NOTIFICATIONS, "false"));
// first create the encyrpted message
DefaultNHINDAgent agent = TestUtils.getStockAgent(Arrays.asList(new String[] { "starugh-stateline.com" }));
String testMessage = TestUtils.readResource("MDNMessage.txt");
final OutgoingMessage SMIMEenvMessage = agent.processOutgoing(testMessage);
;
assertNotNull(SMIMEenvMessage);
// now send received the MDN
agent = TestUtils.getStockAgent(Arrays.asList(new String[] { "Cerner.com" }));
DefaultTrustAnchorResolver resolver = (DefaultTrustAnchorResolver) agent.getTrustAnchors();
CertificateResolver mockResolver = mock(CertificateResolver.class);
DefaultTrustAnchorResolver newResolver = new DefaultTrustAnchorResolver(resolver.getOutgoingAnchors(), mockResolver);
agent.setTrustAnchorResolver(newResolver);
IncomingMessage incomingMessage = null;
try {
incomingMessage = agent.processIncoming(SMIMEenvMessage.getMessage());
} catch (NHINDException e) {
assertEquals(TrustError.NoTrustedRecipients, e.getError());
}
assertNull(incomingMessage);
}
use of org.nhindirect.stagent.cert.CertificateResolver in project nhin-d by DirectProject.
the class LdapCertificateStoreTest method testPublicLdapSearch_requestUserLevelCert_fallbackToOrgLevelCert_assertCertExists.
public void testPublicLdapSearch_requestUserLevelCert_fallbackToOrgLevelCert_assertCertExists() throws Exception {
addStockPublicLDAPCertificats();
PublicLdapCertificateStoreProvider provider = new PublicLdapCertificateStoreProvider(null, null);
CertificateResolver resolver = provider.get();
Collection<X509Certificate> certs = resolver.getCertificates(new InternetAddress("bogus_user@testdomain.com"));
assertEquals(1, certs.size());
X509Certificate cert = certs.iterator().next();
assertTrue(cert.getSubjectX500Principal().toString().contains("direct.fnhubapp01.qa.medplus.com"));
}
use of org.nhindirect.stagent.cert.CertificateResolver in project nhin-d by DirectProject.
the class LdapCertificateStoreTest method testPublicLdapSearch_userLevelCert_assertCertExists.
public void testPublicLdapSearch_userLevelCert_assertCertExists() throws Exception {
addStockPublicLDAPCertificats();
PublicLdapCertificateStoreProvider provider = new PublicLdapCertificateStoreProvider(null, null);
CertificateResolver resolver = provider.get();
Collection<X509Certificate> certs = resolver.getCertificates(new InternetAddress("user@testdomain.com"));
assertEquals(1, certs.size());
X509Certificate cert = certs.iterator().next();
assertTrue(cert.getSubjectX500Principal().toString().contains("moe@direct.fnhubapp01.qa.medplus.com"));
}
use of org.nhindirect.stagent.cert.CertificateResolver in project nhin-d by DirectProject.
the class CertResolverTestModule method configure.
protected void configure() {
CertificateResolver resolver = new KeyStoreCertificateStore(keyStoreFile, keyStorePassword, keyStorePrivPassword);
Collection<CertificateResolver> certResolvers = Arrays.asList(resolver);
bindConstant().annotatedWith(CertStoreKeyFile.class).to(keyStoreFile);
bindConstant().annotatedWith(CertStoreKeyFilePassword.class).to(keyStorePassword);
bindConstant().annotatedWith(CertStoreKeyFilePrivKeyPassword.class).to(keyStorePrivPassword);
this.bind(CertificateResolver.class).annotatedWith(PrivateCerts.class).to(KeyStoreCertificateStore.class);
this.bind(TestUtils.collectionOf(CertificateResolver.class)).annotatedWith(PublicCerts.class).toInstance(certResolvers);
}
Aggregations