Port default configuration values
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* mxisd - Matrix Identity Server Daemon
|
||||
* Copyright (C) 2018 Kamax Sàrl
|
||||
*
|
||||
* https://www.kamax.io/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.kamax.mxisd.config.threepid;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import io.kamax.mxisd.config.threepid.medium.EmailConfig;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ThreePidConfig {
|
||||
|
||||
private Map<String, JsonObject> medium = new HashMap<>();
|
||||
|
||||
public ThreePidConfig() {
|
||||
EmailConfig emailCfg = new EmailConfig();
|
||||
}
|
||||
|
||||
public Map<String, JsonObject> getMedium() {
|
||||
return medium;
|
||||
}
|
||||
|
||||
public void setMedium(Map<String, JsonObject> medium) {
|
||||
this.medium = medium;
|
||||
}
|
||||
|
||||
public void build() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,8 +31,8 @@ public class EmailSmtpConfig {
|
||||
private transient final Logger log = LoggerFactory.getLogger(EmailSmtpConfig.class);
|
||||
|
||||
private String host;
|
||||
private int port;
|
||||
private int tls;
|
||||
private int port = 587;
|
||||
private int tls = 1;
|
||||
private String login;
|
||||
private String password;
|
||||
|
||||
|
||||
@@ -20,18 +20,17 @@
|
||||
|
||||
package io.kamax.mxisd.config.threepid.medium;
|
||||
|
||||
import io.kamax.mxisd.config.MatrixConfig;
|
||||
import io.kamax.mxisd.exception.ConfigurationException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
public class EmailConfig {
|
||||
public class EmailConfig extends MediumConfig {
|
||||
|
||||
public static class Identity {
|
||||
|
||||
private String from;
|
||||
private String name;
|
||||
|
||||
@@ -55,36 +54,17 @@ public class EmailConfig {
|
||||
|
||||
private transient final Logger log = LoggerFactory.getLogger(EmailConfig.class);
|
||||
|
||||
private String generator;
|
||||
private String connector;
|
||||
|
||||
private MatrixConfig mxCfg;
|
||||
private Identity identity = new Identity();
|
||||
|
||||
public EmailConfig(MatrixConfig mxCfg) {
|
||||
this.mxCfg = mxCfg;
|
||||
public EmailConfig() {
|
||||
setConnector("smtp");
|
||||
setGenerator("template");
|
||||
}
|
||||
|
||||
public Identity getIdentity() {
|
||||
return identity;
|
||||
}
|
||||
|
||||
public String getGenerator() {
|
||||
return generator;
|
||||
}
|
||||
|
||||
public void setGenerator(String generator) {
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
public String getConnector() {
|
||||
return connector;
|
||||
}
|
||||
|
||||
public void setConnector(String connector) {
|
||||
this.connector = connector;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void build() {
|
||||
log.info("--- E-mail config ---");
|
||||
@@ -97,12 +77,8 @@ public class EmailConfig {
|
||||
throw new ConfigurationException("connector");
|
||||
}
|
||||
|
||||
log.info("From: {}", identity.getFrom());
|
||||
|
||||
if (StringUtils.isBlank(identity.getName())) {
|
||||
identity.setName(WordUtils.capitalize(mxCfg.getDomain()) + " Identity Server");
|
||||
}
|
||||
log.info("Name: {}", identity.getName());
|
||||
log.info("From: {}", getIdentity().getFrom());
|
||||
log.info("Name: {}", getIdentity().getName());
|
||||
log.info("Generator: {}", getGenerator());
|
||||
log.info("Connector: {}", getConnector());
|
||||
}
|
||||
|
||||
@@ -29,6 +29,13 @@ public class EmailTemplateConfig extends GenericTemplateConfig {
|
||||
|
||||
private transient final Logger log = LoggerFactory.getLogger(EmailTemplateConfig.class);
|
||||
|
||||
public EmailTemplateConfig() {
|
||||
setInvite("classpath:threepids/email/invite-template.eml");
|
||||
getGeneric().put("matrixId", "classpath:threepids/email/mxid-template.eml");
|
||||
getSession().getValidation().setLocal("classpath:threepids/email/validate-local-template.eml");
|
||||
getSession().getValidation().setRemote("classpath:threepids/email/validate-remote-template.eml");
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void build() {
|
||||
log.info("--- E-mail Generator templates config ---");
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* mxisd - Matrix Identity Server Daemon
|
||||
* Copyright (C) 2018 Kamax Sàrl
|
||||
*
|
||||
* https://www.kamax.io/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.kamax.mxisd.config.threepid.medium;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MediumConfig {
|
||||
|
||||
private String connector;
|
||||
private Map<String, JsonObject> connectors = new HashMap<>();
|
||||
private String generator;
|
||||
private Map<String, JsonObject> generators = new HashMap<>();
|
||||
|
||||
public String getConnector() {
|
||||
return connector;
|
||||
}
|
||||
|
||||
public void setConnector(String connector) {
|
||||
this.connector = connector;
|
||||
}
|
||||
|
||||
public Map<String, JsonObject> getConnectors() {
|
||||
return connectors;
|
||||
}
|
||||
|
||||
public void setConnectors(Map<String, JsonObject> connectors) {
|
||||
this.connectors = connectors;
|
||||
}
|
||||
|
||||
public String getGenerator() {
|
||||
return generator;
|
||||
}
|
||||
|
||||
public void setGenerator(String generator) {
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
public Map<String, JsonObject> getGenerators() {
|
||||
return generators;
|
||||
}
|
||||
|
||||
public void setGenerators(Map<String, JsonObject> generators) {
|
||||
this.generators = generators;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,50 +20,16 @@
|
||||
|
||||
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;
|
||||
|
||||
public class PhoneConfig {
|
||||
public class PhoneConfig extends MediumConfig {
|
||||
|
||||
private transient final Logger log = LoggerFactory.getLogger(PhoneConfig.class);
|
||||
|
||||
private String generator;
|
||||
private String connector;
|
||||
|
||||
public String getGenerator() {
|
||||
return generator;
|
||||
}
|
||||
|
||||
public void setGenerator(String generator) {
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
public String getConnector() {
|
||||
return connector;
|
||||
}
|
||||
|
||||
public void setConnector(String connector) {
|
||||
this.connector = connector;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void build() {
|
||||
log.info("--- Phone config ---");
|
||||
|
||||
if (StringUtils.isBlank(getGenerator())) {
|
||||
throw new ConfigurationException("generator");
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(getConnector())) {
|
||||
throw new ConfigurationException("connector");
|
||||
}
|
||||
|
||||
log.info("Generator: {}", getGenerator());
|
||||
log.info("Connector: {}", getConnector());
|
||||
public PhoneConfig() {
|
||||
setConnector("twilio");
|
||||
setGenerator("template");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,13 @@ public class PhoneSmsTemplateConfig extends GenericTemplateConfig {
|
||||
|
||||
private transient final Logger log = LoggerFactory.getLogger(EmailTemplateConfig.class);
|
||||
|
||||
public PhoneSmsTemplateConfig() {
|
||||
setInvite("classpath:threepids/sms/invite-template.txt");
|
||||
getGeneric().put("matrixId", "classpath:threepids/email/mxid-template.eml");
|
||||
getSession().getValidation().setLocal("classpath:threepids/sms/validate-local-template.txt");
|
||||
getSession().getValidation().setRemote("classpath:threepids/sms/validate-remote-template.txt");
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void build() {
|
||||
log.info("--- SMS Generator templates config ---");
|
||||
|
||||
Reference in New Issue
Block a user