From 42d49b2ac2ffb50086b5941c93c810cdbaff75ea Mon Sep 17 00:00:00 2001 From: pujavs <43700552+pujavs@users.noreply.github.com> Date: Thu, 24 Nov 2022 21:49:07 +0530 Subject: [PATCH] fix(jans): added null check to avoid NullPointerException (#3077) --- .../docs/jans-config-api-swagger-auto.yaml | 49 +++++++------------ .../orm/model/base/CustomObjectAttribute.java | 6 +-- .../jans/orm/model/base/LocalizedString.java | 3 +- 3 files changed, 24 insertions(+), 34 deletions(-) diff --git a/jans-config-api/docs/jans-config-api-swagger-auto.yaml b/jans-config-api/docs/jans-config-api-swagger-auto.yaml index 2bcba276d05..73d877bf0b0 100644 --- a/jans-config-api/docs/jans-config-api-swagger-auto.yaml +++ b/jans-config-api/docs/jans-config-api-swagger-auto.yaml @@ -7178,19 +7178,19 @@ components: $ref: '#/components/schemas/AttributeValidation' tooltip: type: string - adminCanAccess: - type: boolean - userCanAccess: + whitePagesCanView: type: boolean - userCanView: + adminCanAccess: type: boolean adminCanView: type: boolean - userCanEdit: + userCanAccess: type: boolean adminCanEdit: type: boolean - whitePagesCanView: + userCanView: + type: boolean + userCanEdit: type: boolean baseDn: type: string @@ -7526,10 +7526,6 @@ components: ttl: type: integer format: int32 - displayName: - type: string - tokenBindingSupported: - type: boolean authenticationMethod: type: string enum: @@ -7646,13 +7642,6 @@ components: type: object additionalProperties: type: string - value: - type: string - languageTags: - uniqueItems: true - type: array - items: - type: string AppConfiguration: type: object properties: @@ -8345,17 +8334,6 @@ components: $ref: '#/components/schemas/EngineConfig' ssaConfiguration: $ref: '#/components/schemas/SsaConfiguration' - fapi: - type: boolean - allResponseTypesSupported: - uniqueItems: true - type: array - items: - type: string - enum: - - code - - token - - id_token enabledFeatureFlags: uniqueItems: true type: array @@ -8383,6 +8361,17 @@ components: - STAT - PAR - SSA + allResponseTypesSupported: + uniqueItems: true + type: array + items: + type: string + enum: + - code + - token + - id_token + fapi: + type: boolean AuthenticationFilter: required: - baseDn @@ -8639,13 +8628,13 @@ components: type: boolean internal: type: boolean + locationPath: + type: string locationType: type: string enum: - ldap - file - locationPath: - type: string baseDn: type: string ScriptError: diff --git a/jans-orm/model/src/main/java/io/jans/orm/model/base/CustomObjectAttribute.java b/jans-orm/model/src/main/java/io/jans/orm/model/base/CustomObjectAttribute.java index 693e5aff380..0fd0224386a 100644 --- a/jans-orm/model/src/main/java/io/jans/orm/model/base/CustomObjectAttribute.java +++ b/jans-orm/model/src/main/java/io/jans/orm/model/base/CustomObjectAttribute.java @@ -43,7 +43,7 @@ public Object getValue() { return null; } - if (this.values.size() > 0) { + if (!this.values.isEmpty()) { return this.values.get(0); } @@ -51,7 +51,7 @@ public Object getValue() { } public void setValue(Object value) { - this.values = new ArrayList(); + this.values = new ArrayList<>(); this.values.add(value); this.multiValued = false; } @@ -89,7 +89,7 @@ public String getDisplayValue() { } if (values.size() == 1) { - return values.get(0).toString(); + return (values.get(0)!=null ? values.get(0).toString() : ""); } StringBuilder sb = new StringBuilder(); diff --git a/jans-orm/model/src/main/java/io/jans/orm/model/base/LocalizedString.java b/jans-orm/model/src/main/java/io/jans/orm/model/base/LocalizedString.java index 54c5e564078..add4b8322ff 100644 --- a/jans-orm/model/src/main/java/io/jans/orm/model/base/LocalizedString.java +++ b/jans-orm/model/src/main/java/io/jans/orm/model/base/LocalizedString.java @@ -72,9 +72,10 @@ public int size() { return values.size(); } + @SuppressWarnings("unchecked") @JsonIgnore public Set getLanguageTags() { - return values.keySet(); + return (values!=null ? values.keySet() : Collections.emptySet()); } public String addLdapLanguageTag(String ldapAttributeName, String languageTag) {