Skip to content

Commit

Permalink
Changes the Datastructure to make compatible
Browse files Browse the repository at this point in the history
Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]>
  • Loading branch information
mdanish98 committed Oct 24, 2024
1 parent b7fdb62 commit d61663f
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public List<String> getRoles() {
validateJwt(jwt);

Map<String, Collection<String>> realmAccess = new HashMap<>();
Map<String, Collection<String>> resourceAccess = new HashMap<>();
Map<String, Map<String, Collection<String>>> resourceAccess = new HashMap<>();

if (jwt.hasClaim(CLAIM_REALM_ACCESS))
realmAccess = jwt.getClaim(CLAIM_REALM_ACCESS);
Expand All @@ -80,7 +80,7 @@ public List<String> getRoles() {
return extractRolesFromClaims(realmAccess, resourceAccess);
}

private List<String> extractRolesFromClaims(Map<String, Collection<String>> realmAccess, Map<String, Collection<String>> resourceAccess) {
private List<String> extractRolesFromClaims(Map<String, Collection<String>> realmAccess, Map<String, Map<String, Collection<String>>> resourceAccess) {
if (realmAccess.isEmpty() && resourceAccess.isEmpty())
return new ArrayList<>();

Expand All @@ -91,8 +91,9 @@ private List<String> extractRolesFromClaims(Map<String, Collection<String>> real
if (realmRoles != null && !realmRoles.isEmpty())
roles.addAll(realmRoles);

for (Map.Entry<String, Collection<String>> entry : resourceAccess.entrySet()) {
Collection<String> clientRoles = entry.getValue();
for (Map.Entry<String, Map<String, Collection<String>>> entry : resourceAccess.entrySet()) {
Map<String, Collection<String>> clientRolesMap = entry.getValue();
Collection<String> clientRoles = clientRolesMap.get(CLAIM_ROLES);

if (clientRoles != null)
roles.addAll(clientRoles);
Expand Down

0 comments on commit d61663f

Please sign in to comment.