Merge pull request #75 from hapifhir/ks-20200113-mailtls

Preparing for email TLS support
This commit is contained in:
Sean McIlvenna
2020-01-14 11:01:47 -08:00
committed by GitHub
2 changed files with 156 additions and 140 deletions

View File

@@ -46,6 +46,11 @@ public class FhirServerConfigCommon {
private Integer emailPort = HapiProperties.getEmailPort();
private String emailUsername = HapiProperties.getEmailUsername();
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
private SubscriptionDeliveryHandlerFactory mySubscriptionDeliveryHandlerFactory;
@@ -180,6 +185,11 @@ public class FhirServerConfigCommon {
retVal.setSmtpServerPort(this.emailPort);
retVal.setSmtpServerUsername(this.emailUsername);
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");
mySubscriptionDeliveryHandlerFactory.setEmailSender(retVal);

View File

@@ -406,6 +406,12 @@ public class HapiProperties {
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() {
String value = HapiProperties.getProperty(REUSE_CACHED_SEARCH_RESULTS_MILLIS, "60000");
return Long.valueOf(value);