diff --git a/build.gradle b/build.gradle
index 7e93d92..7af37cd 100644
--- a/build.gradle
+++ b/build.gradle
@@ -74,10 +74,10 @@ dependencies {
compile 'commons-io:commons-io:2.5'
// Spring Boot - standalone app
- compile 'org.springframework.boot:spring-boot-starter-web:1.5.3.RELEASE'
+ compile 'org.springframework.boot:spring-boot-starter-web:1.5.10.RELEASE'
// Thymeleaf for HTML templates
- compile "org.springframework.boot:spring-boot-starter-thymeleaf:1.5.3.RELEASE"
+ compile "org.springframework.boot:spring-boot-starter-thymeleaf:1.5.10.RELEASE"
// Matrix Java SDK
compile 'io.kamax:matrix-java-sdk:0.0.2'
diff --git a/src/main/java/io/kamax/mxisd/backend/ldap/LdapAuthProvider.java b/src/main/java/io/kamax/mxisd/backend/ldap/LdapAuthProvider.java
index 09dad06..6239866 100644
--- a/src/main/java/io/kamax/mxisd/backend/ldap/LdapAuthProvider.java
+++ b/src/main/java/io/kamax/mxisd/backend/ldap/LdapAuthProvider.java
@@ -29,7 +29,7 @@ import io.kamax.mxisd.UserIdType;
import io.kamax.mxisd.auth.provider.AuthenticatorProvider;
import io.kamax.mxisd.auth.provider.BackendAuthResult;
import io.kamax.mxisd.config.MatrixConfig;
-import io.kamax.mxisd.config.ldap.LdapConfig;
+import io.kamax.mxisd.config.ldap.generic.GenericLdapConfig;
import io.kamax.mxisd.util.GsonUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.directory.api.ldap.model.cursor.CursorException;
@@ -52,14 +52,14 @@ import java.util.Optional;
import java.util.Set;
@Component
-public class LdapAuthProvider extends LdapGenericBackend implements AuthenticatorProvider {
+public class LdapAuthProvider extends LdapBackend implements AuthenticatorProvider {
private Logger log = LoggerFactory.getLogger(LdapAuthProvider.class);
private PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
@Autowired
- public LdapAuthProvider(LdapConfig cfg, MatrixConfig mxCfg) {
+ public LdapAuthProvider(GenericLdapConfig cfg, MatrixConfig mxCfg) {
super(cfg, mxCfg);
}
@@ -92,7 +92,7 @@ public class LdapAuthProvider extends LdapGenericBackend implements Authenticato
bind(conn);
String uidType = getAt().getUid().getType();
- String userFilterValue = StringUtils.equals(LdapGenericBackend.UID, uidType) ? mxid.getLocalPart() : mxid.getId();
+ String userFilterValue = StringUtils.equals(LdapBackend.UID, uidType) ? mxid.getLocalPart() : mxid.getId();
if (StringUtils.isBlank(userFilterValue)) {
log.warn("Username is empty, failing auth");
return BackendAuthResult.failure();
diff --git a/src/main/java/io/kamax/mxisd/backend/ldap/LdapGenericBackend.java b/src/main/java/io/kamax/mxisd/backend/ldap/LdapBackend.java
similarity index 88%
rename from src/main/java/io/kamax/mxisd/backend/ldap/LdapGenericBackend.java
rename to src/main/java/io/kamax/mxisd/backend/ldap/LdapBackend.java
index 5b06458..dda3811 100644
--- a/src/main/java/io/kamax/mxisd/backend/ldap/LdapGenericBackend.java
+++ b/src/main/java/io/kamax/mxisd/backend/ldap/LdapBackend.java
@@ -21,7 +21,6 @@
package io.kamax.mxisd.backend.ldap;
import io.kamax.mxisd.config.MatrixConfig;
-import io.kamax.mxisd.config.ldap.LdapAttributeConfig;
import io.kamax.mxisd.config.ldap.LdapConfig;
import org.apache.commons.lang.StringUtils;
import org.apache.directory.api.ldap.model.entry.Attribute;
@@ -40,17 +39,17 @@ import java.util.Arrays;
import java.util.List;
import java.util.Optional;
-public abstract class LdapGenericBackend {
+public abstract class LdapBackend {
public static final String UID = "uid";
public static final String MATRIX_ID = "mxid";
- private Logger log = LoggerFactory.getLogger(LdapGenericBackend.class);
+ private Logger log = LoggerFactory.getLogger(LdapBackend.class);
private LdapConfig cfg;
private MatrixConfig mxCfg;
- public LdapGenericBackend(LdapConfig cfg, MatrixConfig mxCfg) {
+ public LdapBackend(LdapConfig cfg, MatrixConfig mxCfg) {
this.cfg = cfg;
this.mxCfg = mxCfg;
}
@@ -60,10 +59,10 @@ public abstract class LdapGenericBackend {
}
protected String getBaseDn() {
- return cfg.getConn().getBaseDn();
+ return cfg.getConnection().getBaseDn();
}
- protected LdapAttributeConfig getAt() {
+ protected LdapConfig.Attribute getAt() {
return cfg.getAttribute();
}
@@ -72,14 +71,14 @@ public abstract class LdapGenericBackend {
}
protected synchronized LdapConnection getConn() throws LdapException {
- return new LdapNetworkConnection(cfg.getConn().getHost(), cfg.getConn().getPort(), cfg.getConn().isTls());
+ return new LdapNetworkConnection(cfg.getConnection().getHost(), cfg.getConnection().getPort(), cfg.getConnection().isTls());
}
protected void bind(LdapConnection conn) throws LdapException {
- if (StringUtils.isBlank(cfg.getConn().getBindDn()) && StringUtils.isBlank(cfg.getConn().getBindPassword())) {
+ if (StringUtils.isBlank(cfg.getConnection().getBindDn()) && StringUtils.isBlank(cfg.getConnection().getBindPassword())) {
conn.anonymousBind();
} else {
- conn.bind(cfg.getConn().getBindDn(), cfg.getConn().getBindPassword());
+ conn.bind(cfg.getConnection().getBindDn(), cfg.getConnection().getBindPassword());
}
}
diff --git a/src/main/java/io/kamax/mxisd/backend/ldap/LdapDirectoryProvider.java b/src/main/java/io/kamax/mxisd/backend/ldap/LdapDirectoryProvider.java
index ec1a247..650648a 100644
--- a/src/main/java/io/kamax/mxisd/backend/ldap/LdapDirectoryProvider.java
+++ b/src/main/java/io/kamax/mxisd/backend/ldap/LdapDirectoryProvider.java
@@ -21,8 +21,8 @@
package io.kamax.mxisd.backend.ldap;
import io.kamax.mxisd.config.MatrixConfig;
-import io.kamax.mxisd.config.ldap.LdapAttributeConfig;
import io.kamax.mxisd.config.ldap.LdapConfig;
+import io.kamax.mxisd.config.ldap.generic.GenericLdapConfig;
import io.kamax.mxisd.controller.directory.v1.io.UserDirectorySearchResult;
import io.kamax.mxisd.directory.IDirectoryProvider;
import io.kamax.mxisd.exception.InternalServerError;
@@ -44,12 +44,12 @@ import java.util.ArrayList;
import java.util.List;
@Component
-public class LdapDirectoryProvider extends LdapGenericBackend implements IDirectoryProvider {
+public class LdapDirectoryProvider extends LdapBackend implements IDirectoryProvider {
private Logger log = LoggerFactory.getLogger(LdapDirectoryProvider.class);
@Autowired
- public LdapDirectoryProvider(LdapConfig cfg, MatrixConfig mxCfg) {
+ public LdapDirectoryProvider(GenericLdapConfig cfg, MatrixConfig mxCfg) {
super(cfg, mxCfg);
}
@@ -65,7 +65,7 @@ public class LdapDirectoryProvider extends LdapGenericBackend implements IDirect
try (LdapConnection conn = getConn()) {
bind(conn);
- LdapAttributeConfig atCfg = getCfg().getAttribute();
+ LdapConfig.Attribute atCfg = getCfg().getAttribute();
attributes = new ArrayList<>(attributes);
attributes.add(getUidAtt());
diff --git a/src/main/java/io/kamax/mxisd/backend/ldap/LdapThreePidProvider.java b/src/main/java/io/kamax/mxisd/backend/ldap/LdapThreePidProvider.java
index 7835e7f..70e319a 100644
--- a/src/main/java/io/kamax/mxisd/backend/ldap/LdapThreePidProvider.java
+++ b/src/main/java/io/kamax/mxisd/backend/ldap/LdapThreePidProvider.java
@@ -21,7 +21,7 @@
package io.kamax.mxisd.backend.ldap;
import io.kamax.mxisd.config.MatrixConfig;
-import io.kamax.mxisd.config.ldap.LdapConfig;
+import io.kamax.mxisd.config.ldap.generic.GenericLdapConfig;
import io.kamax.mxisd.exception.InternalServerError;
import io.kamax.mxisd.lookup.SingleLookupReply;
import io.kamax.mxisd.lookup.SingleLookupRequest;
@@ -45,11 +45,11 @@ import java.util.List;
import java.util.Optional;
@Component
-public class LdapThreePidProvider extends LdapGenericBackend implements IThreePidProvider {
+public class LdapThreePidProvider extends LdapBackend implements IThreePidProvider {
private Logger log = LoggerFactory.getLogger(LdapThreePidProvider.class);
- public LdapThreePidProvider(LdapConfig cfg, MatrixConfig mxCfg) {
+ public LdapThreePidProvider(GenericLdapConfig cfg, MatrixConfig mxCfg) {
super(cfg, mxCfg);
}
diff --git a/src/main/java/io/kamax/mxisd/backend/ldap/netiq/NetIqLdapAuthProvider.java b/src/main/java/io/kamax/mxisd/backend/ldap/netiq/NetIqLdapAuthProvider.java
new file mode 100644
index 0000000..1550e9a
--- /dev/null
+++ b/src/main/java/io/kamax/mxisd/backend/ldap/netiq/NetIqLdapAuthProvider.java
@@ -0,0 +1,41 @@
+/*
+ * 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 .
+ */
+
+package io.kamax.mxisd.backend.ldap.netiq;
+
+import io.kamax.mxisd.backend.ldap.LdapAuthProvider;
+import io.kamax.mxisd.config.MatrixConfig;
+import io.kamax.mxisd.config.ldap.netiq.NetIqLdapConfig;
+import org.springframework.stereotype.Component;
+
+@Component
+public class NetIqLdapAuthProvider extends LdapAuthProvider {
+
+ public NetIqLdapAuthProvider(NetIqLdapConfig cfg, MatrixConfig mxCfg) {
+ super(cfg, mxCfg);
+ }
+
+ // FIXME this is duplicated in the other NetIQ classes, due to the Matrix ID generation code that was not abstracted
+ @Override
+ public String buildMatrixIdFromUid(String uid) {
+ return super.buildMatrixIdFromUid(uid).toLowerCase();
+ }
+
+}
diff --git a/src/main/java/io/kamax/mxisd/backend/ldap/netiq/NetIqLdapDirectoryProvider.java b/src/main/java/io/kamax/mxisd/backend/ldap/netiq/NetIqLdapDirectoryProvider.java
new file mode 100644
index 0000000..226e0de
--- /dev/null
+++ b/src/main/java/io/kamax/mxisd/backend/ldap/netiq/NetIqLdapDirectoryProvider.java
@@ -0,0 +1,41 @@
+/*
+ * 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 .
+ */
+
+package io.kamax.mxisd.backend.ldap.netiq;
+
+import io.kamax.mxisd.backend.ldap.LdapDirectoryProvider;
+import io.kamax.mxisd.config.MatrixConfig;
+import io.kamax.mxisd.config.ldap.netiq.NetIqLdapConfig;
+import org.springframework.stereotype.Component;
+
+@Component
+public class NetIqLdapDirectoryProvider extends LdapDirectoryProvider {
+
+ public NetIqLdapDirectoryProvider(NetIqLdapConfig cfg, MatrixConfig mxCfg) {
+ super(cfg, mxCfg);
+ }
+
+ // FIXME this is duplicated in the other NetIQ classes, due to the Matrix ID generation code that was not abstracted
+ @Override
+ public String buildMatrixIdFromUid(String uid) {
+ return super.buildMatrixIdFromUid(uid).toLowerCase();
+ }
+
+}
diff --git a/src/main/java/io/kamax/mxisd/backend/ldap/netiq/NetIqLdapThreePidProvider.java b/src/main/java/io/kamax/mxisd/backend/ldap/netiq/NetIqLdapThreePidProvider.java
new file mode 100644
index 0000000..f8c8e93
--- /dev/null
+++ b/src/main/java/io/kamax/mxisd/backend/ldap/netiq/NetIqLdapThreePidProvider.java
@@ -0,0 +1,41 @@
+/*
+ * 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 .
+ */
+
+package io.kamax.mxisd.backend.ldap.netiq;
+
+import io.kamax.mxisd.backend.ldap.LdapThreePidProvider;
+import io.kamax.mxisd.config.MatrixConfig;
+import io.kamax.mxisd.config.ldap.netiq.NetIqLdapConfig;
+import org.springframework.stereotype.Component;
+
+@Component
+public class NetIqLdapThreePidProvider extends LdapThreePidProvider {
+
+ public NetIqLdapThreePidProvider(NetIqLdapConfig cfg, MatrixConfig mxCfg) {
+ super(cfg, mxCfg);
+ }
+
+ // FIXME this is duplicated in the other NetIQ classes, due to the Matrix ID generation code that was not abstracted
+ @Override
+ public String buildMatrixIdFromUid(String uid) {
+ return super.buildMatrixIdFromUid(uid).toLowerCase();
+ }
+
+}
diff --git a/src/main/java/io/kamax/mxisd/config/ldap/LdapAttributeConfig.java b/src/main/java/io/kamax/mxisd/config/ldap/LdapAttributeConfig.java
deleted file mode 100644
index fb01de5..0000000
--- a/src/main/java/io/kamax/mxisd/config/ldap/LdapAttributeConfig.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * mxisd - Matrix Identity Server Daemon
- * Copyright (C) 2017 Maxime Dor
- *
- * https://max.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 .
- */
-
-package io.kamax.mxisd.config.ldap;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@Configuration
-@ConfigurationProperties(prefix = "ldap.attribute")
-public class LdapAttributeConfig {
-
- private LdapAttributeUidConfig uid;
- private String name;
- private Map> threepid = new HashMap<>();
-
- public LdapAttributeUidConfig getUid() {
- return uid;
- }
-
- public void setUid(LdapAttributeUidConfig uid) {
- this.uid = uid;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Map> getThreepid() {
- return threepid;
- }
-
- public void setThreepid(Map> threepid) {
- this.threepid = threepid;
- }
-
-}
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 565ed08..fe49a5a 100644
--- a/src/main/java/io/kamax/mxisd/config/ldap/LdapConfig.java
+++ b/src/main/java/io/kamax/mxisd/config/ldap/LdapConfig.java
@@ -22,28 +22,148 @@ package io.kamax.mxisd.config.ldap;
import com.google.gson.Gson;
import io.kamax.matrix.ThreePidMedium;
-import io.kamax.mxisd.backend.ldap.LdapGenericBackend;
+import io.kamax.mxisd.backend.ldap.LdapBackend;
import io.kamax.mxisd.exception.ConfigurationException;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
@Configuration
@ConfigurationProperties(prefix = "ldap")
public class LdapConfig {
- private Logger log = LoggerFactory.getLogger(LdapConfig.class);
- private static Gson gson = new Gson();
+ public static class UID {
- private boolean enabled;
- private String filter;
+ private String type;
+ private String value;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ }
+
+ public static class Attribute {
+
+ private UID uid;
+ private String name;
+ private Map> threepid = new HashMap<>();
+
+ public UID getUid() {
+ return uid;
+ }
+
+ public void setUid(UID uid) {
+ this.uid = uid;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Map> getThreepid() {
+ return threepid;
+ }
+
+ public void setThreepid(Map> threepid) {
+ this.threepid = threepid;
+ }
+
+ }
+
+ public static class Auth {
+
+ private String filter;
+
+ public String getFilter() {
+ return filter;
+ }
+
+ public void setFilter(String filter) {
+ this.filter = filter;
+ }
+
+ }
+
+ public static class Connection {
+
+ private boolean tls;
+ private String host;
+ private int port;
+ private String bindDn;
+ private String bindPassword;
+ private String baseDn;
+
+ public boolean isTls() {
+ return tls;
+ }
+
+ public void setTls(boolean tls) {
+ this.tls = tls;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getBindDn() {
+ return bindDn;
+ }
+
+ public void setBindDn(String bindDn) {
+ this.bindDn = bindDn;
+ }
+
+ public String getBindPassword() {
+ return bindPassword;
+ }
+
+ public void setBindPassword(String bindPassword) {
+ this.bindPassword = bindPassword;
+ }
+
+ public String getBaseDn() {
+ return baseDn;
+ }
+
+ public void setBaseDn(String baseDn) {
+ this.baseDn = baseDn;
+ }
+
+ }
public static class Directory {
@@ -82,12 +202,54 @@ public class LdapConfig {
}
- @Autowired
- private LdapConnectionConfig conn;
- private LdapAttributeConfig attribute;
- private LdapAuthConfig auth;
+ public static class Identity {
+
+ private String filter;
+ private String token;
+ private Map medium = new HashMap<>();
+
+ public String getFilter() {
+ return filter;
+ }
+
+ public void setFilter(String filter) {
+ this.filter = filter;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ public Map getMedium() {
+ return medium;
+ }
+
+ public Optional getQuery(String key) {
+ return Optional.ofNullable(medium.get(key));
+ }
+
+ public void setMedium(Map medium) {
+ this.medium = medium;
+ }
+
+ }
+
+
+ private Logger log = LoggerFactory.getLogger(LdapConfig.class);
+ private static Gson gson = new Gson();
+
+ private boolean enabled;
+ private String filter;
+
+ private Connection connection;
+ private Attribute attribute;
+ private Auth auth;
private Directory directory;
- private LdapIdentityConfig identity;
+ private Identity identity;
public boolean isEnabled() {
return enabled;
@@ -105,27 +267,27 @@ public class LdapConfig {
this.filter = filter;
}
- public LdapConnectionConfig getConn() {
- return conn;
+ public Connection getConnection() {
+ return connection;
}
- public void setConn(LdapConnectionConfig conn) {
- this.conn = conn;
+ public void setConnection(Connection conn) {
+ this.connection = conn;
}
- public LdapAttributeConfig getAttribute() {
+ public Attribute getAttribute() {
return attribute;
}
- public void setAttribute(LdapAttributeConfig attribute) {
+ public void setAttribute(Attribute attribute) {
this.attribute = attribute;
}
- public LdapAuthConfig getAuth() {
+ public Auth getAuth() {
return auth;
}
- public void setAuth(LdapAuthConfig auth) {
+ public void setAuth(Auth auth) {
this.auth = auth;
}
@@ -137,11 +299,11 @@ public class LdapConfig {
this.directory = directory;
}
- public LdapIdentityConfig getIdentity() {
+ public Identity getIdentity() {
return identity;
}
- public void setIdentity(LdapIdentityConfig identity) {
+ public void setIdentity(Identity identity) {
this.identity = identity;
}
@@ -154,15 +316,15 @@ public class LdapConfig {
return;
}
- if (StringUtils.isBlank(conn.getHost())) {
+ if (StringUtils.isBlank(connection.getHost())) {
throw new IllegalStateException("LDAP Host must be configured!");
}
- if (conn.getPort() < 1 || conn.getPort() > 65535) {
+ if (connection.getPort() < 1 || connection.getPort() > 65535) {
throw new IllegalStateException("LDAP port is not valid");
}
- if (StringUtils.isBlank(conn.getBaseDn())) {
+ if (StringUtils.isBlank(connection.getBaseDn())) {
throw new ConfigurationException("ldap.connection.baseDn");
}
@@ -175,7 +337,7 @@ public class LdapConfig {
}
String uidType = attribute.getUid().getType();
- if (!StringUtils.equals(LdapGenericBackend.UID, uidType) && !StringUtils.equals(LdapGenericBackend.MATRIX_ID, uidType)) {
+ if (!StringUtils.equals(LdapBackend.UID, uidType) && !StringUtils.equals(LdapBackend.MATRIX_ID, uidType)) {
throw new IllegalArgumentException("Unsupported LDAP UID type: " + uidType);
}
@@ -187,9 +349,9 @@ public class LdapConfig {
attribute.getThreepid().forEach((k, v) -> {
if (StringUtils.isBlank(identity.getMedium().get(k))) {
if (ThreePidMedium.PhoneNumber.is(k)) {
- identity.getMedium().put(k, LdapGenericBackend.buildOrQuery("+" + getIdentity().getToken(), v));
+ identity.getMedium().put(k, LdapBackend.buildOrQuery("+" + getIdentity().getToken(), v));
} else {
- identity.getMedium().put(k, LdapGenericBackend.buildOrQuery(getIdentity().getToken(), v));
+ identity.getMedium().put(k, LdapBackend.buildOrQuery(getIdentity().getToken(), v));
}
}
});
@@ -198,10 +360,10 @@ public class LdapConfig {
getDirectory().setFilter(StringUtils.defaultIfBlank(getDirectory().getFilter(), getFilter()));
getIdentity().setFilter(StringUtils.defaultIfBlank(getIdentity().getFilter(), getFilter()));
- log.info("Host: {}", conn.getHost());
- log.info("Port: {}", conn.getPort());
- log.info("Bind DN: {}", conn.getBindDn());
- log.info("Base DN: {}", conn.getBaseDn());
+ log.info("Host: {}", connection.getHost());
+ log.info("Port: {}", connection.getPort());
+ log.info("Bind DN: {}", connection.getBindDn());
+ log.info("Base DN: {}", connection.getBaseDn());
log.info("Attribute: {}", gson.toJson(attribute));
log.info("Auth: {}", gson.toJson(auth));
diff --git a/src/main/java/io/kamax/mxisd/config/ldap/LdapConnectionConfig.java b/src/main/java/io/kamax/mxisd/config/ldap/LdapConnectionConfig.java
deleted file mode 100644
index a4fa419..0000000
--- a/src/main/java/io/kamax/mxisd/config/ldap/LdapConnectionConfig.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * mxisd - Matrix Identity Server Daemon
- * Copyright (C) 2017 Maxime Dor
- *
- * https://max.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 .
- */
-
-package io.kamax.mxisd.config.ldap;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-@ConfigurationProperties(prefix = "ldap.connection")
-public class LdapConnectionConfig {
-
- private boolean tls;
- private String host;
- private int port;
- private String bindDn;
- private String bindPassword;
- private String baseDn;
-
- public boolean isTls() {
- return tls;
- }
-
- public void setTls(boolean tls) {
- this.tls = tls;
- }
-
- public String getHost() {
- return host;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
- public String getBindDn() {
- return bindDn;
- }
-
- public void setBindDn(String bindDn) {
- this.bindDn = bindDn;
- }
-
- public String getBindPassword() {
- return bindPassword;
- }
-
- public void setBindPassword(String bindPassword) {
- this.bindPassword = bindPassword;
- }
-
- public String getBaseDn() {
- return baseDn;
- }
-
- public void setBaseDn(String baseDn) {
- this.baseDn = baseDn;
- }
-
-}
diff --git a/src/main/java/io/kamax/mxisd/config/ldap/LdapIdentityConfig.java b/src/main/java/io/kamax/mxisd/config/ldap/LdapIdentityConfig.java
deleted file mode 100644
index 7d78886..0000000
--- a/src/main/java/io/kamax/mxisd/config/ldap/LdapIdentityConfig.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * mxisd - Matrix Identity Server Daemon
- * Copyright (C) 2017 Maxime Dor
- *
- * https://max.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 .
- */
-
-package io.kamax.mxisd.config.ldap;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-
-@Configuration
-@ConfigurationProperties(prefix = "ldap.identity")
-public class LdapIdentityConfig {
-
- private String filter;
- private String token;
- private Map medium = new HashMap<>();
-
- public String getFilter() {
- return filter;
- }
-
- public void setFilter(String filter) {
- this.filter = filter;
- }
-
- public String getToken() {
- return token;
- }
-
- public void setToken(String token) {
- this.token = token;
- }
-
- public Map getMedium() {
- return medium;
- }
-
- public Optional getQuery(String key) {
- return Optional.ofNullable(medium.get(key));
- }
-
- public void setMedium(Map medium) {
- this.medium = medium;
- }
-
-}
diff --git a/src/main/java/io/kamax/mxisd/config/ldap/LdapAuthConfig.java b/src/main/java/io/kamax/mxisd/config/ldap/generic/GenericLdapConfig.java
similarity index 72%
rename from src/main/java/io/kamax/mxisd/config/ldap/LdapAuthConfig.java
rename to src/main/java/io/kamax/mxisd/config/ldap/generic/GenericLdapConfig.java
index ffea425..cdcfed2 100644
--- a/src/main/java/io/kamax/mxisd/config/ldap/LdapAuthConfig.java
+++ b/src/main/java/io/kamax/mxisd/config/ldap/generic/GenericLdapConfig.java
@@ -1,8 +1,8 @@
/*
* mxisd - Matrix Identity Server Daemon
- * Copyright (C) 2017 Maxime Dor
+ * Copyright (C) 2018 Kamax Sàrl
*
- * https://max.kamax.io/
+ * 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
@@ -18,23 +18,16 @@
* along with this program. If not, see .
*/
-package io.kamax.mxisd.config.ldap;
+package io.kamax.mxisd.config.ldap.generic;
+import io.kamax.mxisd.config.ldap.LdapConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
@Configuration
-@ConfigurationProperties(prefix = "ldap.auth")
-public class LdapAuthConfig {
-
- private String filter;
-
- public String getFilter() {
- return filter;
- }
-
- public void setFilter(String filter) {
- this.filter = filter;
- }
+@ConfigurationProperties(prefix = "ldap")
+@Primary
+public class GenericLdapConfig extends LdapConfig {
}
diff --git a/src/main/java/io/kamax/mxisd/config/ldap/LdapAttributeUidConfig.java b/src/main/java/io/kamax/mxisd/config/ldap/netiq/NetIqLdapConfig.java
similarity index 63%
rename from src/main/java/io/kamax/mxisd/config/ldap/LdapAttributeUidConfig.java
rename to src/main/java/io/kamax/mxisd/config/ldap/netiq/NetIqLdapConfig.java
index 57547b8..e22b1d9 100644
--- a/src/main/java/io/kamax/mxisd/config/ldap/LdapAttributeUidConfig.java
+++ b/src/main/java/io/kamax/mxisd/config/ldap/netiq/NetIqLdapConfig.java
@@ -1,8 +1,8 @@
/*
* mxisd - Matrix Identity Server Daemon
- * Copyright (C) 2017 Maxime Dor
+ * Copyright (C) 2018 Kamax Sàrl
*
- * https://max.kamax.io/
+ * 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
@@ -18,32 +18,14 @@
* along with this program. If not, see .
*/
-package io.kamax.mxisd.config.ldap;
+package io.kamax.mxisd.config.ldap.netiq;
+import io.kamax.mxisd.config.ldap.generic.GenericLdapConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
-@ConfigurationProperties(prefix = "ldap.attribute.uid")
-public class LdapAttributeUidConfig {
-
- private String type;
- private String value;
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
+@ConfigurationProperties(prefix = "netiq")
+public class NetIqLdapConfig extends GenericLdapConfig {
}
diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml
index 45d9b49..71177ce 100644
--- a/src/main/resources/application.yaml
+++ b/src/main/resources/application.yaml
@@ -89,6 +89,46 @@ ldap:
email: ''
msisdn: ''
+netiq:
+ enabled: false
+ filter: ''
+ connection:
+ host: ''
+ tls: false
+ port: 389
+ bindDn: ''
+ bindPassword: ''
+ baseDn: ''
+ attribute:
+ uid:
+ type: 'uid'
+ value: 'userPrincipalName'
+ name: 'displayName'
+ threepid:
+ email:
+ - 'mailPrimaryAddress'
+ - 'mail'
+ - 'otherMailbox'
+ msisdn:
+ - 'telephoneNumber'
+ - 'mobile'
+ - 'homePhone'
+ - 'otherTelephone'
+ - 'otherMobile'
+ - 'otherHomePhone'
+ auth:
+ filter: ''
+ directory:
+ attribute:
+ other: []
+ filter: ''
+ identity:
+ filter: ''
+ token: '%3pid'
+ medium:
+ email: ''
+ msisdn: ''
+
firebase:
enabled: false