use of org.nhindirect.stagent.cert.CertificateResolver in project nhin-d by DirectProject.
the class DefaultNHINDAgent_bindAddressesOutgoingMessageTest method testBindAddresses_noPrivateCerts_assertNoBoundPrivateCerts.
public void testBindAddresses_noPrivateCerts_assertNoBoundPrivateCerts() throws Exception {
final CertificateResolver publicCertResolver = mock(CertificateResolver.class);
when(publicCertResolver.getCertificates((InternetAddress) any())).thenReturn(new ArrayList<X509Certificate>());
final CertificateResolver privateCertResolver = mock(CertificateResolver.class);
when(privateCertResolver.getCertificates((InternetAddress) any())).thenReturn(new ArrayList<X509Certificate>());
final DefaultNHINDAgent agent = new DefaultNHINDAgent("Cerner.com", privateCertResolver, publicCertResolver, mock(TrustAnchorResolver.class));
final OutgoingMessage message = buildOutgoingMessage("MultipartMimeMessage.txt");
message.setAgent(agent);
agent.bindAddresses(message);
assertEquals(0, message.getSender().getCertificates().size());
}
use of org.nhindirect.stagent.cert.CertificateResolver in project nhin-d by DirectProject.
the class DefaultNHINDAgent_bindAddressesOutgoingMessageTest method testBindAddresses_singlePublicCerts_notFiltered_assertSingleBoundPublicCerts.
public void testBindAddresses_singlePublicCerts_notFiltered_assertSingleBoundPublicCerts() throws Exception {
final X509Certificate cert = mock(X509Certificate.class);
final CertificateResolver publicCertResolver = mock(CertificateResolver.class);
when(publicCertResolver.getCertificates((InternetAddress) any())).thenReturn(Arrays.asList(cert));
final CertificateResolver privateCertResolver = mock(CertificateResolver.class);
when(privateCertResolver.getCertificates((InternetAddress) any())).thenReturn(new ArrayList<X509Certificate>());
final DefaultNHINDAgent agent = new DefaultNHINDAgent("Cerner.com", privateCertResolver, publicCertResolver, mock(TrustAnchorResolver.class));
final OutgoingMessage message = buildOutgoingMessage("MultipartMimeMessage.txt");
message.setAgent(agent);
agent.bindAddresses(message);
for (NHINDAddress recipient : message.getRecipients()) assertEquals(1, recipient.getCertificates().size());
}
use of org.nhindirect.stagent.cert.CertificateResolver in project nhin-d by DirectProject.
the class DefaultNHINDAgent_bindAddressesOutgoingMessageTest method testBindAddresses_noPublicCerts_assertNoBoundPublicCerts.
public void testBindAddresses_noPublicCerts_assertNoBoundPublicCerts() throws Exception {
final CertificateResolver publicCertResolver = mock(CertificateResolver.class);
when(publicCertResolver.getCertificates((InternetAddress) any())).thenReturn(new ArrayList<X509Certificate>());
final CertificateResolver privateCertResolver = mock(CertificateResolver.class);
when(privateCertResolver.getCertificates((InternetAddress) any())).thenReturn(new ArrayList<X509Certificate>());
final DefaultNHINDAgent agent = new DefaultNHINDAgent("Cerner.com", privateCertResolver, publicCertResolver, mock(TrustAnchorResolver.class));
final OutgoingMessage message = buildOutgoingMessage("MultipartMimeMessage.txt");
message.setAgent(agent);
agent.bindAddresses(message);
for (NHINDAddress recipient : message.getRecipients()) assertEquals(0, recipient.getCertificates().size());
}
use of org.nhindirect.stagent.cert.CertificateResolver in project nhin-d by DirectProject.
the class NHINDAgentTest method testIncomingMDN_incomingNotTrusted_outgoingTrusted_assertMDNMessageTrusted.
public void testIncomingMDN_incomingNotTrusted_outgoingTrusted_assertMDNMessageTrusted() throws Exception {
OptionsManager.getInstance().setOptionsParameter(new OptionsParameter(OptionsParameter.USE_OUTGOING_POLICY_FOR_INCOMING_NOTIFICATIONS, "true"));
// 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 = agent.processIncoming(SMIMEenvMessage.getMessage());
assertNotNull(incomingMessage);
}
use of org.nhindirect.stagent.cert.CertificateResolver in project nhin-d by DirectProject.
the class NHINDAgentTest method testIncomingDSN_incomingNotTrusted_outgoingTrusted_assertMDNMessageTrusted.
public void testIncomingDSN_incomingNotTrusted_outgoingTrusted_assertMDNMessageTrusted() throws Exception {
OptionsManager.getInstance().setOptionsParameter(new OptionsParameter(OptionsParameter.USE_OUTGOING_POLICY_FOR_INCOMING_NOTIFICATIONS, "true"));
// 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 = agent.processIncoming(SMIMEenvMessage.getMessage());
assertNotNull(incomingMessage);
}
Aggregations