Skip to content

Commit

Permalink
Add and checks for SCIM/Groups PATCH add member operation
Browse files Browse the repository at this point in the history
  • Loading branch information
PasinduYeshan committed Jul 26, 2023
1 parent acf7e1d commit 93e6445
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -932,14 +932,30 @@ private void processValueAttributeOfOperation(SCIMResourceTypeSchema schema, Pat
}

private List<Map<String, String>> transformMembersAttributeToMap(MultiValuedAttribute multiValuedMembersAttribute)
throws CharonException {
throws CharonException, BadRequestException {

List<Map<String, String>> memberList = new ArrayList<>();
List<Attribute> subValuesList = multiValuedMembersAttribute.getAttributeValues();
for (Attribute subValue : subValuesList) {
ComplexAttribute complexAttribute = (ComplexAttribute) subValue;
Map<String, Attribute> subAttributesList = complexAttribute.getSubAttributesList();

// 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);
}

// Check if `display` value is present.
if (!subAttributesList.containsKey(SCIMConstants.CommonSchemaConstants.DISPLAY)) {
throw new BadRequestException(ResponseCodeConstants.DESC_BAD_REQUEST,
ResponseCodeConstants.INVALID_SYNTAX);
}

Map<String, String> member = new HashMap<>();
member.put(SCIMConstants.CommonSchemaConstants.VALUE, ((SimpleAttribute)
(subAttributesList.get(SCIMConstants.CommonSchemaConstants.VALUE))).getStringValue());
Expand Down

0 comments on commit 93e6445

Please sign in to comment.