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 2019/06/26 20:34:27 UTC

[airavata] 01/02: Looks up roles for user using exact username

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch staging
in repository https://gitbox.apache.org/repos/asf/airavata.git

commit 4a291c7a91910d83953e2fe60ff83a4086b7dec0
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Wed Jun 26 16:31:23 2019 -0400

    Looks up roles for user using exact username
---
 .../admin/services/core/impl/TenantManagementKeycloakImpl.java | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

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 b9027e5..e93d6c0 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
@@ -768,16 +768,12 @@ public class TenantManagementKeycloakImpl implements TenantManagementInterface {
         Keycloak client = null;
         try{
             client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, realmAdminCreds);
-            List<UserRepresentation> userRepresentationList = client.realm(tenantId).users().search(username,
-                    null,
-                    null,
-                    null,
-                    0, 1);
-            if (userRepresentationList.isEmpty()) {
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            if (userRepresentation == null) {
                 logger.warn("No Keycloak user found for username [" + username + "] in tenant [" + tenantId + "].");
                 return null;
             }
-            UserResource retrievedUser = client.realm(tenantId).users().get(userRepresentationList.get(0).getId());
+            UserResource retrievedUser = client.realm(tenantId).users().get(userRepresentation.getId());
             return retrievedUser.roles().realmLevel().listAll()
                     .stream()
                     .map(roleRepresentation -> roleRepresentation.getName())