Search in sources :

Example 11 with OptionsParameter

use of org.nhindirect.stagent.options.OptionsParameter 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 12 with OptionsParameter

use of org.nhindirect.stagent.options.OptionsParameter 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 13 with OptionsParameter

use of org.nhindirect.stagent.options.OptionsParameter 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 14 with OptionsParameter

use of org.nhindirect.stagent.options.OptionsParameter in project nhin-d by DirectProject.

the class CRLRevocationManager_initCRLCacheLocationTest method testInitCRLCacheLocation_customOptionParameter.

public void testInitCRLCacheLocation_customOptionParameter() {
    String crlLocation = UUID.randomUUID().toString();
    OptionsManager.getInstance().setOptionsParameter(new OptionsParameter(OptionsParameter.CRL_CACHE_LOCATION, "target/" + crlLocation));
    CRLRevocationManager.initCRLCacheLocation();
    assertTrue(CRLRevocationManager.crlCacheLocation.getAbsolutePath().endsWith(crlLocation));
}
Also used : OptionsParameter(org.nhindirect.stagent.options.OptionsParameter)

Example 15 with OptionsParameter

use of org.nhindirect.stagent.options.OptionsParameter in project nhin-d by DirectProject.

the class CRLRevocationManager_initCRLCacheLocationTest method testInitCRLCacheLocation_invalidLocationName.

public void testInitCRLCacheLocation_invalidLocationName() throws Exception {
    OptionsManager.getInstance().setOptionsParameter(new OptionsParameter(OptionsParameter.CRL_CACHE_LOCATION, "target/" + new String(invalidFileName)));
    CRLRevocationManager.initCRLCacheLocation();
    assertNull(CRLRevocationManager.crlCacheLocation);
}
Also used : OptionsParameter(org.nhindirect.stagent.options.OptionsParameter)

Aggregations

OptionsParameter (org.nhindirect.stagent.options.OptionsParameter)30 DefaultNHINDAgent (org.nhindirect.stagent.DefaultNHINDAgent)5 CertificateResolver (org.nhindirect.stagent.cert.CertificateResolver)4 DefaultTrustAnchorResolver (org.nhindirect.stagent.trust.DefaultTrustAnchorResolver)4 File (java.io.File)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Provider (java.security.Provider)2 BouncyCastleProvider (org.bouncycastle.jce.provider.BouncyCastleProvider)2 Module (com.google.inject.Module)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 CertificateException (java.security.cert.CertificateException)1 CertificateParsingException (java.security.cert.CertificateParsingException)1 MessagingException (javax.mail.MessagingException)1 MimeMessage (javax.mail.internet.MimeMessage)1 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)1 KeyStoreProtectionManager (org.nhindirect.common.crypto.KeyStoreProtectionManager)1 ServiceSecurityManager (org.nhindirect.common.rest.ServiceSecurityManager)1 ServiceException (org.nhindirect.common.rest.exceptions.ServiceException)1