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();
}
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);
}
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();
}
Aggregations