Skip to content

Commit

Permalink
#1027: remove BootstrapConfiguration added by #883
Browse files Browse the repository at this point in the history
After more thoughts, we decide that this was not the good approach. See
#437 (comment) for
more details.

Consequences BootstrapConfig is no more deprecated.
  • Loading branch information
sbernard31 committed Jun 25, 2021
1 parent 4187e01 commit f68537d
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 290 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.eclipse.leshan.core.model.ObjectModel;
import org.eclipse.leshan.core.model.StaticModel;
import org.eclipse.leshan.core.util.SecurityUtil;
import org.eclipse.leshan.server.bootstrap.BootstrapConfigurationStoreAdapter;
import org.eclipse.leshan.server.bootstrap.demo.servlet.BootstrapServlet;
import org.eclipse.leshan.server.bootstrap.demo.servlet.ServerServlet;
import org.eclipse.leshan.server.californium.LeshanServerBuilder;
Expand Down Expand Up @@ -357,7 +356,7 @@ public static void createAndStartServer(String webAddress, int webPort, String l
// Prepare and start bootstrap server
LeshanBootstrapServerBuilder builder = new LeshanBootstrapServerBuilder();
JSONFileBootstrapStore bsStore = new JSONFileBootstrapStore(configFilename);
builder.setConfigStore(new BootstrapConfigurationStoreAdapter(bsStore));
builder.setConfigStore(bsStore);
builder.setSecurityStore(new BootstrapConfigSecurityStore(bsStore));
builder.setModel(new StaticModel(models));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@
import org.eclipse.leshan.server.bootstrap.BootstrapConfig.ACLConfig;
import org.eclipse.leshan.server.bootstrap.BootstrapConfig.ServerConfig;
import org.eclipse.leshan.server.bootstrap.BootstrapConfig.ServerSecurity;
import org.eclipse.leshan.server.bootstrap.BootstrapConfiguration;
import org.eclipse.leshan.server.bootstrap.BootstrapConfigurationStore;
import org.eclipse.leshan.server.bootstrap.BootstrapConfigStore;
import org.eclipse.leshan.server.bootstrap.BootstrapFailureCause;
import org.eclipse.leshan.server.bootstrap.BootstrapHandler;
import org.eclipse.leshan.server.bootstrap.BootstrapHandlerFactory;
import org.eclipse.leshan.server.bootstrap.BootstrapSession;
import org.eclipse.leshan.server.bootstrap.BootstrapSessionManager;
import org.eclipse.leshan.server.bootstrap.BootstrapUtil;
import org.eclipse.leshan.server.bootstrap.DefaultBootstrapHandler;
import org.eclipse.leshan.server.bootstrap.DefaultBootstrapSession;
import org.eclipse.leshan.server.bootstrap.DefaultBootstrapSessionManager;
Expand Down Expand Up @@ -123,7 +121,7 @@ public BootstrapIntegrationTestHelper() {
}

private LeshanBootstrapServerBuilder createBootstrapBuilder(BootstrapSecurityStore securityStore,
BootstrapConfigurationStore bootstrapStore) {
BootstrapConfigStore bootstrapStore) {
if (bootstrapStore == null) {
bootstrapStore = unsecuredBootstrapStore();
}
Expand Down Expand Up @@ -156,12 +154,11 @@ public void end(BootstrapSession bsSession) {
return builder;
}

public void createBootstrapServer(BootstrapSecurityStore securityStore,
BootstrapConfigurationStore bootstrapStore) {
public void createBootstrapServer(BootstrapSecurityStore securityStore, BootstrapConfigStore bootstrapStore) {
bootstrapServer = createBootstrapBuilder(securityStore, bootstrapStore).build();
}

public void createBootstrapServer(BootstrapSecurityStore securityStore, BootstrapConfigurationStore bootstrapStore,
public void createBootstrapServer(BootstrapSecurityStore securityStore, BootstrapConfigStore bootstrapStore,
final BootstrapDiscoverRequest request) {
LeshanBootstrapServerBuilder builder = createBootstrapBuilder(securityStore, bootstrapStore);

Expand Down Expand Up @@ -344,11 +341,11 @@ public Iterator<SecurityInfo> getAllByEndpoint(String endpoint) {
};
}

public BootstrapConfigurationStore unsecuredBootstrapStore() {
return new BootstrapConfigurationStore() {
public BootstrapConfigStore unsecuredBootstrapStore() {
return new BootstrapConfigStore() {

@Override
public BootstrapConfiguration get(String endpoint, Identity deviceIdentity, BootstrapSession session) {
public BootstrapConfig get(String endpoint, Identity deviceIdentity, BootstrapSession session) {

BootstrapConfig bsConfig = new BootstrapConfig();

Expand All @@ -373,12 +370,12 @@ public BootstrapConfiguration get(String endpoint, Identity deviceIdentity, Boot
dmConfig.shortId = 2222;
bsConfig.servers.put(0, dmConfig);

return new BootstrapConfiguration(BootstrapUtil.toRequests(bsConfig, session.getContentFormat()));
return bsConfig;
}
};
}

public BootstrapConfigurationStore deleteSecurityStore(Integer... objectToDelete) {
public BootstrapConfigStore deleteSecurityStore(Integer... objectToDelete) {
String[] pathToDelete = new String[objectToDelete.length];
for (int i = 0; i < pathToDelete.length; i++) {
pathToDelete[i] = "/" + objectToDelete[i];
Expand All @@ -387,24 +384,24 @@ public BootstrapConfigurationStore deleteSecurityStore(Integer... objectToDelete
return deleteSecurityStore(pathToDelete);
}

public BootstrapConfigurationStore deleteSecurityStore(final String... pathToDelete) {
return new BootstrapConfigurationStore() {
public BootstrapConfigStore deleteSecurityStore(final String... pathToDelete) {
return new BootstrapConfigStore() {

@Override
public BootstrapConfiguration get(String endpoint, Identity deviceIdentity, BootstrapSession session) {
public BootstrapConfig get(String endpoint, Identity deviceIdentity, BootstrapSession session) {

BootstrapConfig bsConfig = new BootstrapConfig();
bsConfig.toDelete = Arrays.asList(pathToDelete);
return new BootstrapConfiguration(BootstrapUtil.toRequests(bsConfig, session.getContentFormat()));
return bsConfig;
}
};
}

public BootstrapConfigurationStore unsecuredWithAclBootstrapStore() {
return new BootstrapConfigurationStore() {
public BootstrapConfigStore unsecuredWithAclBootstrapStore() {
return new BootstrapConfigStore() {

@Override
public BootstrapConfiguration get(String endpoint, Identity deviceIdentity, BootstrapSession session) {
public BootstrapConfig get(String endpoint, Identity deviceIdentity, BootstrapSession session) {

BootstrapConfig bsConfig = new BootstrapConfig();

Expand Down Expand Up @@ -445,16 +442,16 @@ public BootstrapConfiguration get(String endpoint, Identity deviceIdentity, Boot
aclConfig.AccessControlOwner = 2222;
bsConfig.acls.put(1, aclConfig);

return new BootstrapConfiguration(BootstrapUtil.toRequests(bsConfig));
return bsConfig;
}
};
}

public BootstrapConfigurationStore pskBootstrapStore() {
return new BootstrapConfigurationStore() {
public BootstrapConfigStore pskBootstrapStore() {
return new BootstrapConfigStore() {

@Override
public BootstrapConfiguration get(String endpoint, Identity deviceIdentity, BootstrapSession session) {
public BootstrapConfig get(String endpoint, Identity deviceIdentity, BootstrapSession session) {

BootstrapConfig bsConfig = new BootstrapConfig();

Expand All @@ -481,16 +478,16 @@ public BootstrapConfiguration get(String endpoint, Identity deviceIdentity, Boot
dmConfig.shortId = 2222;
bsConfig.servers.put(0, dmConfig);

return new BootstrapConfiguration(BootstrapUtil.toRequests(bsConfig, session.getContentFormat()));
return bsConfig;
}
};
}

public BootstrapConfigurationStore rpkBootstrapStore() {
return new BootstrapConfigurationStore() {
public BootstrapConfigStore rpkBootstrapStore() {
return new BootstrapConfigStore() {

@Override
public BootstrapConfiguration get(String endpoint, Identity deviceIdentity, BootstrapSession session) {
public BootstrapConfig get(String endpoint, Identity deviceIdentity, BootstrapSession session) {

BootstrapConfig bsConfig = new BootstrapConfig();

Expand Down Expand Up @@ -518,7 +515,7 @@ public BootstrapConfiguration get(String endpoint, Identity deviceIdentity, Boot
dmConfig.shortId = 2222;
bsConfig.servers.put(0, dmConfig);

return new BootstrapConfiguration(BootstrapUtil.toRequests(bsConfig, session.getContentFormat()));
return bsConfig;
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.eclipse.leshan.core.node.codec.LwM2mNodeDecoder;
import org.eclipse.leshan.core.node.codec.LwM2mNodeEncoder;
import org.eclipse.leshan.core.util.Validate;
import org.eclipse.leshan.server.bootstrap.BootstrapConfigurationStore;
import org.eclipse.leshan.server.bootstrap.BootstrapConfigStore;
import org.eclipse.leshan.server.bootstrap.BootstrapHandler;
import org.eclipse.leshan.server.bootstrap.BootstrapHandlerFactory;
import org.eclipse.leshan.server.bootstrap.BootstrapSessionManager;
Expand All @@ -54,7 +54,7 @@ public class LeshanBootstrapServer {
private final CoapEndpoint securedEndpoint;

// LWM2M attributes
private final BootstrapConfigurationStore bsStore;
private final BootstrapConfigStore bsStore;
private final BootstrapSecurityStore bsSecurityStore;

private LwM2mBootstrapRequestSender requestSender;
Expand All @@ -76,7 +76,7 @@ public class LeshanBootstrapServer {
* @param decoder decoder used to decode response payload.
*/
public LeshanBootstrapServer(CoapEndpoint unsecuredEndpoint, CoapEndpoint securedEndpoint,
BootstrapConfigurationStore bsStore, BootstrapSecurityStore bsSecurityStore,
BootstrapConfigStore bsStore, BootstrapSecurityStore bsSecurityStore,
BootstrapSessionManager bsSessionManager, BootstrapHandlerFactory bsHandlerFactory, LwM2mModel model,
NetworkConfig coapConfig, LwM2mNodeEncoder encoder, LwM2mNodeDecoder decoder) {

Expand Down Expand Up @@ -140,9 +140,9 @@ public BootstrapSecurityStore getBootstrapSecurityStore() {
* Access to the bootstrap configuration store. It's used for sending configuration to the devices initiating a
* bootstrap.
*
* @return the {@link BootstrapConfigurationStore} containing configuration to apply to each devices.
* @return the {@link BootstrapConfigStore} containing configuration to apply to each devices.
*/
public BootstrapConfigurationStore getBoostrapStore() {
public BootstrapConfigStore getBoostrapStore() {
return bsStore;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@
import org.eclipse.leshan.core.node.codec.LwM2mNodeDecoder;
import org.eclipse.leshan.core.node.codec.LwM2mNodeEncoder;
import org.eclipse.leshan.server.bootstrap.BootstrapConfig;
import org.eclipse.leshan.server.bootstrap.BootstrapConfigurationStore;
import org.eclipse.leshan.server.bootstrap.BootstrapConfigurationStoreAdapter;
import org.eclipse.leshan.server.bootstrap.BootstrapConfigStore;
import org.eclipse.leshan.server.bootstrap.BootstrapHandler;
import org.eclipse.leshan.server.bootstrap.BootstrapHandlerFactory;
import org.eclipse.leshan.server.bootstrap.BootstrapSessionManager;
import org.eclipse.leshan.server.bootstrap.DefaultBootstrapHandler;
import org.eclipse.leshan.server.bootstrap.DefaultBootstrapSessionManager;
import org.eclipse.leshan.server.bootstrap.InMemoryBootstrapConfigurationStore;
import org.eclipse.leshan.server.bootstrap.InMemoryBootstrapConfigStore;
import org.eclipse.leshan.server.bootstrap.LwM2mBootstrapRequestSender;
import org.eclipse.leshan.server.security.BootstrapSecurityStore;
import org.slf4j.Logger;
Expand All @@ -69,7 +68,7 @@ public class LeshanBootstrapServerBuilder {

private InetSocketAddress localAddress;
private InetSocketAddress localAddressSecure;
private BootstrapConfigurationStore configStore;
private BootstrapConfigStore configStore;
private BootstrapSecurityStore securityStore;
private BootstrapSessionManager sessionManager;
private BootstrapHandlerFactory bootstrapHandlerFactory;
Expand Down Expand Up @@ -220,18 +219,17 @@ public <T extends Certificate> LeshanBootstrapServerBuilder setTrustedCertificat
}

/**
* Set the {@link BootstrapConfigurationStore} containing bootstrap configuration to apply to each devices.
* Set the {@link BootstrapConfigStore} containing bootstrap configuration to apply to each devices.
* <p>
* By default an {@link InMemoryBootstrapConfigurationStore} is used.
* By default an {@link InMemoryBootstrapConfigStore} is used.
* <p>
* See {@link BootstrapConfig} to see what is could be done during a bootstrap session.
*
* @param configStore the bootstrap configuration store.
* @return the builder for fluent Bootstrap Server creation.
*
* @see BootstrapConfigurationStoreAdapter
*/
public LeshanBootstrapServerBuilder setConfigStore(BootstrapConfigurationStore configStore) {
public LeshanBootstrapServerBuilder setConfigStore(BootstrapConfigStore configStore) {
this.configStore = configStore;
return this;
}
Expand Down Expand Up @@ -403,7 +401,7 @@ public LeshanBootstrapServer build() {
if (localAddress == null)
localAddress = new InetSocketAddress(LwM2m.DEFAULT_COAP_PORT);
if (configStore == null)
configStore = new InMemoryBootstrapConfigurationStore();
configStore = new InMemoryBootstrapConfigStore();

if (sessionManager == null)
sessionManager = new DefaultBootstrapSessionManager(securityStore, configStore);
Expand Down Expand Up @@ -597,7 +595,7 @@ protected boolean shouldTryToCreateSecureEndpoint() {
* @return the LWM2M Bootstrap server.
*/
protected LeshanBootstrapServer createBootstrapServer(CoapEndpoint unsecuredEndpoint, CoapEndpoint securedEndpoint,
BootstrapConfigurationStore bsStore, BootstrapSecurityStore bsSecurityStore,
BootstrapConfigStore bsStore, BootstrapSecurityStore bsSecurityStore,
BootstrapSessionManager bsSessionManager, BootstrapHandlerFactory bsHandlerFactory, LwM2mModel model,
NetworkConfig coapConfig, LwM2mNodeEncoder encoder, LwM2mNodeDecoder decoder) {
return new LeshanBootstrapServer(unsecuredEndpoint, securedEndpoint, bsStore, bsSecurityStore, bsSessionManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import java.util.Iterator;

import org.eclipse.leshan.core.request.Identity;
import org.eclipse.leshan.server.bootstrap.BootstrapConfiguration;
import org.eclipse.leshan.server.bootstrap.BootstrapConfigurationStore;
import org.eclipse.leshan.server.bootstrap.BootstrapConfig;
import org.eclipse.leshan.server.bootstrap.BootstrapConfigStore;
import org.eclipse.leshan.server.bootstrap.BootstrapSession;
import org.eclipse.leshan.server.security.BootstrapSecurityStore;
import org.eclipse.leshan.server.security.SecurityInfo;
Expand All @@ -36,10 +36,10 @@ public class LeshanBootstrapServerBuilderTest {
@Before
public void start() {
builder = new LeshanBootstrapServerBuilder();
builder.setConfigStore(new BootstrapConfigurationStore() {
builder.setConfigStore(new BootstrapConfigStore() {

@Override
public BootstrapConfiguration get(String endpoint, Identity deviceIdentity, BootstrapSession session) {
public BootstrapConfig get(String endpoint, Identity deviceIdentity, BootstrapSession session) {
return null;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@

import java.net.InetSocketAddress;

import org.eclipse.leshan.core.request.BootstrapDeleteRequest;
import org.eclipse.leshan.core.request.BootstrapRequest;
import org.eclipse.leshan.core.request.Identity;
import org.eclipse.leshan.core.response.BootstrapResponse;
import org.eclipse.leshan.core.response.SendableResponse;
import org.eclipse.leshan.server.bootstrap.BootstrapConfiguration;
import org.eclipse.leshan.server.bootstrap.BootstrapConfigurationStore;
import org.eclipse.leshan.server.bootstrap.BootstrapConfig;
import org.eclipse.leshan.server.bootstrap.BootstrapConfigStore;
import org.eclipse.leshan.server.bootstrap.BootstrapHandler;
import org.eclipse.leshan.server.bootstrap.BootstrapHandlerFactory;
import org.eclipse.leshan.server.bootstrap.BootstrapSession;
Expand All @@ -49,11 +48,13 @@ public BootstrapHandler create(LwM2mBootstrapRequestSender sender, BootstrapSess
return bsHandler;
}
});
builder.setConfigStore(new BootstrapConfigurationStore() {
builder.setConfigStore(new BootstrapConfigStore() {

@Override
public BootstrapConfiguration get(String endpoint, Identity deviceIdentity, BootstrapSession session) {
return new BootstrapConfiguration(new BootstrapDeleteRequest());
public BootstrapConfig get(String endpoint, Identity deviceIdentity, BootstrapSession session) {
BootstrapConfig config = new BootstrapConfig();
config.toDelete.add("/");
return config;
}
});
return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
/**
* A store containing the bootstrap information to be sent to the devices.
*
* @deprecated use {@link BootstrapConfigurationStore} instead or see {@link BootstrapConfigurationStoreAdapter} or
* {@link BootstrapUtil#toRequests(BootstrapConfig, org.eclipse.leshan.core.request.ContentFormat)}
*/
@Deprecated
public interface BootstrapConfigStore {

/**
Expand Down

This file was deleted.

Loading

0 comments on commit f68537d

Please sign in to comment.