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