Search in sources :

Example 1 with SmtpAgentException

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

the class RESTSmtpAgentConfig method buildMDNSettings.

protected void buildMDNSettings() {
    Setting autoResponseSettings;
    Setting prodNameSetting;
    Setting textSetting;
    try {
        autoResponseSettings = settingsService.getSetting("MDNAutoResponse");
        prodNameSetting = settingsService.getSetting("MDNProdName");
        textSetting = settingsService.getSetting("MDNProdName");
    } catch (Exception e) {
        throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting MDN settings: " + e.getMessage(), e);
    }
    boolean autoResponse = (autoResponseSettings == null) ? true : Boolean.parseBoolean(autoResponseSettings.getValue());
    String prodName = (prodNameSetting == null) ? "" : prodNameSetting.getValue();
    String text = (textSetting == null) ? "" : textSetting.getValue();
    notificationProducer = new NotificationProducer(new NotificationSettings(autoResponse, prodName, text));
}
Also used : SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) NotificationProducer(org.nhindirect.gateway.smtp.NotificationProducer) Setting(org.nhindirect.config.model.Setting) NotificationSettings(org.nhindirect.gateway.smtp.NotificationSettings) AddressException(javax.mail.internet.AddressException) SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) PolicyParseException(org.nhindirect.policy.PolicyParseException)

Example 2 with SmtpAgentException

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

the class RESTSmtpAgentConfig method buildMessageSettings.

protected void buildMessageSettings(String type) {
    Setting folderSettings;
    try {
        folderSettings = settingsService.getSetting("MessageSaveFolder");
    } catch (Exception e) {
        throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting " + type + " message settings: " + e.getMessage(), e);
    }
    String saveFolder = (folderSettings == null) ? null : folderSettings.getValue();
    MessageProcessingSettings settings = null;
    if (type.equalsIgnoreCase(MESSAGE_SETTING_RAW))
        settings = rawSettings = new RawMessageSettings();
    else if (type.equalsIgnoreCase(MESSAGE_SETTING_INCOMING))
        settings = incomingSettings = new ProcessIncomingSettings();
    else if (type.equalsIgnoreCase(MESSAGE_SETTING_OUTGOING))
        settings = outgoingSettings = new ProcessOutgoingSettings();
    else if (type.equalsIgnoreCase(MESSAGE_SETTING_BAD))
        settings = badSettings = new ProcessBadMessageSettings();
    if (saveFolder != null && settings != null)
        settings.setSaveMessageFolder(new File(saveFolder));
}
Also used : ProcessOutgoingSettings(org.nhindirect.gateway.smtp.ProcessOutgoingSettings) SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) ProcessBadMessageSettings(org.nhindirect.gateway.smtp.ProcessBadMessageSettings) Setting(org.nhindirect.config.model.Setting) MessageProcessingSettings(org.nhindirect.gateway.smtp.MessageProcessingSettings) ProcessIncomingSettings(org.nhindirect.gateway.smtp.ProcessIncomingSettings) RawMessageSettings(org.nhindirect.gateway.smtp.RawMessageSettings) File(java.io.File) AddressException(javax.mail.internet.AddressException) SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) PolicyParseException(org.nhindirect.policy.PolicyParseException)

Example 3 with SmtpAgentException

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

the class RESTSmtpAgentConfig method buildPrivateCertStore.

protected void buildPrivateCertStore() {
    Provider<CertificateResolver> resolverProvider = null;
    Setting setting = null;
    String storeType;
    try {
        setting = settingsService.getSetting("PrivateStoreType");
    } catch (Exception e) {
        throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting public store type: " + e.getMessage(), e);
    }
    if (setting == null || setting.getValue() == null || setting.getValue().isEmpty())
        // default to WS
        storeType = STORE_TYPE_WS;
    else
        storeType = setting.getValue();
    /*
		 * KeyStore based resolver
		 */
    if (storeType.equalsIgnoreCase(STORE_TYPE_KEYSTORE)) {
        Setting file;
        Setting pass;
        Setting privKeyPass;
        try {
            file = settingsService.getSetting("PrivateStoreFile");
            pass = settingsService.getSetting("PrivateStoreFilePass");
            privKeyPass = settingsService.getSetting("PrivateStorePrivKeyPass");
        } catch (Exception e) {
            throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting private store file settings: " + e.getMessage(), e);
        }
        resolverProvider = new KeyStoreCertificateStoreProvider((file == null) ? null : file.getValue(), (pass == null) ? null : pass.getValue(), (privKeyPass == null) ? null : privKeyPass.getValue());
    } else if (storeType.equalsIgnoreCase(STORE_TYPE_LDAP)) {
        resolverProvider = buildLdapCertificateStoreProvider("PrivateStore", "LDAPPrivateCertStore");
    } else if (storeType.equalsIgnoreCase(STORE_TYPE_WS)) {
        resolverProvider = new ConfigServiceRESTCertificateStoreProvider(certificateService, null, new ConfigServiceCertificateStore.DefaultConfigStoreCachePolicy(), this.storeProvider);
    } else {
        throw new SmtpAgentException(SmtpAgentError.InvalidPrivateCertStoreSettings);
    }
    privateCertModule = new PrivateCertStoreModule(resolverProvider);
}
Also used : PrivateCertStoreModule(org.nhindirect.stagent.module.PrivateCertStoreModule) SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) KeyStoreCertificateStoreProvider(org.nhindirect.stagent.cert.impl.provider.KeyStoreCertificateStoreProvider) Setting(org.nhindirect.config.model.Setting) ConfigServiceRESTCertificateStoreProvider(org.nhindirect.gateway.smtp.config.cert.impl.provider.ConfigServiceRESTCertificateStoreProvider) CertificateResolver(org.nhindirect.stagent.cert.CertificateResolver) AddressException(javax.mail.internet.AddressException) SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) PolicyParseException(org.nhindirect.policy.PolicyParseException)

Example 4 with SmtpAgentException

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

the class RESTSmtpAgentConfig method addPolicyToMap.

public void addPolicyToMap(Map<String, Collection<PolicyExpression>> policyMap, String domainName, CertPolicyGroupUse policyReltn) {
    // check to see if the domain is in the map
    Collection<PolicyExpression> policyExpressionCollection = policyMap.get(domainName);
    if (policyExpressionCollection == null) {
        policyExpressionCollection = new ArrayList<PolicyExpression>();
        policyMap.put(domainName, policyExpressionCollection);
    }
    final CertPolicy policy = policyReltn.getPolicy();
    final PolicyLexicon lexicon = policy.getLexicon();
    final InputStream inStr = new ByteArrayInputStream(policy.getPolicyData());
    try {
        // grab a parser and compile this policy
        final PolicyLexiconParser parser = PolicyLexiconParserFactory.getInstance(lexicon);
        policyExpressionCollection.add(parser.parse(inStr));
    } catch (PolicyParseException ex) {
        throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "Failed parse policy into policy expression: " + ex.getMessage(), ex);
    } finally {
        IOUtils.closeQuietly(inStr);
    }
}
Also used : PolicyLexicon(org.nhindirect.policy.PolicyLexicon) SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) CertPolicy(org.nhindirect.config.model.CertPolicy) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) PolicyLexiconParser(org.nhindirect.policy.PolicyLexiconParser) PolicyExpression(org.nhindirect.policy.PolicyExpression) PolicyParseException(org.nhindirect.policy.PolicyParseException)

Example 5 with SmtpAgentException

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

the class RecipAndSenderIsNotLocal method init.

/**
	 * {@inheritDoc}
	 */
@Override
public void init() {
    LOGGER.info("Initializing RecipAndSenderIsNotLocal matcher.");
    String localDomains = getCondition();
    if (localDomains == null || localDomains.isEmpty())
        throw new SmtpAgentException(SmtpAgentError.Uninitialized, "Matcher condition must contain at least 1 local domain.");
    String[] domainsParsed = localDomains.split(",");
    StringBuilder logMessage = new StringBuilder("Local matching domains:\r\n");
    for (String domain : domainsParsed) {
        logMessage.append("\t" + domain + "\r\n");
        this.domains.add(domain.toUpperCase(Locale.getDefault()));
    }
    LOGGER.info(logMessage);
}
Also used : SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException)

Aggregations

SmtpAgentException (org.nhindirect.gateway.smtp.SmtpAgentException)31 PolicyParseException (org.nhindirect.policy.PolicyParseException)20 AddressException (javax.mail.internet.AddressException)19 IOException (java.io.IOException)10 CertificateException (java.security.cert.CertificateException)10 Collection (java.util.Collection)8 ArrayList (java.util.ArrayList)7 Setting (org.nhind.config.Setting)7 Setting (org.nhindirect.config.model.Setting)7 LDAPCertificateStore (org.nhindirect.stagent.cert.impl.LDAPCertificateStore)7 X509Certificate (java.security.cert.X509Certificate)6 HashMap (java.util.HashMap)6 CertificateResolver (org.nhindirect.stagent.cert.CertificateResolver)5 KeyStoreCertificateStoreProvider (org.nhindirect.stagent.cert.impl.provider.KeyStoreCertificateStoreProvider)5 LdapCertificateStoreProvider (org.nhindirect.stagent.cert.impl.provider.LdapCertificateStoreProvider)5 MultiDomainTrustAnchorResolverProvider (org.nhindirect.stagent.trust.provider.MultiDomainTrustAnchorResolverProvider)5 UniformTrustAnchorResolverProvider (org.nhindirect.stagent.trust.provider.UniformTrustAnchorResolverProvider)5 DomainPolicyResolverProvider (org.nhindirect.stagent.policy.impl.provider.DomainPolicyResolverProvider)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InternetAddress (javax.mail.internet.InternetAddress)3