Lwm2m Fix bug create new Device with X509 Trust / update credential to X509 trust

This commit is contained in:
nickAS21 2021-09-16 08:43:28 +03:00
parent e2b3f0f742
commit b297ab231c
2 changed files with 10 additions and 2 deletions

View File

@ -21,7 +21,15 @@ public class StringUtils {
return source == null || source.isEmpty();
}
public static boolean isBlank(String source) {
return source == null || source.isEmpty() || source.trim().isEmpty();
}
public static boolean isNotEmpty(String source) {
return source != null && !source.isEmpty();
}
public static boolean isNotBlank(String source) {
return source != null && !source.isEmpty() && !source.trim().isEmpty();
}
}

View File

@ -183,7 +183,7 @@ public class DeviceCredentialsServiceImpl extends AbstractEntityService implemen
break;
case X509:
X509ClientCredentials x509Config = (X509ClientCredentials) clientCredentials;
if (x509Config.getCert() != null) {
if ((StringUtils.isNotBlank(x509Config.getCert()))) {
String cert = EncryptionUtil.trimNewLines(x509Config.getCert());
String sha3Hash = EncryptionUtil.getSha3Hash(cert);
x509Config.setCert(cert);
@ -272,7 +272,7 @@ public class DeviceCredentialsServiceImpl extends AbstractEntityService implemen
break;
case X509:
X509ClientCredentials x509CCredentials = (X509ClientCredentials) clientCredentials;
if (x509CCredentials.getCert() != null) {
if (StringUtils.isNotBlank(x509CCredentials.getCert())) {
try {
SecurityUtil.certificate.decode(Base64.decodeBase64(x509CCredentials.getCert()));
} catch (Exception e) {