Search in sources :

Example 1 with DomainPostmaster

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

the class WSSmtpAgentConfig method buildDomains.

protected void buildDomains() {
    domains = new ArrayList<String>();
    domainPostmasters = new HashMap<String, DomainPostmaster>();
    // get the domain list first
    try {
        int domainCount = cfService.getDomainCount();
        lookedupWSDomains = cfService.listDomains(null, domainCount);
    } catch (Exception e) {
        throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting domains list: " + e.getMessage(), e);
    }
    if (lookedupWSDomains != null) {
        for (Domain dom : lookedupWSDomains) {
            domains.add(dom.getDomainName());
            try {
                String configuredAddress = dom.getPostMasterEmail();
                configuredAddress = (configuredAddress == null || configuredAddress.trim().isEmpty()) ? DomainPostmaster.getDefaultPostmaster(dom.getDomainName()) : configuredAddress;
                domainPostmasters.put(dom.getDomainName().toUpperCase(Locale.getDefault()), new DomainPostmaster(dom.getDomainName(), new InternetAddress(configuredAddress)));
            } catch (AddressException e) {
            }
        }
    }
    if (domains.size() == 0)
        throw new SmtpAgentException(SmtpAgentError.MissingDomains);
    // now get the trust anchors
    buildTrustAnchorResolver();
}
Also used : SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) InternetAddress(javax.mail.internet.InternetAddress) AddressException(javax.mail.internet.AddressException) DomainPostmaster(org.nhindirect.gateway.smtp.DomainPostmaster) Domain(org.nhind.config.Domain) 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 2 with DomainPostmaster

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

the class XMLSmtpAgentConfig method buildDomains.

/*
	 * Builds the list of domains managed by the agent.
	 */
private void buildDomains(Node domainsNode) {
    domains = new ArrayList<String>();
    domainPostmasters = new HashMap<String, DomainPostmaster>();
    // get all domains
    Node domainNode = domainsNode.getFirstChild();
    Node anchorStoreNode = null;
    Map<String, Collection<String>> incomingAnchorHolder = new HashMap<String, Collection<String>>();
    Map<String, Collection<String>> outgoingAnchorHolder = new HashMap<String, Collection<String>>();
    do {
        // get an individual domain
        String domain = "";
        String postmasterAddr = "";
        if (domainNode.getNodeType() == Node.ELEMENT_NODE) {
            if (domainNode.getNodeName().equalsIgnoreCase("domain")) {
                Element domainEl = (Element) domainNode;
                domain = domainEl.getAttribute("name");
                if (domain == null || domain.trim().length() == 0)
                    throw new SmtpAgentException(SmtpAgentError.MissingDomainName);
                postmasterAddr = domainEl.getAttribute("postmaster");
                if (postmasterAddr == null || postmasterAddr.trim().length() == 0)
                    postmasterAddr = DomainPostmaster.getDefaultPostmaster(domain);
                domains.add(domain);
                try {
                    domainPostmasters.put(domain.toUpperCase(Locale.getDefault()), new DomainPostmaster(domain, new InternetAddress(postmasterAddr)));
                } catch (AddressException e) {
                }
                // get the trust anchors configured for this domain
                Node anchorsNode = domainNode.getFirstChild();
                do {
                    if (anchorsNode.getNodeType() == Node.ELEMENT_NODE) {
                        /*
							 * Incoming trust anchors
							 */
                        if (anchorsNode.getNodeName().equalsIgnoreCase("incomingtrustanchors"))
                            incomingAnchorHolder.put(domain, getConfiguredTrustAnchorNames(anchorsNode));
                        else /*
							 * Outgoing trust anchors
							 */
                        if (anchorsNode.getNodeName().equalsIgnoreCase("outgoingtrustanchors"))
                            outgoingAnchorHolder.put(domain, getConfiguredTrustAnchorNames(anchorsNode));
                    }
                    anchorsNode = anchorsNode.getNextSibling();
                } while (anchorsNode != null);
            } else if (domainNode.getNodeName().equalsIgnoreCase("anchorstore")) {
                // save off for later configuration
                anchorStoreNode = domainNode;
            }
        }
        domainNode = domainNode.getNextSibling();
    } while (domainNode != null);
    if (domains.size() == 0)
        throw new SmtpAgentException(SmtpAgentError.MissingDomains);
    buildTrustAnchorResolver((Element) anchorStoreNode, incomingAnchorHolder, outgoingAnchorHolder);
}
Also used : SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) InternetAddress(javax.mail.internet.InternetAddress) HashMap(java.util.HashMap) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) AddressException(javax.mail.internet.AddressException) DomainPostmaster(org.nhindirect.gateway.smtp.DomainPostmaster) Collection(java.util.Collection)

Example 3 with DomainPostmaster

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

the class RESTSmtpAgentConfig method buildDomains.

@Override
protected void buildDomains() {
    domains = new ArrayList<String>();
    domainPostmasters = new HashMap<String, DomainPostmaster>();
    // get the domain list first
    try {
        lookedupRESTServiceDomains = domainService.searchDomains("", null);
    } catch (Exception e) {
        throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting domains list: " + e.getMessage(), e);
    }
    if (lookedupRESTServiceDomains != null) {
        for (Domain dom : lookedupRESTServiceDomains) {
            domains.add(dom.getDomainName());
            try {
                String configuredAddress = (dom.getPostmasterAddress() == null) ? "" : dom.getPostmasterAddress().getEmailAddress();
                configuredAddress = (configuredAddress == null || configuredAddress.trim().isEmpty()) ? DomainPostmaster.getDefaultPostmaster(dom.getDomainName()) : configuredAddress;
                domainPostmasters.put(dom.getDomainName().toUpperCase(Locale.getDefault()), new DomainPostmaster(dom.getDomainName(), new InternetAddress(configuredAddress)));
            } catch (AddressException e) {
            }
        }
    }
    if (domains.size() == 0)
        throw new SmtpAgentException(SmtpAgentError.MissingDomains);
    // now get the trust anchors
    buildTrustAnchorResolver();
}
Also used : SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) InternetAddress(javax.mail.internet.InternetAddress) AddressException(javax.mail.internet.AddressException) DomainPostmaster(org.nhindirect.gateway.smtp.DomainPostmaster) Domain(org.nhindirect.config.model.Domain) AddressException(javax.mail.internet.AddressException) SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) PolicyParseException(org.nhindirect.policy.PolicyParseException)

Aggregations

AddressException (javax.mail.internet.AddressException)3 InternetAddress (javax.mail.internet.InternetAddress)3 DomainPostmaster (org.nhindirect.gateway.smtp.DomainPostmaster)3 SmtpAgentException (org.nhindirect.gateway.smtp.SmtpAgentException)3 PolicyParseException (org.nhindirect.policy.PolicyParseException)2 IOException (java.io.IOException)1 CertificateException (java.security.cert.CertificateException)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Domain (org.nhind.config.Domain)1 Domain (org.nhindirect.config.model.Domain)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1