From 3768c1f1ad2e9255f2eb7a980992775f67bab8ce Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Thu, 30 Apr 2015 14:31:20 +0200 Subject: [PATCH] KEYCLOAK-1243 Federated Identities table is empty for user synced from classpath properties provider --- .../admin/resources/templates/kc-tabs-user.html | 2 +- .../services/resources/admin/UsersResource.java | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/templates/kc-tabs-user.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/templates/kc-tabs-user.html index 584d4d4998..9314e7abd8 100644 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/templates/kc-tabs-user.html +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/templates/kc-tabs-user.html @@ -4,5 +4,5 @@
  • Role Mappings
  • Consents
  • Sessions
  • -
  • Federated Identities
  • +
  • Identity Provider Links
  • \ No newline at end of file diff --git a/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java b/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java index 666c1daca6..ee9dc90dc0 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java @@ -59,6 +59,7 @@ import javax.ws.rs.core.UriInfo; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -217,7 +218,20 @@ public class UsersResource { throw new NotFoundException("User not found"); } - return ModelToRepresentation.toRepresentation(user); + UserRepresentation rep = ModelToRepresentation.toRepresentation(user); + + if (realm.isIdentityFederationEnabled()) { + Set identities = session.users().getFederatedIdentities(user, realm); + if (!identities.isEmpty()) { + List reps = new LinkedList<>(); + for (FederatedIdentityModel m : identities) { + reps.add(ModelToRepresentation.toRepresentation(m)); + } + rep.setFederatedIdentities(reps); + } + } + + return rep; } /**