Skip to content
This repository was archived by the owner on Sep 28, 2022. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f4572b8

Browse files
author
Dominik František Bučík
authoredApr 11, 2022
Merge pull request #169 from dBucik/fix_null_pointer
fix: 🐛 Fix nullPointer in SamlAuthenticationDetailsStringCon
2 parents 08ddf5b + 3c034f4 commit f4572b8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

‎perun-oidc-server/src/main/java/cz/muni/ics/oauth2/model/SamlAuthenticationDetails.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,18 @@ public static String serialize(SamlAuthenticationDetails o) {
172172
}
173173

174174
private static void addStringOrNull(JsonObject target, String key, String value) {
175-
if (value == null) {
175+
if (target == null || !StringUtils.hasText(key)) {
176+
return;
177+
}
178+
if (value == null || "null".equalsIgnoreCase(value)) {
176179
target.add(key, new JsonNull());
177180
} else {
178181
target.addProperty(key, value);
179182
}
180183
}
181184

182185
private static String getStringOrNull(JsonElement jsonElement) {
183-
if (jsonElement.isJsonPrimitive()) {
186+
if (jsonElement != null && jsonElement.isJsonPrimitive()) {
184187
return jsonElement.getAsString();
185188
} else {
186189
return null;

0 commit comments

Comments
 (0)
This repository has been archived.