Merge pull request #169 from dBucik/fix_null_pointer

fix: 🐛 Fix nullPointer in SamlAuthenticationDetailsStringCon
pull/1580/head
Dominik František Bučík 2022-04-11 09:47:12 +02:00 committed by GitHub
commit f4572b8d2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -172,7 +172,10 @@ public class SamlAuthenticationDetails {
}
private static void addStringOrNull(JsonObject target, String key, String value) {
if (value == null) {
if (target == null || !StringUtils.hasText(key)) {
return;
}
if (value == null || "null".equalsIgnoreCase(value)) {
target.add(key, new JsonNull());
} else {
target.addProperty(key, value);
@ -180,7 +183,7 @@ public class SamlAuthenticationDetails {
}
private static String getStringOrNull(JsonElement jsonElement) {
if (jsonElement.isJsonPrimitive()) {
if (jsonElement != null && jsonElement.isJsonPrimitive()) {
return jsonElement.getAsString();
} else {
return null;