Lwm2m Fix bug create new Device with X509 Trust / update credential to X509 trust
This commit is contained in:
parent
e2b3f0f742
commit
b297ab231c
@ -21,7 +21,15 @@ public class StringUtils {
|
|||||||
return source == null || source.isEmpty();
|
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) {
|
public static boolean isNotEmpty(String source) {
|
||||||
return source != null && !source.isEmpty();
|
return source != null && !source.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isNotBlank(String source) {
|
||||||
|
return source != null && !source.isEmpty() && !source.trim().isEmpty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -183,7 +183,7 @@ public class DeviceCredentialsServiceImpl extends AbstractEntityService implemen
|
|||||||
break;
|
break;
|
||||||
case X509:
|
case X509:
|
||||||
X509ClientCredentials x509Config = (X509ClientCredentials) clientCredentials;
|
X509ClientCredentials x509Config = (X509ClientCredentials) clientCredentials;
|
||||||
if (x509Config.getCert() != null) {
|
if ((StringUtils.isNotBlank(x509Config.getCert()))) {
|
||||||
String cert = EncryptionUtil.trimNewLines(x509Config.getCert());
|
String cert = EncryptionUtil.trimNewLines(x509Config.getCert());
|
||||||
String sha3Hash = EncryptionUtil.getSha3Hash(cert);
|
String sha3Hash = EncryptionUtil.getSha3Hash(cert);
|
||||||
x509Config.setCert(cert);
|
x509Config.setCert(cert);
|
||||||
@ -272,7 +272,7 @@ public class DeviceCredentialsServiceImpl extends AbstractEntityService implemen
|
|||||||
break;
|
break;
|
||||||
case X509:
|
case X509:
|
||||||
X509ClientCredentials x509CCredentials = (X509ClientCredentials) clientCredentials;
|
X509ClientCredentials x509CCredentials = (X509ClientCredentials) clientCredentials;
|
||||||
if (x509CCredentials.getCert() != null) {
|
if (StringUtils.isNotBlank(x509CCredentials.getCert())) {
|
||||||
try {
|
try {
|
||||||
SecurityUtil.certificate.decode(Base64.decodeBase64(x509CCredentials.getCert()));
|
SecurityUtil.certificate.decode(Base64.decodeBase64(x509CCredentials.getCert()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user