From b1855cfea277c244814d73bca752291167a7a9a8 Mon Sep 17 00:00:00 2001 From: nickAS21 Date: Mon, 17 Jan 2022 15:49:53 +0200 Subject: [PATCH] lwm2m: refactoring by commit in PR --- .../TbLwM2MDtlsBootstrapCertificateVerifier.java | 2 +- .../store/LwM2MBootstrapSecurityStore.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/bootstrap/secure/TbLwM2MDtlsBootstrapCertificateVerifier.java b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/bootstrap/secure/TbLwM2MDtlsBootstrapCertificateVerifier.java index 2f708989bb..b0fbb91a97 100644 --- a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/bootstrap/secure/TbLwM2MDtlsBootstrapCertificateVerifier.java +++ b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/bootstrap/secure/TbLwM2MDtlsBootstrapCertificateVerifier.java @@ -128,7 +128,7 @@ public class TbLwM2MDtlsBootstrapCertificateVerifier implements NewAdvancedCerti try { securityInfo = bsSecurityStore.getX509ByEndpoint(sha3Hash); } catch (LwM2MAuthException e) { - log.trace("Failed find security info: {}", sha3Hash, e); + log.trace("Failed to find security info: {}", sha3Hash, e); } } ValidateDeviceCredentialsResponse msg = securityInfo != null ? securityInfo.getMsg() : null; diff --git a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/bootstrap/store/LwM2MBootstrapSecurityStore.java b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/bootstrap/store/LwM2MBootstrapSecurityStore.java index 1e33106ac5..79aed5fc93 100644 --- a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/bootstrap/store/LwM2MBootstrapSecurityStore.java +++ b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/bootstrap/store/LwM2MBootstrapSecurityStore.java @@ -68,9 +68,9 @@ public class LwM2MBootstrapSecurityStore implements BootstrapSecurityStore { } @Override - public Iterator getAllByEndpoint(String endPoint) { - TbLwM2MSecurityInfo store = lwM2MCredentialsSecurityInfoValidator.getEndpointSecurityInfoByCredentialsId(endPoint, BOOTSTRAP); - SecurityInfo securityInfo = this.addValueToStore(store, endPoint); + public Iterator getAllByEndpoint(String endpoint) { + TbLwM2MSecurityInfo store = lwM2MCredentialsSecurityInfoValidator.getEndpointSecurityInfoByCredentialsId(endpoint, BOOTSTRAP); + SecurityInfo securityInfo = this.addValueToStore(store, endpoint); return securityInfo == null ? null : Collections.singletonList(store.getSecurityInfo()).iterator(); } @@ -162,7 +162,7 @@ public class LwM2MBootstrapSecurityStore implements BootstrapSecurityStore { } } }); - return validBs.get() & validLw.get(); + return validBs.get() && validLw.get(); } public TransportProtos.SessionInfoProto getSessionByEndpoint(String endpoint) { @@ -177,7 +177,7 @@ public class LwM2MBootstrapSecurityStore implements BootstrapSecurityStore { return bootstrapConfigStore.getAll().get(endpoint); } - public SecurityInfo addValueToStore(TbLwM2MSecurityInfo store, String endPoint) { + public SecurityInfo addValueToStore(TbLwM2MSecurityInfo store, String endpoint) { /* add value to store from BootstrapJson */ SecurityInfo securityInfo = null; if (store != null && store.getBootstrapCredentialConfig() != null && store.getSecurityMode() != null) { @@ -199,11 +199,11 @@ public class LwM2MBootstrapSecurityStore implements BootstrapSecurityStore { } } for (String config : bootstrapConfigStore.getAll().keySet()) { - if (config.equals(endPoint)) { + if (config.equals(endpoint)) { bootstrapConfigStore.remove(config); } } - bootstrapConfigStore.add(endPoint, bsConfigNew); + bootstrapConfigStore.add(endpoint, bsConfigNew); } catch (InvalidConfigurationException e) { if (e.getMessage().contains("Psk identity") && e.getMessage().contains("already used for this bootstrap server")) { log.trace("Invalid Bootstrap Configuration", e); @@ -215,4 +215,4 @@ public class LwM2MBootstrapSecurityStore implements BootstrapSecurityStore { } return securityInfo; } -} +} \ No newline at end of file