Search in sources :

Example 6 with Setting

use of org.nhind.config.Setting in project nhin-d by DirectProject.

the class XdConfig method getValue.

private String getValue(Settings xdSetting) throws Exception {
    Setting tmp;
    String value = null;
    if (proxy != null) {
        tmp = proxy.getSettingByName(xdSetting.getKey());
        if (tmp != null)
            value = tmp.getValue();
        else
            value = xdSetting.getDefault();
    }
    return value;
}
Also used : Setting(org.nhind.config.Setting)

Example 7 with Setting

use of org.nhind.config.Setting in project nhin-d by DirectProject.

the class WSDNSServerConfig method getServerSettings.

/*
	 * Just use the basic settings provider for now.  Will only allow setting the port and IP bindings.
	 */
private Provider<DNSServerSettings> getServerSettings() {
    String ipBindings = "";
    int port = 0;
    try {
        Setting[] settings = cfService.getSettingsByNames(new String[] { DNS_SERVER_BINDING, DNS_SERVER_PORT });
        if (settings != null && settings.length > 0) {
            for (Setting setting : settings) {
                if (setting.getName().equalsIgnoreCase(DNS_SERVER_BINDING)) {
                    ipBindings = setting.getValue();
                } else if (setting.getName().equalsIgnoreCase(DNS_SERVER_PORT)) {
                    String sPort = setting.getValue();
                    try {
                        port = Integer.parseInt(sPort);
                    } catch (Exception e) {
                        LOGGER.warn("Could not parse port setting " + port + " from configuration service");
                    }
                }
            }
        }
    } catch (Exception e) {
        LOGGER.warn("Could not get DNS setting from web service.");
    }
    if ((ipBindings == null || ipBindings.length() == 0) && port == 0 && settings != null) {
        LOGGER.info("Using DNS server settings from injected provider.");
        return settings;
    }
    LOGGER.info("Using DNS server settings from configuration service.");
    return new BasicDNSServerSettingsProvider(ipBindings, port);
}
Also used : BasicDNSServerSettingsProvider(org.nhindirect.dns.provider.BasicDNSServerSettingsProvider) Setting(org.nhind.config.Setting)

Example 8 with Setting

use of org.nhind.config.Setting in project nhin-d by DirectProject.

the class WSSmtpAgentConfig method buildMDNSettings.

protected void buildMDNSettings() {
    Setting autoResponseSettings;
    Setting prodNameSetting;
    Setting textSetting;
    try {
        autoResponseSettings = cfService.getSettingByName("MDNAutoResponse");
        prodNameSetting = cfService.getSettingByName("MDNProdName");
        textSetting = cfService.getSettingByName("MDNText");
    } 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.nhind.config.Setting) NotificationSettings(org.nhindirect.gateway.smtp.NotificationSettings) AddressException(javax.mail.internet.AddressException) SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) PolicyParseException(org.nhindirect.policy.PolicyParseException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException)

Example 9 with Setting

use of org.nhind.config.Setting in project nhin-d by DirectProject.

the class WSSmtpAgentConfig method buildPublicCertStore.

/*
	 * Build the certificate resolver for public certificates
	 */
@SuppressWarnings("unchecked")
protected void buildPublicCertStore() {
    Provider<CertificateResolver> resolverProvider = null;
    Collection<Provider<CertificateResolver>> resolverProviders = new ArrayList<Provider<CertificateResolver>>();
    Setting setting = null;
    String storeTypes;
    try {
        setting = cfService.getSettingByName("PublicStoreType");
    } 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 DNS
        storeTypes = STORE_TYPE_DNS + "," + STORE_TYPE_PUBLIC_LDAP;
    else
        storeTypes = setting.getValue();
    /*
		 * KeyStore based resolver
		 */
    String[] types = storeTypes.split(",");
    for (String storeType : types) {
        if (storeType.equalsIgnoreCase(STORE_TYPE_KEYSTORE)) {
            Setting file;
            Setting pass;
            Setting privKeyPass;
            try {
                file = cfService.getSettingByName("PublicStoreFile");
                pass = cfService.getSettingByName("PublicStoreFilePass");
                privKeyPass = cfService.getSettingByName("PublicStorePrivKeyPass");
            } catch (Exception e) {
                throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting public store file settings: " + e.getMessage(), e);
            }
            resolverProvider = new KeyStoreCertificateStoreProvider((file == null) ? "PublicStoreKeyFile" : file.getValue(), (pass == null) ? "DefaultFilePass" : pass.getValue(), (privKeyPass == null) ? "DefaultKeyPass" : privKeyPass.getValue());
        } else /*
			 * DNS resolver
			 */
        if (storeType.equalsIgnoreCase(STORE_TYPE_DNS)) {
            resolverProvider = new DNSCertStoreProvider(Collections.EMPTY_LIST, null, new DNSCertificateStore.DefaultDNSCachePolicy());
        } else /*
			 * Web Services
			 */
        if (storeType.equalsIgnoreCase(STORE_TYPE_WS)) {
            resolverProvider = new ConfigServiceCertificateStoreProvider(cfService, null, new ConfigServiceCertificateStore.DefaultConfigStoreCachePolicy(), this.storeProvider);
        } else /*
			 * Public LDAP resolver
			 */
        if (storeType.equalsIgnoreCase(STORE_TYPE_PUBLIC_LDAP)) {
            resolverProvider = new PublicLdapCertificateStoreProvider(null, new LDAPCertificateStore.DefaultLDAPCachePolicy());
        } else /*
			 * Default to DNS with a default cache policy
			 */
        {
            resolverProvider = new DNSCertStoreProvider(Collections.EMPTY_LIST, null, new DNSCertificateStore.DefaultDNSCachePolicy());
        }
        resolverProviders.add(resolverProvider);
    }
    publicCertModule = new PublicCertStoreModule(resolverProviders);
}
Also used : SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) ConfigServiceCertificateStoreProvider(org.nhindirect.gateway.smtp.config.cert.impl.provider.ConfigServiceCertificateStoreProvider) KeyStoreCertificateStoreProvider(org.nhindirect.stagent.cert.impl.provider.KeyStoreCertificateStoreProvider) Setting(org.nhind.config.Setting) PublicCertStoreModule(org.nhindirect.stagent.module.PublicCertStoreModule) ArrayList(java.util.ArrayList) PublicLdapCertificateStoreProvider(org.nhindirect.stagent.cert.impl.provider.PublicLdapCertificateStoreProvider) AddressException(javax.mail.internet.AddressException) SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) PolicyParseException(org.nhindirect.policy.PolicyParseException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) DefaultSmtpAgentProvider(org.nhindirect.gateway.smtp.provider.DefaultSmtpAgentProvider) KeyStoreCertificateStoreProvider(org.nhindirect.stagent.cert.impl.provider.KeyStoreCertificateStoreProvider) ConfigServiceCertificateStoreProvider(org.nhindirect.gateway.smtp.config.cert.impl.provider.ConfigServiceCertificateStoreProvider) MultiDomainTrustAnchorResolverProvider(org.nhindirect.stagent.trust.provider.MultiDomainTrustAnchorResolverProvider) UniformTrustAnchorResolverProvider(org.nhindirect.stagent.trust.provider.UniformTrustAnchorResolverProvider) DNSCertStoreProvider(org.nhindirect.stagent.cert.impl.provider.DNSCertStoreProvider) PublicLdapCertificateStoreProvider(org.nhindirect.stagent.cert.impl.provider.PublicLdapCertificateStoreProvider) DomainPolicyResolverProvider(org.nhindirect.stagent.policy.impl.provider.DomainPolicyResolverProvider) LdapCertificateStoreProvider(org.nhindirect.stagent.cert.impl.provider.LdapCertificateStoreProvider) Provider(com.google.inject.Provider) DNSCertificateStore(org.nhindirect.stagent.cert.impl.DNSCertificateStore) LDAPCertificateStore(org.nhindirect.stagent.cert.impl.LDAPCertificateStore) DNSCertStoreProvider(org.nhindirect.stagent.cert.impl.provider.DNSCertStoreProvider) CertificateResolver(org.nhindirect.stagent.cert.CertificateResolver)

Example 10 with Setting

use of org.nhind.config.Setting in project nhin-d by DirectProject.

the class WSSmtpAgentConfig method buildMessageSettings.

protected void buildMessageSettings(String type) {
    Setting folderSettings;
    try {
        folderSettings = cfService.getSettingByName(type + "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.nhind.config.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) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException)

Aggregations

Setting (org.nhind.config.Setting)10 IOException (java.io.IOException)7 CertificateException (java.security.cert.CertificateException)7 AddressException (javax.mail.internet.AddressException)7 SmtpAgentException (org.nhindirect.gateway.smtp.SmtpAgentException)7 PolicyParseException (org.nhindirect.policy.PolicyParseException)7 ArrayList (java.util.ArrayList)3 LDAPCertificateStore (org.nhindirect.stagent.cert.impl.LDAPCertificateStore)3 X509Certificate (java.security.cert.X509Certificate)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 Anchor (org.nhind.config.Anchor)2 Domain (org.nhind.config.Domain)2 ConfigServiceCertificateStoreProvider (org.nhindirect.gateway.smtp.config.cert.impl.provider.ConfigServiceCertificateStoreProvider)2 CertificateResolver (org.nhindirect.stagent.cert.CertificateResolver)2 KeyStoreCertificateStoreProvider (org.nhindirect.stagent.cert.impl.provider.KeyStoreCertificateStoreProvider)2 LdapCertificateStoreProvider (org.nhindirect.stagent.cert.impl.provider.LdapCertificateStoreProvider)2 PublicLdapCertificateStoreProvider (org.nhindirect.stagent.cert.impl.provider.PublicLdapCertificateStoreProvider)2 MultiDomainTrustAnchorResolverProvider (org.nhindirect.stagent.trust.provider.MultiDomainTrustAnchorResolverProvider)2 UniformTrustAnchorResolverProvider (org.nhindirect.stagent.trust.provider.UniformTrustAnchorResolverProvider)2