diff --git a/src/main/java/io/kamax/mxisd/HttpMxisd.java b/src/main/java/io/kamax/mxisd/HttpMxisd.java index 0c71441..83ce897 100644 --- a/src/main/java/io/kamax/mxisd/HttpMxisd.java +++ b/src/main/java/io/kamax/mxisd/HttpMxisd.java @@ -111,7 +111,6 @@ public class HttpMxisd { public void stop() { httpSrv.stop(); - m.stop(); } diff --git a/src/main/java/io/kamax/mxisd/Mxisd.java b/src/main/java/io/kamax/mxisd/Mxisd.java index dc9ed9f..547c445 100644 --- a/src/main/java/io/kamax/mxisd/Mxisd.java +++ b/src/main/java/io/kamax/mxisd/Mxisd.java @@ -56,31 +56,31 @@ import java.util.ServiceLoader; public class Mxisd { - protected MxisdConfig cfg; + private MxisdConfig cfg; - protected CloseableHttpClient httpClient; - protected IRemoteIdentityServerFetcher srvFetcher; + private CloseableHttpClient httpClient; + private IRemoteIdentityServerFetcher srvFetcher; - protected IStorage store; + private IStorage store; - protected KeyManager keyMgr; - protected SignatureManager signMgr; + private KeyManager keyMgr; + private SignatureManager signMgr; // Features - protected AuthManager authMgr; - protected DirectoryManager dirMgr; - protected LookupStrategy idStrategy; - protected InvitationManager invMgr; - protected ProfileManager pMgr; - protected AppSvcManager asHander; - protected SessionManager sessMgr; - protected NotificationManager notifMgr; + private AuthManager authMgr; + private DirectoryManager dirMgr; + private LookupStrategy idStrategy; + private InvitationManager invMgr; + private ProfileManager pMgr; + private AppSvcManager asHander; + private SessionManager sessMgr; + private NotificationManager notifMgr; public Mxisd(MxisdConfig cfg) { this.cfg = cfg.build(); } - protected void build() { + private void build() { httpClient = HttpClients.custom() .setUserAgent("mxisd") .setMaxConnPerRoute(Integer.MAX_VALUE) diff --git a/src/main/java/io/kamax/mxisd/MxisdStandaloneExec.java b/src/main/java/io/kamax/mxisd/MxisdStandaloneExec.java index 42b5c25..4247dc1 100644 --- a/src/main/java/io/kamax/mxisd/MxisdStandaloneExec.java +++ b/src/main/java/io/kamax/mxisd/MxisdStandaloneExec.java @@ -23,6 +23,8 @@ package io.kamax.mxisd; import io.kamax.mxisd.config.MxisdConfig; import io.kamax.mxisd.config.YamlConfigLoader; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.Arrays; @@ -31,7 +33,10 @@ import java.util.Objects; public class MxisdStandaloneExec { + private static final Logger log = LoggerFactory.getLogger(""); + public static void main(String[] args) throws IOException { + log.info("------------- mxisd starting -------------"); MxisdConfig cfg = null; Iterator argsIt = Arrays.asList(args).iterator(); @@ -40,9 +45,8 @@ public class MxisdStandaloneExec { if (StringUtils.equals("-c", arg)) { String cfgFile = argsIt.next(); cfg = YamlConfigLoader.loadFromFile(cfgFile); - System.out.println("Loaded configuration from " + cfgFile); } else { - System.out.println("Invalid argument: " + arg); + log.info("Invalid argument: {}", arg); System.exit(1); } } @@ -55,11 +59,11 @@ public class MxisdStandaloneExec { HttpMxisd mxisd = new HttpMxisd(cfg); Runtime.getRuntime().addShutdownHook(new Thread(() -> { mxisd.stop(); - System.out.println("------------- mxisd stopped -------------"); + log.info("------------- mxisd stopped -------------"); })); mxisd.start(); - System.out.println("------------- mxisd started -------------"); + log.info("------------- mxisd started -------------"); } catch (Throwable t) { t.printStackTrace(); System.exit(1); diff --git a/src/main/java/io/kamax/mxisd/config/DirectoryConfig.java b/src/main/java/io/kamax/mxisd/config/DirectoryConfig.java index 8d0bcd1..a2b59f3 100644 --- a/src/main/java/io/kamax/mxisd/config/DirectoryConfig.java +++ b/src/main/java/io/kamax/mxisd/config/DirectoryConfig.java @@ -64,8 +64,8 @@ public class DirectoryConfig { public void build() { log.info("--- Directory config ---"); log.info("Exclude:"); - log.info("\tHomeserver: {}", getExclude().getHomeserver()); - log.info("\t3PID: {}", getExclude().getThreepid()); + log.info(" Homeserver: {}", getExclude().getHomeserver()); + log.info(" 3PID: {}", getExclude().getThreepid()); } } diff --git a/src/main/java/io/kamax/mxisd/config/YamlConfigLoader.java b/src/main/java/io/kamax/mxisd/config/YamlConfigLoader.java index dea628d..55f07bd 100644 --- a/src/main/java/io/kamax/mxisd/config/YamlConfigLoader.java +++ b/src/main/java/io/kamax/mxisd/config/YamlConfigLoader.java @@ -21,6 +21,8 @@ package io.kamax.mxisd.config; import io.kamax.matrix.json.GsonUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.Constructor; import org.yaml.snakeyaml.representer.Representer; @@ -32,21 +34,29 @@ import java.util.Optional; public class YamlConfigLoader { + private static final Logger log = LoggerFactory.getLogger(YamlConfigLoader.class); + public static MxisdConfig loadFromFile(String path) throws IOException { + log.debug("Reading config from {}", path); Representer rep = new Representer(); rep.getPropertyUtils().setAllowReadOnlyProperties(true); rep.getPropertyUtils().setSkipMissingProperties(true); Yaml yaml = new Yaml(new Constructor(MxisdConfig.class), rep); try (FileInputStream is = new FileInputStream(path)) { Object o = yaml.load(is); - return GsonUtil.get().fromJson(GsonUtil.get().toJson(o), MxisdConfig.class); + log.debug("Read config in memory from {}", path); + MxisdConfig cfg = GsonUtil.get().fromJson(GsonUtil.get().toJson(o), MxisdConfig.class); + log.info("Loaded config from {}", path); + return cfg; } } public static Optional tryLoadFromFile(String path) { + log.debug("Attempting to read config from {}", path); try { return Optional.of(loadFromFile(path)); } catch (FileNotFoundException e) { + log.info("No config file at {}", path); return Optional.empty(); } catch (IOException e) { throw new RuntimeException(e); diff --git a/src/main/java/io/kamax/mxisd/config/ldap/LdapConfig.java b/src/main/java/io/kamax/mxisd/config/ldap/LdapConfig.java index a5fa42d..0dda7b9 100644 --- a/src/main/java/io/kamax/mxisd/config/ldap/LdapConfig.java +++ b/src/main/java/io/kamax/mxisd/config/ldap/LdapConfig.java @@ -421,9 +421,9 @@ public abstract class LdapConfig { log.info("Port: {}", connection.getPort()); log.info("TLS: {}", connection.isTls()); log.info("Bind DN: {}", connection.getBindDn()); - log.info("Base DNs: {}"); + log.info("Base DNs:"); for (String baseDN : connection.getBaseDNs()) { - log.info("\t- {}", baseDN); + log.info(" - {}", baseDN); } log.info("Attribute: {}", GsonUtil.get().toJson(attribute)); diff --git a/src/main/java/io/kamax/mxisd/config/threepid/medium/EmailTemplateConfig.java b/src/main/java/io/kamax/mxisd/config/threepid/medium/EmailTemplateConfig.java index 3e9ad41..528ebed 100644 --- a/src/main/java/io/kamax/mxisd/config/threepid/medium/EmailTemplateConfig.java +++ b/src/main/java/io/kamax/mxisd/config/threepid/medium/EmailTemplateConfig.java @@ -38,9 +38,9 @@ public class EmailTemplateConfig extends GenericTemplateConfig { log.info("--- E-mail Generator templates config ---"); log.info("Invite: {}", getName(getInvite())); log.info("Session:"); - log.info("\tValidation: {}", getSession().getValidation()); - log.info("\tUnbind:"); - log.info("\t\tFraudulent: {}", getSession().getUnbind().getFraudulent()); + log.info(" Validation: {}", getSession().getValidation()); + log.info(" Unbind:"); + log.info(" Fraudulent: {}", getSession().getUnbind().getFraudulent()); return this; } diff --git a/src/main/java/io/kamax/mxisd/config/threepid/medium/PhoneSmsTemplateConfig.java b/src/main/java/io/kamax/mxisd/config/threepid/medium/PhoneSmsTemplateConfig.java index a14c200..20b3aea 100644 --- a/src/main/java/io/kamax/mxisd/config/threepid/medium/PhoneSmsTemplateConfig.java +++ b/src/main/java/io/kamax/mxisd/config/threepid/medium/PhoneSmsTemplateConfig.java @@ -37,9 +37,9 @@ public class PhoneSmsTemplateConfig extends GenericTemplateConfig { log.info("--- SMS Generator templates config ---"); log.info("Invite: {}", getName(getInvite())); log.info("Session:"); - log.info("\tValidation: {}", getSession().getValidation()); - log.info("\tUnbind:"); - log.info("\t\tFraudulent: {}", getSession().getUnbind().getFraudulent()); + log.info(" Validation: {}", getSession().getValidation()); + log.info(" Unbind:"); + log.info(" Fraudulent: {}", getSession().getUnbind().getFraudulent()); return this; } diff --git a/src/main/java/io/kamax/mxisd/config/threepid/notification/NotificationConfig.java b/src/main/java/io/kamax/mxisd/config/threepid/notification/NotificationConfig.java index 21169f1..cf3e330 100644 --- a/src/main/java/io/kamax/mxisd/config/threepid/notification/NotificationConfig.java +++ b/src/main/java/io/kamax/mxisd/config/threepid/notification/NotificationConfig.java @@ -61,7 +61,7 @@ public class NotificationConfig { public void build() { log.info("--- Notification config ---"); log.info("Handlers:"); - handler.forEach((k, v) -> log.info("\t{}: {}", k, v)); + handler.forEach((k, v) -> log.info(" {}: {}", k, v)); } } diff --git a/src/main/java/io/kamax/mxisd/directory/DirectoryManager.java b/src/main/java/io/kamax/mxisd/directory/DirectoryManager.java index 6197692..5ed9bce 100644 --- a/src/main/java/io/kamax/mxisd/directory/DirectoryManager.java +++ b/src/main/java/io/kamax/mxisd/directory/DirectoryManager.java @@ -62,7 +62,7 @@ public class DirectoryManager { this.providers = new ArrayList<>(providers); log.info("Directory providers:"); - this.providers.forEach(p -> log.info("\t- {}", p.getClass().getName())); + this.providers.forEach(p -> log.info(" - {}", p.getClass().getName())); } public UserDirectorySearchResult search(URI target, String accessToken, String query) { diff --git a/src/main/java/io/kamax/mxisd/lookup/strategy/RecursivePriorityLookupStrategy.java b/src/main/java/io/kamax/mxisd/lookup/strategy/RecursivePriorityLookupStrategy.java index c03821b..3589eb7 100644 --- a/src/main/java/io/kamax/mxisd/lookup/strategy/RecursivePriorityLookupStrategy.java +++ b/src/main/java/io/kamax/mxisd/lookup/strategy/RecursivePriorityLookupStrategy.java @@ -57,7 +57,7 @@ public class RecursivePriorityLookupStrategy implements LookupStrategy { try { log.info("Found {} providers", providers.size()); - providers.forEach(p -> log.info("\t- {}", p.getClass().getName())); + providers.forEach(p -> log.info(" - {}", p.getClass().getName())); providers.sort((o1, o2) -> Integer.compare(o2.getPriority(), o1.getPriority())); log.info("Recursive lookup enabled: {}", cfg.getRecursive().isEnabled()); diff --git a/src/main/java/io/kamax/mxisd/profile/ProfileManager.java b/src/main/java/io/kamax/mxisd/profile/ProfileManager.java index c527d27..c803626 100644 --- a/src/main/java/io/kamax/mxisd/profile/ProfileManager.java +++ b/src/main/java/io/kamax/mxisd/profile/ProfileManager.java @@ -58,7 +58,7 @@ public class ProfileManager { this.providers = new ArrayList<>(providers); log.info("Profile Providers:"); - providers.forEach(p -> log.info("\t- {}", p.getClass().getSimpleName())); + providers.forEach(p -> log.info(" - {}", p.getClass().getSimpleName())); } public List getList(Function> function) {