Continue structural port from Spring Boot to Undertow
This commit is contained in:
@@ -25,6 +25,7 @@ import io.kamax.mxisd.lookup.SingleLookupReply;
|
||||
import io.kamax.mxisd.lookup.SingleLookupRequest;
|
||||
import io.kamax.mxisd.lookup.ThreePidMapping;
|
||||
import io.kamax.mxisd.lookup.fetcher.IBridgeFetcher;
|
||||
import io.kamax.mxisd.lookup.fetcher.IRemoteIdentityServerFetcher;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -38,9 +39,9 @@ public class BridgeFetcher implements IBridgeFetcher {
|
||||
private transient final Logger log = LoggerFactory.getLogger(BridgeFetcher.class);
|
||||
|
||||
private RecursiveLookupBridgeConfig cfg;
|
||||
private RemoteIdentityServerFetcher fetcher;
|
||||
private IRemoteIdentityServerFetcher fetcher;
|
||||
|
||||
public BridgeFetcher(RecursiveLookupBridgeConfig cfg, RemoteIdentityServerFetcher fetcher) {
|
||||
public BridgeFetcher(RecursiveLookupBridgeConfig cfg, IRemoteIdentityServerFetcher fetcher) {
|
||||
this.cfg = cfg;
|
||||
this.fetcher = fetcher;
|
||||
}
|
||||
|
||||
@@ -47,11 +47,6 @@ class DnsLookupProvider implements IThreePidProvider {
|
||||
this.fetcher = fetcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocal() {
|
||||
return false;
|
||||
|
||||
@@ -22,6 +22,7 @@ package io.kamax.mxisd.lookup.provider;
|
||||
|
||||
import io.kamax.mxisd.config.ForwardConfig;
|
||||
import io.kamax.mxisd.config.MatrixConfig;
|
||||
import io.kamax.mxisd.config.MxisdConfig;
|
||||
import io.kamax.mxisd.lookup.SingleLookupReply;
|
||||
import io.kamax.mxisd.lookup.SingleLookupRequest;
|
||||
import io.kamax.mxisd.lookup.ThreePidMapping;
|
||||
@@ -41,17 +42,16 @@ public class ForwarderProvider implements IThreePidProvider {
|
||||
private MatrixConfig mxCfg;
|
||||
private IRemoteIdentityServerFetcher fetcher;
|
||||
|
||||
public ForwarderProvider(MxisdConfig cfg, IRemoteIdentityServerFetcher fetcher) {
|
||||
this(cfg.getForward(), cfg.getMatrix(), fetcher);
|
||||
}
|
||||
|
||||
public ForwarderProvider(ForwardConfig cfg, MatrixConfig mxCfg, IRemoteIdentityServerFetcher fetcher) {
|
||||
this.cfg = cfg;
|
||||
this.mxCfg = mxCfg;
|
||||
this.fetcher = fetcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocal() {
|
||||
return false;
|
||||
|
||||
@@ -29,8 +29,6 @@ import java.util.Optional;
|
||||
|
||||
public interface IThreePidProvider {
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
boolean isLocal();
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* mxisd - Matrix Identity Server Daemon
|
||||
* Copyright (C) 2018 Kamax Sarl
|
||||
*
|
||||
* 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.lookup.provider;
|
||||
|
||||
import io.kamax.mxisd.Mxisd;
|
||||
import io.kamax.mxisd.backend.IdentityStoreSupplier;
|
||||
import io.kamax.mxisd.lookup.ThreePidProviders;
|
||||
|
||||
public class RemoteLookupProviderSupplier implements IdentityStoreSupplier {
|
||||
|
||||
@Override
|
||||
public void accept(Mxisd mxisd) {
|
||||
ThreePidProviders.register(() -> new DnsLookupProvider(mxisd.getConfig().getMatrix(), mxisd.getServerFetcher()));
|
||||
ThreePidProviders.register(() -> new ForwarderProvider(mxisd.getConfig(), mxisd.getServerFetcher()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,10 +49,7 @@ public class RecursivePriorityLookupStrategy implements LookupStrategy {
|
||||
public RecursivePriorityLookupStrategy(MxisdConfig.Lookup cfg, List<? extends IThreePidProvider> providers, IBridgeFetcher bridge) {
|
||||
this.cfg = cfg;
|
||||
this.bridge = bridge;
|
||||
this.providers = providers.stream().filter(p -> {
|
||||
log.info("3PID Provider {} is enabled: {}", p.getClass().getSimpleName(), p.isEnabled());
|
||||
return p.isEnabled();
|
||||
}).collect(Collectors.toList());
|
||||
this.providers = new ArrayList<>(providers);
|
||||
|
||||
try {
|
||||
log.info("Found {} providers", providers.size());
|
||||
@@ -114,11 +111,11 @@ public class RecursivePriorityLookupStrategy implements LookupStrategy {
|
||||
|
||||
@Override
|
||||
public List<IThreePidProvider> getLocalProviders() {
|
||||
return providers.stream().filter(iThreePidProvider -> iThreePidProvider.isEnabled() && iThreePidProvider.isLocal()).collect(Collectors.toList());
|
||||
return providers.stream().filter(IThreePidProvider::isLocal).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<IThreePidProvider> getRemoteProviders() {
|
||||
return providers.stream().filter(iThreePidProvider -> iThreePidProvider.isEnabled() && !iThreePidProvider.isLocal()).collect(Collectors.toList());
|
||||
return providers.stream().filter(iThreePidProvider -> !iThreePidProvider.isLocal()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static SingleLookupRequest build(String medium, String address) {
|
||||
|
||||
Reference in New Issue
Block a user