From cce36ab990d9bd4caf8aeec46718a555c100c1fc Mon Sep 17 00:00:00 2001 From: Alex Morel Date: Fri, 21 Jun 2024 17:13:04 +0200 Subject: [PATCH] Fix /Users URI for group membership changes --- src/main/java/sh/libre/scim/core/GroupScimService.java | 5 +++-- src/main/java/sh/libre/scim/core/ScimClient.java | 2 +- src/main/java/sh/libre/scim/core/ScimDispatcher.java | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/sh/libre/scim/core/GroupScimService.java b/src/main/java/sh/libre/scim/core/GroupScimService.java index 0648f10c10..99c8c5cb52 100644 --- a/src/main/java/sh/libre/scim/core/GroupScimService.java +++ b/src/main/java/sh/libre/scim/core/GroupScimService.java @@ -99,13 +99,14 @@ public class GroupScimService extends AbstractScimService { logger.debug(userMapping.getExternalIdAsEntityOnRemoteScimId()); logger.debug(userMapping.getIdAsKeycloakId()); groupMember.setValue(userMapping.getExternalIdAsEntityOnRemoteScimId().asString()); - URI ref = new URI(String.format("Users/%s", userMapping.getExternalIdAsEntityOnRemoteScimId())); + String refString = String.format("Users/%s", userMapping.getExternalIdAsEntityOnRemoteScimId().asString()); + URI ref = new URI(refString); groupMember.setRef(ref.toString()); group.addMember(groupMember); } catch (NoSuchElementException e) { logger.warnf("member %s not found for group %s", member, groupModel.getId()); } catch (URISyntaxException e) { - logger.warnf("bad ref uri"); + logger.warnf("bad ref uri for member " + member); } } return group; diff --git a/src/main/java/sh/libre/scim/core/ScimClient.java b/src/main/java/sh/libre/scim/core/ScimClient.java index 22bfa0e7ec..9189ad308b 100644 --- a/src/main/java/sh/libre/scim/core/ScimClient.java +++ b/src/main/java/sh/libre/scim/core/ScimClient.java @@ -83,6 +83,7 @@ public class ScimClient implements AutoCloseable { private void checkResponseIsSuccess(ServerResponse response) { if (!response.isSuccess()) { + LOGGER.warn("[SCIM] Issue on SCIM Server response "); LOGGER.warn(response.getResponseBody()); LOGGER.warn(response.getHttpStatus()); } @@ -98,7 +99,6 @@ public class ScimClient implements AutoCloseable { public void replace(EntityOnRemoteScimId externalId, S scimForReplace) { Retry retry = retryRegistry.retry("replace-%s".formatted(externalId.asString())); - LOGGER.warn(scimForReplace); ServerResponse response = retry.executeSupplier(() -> scimRequestBuilder .update(getResourceClass(), getScimEndpoint(), externalId.asString()) .setResource(scimForReplace) diff --git a/src/main/java/sh/libre/scim/core/ScimDispatcher.java b/src/main/java/sh/libre/scim/core/ScimDispatcher.java index 6be68dc3d2..8154bb3930 100644 --- a/src/main/java/sh/libre/scim/core/ScimDispatcher.java +++ b/src/main/java/sh/libre/scim/core/ScimDispatcher.java @@ -146,7 +146,7 @@ public class ScimDispatcher { private void logAndRollback(ScrimProviderConfiguration scimServerConfiguration, ScimPropagationException e) { logger.error("[SCIM] Error while propagating to SCIM endpoint " + scimServerConfiguration.getId(), e); - session.getTransactionManager().rollback(); + // TODO session.getTransactionManager().rollback(); } private void initializeClientsIfNeeded() {