Deal with the case when there are no existing client role mappings for
the user(ie, it's a first time for an update).
Showing
1 changed file
with
2 additions
and
2 deletions
... | @@ -227,8 +227,8 @@ void updateUser(RealmResource realm, String keycloakClientId, String keycloakUse | ... | @@ -227,8 +227,8 @@ void updateUser(RealmResource realm, String keycloakClientId, String keycloakUse |
227 | 227 | ||
228 | List<RoleRepresentation> toRemove = [] | 228 | List<RoleRepresentation> toRemove = [] |
229 | RoleMappingResource roleMappingResource = userResource.roles() | 229 | RoleMappingResource roleMappingResource = userResource.roles() |
230 | ClientMappingsRepresentation clientMappingsRespresentation = roleMappingResource.getAll().getClientMappings()[keycloakClientId] | 230 | ClientMappingsRepresentation clientMappingsRespresentation = roleMappingResource.getAll().getClientMappings()?[keycloakClientId] |
231 | for (RoleRepresentation existingRoleRep: clientMappingsRespresentation.getMappings()) { | 231 | for (RoleRepresentation existingRoleRep: clientMappingsRespresentation?.getMappings()) { |
232 | if (!wantedClientRoles.remove(existingRoleRep.getName())) { | 232 | if (!wantedClientRoles.remove(existingRoleRep.getName())) { |
233 | toRemove.add(existingRoleRep) | 233 | toRemove.add(existingRoleRep) |
234 | } | 234 | } | ... | ... |
-
Please register or sign in to post a comment