Skip to content

Commit

Permalink
Add StringUtils.isEmpty() check for getStringValue()
Browse files Browse the repository at this point in the history
  • Loading branch information
PasinduYeshan committed Jul 27, 2023
1 parent 93e6445 commit 985923e
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.wso2.charon3.core.protocol.endpoints;

import org.apache.commons.lang.StringUtils;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
Expand Down Expand Up @@ -940,14 +941,18 @@ private List<Map<String, String>> transformMembersAttributeToMap(MultiValuedAttr
ComplexAttribute complexAttribute = (ComplexAttribute) subValue;
Map<String, Attribute> subAttributesList = complexAttribute.getSubAttributesList();

// Check if `value` (member id) attribute is present and not empty.
// Check if `value` (member id) attribute is present and not empty.
if (!subAttributesList.containsKey(SCIMConstants.CommonSchemaConstants.VALUE)) {
throw new BadRequestException(ResponseCodeConstants.DESC_BAD_REQUEST,
ResponseCodeConstants.INVALID_SYNTAX);
} else if (((SimpleAttribute)
(subAttributesList.get(SCIMConstants.CommonSchemaConstants.VALUE))).getStringValue().isEmpty()) {
throw new BadRequestException(ResponseCodeConstants.DESC_BAD_REQUEST,
ResponseCodeConstants.INVALID_VALUE);
} else {
SimpleAttribute valueAttribute = (SimpleAttribute)
subAttributesList.get(SCIMConstants.CommonSchemaConstants.VALUE);
if (StringUtils.isEmpty(valueAttribute.getStringValue())) {
throw new BadRequestException(ResponseCodeConstants.DESC_BAD_REQUEST,
ResponseCodeConstants.INVALID_VALUE);
}
}

// Check if `display` value is present.
Expand Down

0 comments on commit 985923e

Please sign in to comment.