|
@@ -36,6 +36,11 @@ |
|
|
import org.eclipse.leshan.core.californium.EndpointFactory; |
|
|
import org.eclipse.leshan.core.model.LwM2mModel; |
|
|
import org.eclipse.leshan.core.model.ObjectLoader; |
|
|
import org.eclipse.leshan.core.node.LwM2mNode; |
|
|
import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeDecoder; |
|
|
import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeEncoder; |
|
|
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.BootstrapConfigStore; |
|
|
import org.eclipse.leshan.server.bootstrap.BootstrapHandler; |
|
@@ -72,6 +77,9 @@ |
|
|
private NetworkConfig coapConfig; |
|
|
private Builder dtlsConfigBuilder; |
|
|
|
|
|
private LwM2mNodeEncoder encoder; |
|
|
private LwM2mNodeDecoder decoder; |
|
|
|
|
|
private PublicKey publicKey; |
|
|
private PrivateKey privateKey; |
|
|
private X509Certificate[] certificateChain; |
|
@@ -292,6 +300,28 @@ public LeshanBootstrapServerBuilder setModel(LwM2mModel model) { |
|
|
return this; |
|
|
} |
|
|
|
|
|
/** |
|
|
* <p> |
|
|
* Set the {@link LwM2mNodeEncoder} which will encode {@link LwM2mNode} with supported content format. |
|
|
* </p> |
|
|
* By default the {@link DefaultLwM2mNodeEncoder} is used. It supports Text, Opaque, TLV and JSON format. |
|
|
*/ |
|
|
public LeshanBootstrapServerBuilder setEncoder(LwM2mNodeEncoder encoder) { |
|
|
this.encoder = encoder; |
|
|
return this; |
|
|
} |
|
|
|
|
|
/** |
|
|
* <p> |
|
|
* Set the {@link LwM2mNodeDecoder} which will decode data in supported content format to create {@link LwM2mNode}. |
|
|
* </p> |
|
|
* By default the {@link DefaultLwM2mNodeDecoder} is used. It supports Text, Opaque, TLV and JSON format. |
|
|
*/ |
|
|
public LeshanBootstrapServerBuilder setDecoder(LwM2mNodeDecoder decoder) { |
|
|
this.decoder = decoder; |
|
|
return this; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Set the CoAP/Californium {@link NetworkConfig}. |
|
|
* <p> |
|
@@ -398,6 +428,10 @@ public BootstrapHandler create(BootstrapConfigStore store, LwM2mBootstrapRequest |
|
|
if (endpointFactory == null) { |
|
|
endpointFactory = new DefaultEndpointFactory(); |
|
|
} |
|
|
if (encoder == null) |
|
|
encoder = new DefaultLwM2mNodeEncoder(); |
|
|
if (decoder == null) |
|
|
decoder = new DefaultLwM2mNodeDecoder(); |
|
|
|
|
|
// handle dtlsConfig |
|
|
DtlsConnectorConfig dtlsConfig = null; |
|
@@ -525,7 +559,7 @@ public BootstrapHandler create(BootstrapConfigStore store, LwM2mBootstrapRequest |
|
|
} |
|
|
|
|
|
return createBootstrapServer(unsecuredEndpoint, securedEndpoint, configStore, securityStore, sessionManager, |
|
|
bootstrapHandlerFactory, model, coapConfig); |
|
|
bootstrapHandlerFactory, model, coapConfig, encoder, decoder); |
|
|
} |
|
|
|
|
|
/** |
|
@@ -550,13 +584,15 @@ protected boolean shouldTryToCreateSecureEndpoint() { |
|
|
* @param bsHandlerFactory the factory used to create {@link BootstrapHandler}. |
|
|
* @param model the LWM2M model used mainly used for data encoding. |
|
|
* @param coapConfig the CoAP configuration. |
|
|
* @param decoder decoder used to decode response payload. |
|
|
* @param encoder encode used to encode request payload. |
|
|
* @return the LWM2M Bootstrap server. |
|
|
*/ |
|
|
protected LeshanBootstrapServer createBootstrapServer(CoapEndpoint unsecuredEndpoint, CoapEndpoint securedEndpoint, |
|
|
BootstrapConfigStore bsStore, BootstrapSecurityStore bsSecurityStore, |
|
|
BootstrapSessionManager bsSessionManager, BootstrapHandlerFactory bsHandlerFactory, LwM2mModel model, |
|
|
NetworkConfig coapConfig) { |
|
|
NetworkConfig coapConfig, LwM2mNodeEncoder encoder, LwM2mNodeDecoder decoder) { |
|
|
return new LeshanBootstrapServer(unsecuredEndpoint, securedEndpoint, bsStore, bsSecurityStore, bsSessionManager, |
|
|
bsHandlerFactory, model, coapConfig); |
|
|
bsHandlerFactory, model, coapConfig, encoder, decoder); |
|
|
} |
|
|
} |
0 comments on commit
5e344d3