Continue structural port from Spring Boot to Undertow
This commit is contained in:
@@ -53,7 +53,7 @@ public class InvitationConfig {
|
||||
|
||||
}
|
||||
|
||||
private Resolution resolution;
|
||||
private Resolution resolution = new Resolution();
|
||||
|
||||
public Resolution getResolution() {
|
||||
return resolution;
|
||||
|
||||
@@ -21,7 +21,10 @@
|
||||
package io.kamax.mxisd.config.threepid;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import io.kamax.matrix.ThreePidMedium;
|
||||
import io.kamax.matrix.json.GsonUtil;
|
||||
import io.kamax.mxisd.config.threepid.medium.EmailConfig;
|
||||
import io.kamax.mxisd.config.threepid.medium.PhoneConfig;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -31,7 +34,8 @@ public class ThreePidConfig {
|
||||
private Map<String, JsonObject> medium = new HashMap<>();
|
||||
|
||||
public ThreePidConfig() {
|
||||
EmailConfig emailCfg = new EmailConfig();
|
||||
medium.put(ThreePidMedium.Email.getId(), GsonUtil.makeObj(new EmailConfig()));
|
||||
medium.put(ThreePidMedium.PhoneNumber.getId(), GsonUtil.makeObj(new PhoneConfig()));
|
||||
}
|
||||
|
||||
public Map<String, JsonObject> getMedium() {
|
||||
|
||||
@@ -24,13 +24,11 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
public class EmailSmtpConfig {
|
||||
|
||||
private transient final Logger log = LoggerFactory.getLogger(EmailSmtpConfig.class);
|
||||
|
||||
private String host;
|
||||
private String host = "";
|
||||
private int port = 587;
|
||||
private int tls = 1;
|
||||
private String login;
|
||||
@@ -76,14 +74,15 @@ public class EmailSmtpConfig {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void build() {
|
||||
public EmailSmtpConfig build() {
|
||||
log.info("--- E-mail SMTP Connector config ---");
|
||||
log.info("Host: {}", getHost());
|
||||
log.info("Port: {}", getPort());
|
||||
log.info("TLS Mode: {}", getTls());
|
||||
log.info("Login: {}", getLogin());
|
||||
log.info("Has password: {}", StringUtils.isNotBlank(getPassword()));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,16 +23,12 @@ package io.kamax.mxisd.config.threepid.connector;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
public class PhoneTwilioConfig {
|
||||
|
||||
static final String NAMESPACE = "threepid.medium.msisdn.connectors.twilio";
|
||||
|
||||
private transient final Logger log = LoggerFactory.getLogger(PhoneTwilioConfig.class);
|
||||
|
||||
private String accountSid;
|
||||
private String authToken;
|
||||
private String accountSid = "";
|
||||
private String authToken = "";
|
||||
private String number;
|
||||
|
||||
public String getAccountSid() {
|
||||
@@ -59,11 +55,12 @@ public class PhoneTwilioConfig {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void build() {
|
||||
public PhoneTwilioConfig build() {
|
||||
log.info("--- Phone SMS Twilio connector config ---");
|
||||
log.info("Account SID: {}", getAccountSid());
|
||||
log.info("Sender number: {}", getNumber());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,12 +20,8 @@
|
||||
|
||||
package io.kamax.mxisd.config.threepid.medium;
|
||||
|
||||
import io.kamax.mxisd.exception.ConfigurationException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import io.kamax.mxisd.threepid.connector.email.EmailSmtpConnector;
|
||||
import io.kamax.mxisd.threepid.generator.email.GenericEmailNotificationGenerator;
|
||||
|
||||
public class EmailConfig extends MediumConfig {
|
||||
|
||||
@@ -52,35 +48,15 @@ public class EmailConfig extends MediumConfig {
|
||||
|
||||
}
|
||||
|
||||
private transient final Logger log = LoggerFactory.getLogger(EmailConfig.class);
|
||||
|
||||
private Identity identity = new Identity();
|
||||
|
||||
public EmailConfig() {
|
||||
setConnector("smtp");
|
||||
setGenerator("template");
|
||||
setConnector(EmailSmtpConnector.ID);
|
||||
setGenerator(GenericEmailNotificationGenerator.ID);
|
||||
}
|
||||
|
||||
public Identity getIdentity() {
|
||||
return identity;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void build() {
|
||||
log.info("--- E-mail config ---");
|
||||
|
||||
if (StringUtils.isBlank(getGenerator())) {
|
||||
throw new ConfigurationException("generator");
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(getConnector())) {
|
||||
throw new ConfigurationException("connector");
|
||||
}
|
||||
|
||||
log.info("From: {}", getIdentity().getFrom());
|
||||
log.info("Name: {}", getIdentity().getName());
|
||||
log.info("Generator: {}", getGenerator());
|
||||
log.info("Connector: {}", getConnector());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ package io.kamax.mxisd.config.threepid.medium;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
public class EmailTemplateConfig extends GenericTemplateConfig {
|
||||
|
||||
private transient final Logger log = LoggerFactory.getLogger(EmailTemplateConfig.class);
|
||||
@@ -36,13 +34,14 @@ public class EmailTemplateConfig extends GenericTemplateConfig {
|
||||
getSession().getValidation().setRemote("classpath:threepids/email/validate-remote-template.eml");
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void build() {
|
||||
public EmailTemplateConfig build() {
|
||||
log.info("--- E-mail Generator templates config ---");
|
||||
log.info("Invite: {}", getName(getInvite()));
|
||||
log.info("Session validation:");
|
||||
log.info("\tLocal: {}", getName(getSession().getValidation().getLocal()));
|
||||
log.info("\tRemote: {}", getName(getSession().getValidation().getRemote()));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class GenericTemplateConfig {
|
||||
|
||||
}
|
||||
|
||||
private SessionValidation validation;
|
||||
private SessionValidation validation = new SessionValidation();
|
||||
|
||||
public SessionValidation getValidation() {
|
||||
return validation;
|
||||
|
||||
@@ -20,16 +20,14 @@
|
||||
|
||||
package io.kamax.mxisd.config.threepid.medium;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import io.kamax.mxisd.threepid.connector.phone.PhoneSmsTwilioConnector;
|
||||
import io.kamax.mxisd.threepid.generator.phone.SmsNotificationGenerator;
|
||||
|
||||
public class PhoneConfig extends MediumConfig {
|
||||
|
||||
private transient final Logger log = LoggerFactory.getLogger(PhoneConfig.class);
|
||||
|
||||
public PhoneConfig() {
|
||||
setConnector("twilio");
|
||||
setGenerator("template");
|
||||
setConnector(PhoneSmsTwilioConnector.ID);
|
||||
setGenerator(SmsNotificationGenerator.ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ package io.kamax.mxisd.config.threepid.medium;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
public class PhoneSmsTemplateConfig extends GenericTemplateConfig {
|
||||
|
||||
private transient final Logger log = LoggerFactory.getLogger(EmailTemplateConfig.class);
|
||||
@@ -36,13 +34,14 @@ public class PhoneSmsTemplateConfig extends GenericTemplateConfig {
|
||||
getSession().getValidation().setRemote("classpath:threepids/sms/validate-remote-template.txt");
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void build() {
|
||||
public PhoneSmsTemplateConfig build() {
|
||||
log.info("--- SMS Generator templates config ---");
|
||||
log.info("Invite: {}", getName(getInvite()));
|
||||
log.info("Session validation:");
|
||||
log.info("\tLocal: {}", getName(getSession().getValidation().getLocal()));
|
||||
log.info("\tRemote: {}", getName(getSession().getValidation().getRemote()));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
package io.kamax.mxisd.config.threepid.notification;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import io.kamax.matrix.ThreePidMedium;
|
||||
import io.kamax.mxisd.threepid.notification.email.EmailRawNotificationHandler;
|
||||
import io.kamax.mxisd.threepid.notification.phone.PhoneNotificationHandler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -35,6 +38,11 @@ public class NotificationConfig {
|
||||
private Map<String, String> handler = new HashMap<>();
|
||||
private Map<String, JsonObject> handlers = new HashMap<>();
|
||||
|
||||
public NotificationConfig() {
|
||||
handler.put(ThreePidMedium.Email.getId(), EmailRawNotificationHandler.ID);
|
||||
handler.put(ThreePidMedium.PhoneNumber.getId(), PhoneNotificationHandler.ID);
|
||||
}
|
||||
|
||||
public Map<String, String> getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user