From 1e3ae07e7272eacc9134646060ff3cec445c5025 Mon Sep 17 00:00:00 2001 From: Hugo Renard Date: Fri, 23 Sep 2022 17:34:09 +0200 Subject: [PATCH] add scim-skip attribute --- src/main/java/sh/libre/scim/core/Adapter.java | 1 + src/main/java/sh/libre/scim/core/GroupAdapter.java | 2 ++ src/main/java/sh/libre/scim/core/ScimClient.java | 2 ++ src/main/java/sh/libre/scim/core/UserAdapter.java | 1 + 4 files changed, 6 insertions(+) diff --git a/src/main/java/sh/libre/scim/core/Adapter.java b/src/main/java/sh/libre/scim/core/Adapter.java index 913ef09d03..7eada91123 100644 --- a/src/main/java/sh/libre/scim/core/Adapter.java +++ b/src/main/java/sh/libre/scim/core/Adapter.java @@ -25,6 +25,7 @@ public abstract class Adapter { .getGroupMembersStream(session.getContext().getRealm(), group) .map(x -> x.getId()) .collect(Collectors.toSet()); + this.skip = StringUtils.equals(group.getFirstAttribute("scim-skip"), "true"); } @Override diff --git a/src/main/java/sh/libre/scim/core/ScimClient.java b/src/main/java/sh/libre/scim/core/ScimClient.java index 702ff39ba2..fc2610c13a 100644 --- a/src/main/java/sh/libre/scim/core/ScimClient.java +++ b/src/main/java/sh/libre/scim/core/ScimClient.java @@ -78,6 +78,7 @@ public class ScimClient { M kcModel) { var adapter = getAdapter(aClass); adapter.apply(kcModel); + if (adapter.skip) return; // If mapping exist then it was created by import so skip. if (adapter.query("findById", adapter.getId()).getResultList().size() != 0) { return; @@ -102,6 +103,7 @@ public class ScimClient { var adapter = getAdapter(aClass); try { adapter.apply(kcModel); + if (adapter.skip) return; var resource = adapter.query("findById", adapter.getId()).getSingleResult(); adapter.apply(resource); var retry = registry.retry("replace-" + adapter.getId()); diff --git a/src/main/java/sh/libre/scim/core/UserAdapter.java b/src/main/java/sh/libre/scim/core/UserAdapter.java index dbfd2f0b09..df6676e628 100644 --- a/src/main/java/sh/libre/scim/core/UserAdapter.java +++ b/src/main/java/sh/libre/scim/core/UserAdapter.java @@ -110,6 +110,7 @@ public class UserAdapter extends Adapter { var roles = new String[rolesSet.size()]; rolesSet.toArray(roles); setRoles(roles); + this.skip = StringUtils.equals(user.getFirstAttribute("scim-skip"), "true"); } @Override