diff --git a/src/main/groovy/io/kamax/mxisd/api/ThreePidType.groovy b/src/main/groovy/io/kamax/mxisd/api/ThreePidType.groovy
deleted file mode 100644
index 29ef36d..0000000
--- a/src/main/groovy/io/kamax/mxisd/api/ThreePidType.groovy
+++ /dev/null
@@ -1,28 +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.api
-
-enum ThreePidType {
-
- email,
- msisdn,
-
-}
diff --git a/src/main/groovy/io/kamax/mxisd/config/LdapConfig.groovy b/src/main/groovy/io/kamax/mxisd/config/LdapConfig.groovy
index f9f2882..db2495e 100644
--- a/src/main/groovy/io/kamax/mxisd/config/LdapConfig.groovy
+++ b/src/main/groovy/io/kamax/mxisd/config/LdapConfig.groovy
@@ -20,7 +20,6 @@
package io.kamax.mxisd.config
-import io.kamax.mxisd.api.ThreePidType
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.InitializingBean
@@ -40,7 +39,7 @@ class LdapConfig implements InitializingBean {
private String attribute
private String bindDn
private String bindPassword
- private Map mappings
+ private Map mappings
String getHost() {
return host
@@ -98,15 +97,15 @@ class LdapConfig implements InitializingBean {
this.bindPassword = bindPassword
}
- Map getMappings() {
+ Map getMappings() {
return mappings
}
- void setMappings(Map mappings) {
+ void setMappings(Map mappings) {
this.mappings = mappings
}
- Optional getMapping(ThreePidType type) {
+ Optional getMapping(String type) {
if (mappings == null) {
return Optional.empty()
}
@@ -118,4 +117,5 @@ class LdapConfig implements InitializingBean {
void afterPropertiesSet() throws Exception {
log.info("Matrix ID type: {}", getType())
}
+
}
diff --git a/src/main/groovy/io/kamax/mxisd/controller/v1/MappingController.groovy b/src/main/groovy/io/kamax/mxisd/controller/v1/MappingController.groovy
index dbc870e..45bd0f2 100644
--- a/src/main/groovy/io/kamax/mxisd/controller/v1/MappingController.groovy
+++ b/src/main/groovy/io/kamax/mxisd/controller/v1/MappingController.groovy
@@ -22,7 +22,6 @@ package io.kamax.mxisd.controller.v1
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
-import io.kamax.mxisd.api.ThreePidType
import io.kamax.mxisd.lookup.BulkLookupRequest
import io.kamax.mxisd.lookup.SingleLookupRequest
import io.kamax.mxisd.lookup.ThreePidMapping
@@ -58,11 +57,9 @@ class MappingController {
String remote = StringUtils.defaultIfBlank(request.getHeader("X-FORWARDED-FOR"), request.getRemoteAddr())
log.info("Got request from {}", remote)
- ThreePidType type = ThreePidType.valueOf(medium)
-
SingleLookupRequest lookupRequest = new SingleLookupRequest()
lookupRequest.setRequester(remote)
- lookupRequest.setType(type)
+ lookupRequest.setType(medium)
lookupRequest.setThreePid(address)
Optional> lookupOpt = strategy.find(lookupRequest)
diff --git a/src/main/groovy/io/kamax/mxisd/lookup/SingleLookupRequest.groovy b/src/main/groovy/io/kamax/mxisd/lookup/SingleLookupRequest.groovy
index ba256dd..3f36ae6 100644
--- a/src/main/groovy/io/kamax/mxisd/lookup/SingleLookupRequest.groovy
+++ b/src/main/groovy/io/kamax/mxisd/lookup/SingleLookupRequest.groovy
@@ -20,18 +20,16 @@
package io.kamax.mxisd.lookup
-import io.kamax.mxisd.api.ThreePidType
-
class SingleLookupRequest extends ALookupRequest {
- private ThreePidType type
+ private String type
private String threePid
- ThreePidType getType() {
+ String getType() {
return type
}
- void setType(ThreePidType type) {
+ void setType(String type) {
this.type = type
}
diff --git a/src/main/groovy/io/kamax/mxisd/lookup/ThreePidMapping.java b/src/main/groovy/io/kamax/mxisd/lookup/ThreePidMapping.java
index 9d37783..741e56b 100644
--- a/src/main/groovy/io/kamax/mxisd/lookup/ThreePidMapping.java
+++ b/src/main/groovy/io/kamax/mxisd/lookup/ThreePidMapping.java
@@ -74,4 +74,5 @@ public class ThreePidMapping {
public String toString() {
return JsonOutput.toJson(this);
}
+
}
diff --git a/src/main/groovy/io/kamax/mxisd/lookup/provider/DnsLookupProvider.groovy b/src/main/groovy/io/kamax/mxisd/lookup/provider/DnsLookupProvider.groovy
index d8033f7..f373bc1 100644
--- a/src/main/groovy/io/kamax/mxisd/lookup/provider/DnsLookupProvider.groovy
+++ b/src/main/groovy/io/kamax/mxisd/lookup/provider/DnsLookupProvider.groovy
@@ -20,7 +20,6 @@
package io.kamax.mxisd.lookup.provider
-import io.kamax.mxisd.api.ThreePidType
import io.kamax.mxisd.config.ServerConfig
import io.kamax.mxisd.lookup.SingleLookupRequest
import io.kamax.mxisd.lookup.ThreePidMapping
@@ -112,12 +111,13 @@ class DnsLookupProvider extends RemoteIdentityServerProvider {
@Override
Optional> find(SingleLookupRequest request) {
- log.info("Performing DNS lookup for {}", request.getThreePid())
- if (ThreePidType.email != request.getType()) {
+ if (!StringUtils.equals("email", request.getType())) { // TODO use enum
log.info("Skipping unsupported type {} for {}", request.getType(), request.getThreePid())
return Optional.empty()
}
+ log.info("Performing DNS lookup for {}", request.getThreePid())
+
String domain = request.getThreePid().substring(request.getThreePid().lastIndexOf("@") + 1)
log.info("Domain name for {}: {}", request.getThreePid(), domain)
Optional baseUrl = findIdentityServerForDomain(domain)
@@ -134,7 +134,7 @@ class DnsLookupProvider extends RemoteIdentityServerProvider {
Map> domains = new HashMap<>()
for (ThreePidMapping mapping : mappings) {
- if (!StringUtils.equals(mapping.getMedium(), ThreePidType.email.toString())) {
+ if (!StringUtils.equals("email", mapping.getMedium())) {
log.info("Skipping unsupported type {} for {}", mapping.getMedium(), mapping.getValue())
continue
}
diff --git a/src/main/groovy/io/kamax/mxisd/lookup/provider/LdapProvider.groovy b/src/main/groovy/io/kamax/mxisd/lookup/provider/LdapProvider.groovy
index 53e3348..a1e60aa 100644
--- a/src/main/groovy/io/kamax/mxisd/lookup/provider/LdapProvider.groovy
+++ b/src/main/groovy/io/kamax/mxisd/lookup/provider/LdapProvider.groovy
@@ -20,7 +20,6 @@
package io.kamax.mxisd.lookup.provider
-import io.kamax.mxisd.api.ThreePidType
import io.kamax.mxisd.config.LdapConfig
import io.kamax.mxisd.config.ServerConfig
import io.kamax.mxisd.lookup.SingleLookupRequest
@@ -61,7 +60,7 @@ class LdapProvider implements ThreePidProvider {
return 20
}
- Optional lookup(LdapConnection conn, ThreePidType medium, String value) {
+ Optional lookup(LdapConnection conn, String medium, String value) {
Optional queryOpt = ldapCfg.getMapping(medium)
if (!queryOpt.isPresent()) {
log.warn("{} is not a supported 3PID type for LDAP lookup", medium)
@@ -142,8 +141,7 @@ class LdapProvider implements ThreePidProvider {
for (ThreePidMapping mapping : mappings) {
try {
- ThreePidType type = ThreePidType.valueOf(mapping.getMedium())
- Optional mxid = lookup(conn, type, mapping.getValue())
+ Optional mxid = lookup(conn, mapping.getMedium(), mapping.getValue())
if (mxid.isPresent()) {
mapping.setMxid(mxid.get())
mappingsFound.add(mapping)
diff --git a/src/main/groovy/io/kamax/mxisd/lookup/provider/RemoteIdentityServerProvider.groovy b/src/main/groovy/io/kamax/mxisd/lookup/provider/RemoteIdentityServerProvider.groovy
index abcee20..46da9b1 100644
--- a/src/main/groovy/io/kamax/mxisd/lookup/provider/RemoteIdentityServerProvider.groovy
+++ b/src/main/groovy/io/kamax/mxisd/lookup/provider/RemoteIdentityServerProvider.groovy
@@ -23,7 +23,6 @@ package io.kamax.mxisd.lookup.provider
import groovy.json.JsonException
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
-import io.kamax.mxisd.api.ThreePidType
import io.kamax.mxisd.controller.v1.ClientBulkLookupRequest
import io.kamax.mxisd.lookup.ThreePidMapping
import org.apache.http.HttpEntity
@@ -94,7 +93,7 @@ abstract class RemoteIdentityServerProvider implements ThreePidProvider {
return Optional.empty()
}
- Optional> find(String remote, ThreePidType type, String threePid) {
+ Optional> find(String remote, String type, String threePid) {
log.info("Looking up {} 3PID {} using {}", type, threePid, remote)
HttpURLConnection rootSrvConn = (HttpURLConnection) new URL(