Skip to content

Commit

Permalink
Validate at least one attribute is available and populate members map…
Browse files Browse the repository at this point in the history
… accordingly
  • Loading branch information
ZiyamSanthosh committed Aug 29, 2023
1 parent d5f33f8 commit 79a0f66
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -950,10 +950,18 @@ private List<Map<String, String>> transformMembersAttributeToMap(MultiValuedAttr
}

Map<String, String> member = new HashMap<>();
member.put(SCIMConstants.CommonSchemaConstants.VALUE, ((SimpleAttribute)
(subAttributesList.get(SCIMConstants.CommonSchemaConstants.VALUE))).getStringValue());
member.put(SCIMConstants.CommonSchemaConstants.DISPLAY, ((SimpleAttribute)
(subAttributesList.get(SCIMConstants.CommonSchemaConstants.DISPLAY))).getStringValue());
if (!subAttributesList.containsKey(SCIMConstants.CommonSchemaConstants.VALUE) &&
!subAttributesList.containsKey(SCIMConstants.CommonSchemaConstants.DISPLAY)) {
throw new CharonException("Either value or display attribute is required for members attribute");
}
if (subAttributesList.containsKey(SCIMConstants.CommonSchemaConstants.DISPLAY)) {
member.put(SCIMConstants.CommonSchemaConstants.DISPLAY, ((SimpleAttribute)
(subAttributesList.get(SCIMConstants.CommonSchemaConstants.DISPLAY))).getStringValue());
}
if (subAttributesList.containsKey(SCIMConstants.CommonSchemaConstants.VALUE)) {
member.put(SCIMConstants.CommonSchemaConstants.VALUE, ((SimpleAttribute)
(subAttributesList.get(SCIMConstants.CommonSchemaConstants.VALUE))).getStringValue());
}
memberList.add(member);
}
return memberList;
Expand Down

0 comments on commit 79a0f66

Please sign in to comment.