diff --git a/leshan-client-cf/src/main/java/org/eclipse/leshan/client/californium/impl/CaliforniumEndpointsManager.java b/leshan-client-cf/src/main/java/org/eclipse/leshan/client/californium/impl/CaliforniumEndpointsManager.java index 7892c860a9..858cbefdeb 100644 --- a/leshan-client-cf/src/main/java/org/eclipse/leshan/client/californium/impl/CaliforniumEndpointsManager.java +++ b/leshan-client-cf/src/main/java/org/eclipse/leshan/client/californium/impl/CaliforniumEndpointsManager.java @@ -27,7 +27,6 @@ import org.eclipse.californium.core.network.config.NetworkConfig; import org.eclipse.californium.elements.auth.RawPublicKeyIdentity; import org.eclipse.californium.scandium.DTLSConnector; -import org.eclipse.californium.scandium.config.DtlsConnectorConfig; import org.eclipse.californium.scandium.config.DtlsConnectorConfig.Builder; import org.eclipse.californium.scandium.dtls.pskstore.StaticPskStore; import org.eclipse.californium.scandium.dtls.rpkstore.TrustedRpkStore; @@ -73,7 +72,7 @@ public synchronized Identity createEndpoint(ServerInfo serverInfo) { // Create new endpoint Identity server; if (serverInfo.isSecure()) { - Builder newBuilder = cloneDtlsConfigBuilder(dtlsConfigbuilder); + Builder newBuilder = new Builder(dtlsConfigbuilder.getIncompleteConfig()); // Support PSK if (serverInfo.secureMode == SecurityMode.PSK) { @@ -140,43 +139,6 @@ public boolean isTrusted(RawPublicKeyIdentity id) { return server; } - public static Builder cloneDtlsConfigBuilder(Builder builder) { - return cloneDtlsConfigBuilder(builder.getIncompleteConfig()); - } - - public static Builder cloneDtlsConfigBuilder(DtlsConnectorConfig config) { - Builder newBuilder = new Builder(); - - newBuilder.setAddress(config.getAddress()); - newBuilder.setMaxConnections(config.getMaxConnections()); - newBuilder.setStaleConnectionThreshold(config.getStaleConnectionThreshold()); - newBuilder.setConnectionThreadCount(config.getConnectionThreadCount()); - - if (config.getPskStore() != null) - newBuilder.setPskStore(config.getPskStore()); - if (config.isAddressReuseEnabled() != null) - newBuilder.setEnableAddressReuse(config.isAddressReuseEnabled()); - if (config.isClientAuthenticationRequired() != null) - newBuilder.setClientAuthenticationRequired(config.isClientAuthenticationRequired()); - if (config.isEarlyStopRetransmission() != null) - newBuilder.setEarlyStopRetransmission(config.isEarlyStopRetransmission()); - if (config.getMaxFragmentLengthCode() != null) - newBuilder.setMaxFragmentLengthCode(config.getMaxFragmentLengthCode()); - if (config.getMaxRetransmissions() != null) - newBuilder.setMaxRetransmissions(config.getMaxRetransmissions()); - if (config.getOutboundMessageBufferSize() != null) - newBuilder.setOutboundMessageBufferSize(config.getOutboundMessageBufferSize()); - if (config.getRetransmissionTimeout() != null) - newBuilder.setRetransmissionTimeout(config.getRetransmissionTimeout()); - if (config.getTrustStore() != null) - newBuilder.setTrustStore(config.getTrustStore()); - - // TODO we should probably clean cipherSuite depending on which kind of endpoint(psk,rpk,x509) we will create - // in case users choose specific cipher - - return newBuilder; - } - @Override public synchronized Collection createEndpoints(Collection serverInfo) { if (serverInfo == null || serverInfo.isEmpty()) diff --git a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/SecureIntegrationTestHelper.java b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/SecureIntegrationTestHelper.java index 723eafb3a6..c55360e0e1 100644 --- a/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/SecureIntegrationTestHelper.java +++ b/leshan-integration-tests/src/test/java/org/eclipse/leshan/integration/tests/SecureIntegrationTestHelper.java @@ -47,7 +47,6 @@ import org.eclipse.californium.scandium.config.DtlsConnectorConfig.Builder; import org.eclipse.leshan.LwM2mId; import org.eclipse.leshan.client.californium.LeshanClientBuilder; -import org.eclipse.leshan.client.californium.impl.CaliforniumEndpointsManager; import org.eclipse.leshan.client.object.Device; import org.eclipse.leshan.client.object.Security; import org.eclipse.leshan.client.object.Server; @@ -200,7 +199,7 @@ public CoapEndpoint createUnsecuredEndpoint(InetSocketAddress address, NetworkCo public CoapEndpoint createSecuredEndpoint(DtlsConnectorConfig dtlsConfig, NetworkConfig coapConfig, ObservationStore store) { CoapEndpoint.CoapEndpointBuilder builder = new CoapEndpoint.CoapEndpointBuilder(); - Builder dtlsConfigBuilder = CaliforniumEndpointsManager.cloneDtlsConfigBuilder(dtlsConfig); + Builder dtlsConfigBuilder = new Builder(dtlsConfig); if (dtlsConfig.getPskStore() != null) { String identity = dtlsConfig.getPskStore().getIdentity(null); byte[] key = dtlsConfig.getPskStore().getKey(null);