Skip to content

Commit

Permalink
Add BootstrapSession param to BootstrapConfigStore.get()
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Aug 9, 2019
1 parent 831ad40 commit 3516342
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public SecurityInfo getByIdentity(String identity) {
@Override
public List<SecurityInfo> getAllByEndpoint(String endpoint) {

BootstrapConfig bsConfig = bootstrapConfigStore.get(endpoint, null);
BootstrapConfig bsConfig = bootstrapConfigStore.get(endpoint, null, null);

if (bsConfig == null || bsConfig.security == null)
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.eclipse.leshan.server.bootstrap.BootstrapConfig.ServerConfig;
import org.eclipse.leshan.server.bootstrap.BootstrapConfig.ServerSecurity;
import org.eclipse.leshan.server.bootstrap.BootstrapConfigStore;
import org.eclipse.leshan.server.bootstrap.BootstrapSession;
import org.eclipse.leshan.server.californium.LeshanBootstrapServerBuilder;
import org.eclipse.leshan.server.californium.impl.LeshanBootstrapServer;
import org.eclipse.leshan.server.security.BootstrapSecurityStore;
Expand Down Expand Up @@ -233,7 +234,7 @@ public BootstrapConfigStore unsecuredBootstrapStore() {
return new BootstrapConfigStore() {

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

BootstrapConfig bsConfig = new BootstrapConfig();

Expand Down Expand Up @@ -277,7 +278,7 @@ public BootstrapConfigStore deleteSecurityStore(final String... pathToDelete) {
return new BootstrapConfigStore() {

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

BootstrapConfig bsConfig = new BootstrapConfig();
bsConfig.toDelete = Arrays.asList(pathToDelete);
Expand All @@ -290,7 +291,7 @@ public BootstrapConfigStore unsecuredWithAclBootstrapStore() {
return new BootstrapConfigStore() {

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

BootstrapConfig bsConfig = new BootstrapConfig();

Expand Down Expand Up @@ -341,7 +342,7 @@ public BootstrapConfigStore pskBootstrapStore() {
return new BootstrapConfigStore() {

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

BootstrapConfig bsConfig = new BootstrapConfig();

Expand Down Expand Up @@ -378,7 +379,7 @@ public BootstrapConfigStore rpkBootstrapStore() {
return new BootstrapConfigStore() {

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

BootstrapConfig bsConfig = new BootstrapConfig();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.leshan.core.request.Identity;
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.californium.impl.LeshanBootstrapServer;
import org.eclipse.leshan.server.security.BootstrapSecurityStore;
import org.eclipse.leshan.server.security.SecurityInfo;
Expand All @@ -38,7 +39,7 @@ public void start() {
builder = new LeshanBootstrapServerBuilder();
builder.setConfigStore(new BootstrapConfigStore() {
@Override
public BootstrapConfig get(String endpoint, Identity deviceIdentity) {
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 @@ -27,7 +27,8 @@ public interface BootstrapConfigStore {
*
* @param endpoint the endpoint of the device.
* @param deviceIdentity the {@link Identity} the device.
* @param session the current {@link BootstrapSession}.
* @return the {@link BootstrapConfig} to apply.
*/
BootstrapConfig get(String endpoint, Identity deviceIdentity);
BootstrapConfig get(String endpoint, Identity deviceIdentity, BootstrapSession session);
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public SendableResponse<BootstrapResponse> bootstrap(Identity sender, BootstrapR

try {
// Get the desired bootstrap config for the endpoint
final BootstrapConfig cfg = store.get(endpoint, sender);
final BootstrapConfig cfg = store.get(endpoint, sender, session);
if (cfg == null) {
LOG.debug("No bootstrap config for {}", session);
stopSession(session, NO_BOOTSTRAP_CONFIG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class InMemoryBootstrapConfigStore implements EditableBootstrapConfigStor
protected final Map<String, BootstrapConfig> bootstrapByEndpoint = new ConcurrentHashMap<>();

@Override
public BootstrapConfig get(String endpoint, Identity deviceIdentity) {
public BootstrapConfig get(String endpoint, Identity deviceIdentity, BootstrapSession session) {
return bootstrapByEndpoint.get(endpoint);
}

Expand Down

0 comments on commit 3516342

Please sign in to comment.