use of org.nhindirect.stagent.cert.CertificateResolver in project nhin-d by DirectProject.
the class DefaultNHINDAgent_bindAddressesOutgoingMessageTest method testBindAddresses_singlePrivateCerts_policyFiltered_assertNoBoundPrivateCerts.
public void testBindAddresses_singlePrivateCerts_policyFiltered_assertNoBoundPrivateCerts() throws Exception {
final X509Certificate cert = mock(X509Certificate.class);
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(Arrays.asList(cert));
final DefaultNHINDAgent agent = new DefaultNHINDAgent("Cerner.com", privateCertResolver, publicCertResolver, mock(TrustAnchorResolver.class)) {
@Override
protected Collection<X509Certificate> filterCertificatesByPolicy(InternetAddress sender, PolicyResolver resolver, Collection<X509Certificate> certsToFilter, boolean incoming) {
return Collections.emptyList();
}
};
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_bindAddressesIncomingMessageTest method testBindAddresses_singlePrivateCerts_plicyFiltered_assertNoBoundPrivateCerts.
public void testBindAddresses_singlePrivateCerts_plicyFiltered_assertNoBoundPrivateCerts() throws Exception {
final X509Certificate cert = mock(X509Certificate.class);
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(Arrays.asList(cert));
final DefaultNHINDAgent agent = new DefaultNHINDAgent("starugh-stateline.com", privateCertResolver, publicCertResolver, mock(TrustAnchorResolver.class)) {
@Override
protected Collection<X509Certificate> filterCertificatesByPolicy(InternetAddress sender, PolicyResolver resolver, Collection<X509Certificate> certsToFilter, boolean incoming) {
return Collections.emptyList();
}
};
final IncomingMessage message = buildIncomingMessage("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 DefaultNHINDAgent_bindAddressesIncomingMessageTest method testBindAddresses_noPrivateCerts_assertNoBoundPrivateCerts.
// PUBLIC CERTS ARE NO LONGER RESOLVED FOR INCOMING MESSAGES
// THEY ARE ALWAYS EXTRACTED FROM THE CERTIFICATE, SO PULBIC RESOLUTION IS REDUNDANT
/*
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("starugh-stateline.com", privateCertResolver,
publicCertResolver, mock(TrustAnchorResolver.class));
final IncomingMessage message = buildIncomingMessage("MultipartMimeMessage.txt");
message.setAgent(agent);
agent.bindAddresses(message);
assertEquals(0, message.getSender().getCertificates().size());
}
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("starugh-stateline.com", privateCertResolver,
publicCertResolver, mock(TrustAnchorResolver.class));
final IncomingMessage message = buildIncomingMessage("MultipartMimeMessage.txt");
message.setAgent(agent);
agent.bindAddresses(message);
assertEquals(1, message.getSender().getCertificates().size());
}
public void testBindAddresses_singlePublicCerts_policyFiltered_assertNoBoundPublicCerts() 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("starugh-stateline.com", privateCertResolver,
publicCertResolver, mock(TrustAnchorResolver.class))
{
@Override
protected Collection<X509Certificate> filterCertificatesByPolicy(InternetAddress sender, PolicyResolver resolver,
Collection<X509Certificate> certsToFilter, boolean incoming)
{
return Collections.emptyList();
}
};
final IncomingMessage message = buildIncomingMessage("MultipartMimeMessage.txt");
message.setAgent(agent);
agent.bindAddresses(message);
assertEquals(0, message.getSender().getCertificates().size());
}
*/
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("starugh-stateline.com", privateCertResolver, publicCertResolver, mock(TrustAnchorResolver.class));
final IncomingMessage message = buildIncomingMessage("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 DefaultNHINDAgent_bindAddressesIncomingMessageTest method testBindAddresses_singlePrivateCerts_notFiltered_assertBoundPrivateCerts.
public void testBindAddresses_singlePrivateCerts_notFiltered_assertBoundPrivateCerts() throws Exception {
final X509Certificate cert = mock(X509Certificate.class);
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(Arrays.asList(cert));
final DefaultNHINDAgent agent = new DefaultNHINDAgent("starugh-stateline.com", privateCertResolver, publicCertResolver, mock(TrustAnchorResolver.class));
final IncomingMessage message = buildIncomingMessage("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_singlePrivateCerts_notFiltered_assertBoundPrivateCerts.
public void testBindAddresses_singlePrivateCerts_notFiltered_assertBoundPrivateCerts() throws Exception {
final X509Certificate cert = mock(X509Certificate.class);
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(Arrays.asList(cert));
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(1, message.getSender().getCertificates().size());
}
Aggregations