You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2017/06/26 19:02:06 UTC

airavata git commit: AIRAVATA-2405 Fix getUsersWithRole

Repository: airavata
Updated Branches:
  refs/heads/develop cd230e275 -> 0479066b2


AIRAVATA-2405 Fix getUsersWithRole

Must make additional call to get realm roles.


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/0479066b
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/0479066b
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/0479066b

Branch: refs/heads/develop
Commit: 0479066b2c6206c5a24a95c1e59447bc4cfe1fe8
Parents: cd230e2
Author: Marcus Christie <ma...@apache.org>
Authored: Mon Jun 26 15:00:48 2017 -0400
Committer: Marcus Christie <ma...@apache.org>
Committed: Mon Jun 26 15:01:57 2017 -0400

----------------------------------------------------------------------
 .../services/core/impl/TenantManagementKeycloakImpl.java  | 10 ++++++++--
 .../service/profile/handlers/IamAdminServicesHandler.java |  4 ++--
 2 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/0479066b/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
----------------------------------------------------------------------
diff --git a/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java b/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
index 2da9276..6ae0082 100644
--- a/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
+++ b/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
@@ -538,8 +538,14 @@ public class TenantManagementKeycloakImpl implements TenantManagementInterface {
 
             List<UserProfile> usersWithRole = new ArrayList<>();
             for (UserRepresentation user: allUsers) {
-                if (user.getRealmRoles().contains(roleName)) {
-                    usersWithRole.add(convertUserRepresentationToUserProfile(user, tenantId));
+                UserResource userResource = client.realm(tenantId).users().get(user.getId());
+
+                List<RoleRepresentation> roleRepresentations = userResource.roles().realmLevel().listAll();
+                for (RoleRepresentation roleRepresentation : roleRepresentations){
+                    if (roleRepresentation.getName().equals(roleName)) {
+                        usersWithRole.add(convertUserRepresentationToUserProfile(user, tenantId));
+                        break;
+                    }
                 }
             }
             return usersWithRole;

http://git-wip-us.apache.org/repos/asf/airavata/blob/0479066b/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/handlers/IamAdminServicesHandler.java
----------------------------------------------------------------------
diff --git a/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/handlers/IamAdminServicesHandler.java b/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/handlers/IamAdminServicesHandler.java
index 15f4596..7b8a1e5 100644
--- a/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/handlers/IamAdminServicesHandler.java
+++ b/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/handlers/IamAdminServicesHandler.java
@@ -213,8 +213,8 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
         try {
             PasswordCredential isRealmAdminCredentials = getTenantAdminPasswordCredential(gatewayId);
             return keycloakclient.getUsersWithRole(isRealmAdminCredentials, gatewayId, roleName);
-        } catch (TException | ApplicationSettingsException ex) {
-            String msg = "Error while retrieving users from Identity Server, reason: " + ex.getMessage();
+        } catch (Exception ex) {
+            String msg = "Error while retrieving users with role, reason: " + ex.getMessage();
             logger.error(msg, ex);
             throw new IamAdminServicesException(msg);
         }