lwm2m - Security config default
This commit is contained in:
parent
781ef66f0b
commit
6892074646
@ -29,8 +29,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.thingsboard.server.common.data.Device;
|
import org.thingsboard.server.common.data.Device;
|
||||||
import org.thingsboard.server.common.data.SaveDeviceWithCredentialsRequest;
|
import org.thingsboard.server.common.data.SaveDeviceWithCredentialsRequest;
|
||||||
|
import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MServerSecurityConfigDefault;
|
||||||
import org.thingsboard.server.common.data.exception.ThingsboardException;
|
import org.thingsboard.server.common.data.exception.ThingsboardException;
|
||||||
import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MServerSecurityConfig;
|
|
||||||
import org.thingsboard.server.common.data.security.DeviceCredentials;
|
import org.thingsboard.server.common.data.security.DeviceCredentials;
|
||||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||||
import org.thingsboard.server.service.lwm2m.LwM2MService;
|
import org.thingsboard.server.service.lwm2m.LwM2MService;
|
||||||
@ -61,7 +61,7 @@ public class Lwm2mController extends BaseController {
|
|||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/lwm2m/deviceProfile/bootstrap/{isBootstrapServer}", method = RequestMethod.GET)
|
@RequestMapping(value = "/lwm2m/deviceProfile/bootstrap/{isBootstrapServer}", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public LwM2MServerSecurityConfig getLwm2mBootstrapSecurityInfo(
|
public LwM2MServerSecurityConfigDefault getLwm2mBootstrapSecurityInfo(
|
||||||
@ApiParam(value = IS_BOOTSTRAP_SERVER_PARAM_DESCRIPTION)
|
@ApiParam(value = IS_BOOTSTRAP_SERVER_PARAM_DESCRIPTION)
|
||||||
@PathVariable(IS_BOOTSTRAP_SERVER) boolean bootstrapServer) throws ThingsboardException {
|
@PathVariable(IS_BOOTSTRAP_SERVER) boolean bootstrapServer) throws ThingsboardException {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -15,10 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.service.lwm2m;
|
package org.thingsboard.server.service.lwm2m;
|
||||||
|
|
||||||
import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MServerSecurityConfig;
|
import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MServerSecurityConfigDefault;
|
||||||
|
|
||||||
public interface LwM2MService {
|
public interface LwM2MService {
|
||||||
|
|
||||||
LwM2MServerSecurityConfig getServerSecurityInfo(boolean bootstrapServer);
|
LwM2MServerSecurityConfigDefault getServerSecurityInfo(boolean bootstrapServer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MServerSecurityConfig;
|
import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MServerSecurityConfigDefault;
|
||||||
import org.thingsboard.server.common.transport.config.ssl.SslCredentials;
|
import org.thingsboard.server.common.transport.config.ssl.SslCredentials;
|
||||||
import org.thingsboard.server.transport.lwm2m.config.LwM2MSecureServerConfig;
|
import org.thingsboard.server.transport.lwm2m.config.LwM2MSecureServerConfig;
|
||||||
import org.thingsboard.server.transport.lwm2m.config.LwM2MTransportBootstrapConfig;
|
import org.thingsboard.server.transport.lwm2m.config.LwM2MTransportBootstrapConfig;
|
||||||
@ -36,14 +36,14 @@ public class LwM2MServiceImpl implements LwM2MService {
|
|||||||
private final LwM2MTransportBootstrapConfig bootstrapConfig;
|
private final LwM2MTransportBootstrapConfig bootstrapConfig;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LwM2MServerSecurityConfig getServerSecurityInfo(boolean bootstrapServer) {
|
public LwM2MServerSecurityConfigDefault getServerSecurityInfo(boolean bootstrapServer) {
|
||||||
LwM2MServerSecurityConfig result = getServerSecurityConfig(bootstrapServer ? bootstrapConfig : serverConfig);
|
LwM2MServerSecurityConfigDefault result = getServerSecurityConfig(bootstrapServer ? bootstrapConfig : serverConfig);
|
||||||
result.setBootstrapServerIs(bootstrapServer);
|
result.setBootstrapServerIs(bootstrapServer);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LwM2MServerSecurityConfig getServerSecurityConfig(LwM2MSecureServerConfig serverConfig) {
|
private LwM2MServerSecurityConfigDefault getServerSecurityConfig(LwM2MSecureServerConfig serverConfig) {
|
||||||
LwM2MServerSecurityConfig bsServ = new LwM2MServerSecurityConfig();
|
LwM2MServerSecurityConfigDefault bsServ = new LwM2MServerSecurityConfigDefault();
|
||||||
bsServ.setShortServerId(serverConfig.getId());
|
bsServ.setShortServerId(serverConfig.getId());
|
||||||
bsServ.setHost(serverConfig.getHost());
|
bsServ.setHost(serverConfig.getHost());
|
||||||
bsServ.setPort(serverConfig.getPort());
|
bsServ.setPort(serverConfig.getPort());
|
||||||
|
|||||||
@ -34,10 +34,6 @@ public class LwM2MServerSecurityConfig {
|
|||||||
protected String host;
|
protected String host;
|
||||||
@ApiModelProperty(position = 4, value = "Port for Lwm2m Server: 'No Security' mode: Lwm2m Server or Bootstrap Server", example = "'5685' or '5687'", readOnly = true)
|
@ApiModelProperty(position = 4, value = "Port for Lwm2m Server: 'No Security' mode: Lwm2m Server or Bootstrap Server", example = "'5685' or '5687'", readOnly = true)
|
||||||
protected Integer port;
|
protected Integer port;
|
||||||
@ApiModelProperty(position = 5, value = "Host for 'Security' mode (DTLS)", example = "0.0.0.0", readOnly = true)
|
|
||||||
protected String securityHost;
|
|
||||||
@ApiModelProperty(position = 6, value = "Port for 'Security' mode (DTLS): Lwm2m Server or Bootstrap Server", example = "5686 or 5688", readOnly = true)
|
|
||||||
protected Integer securityPort;
|
|
||||||
@ApiModelProperty(position = 7, value = "Client Hold Off Time. The number of seconds to wait before initiating a Client Initiated Bootstrap once the LwM2M Client has determined it should initiate this bootstrap mode. (This information is relevant for use with a Bootstrap-Server only.)", example = "1", readOnly = true)
|
@ApiModelProperty(position = 7, value = "Client Hold Off Time. The number of seconds to wait before initiating a Client Initiated Bootstrap once the LwM2M Client has determined it should initiate this bootstrap mode. (This information is relevant for use with a Bootstrap-Server only.)", example = "1", readOnly = true)
|
||||||
protected Integer clientHoldOffTime = 1;
|
protected Integer clientHoldOffTime = 1;
|
||||||
@ApiModelProperty(position = 8, value = "Server Public Key for 'Security' mode (DTLS): RPK or X509. Format: base64 encoded", example = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAZ0pSaGKHk/GrDaUDnQZpeEdGwX7m3Ws+U/kiVat\n" +
|
@ApiModelProperty(position = 8, value = "Server Public Key for 'Security' mode (DTLS): RPK or X509. Format: base64 encoded", example = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAZ0pSaGKHk/GrDaUDnQZpeEdGwX7m3Ws+U/kiVat\n" +
|
||||||
|
|||||||
@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* Copyright © 2016-2021 The Thingsboard Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ApiModel
|
||||||
|
@Data
|
||||||
|
public class LwM2MServerSecurityConfigDefault extends LwM2MServerSecurityConfig {
|
||||||
|
@ApiModelProperty(position = 5, value = "Host for 'Security' mode (DTLS)", example = "0.0.0.0", readOnly = true)
|
||||||
|
protected String securityHost;
|
||||||
|
@ApiModelProperty(position = 6, value = "Port for 'Security' mode (DTLS): Lwm2m Server or Bootstrap Server", example = "5686 or 5688", readOnly = true)
|
||||||
|
protected Integer securityPort;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user