commit
772c565619
@ -43,6 +43,7 @@ import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.Abstrac
|
|||||||
import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MBootstrapServerCredential;
|
import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MBootstrapServerCredential;
|
||||||
import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.RPKLwM2MBootstrapServerCredential;
|
import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.RPKLwM2MBootstrapServerCredential;
|
||||||
import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.X509LwM2MBootstrapServerCredential;
|
import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.X509LwM2MBootstrapServerCredential;
|
||||||
|
import org.thingsboard.server.common.data.id.RuleChainId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.data.queue.Queue;
|
import org.thingsboard.server.common.data.queue.Queue;
|
||||||
import org.thingsboard.server.common.data.rule.RuleChain;
|
import org.thingsboard.server.common.data.rule.RuleChain;
|
||||||
@ -188,13 +189,11 @@ public class DeviceProfileDataValidator extends AbstractHasOtaPackageValidator<D
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (deviceProfile.getDefaultRuleChainId() != null) {
|
if (deviceProfile.getDefaultRuleChainId() != null) {
|
||||||
RuleChain ruleChain = ruleChainService.findRuleChainById(tenantId, deviceProfile.getDefaultRuleChainId());
|
validateRuleChain(tenantId, deviceProfile.getTenantId(), deviceProfile.getDefaultRuleChainId());
|
||||||
if (ruleChain == null) {
|
}
|
||||||
throw new DataValidationException("Can't assign non-existent rule chain!");
|
|
||||||
}
|
if (deviceProfile.getDefaultEdgeRuleChainId() != null) {
|
||||||
if (!ruleChain.getTenantId().equals(deviceProfile.getTenantId())) {
|
validateRuleChain(tenantId, deviceProfile.getTenantId(), deviceProfile.getDefaultEdgeRuleChainId());
|
||||||
throw new DataValidationException("Can't assign rule chain from different tenant!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deviceProfile.getDefaultDashboardId() != null) {
|
if (deviceProfile.getDefaultDashboardId() != null) {
|
||||||
@ -210,6 +209,16 @@ public class DeviceProfileDataValidator extends AbstractHasOtaPackageValidator<D
|
|||||||
validateOtaPackage(tenantId, deviceProfile, deviceProfile.getId());
|
validateOtaPackage(tenantId, deviceProfile, deviceProfile.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validateRuleChain(TenantId tenantId, TenantId deviceProfileTenantId, RuleChainId ruleChainId) {
|
||||||
|
RuleChain ruleChain = ruleChainService.findRuleChainById(tenantId, ruleChainId);
|
||||||
|
if (ruleChain == null) {
|
||||||
|
throw new DataValidationException("Can't assign non-existent rule chain!");
|
||||||
|
}
|
||||||
|
if (!ruleChain.getTenantId().equals(deviceProfileTenantId)) {
|
||||||
|
throw new DataValidationException("Can't assign rule chain from different tenant!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DeviceProfile validateUpdate(TenantId tenantId, DeviceProfile deviceProfile) {
|
protected DeviceProfile validateUpdate(TenantId tenantId, DeviceProfile deviceProfile) {
|
||||||
DeviceProfile old = deviceProfileDao.findById(deviceProfile.getTenantId(), deviceProfile.getId().getId());
|
DeviceProfile old = deviceProfileDao.findById(deviceProfile.getTenantId(), deviceProfile.getId().getId());
|
||||||
@ -329,8 +338,8 @@ public class DeviceProfileDataValidator extends AbstractHasOtaPackageValidator<D
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (serverConfig.getShortServerId() != null) {
|
if (serverConfig.getShortServerId() != null) {
|
||||||
if (serverConfig.isBootstrapServerIs()){
|
if (serverConfig.isBootstrapServerIs()) {
|
||||||
if(serverConfig.getShortServerId() < 0 || serverConfig.getShortServerId() > 65535){
|
if (serverConfig.getShortServerId() < 0 || serverConfig.getShortServerId() > 65535) {
|
||||||
throw new DeviceCredentialsValidationException("Bootstrap Server ShortServerId must be in range [0 - 65535]!");
|
throw new DeviceCredentialsValidationException("Bootstrap Server ShortServerId must be in range [0 - 65535]!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -423,4 +432,5 @@ public class DeviceProfileDataValidator extends AbstractHasOtaPackageValidator<D
|
|||||||
private String getCertificateString(X509Certificate cert) throws CertificateEncodingException {
|
private String getCertificateString(X509Certificate cert) throws CertificateEncodingException {
|
||||||
return EncryptionUtil.certTrimNewLines(Base64.getEncoder().encodeToString(cert.getEncoded()));
|
return EncryptionUtil.certTrimNewLines(Base64.getEncoder().encodeToString(cert.getEncoded()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user