Search in sources :

Example 1 with XMLSmtpAgentConfigProvider

use of org.nhindirect.gateway.smtp.provider.XMLSmtpAgentConfigProvider in project nhin-d by DirectProject.

the class NHINDSecurityAndTrustMailet method createCompatConfigProvider.

protected Provider<SmtpAgentConfig> createCompatConfigProvider(URL configURL) {
    Provider<SmtpAgentConfig> provider;
    if (configURL.getProtocol().equalsIgnoreCase("HTTP") || configURL.getProtocol().equalsIgnoreCase("HTTPS")) {
        // web services based
        provider = new WSSmtpAgentConfigProvider(configURL, null);
    } else {
        // use the default XML configuration
        // convert URL to file location
        File fl = FileUtils.toFile(configURL);
        provider = new XMLSmtpAgentConfigProvider(fl.getAbsolutePath(), null);
    }
    return provider;
}
Also used : WSSmtpAgentConfigProvider(org.nhindirect.gateway.smtp.provider.WSSmtpAgentConfigProvider) XMLSmtpAgentConfigProvider(org.nhindirect.gateway.smtp.provider.XMLSmtpAgentConfigProvider) File(java.io.File) SmtpAgentConfig(org.nhindirect.gateway.smtp.config.SmtpAgentConfig)

Example 2 with XMLSmtpAgentConfigProvider

use of org.nhindirect.gateway.smtp.provider.XMLSmtpAgentConfigProvider in project nhin-d by DirectProject.

the class SmtpAgentFactory_CreateAgent_Test method testCreateDefaultAgent_XMLConfigurationProvider_AuditorModule.

public void testCreateDefaultAgent_XMLConfigurationProvider_AuditorModule() throws Exception {
    Provider<SmtpAgentConfig> configProvider = new XMLSmtpAgentConfigProvider(TestUtils.getTestConfigFile("ValidConfig.xml"), new MockNHINDAgentProvider(Arrays.asList("mydomain")));
    SmtpAgent agent = SmtpAgentFactory.createAgent(null, configProvider, new MockNHINDAgentProvider(Arrays.asList("mydomain")), Arrays.asList(FileAuditorModule.create("target/AuditFile.txt")));
    assertNotNull(agent);
    assertNotNull(agent.getAgent());
    assertTrue(agent.getAgent() instanceof MockNHINDAgent);
    DefaultSmtpAgent smtpAgent = (DefaultSmtpAgent) agent;
    assertNotNull(smtpAgent.getAuditor());
    assertTrue(smtpAgent.getAuditor() instanceof FileAuditor);
}
Also used : MockNHINDAgent(org.nhindirect.stagent.MockNHINDAgent) XMLSmtpAgentConfigProvider(org.nhindirect.gateway.smtp.provider.XMLSmtpAgentConfigProvider) MockNHINDAgentProvider(org.nhindirect.stagent.provider.MockNHINDAgentProvider) SmtpAgentConfig(org.nhindirect.gateway.smtp.config.SmtpAgentConfig) FileAuditor(org.nhindirect.common.audit.impl.FileAuditor)

Example 3 with XMLSmtpAgentConfigProvider

use of org.nhindirect.gateway.smtp.provider.XMLSmtpAgentConfigProvider in project nhin-d by DirectProject.

the class SmtpAgentFactory_CreateAgent_Test method testCreateDefaultAgent_XMLConfigurationProvider_MockAgent.

public void testCreateDefaultAgent_XMLConfigurationProvider_MockAgent() throws Exception {
    Provider<SmtpAgentConfig> configProvider = new XMLSmtpAgentConfigProvider(TestUtils.getTestConfigFile("ValidConfig.xml"), new MockNHINDAgentProvider(Arrays.asList("mydomain")));
    SmtpAgent agent = SmtpAgentFactory.createAgent(null, configProvider, new MockNHINDAgentProvider(Arrays.asList("mydomain")));
    assertNotNull(agent);
    assertNotNull(agent.getAgent());
    assertTrue(agent.getAgent() instanceof MockNHINDAgent);
}
Also used : MockNHINDAgent(org.nhindirect.stagent.MockNHINDAgent) XMLSmtpAgentConfigProvider(org.nhindirect.gateway.smtp.provider.XMLSmtpAgentConfigProvider) MockNHINDAgentProvider(org.nhindirect.stagent.provider.MockNHINDAgentProvider) SmtpAgentConfig(org.nhindirect.gateway.smtp.config.SmtpAgentConfig)

Example 4 with XMLSmtpAgentConfigProvider

use of org.nhindirect.gateway.smtp.provider.XMLSmtpAgentConfigProvider in project nhin-d by DirectProject.

the class SmtpAgentConfigModule method configure.

protected void configure() {
    Provider<SmtpAgentConfig> provider = smtpAgentConfigProvider;
    if (provider == null) {
        if (configLocation.getProtocol().equalsIgnoreCase("HTTP") || configLocation.getProtocol().equalsIgnoreCase("HTTPS")) {
            // web services based
            provider = new WSSmtpAgentConfigProvider(configLocation, agentProvider);
        } else {
            // use the default XML configuration
            // convert URL to file location
            File fl = FileUtils.toFile(configLocation);
            provider = new XMLSmtpAgentConfigProvider(fl.getAbsolutePath(), agentProvider);
        }
    }
    bind(SmtpAgentConfig.class).toProvider(provider);
}
Also used : WSSmtpAgentConfigProvider(org.nhindirect.gateway.smtp.provider.WSSmtpAgentConfigProvider) XMLSmtpAgentConfigProvider(org.nhindirect.gateway.smtp.provider.XMLSmtpAgentConfigProvider) File(java.io.File) SmtpAgentConfig(org.nhindirect.gateway.smtp.config.SmtpAgentConfig)

Aggregations

SmtpAgentConfig (org.nhindirect.gateway.smtp.config.SmtpAgentConfig)4 XMLSmtpAgentConfigProvider (org.nhindirect.gateway.smtp.provider.XMLSmtpAgentConfigProvider)4 File (java.io.File)2 WSSmtpAgentConfigProvider (org.nhindirect.gateway.smtp.provider.WSSmtpAgentConfigProvider)2 MockNHINDAgent (org.nhindirect.stagent.MockNHINDAgent)2 MockNHINDAgentProvider (org.nhindirect.stagent.provider.MockNHINDAgentProvider)2 FileAuditor (org.nhindirect.common.audit.impl.FileAuditor)1