Preparing for email TLS support

This commit is contained in:
Ken Stevens
2020-01-13 11:16:55 -05:00
parent d8d0f2aaa0
commit 3b8c075b09
2 changed files with 156 additions and 140 deletions

View File

@@ -46,6 +46,11 @@ public class FhirServerConfigCommon {
private Integer emailPort = HapiProperties.getEmailPort(); private Integer emailPort = HapiProperties.getEmailPort();
private String emailUsername = HapiProperties.getEmailUsername(); private String emailUsername = HapiProperties.getEmailUsername();
private String emailPassword = HapiProperties.getEmailPassword(); private String emailPassword = HapiProperties.getEmailPassword();
private Boolean emailAuth = HapiProperties.getEmailAuth();
private Boolean emailStartTlsEnable = HapiProperties.getEmailStartTlsEnable();
private Boolean emailStartTlsRequired = HapiProperties.getEmailStartTlsRequired();
private Boolean emailQuitWait = HapiProperties.getEmailQuitWait();
@Autowired @Autowired
private SubscriptionDeliveryHandlerFactory mySubscriptionDeliveryHandlerFactory; private SubscriptionDeliveryHandlerFactory mySubscriptionDeliveryHandlerFactory;
@@ -180,6 +185,11 @@ public class FhirServerConfigCommon {
retVal.setSmtpServerPort(this.emailPort); retVal.setSmtpServerPort(this.emailPort);
retVal.setSmtpServerUsername(this.emailUsername); retVal.setSmtpServerUsername(this.emailUsername);
retVal.setSmtpServerPassword(this.emailPassword); retVal.setSmtpServerPassword(this.emailPassword);
// TODO KHS add these when HAPI 4.2.0 is released
// retVal.setAuth(this.emailAuth);
// retVal.setStartTlsEnable(this.emailStartTlsEnable);
// retVal.setStartTlsRequired(this.emailStartTlsRequired);
// retVal.setQuitWait(this.emailQuitWait);
Validate.notNull(mySubscriptionDeliveryHandlerFactory, "No subscription delivery handler"); Validate.notNull(mySubscriptionDeliveryHandlerFactory, "No subscription delivery handler");
mySubscriptionDeliveryHandlerFactory.setEmailSender(retVal); mySubscriptionDeliveryHandlerFactory.setEmailSender(retVal);

View File

@@ -406,6 +406,12 @@ public class HapiProperties {
return HapiProperties.getProperty("email.password"); return HapiProperties.getProperty("email.password");
} }
// Defaults from https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html
public static Boolean getEmailAuth() { return HapiProperties.getBooleanProperty("email.auth", false); }
public static Boolean getEmailStartTlsEnable() { return HapiProperties.getBooleanProperty("email.starttls.enable", false); }
public static Boolean getEmailStartTlsRequired() { return HapiProperties.getBooleanProperty("email.starttls.required", false); }
public static Boolean getEmailQuitWait() { return HapiProperties.getBooleanProperty("email.quitwait", true); }
public static Long getReuseCachedSearchResultsMillis() { public static Long getReuseCachedSearchResultsMillis() {
String value = HapiProperties.getProperty(REUSE_CACHED_SEARCH_RESULTS_MILLIS, "60000"); String value = HapiProperties.getProperty(REUSE_CACHED_SEARCH_RESULTS_MILLIS, "60000");
return Long.valueOf(value); return Long.valueOf(value);