Search in sources :

Example 1 with DefaultTrustAnchorResolver

use of org.nhindirect.stagent.trust.DefaultTrustAnchorResolver 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);
}
Also used : OptionsParameter(org.nhindirect.stagent.options.OptionsParameter) CertificateResolver(org.nhindirect.stagent.cert.CertificateResolver) DefaultNHINDAgent(org.nhindirect.stagent.DefaultNHINDAgent) DefaultTrustAnchorResolver(org.nhindirect.stagent.trust.DefaultTrustAnchorResolver)

Example 2 with DefaultTrustAnchorResolver

use of org.nhindirect.stagent.trust.DefaultTrustAnchorResolver 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);
}
Also used : OptionsParameter(org.nhindirect.stagent.options.OptionsParameter) CertificateResolver(org.nhindirect.stagent.cert.CertificateResolver) DefaultNHINDAgent(org.nhindirect.stagent.DefaultNHINDAgent) DefaultTrustAnchorResolver(org.nhindirect.stagent.trust.DefaultTrustAnchorResolver)

Example 3 with DefaultTrustAnchorResolver

use of org.nhindirect.stagent.trust.DefaultTrustAnchorResolver 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);
}
Also used : OptionsParameter(org.nhindirect.stagent.options.OptionsParameter) CertificateResolver(org.nhindirect.stagent.cert.CertificateResolver) DefaultNHINDAgent(org.nhindirect.stagent.DefaultNHINDAgent) DefaultTrustAnchorResolver(org.nhindirect.stagent.trust.DefaultTrustAnchorResolver)

Example 4 with DefaultTrustAnchorResolver

use of org.nhindirect.stagent.trust.DefaultTrustAnchorResolver 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);
}
Also used : OptionsParameter(org.nhindirect.stagent.options.OptionsParameter) CertificateResolver(org.nhindirect.stagent.cert.CertificateResolver) DefaultNHINDAgent(org.nhindirect.stagent.DefaultNHINDAgent) DefaultTrustAnchorResolver(org.nhindirect.stagent.trust.DefaultTrustAnchorResolver)

Example 5 with DefaultTrustAnchorResolver

use of org.nhindirect.stagent.trust.DefaultTrustAnchorResolver in project nhin-d by DirectProject.

the class NHINDAgentTest method testIncomingNormalMessage_incomingNotTrusted_outgoingTrusted_assertMessageNotTrusted.

public void testIncomingNormalMessage_incomingNotTrusted_outgoingTrusted_assertMessageNotTrusted() throws Exception {
    // first create the encyrpted message
    DefaultNHINDAgent agent = TestUtils.getStockAgent(Arrays.asList(new String[] { "cerner.com" }));
    String testMessage = TestUtils.readResource("MultipartMimeMessage.txt");
    final OutgoingMessage SMIMEenvMessage = agent.processOutgoing(testMessage);
    ;
    assertNotNull(SMIMEenvMessage);
    // now send received the MDN
    agent = TestUtils.getStockAgent(Arrays.asList(new String[] { "starugh-stateline.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);
}
Also used : CertificateResolver(org.nhindirect.stagent.cert.CertificateResolver) DefaultNHINDAgent(org.nhindirect.stagent.DefaultNHINDAgent) DefaultTrustAnchorResolver(org.nhindirect.stagent.trust.DefaultTrustAnchorResolver)

Aggregations

DefaultNHINDAgent (org.nhindirect.stagent.DefaultNHINDAgent)5 CertificateResolver (org.nhindirect.stagent.cert.CertificateResolver)5 DefaultTrustAnchorResolver (org.nhindirect.stagent.trust.DefaultTrustAnchorResolver)5 OptionsParameter (org.nhindirect.stagent.options.OptionsParameter)4