diff --git a/src/main/java/sh/libre/scim/core/GroupAdapter.java b/src/main/java/sh/libre/scim/core/GroupAdapter.java index e7edf6d7c8..5b5b94420a 100644 --- a/src/main/java/sh/libre/scim/core/GroupAdapter.java +++ b/src/main/java/sh/libre/scim/core/GroupAdapter.java @@ -10,6 +10,7 @@ import jakarta.persistence.NoResultException; import de.captaingoldfish.scim.sdk.common.resources.Group; import de.captaingoldfish.scim.sdk.common.resources.multicomplex.Member; import de.captaingoldfish.scim.sdk.common.resources.complex.Meta; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.jboss.logging.Logger; import org.keycloak.models.GroupModel; @@ -47,7 +48,7 @@ public class GroupAdapter extends Adapter { .getGroupMembersStream(session.getContext().getRealm(), group) .map(x -> x.getId()) .collect(Collectors.toSet()); - this.skip = StringUtils.equals(group.getFirstAttribute("scim-skip"), "true"); + this.skip = BooleanUtils.TRUE.equals(group.getFirstAttribute("scim-skip")); } @Override diff --git a/src/main/java/sh/libre/scim/core/UserAdapter.java b/src/main/java/sh/libre/scim/core/UserAdapter.java index ff85170bc0..4d40d5590e 100644 --- a/src/main/java/sh/libre/scim/core/UserAdapter.java +++ b/src/main/java/sh/libre/scim/core/UserAdapter.java @@ -15,6 +15,7 @@ import de.captaingoldfish.scim.sdk.common.resources.complex.Name; import de.captaingoldfish.scim.sdk.common.resources.multicomplex.PersonRole; import de.captaingoldfish.scim.sdk.common.resources.complex.Meta; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.jboss.logging.Logger; import org.keycloak.models.KeycloakSession; @@ -119,17 +120,17 @@ public class UserAdapter extends Adapter { setLastName(user.getLastName()); var rolesSet = new HashSet(); user.getGroupsStream().flatMap(g -> g.getRoleMappingsStream()) - .filter((r) -> StringUtils.equals(r.getFirstAttribute("scim"), "true")) + .filter((r) -> BooleanUtils.TRUE.equals(r.getFirstAttribute("scim"))) .map((r) -> r.getName()) .forEach(r -> rolesSet.add(r)); user.getRoleMappingsStream() - .filter((r) -> StringUtils.equals(r.getFirstAttribute("scim"), "true")) + .filter((r) -> BooleanUtils.TRUE.equals(r.getFirstAttribute("scim"))) .map((r) -> r.getName()) .forEach(r -> rolesSet.add(r)); var roles = new String[rolesSet.size()]; rolesSet.toArray(roles); setRoles(roles); - this.skip = StringUtils.equals(user.getFirstAttribute("scim-skip"), "true"); + this.skip = BooleanUtils.TRUE.equals(user.getFirstAttribute("scim-skip")); } @Override diff --git a/src/main/java/sh/libre/scim/event/ScimEventListenerProvider.java b/src/main/java/sh/libre/scim/event/ScimEventListenerProvider.java index 24dab78dbb..b64cf49739 100644 --- a/src/main/java/sh/libre/scim/event/ScimEventListenerProvider.java +++ b/src/main/java/sh/libre/scim/event/ScimEventListenerProvider.java @@ -3,6 +3,7 @@ package sh.libre.scim.event; import java.util.HashMap; import java.util.regex.Pattern; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.jboss.logging.Logger; import org.keycloak.events.Event; @@ -100,7 +101,7 @@ public class ScimEventListenerProvider implements EventListenerProvider { var groupId = matcher.group(2); LOGGER.infof("%s %s from %s", event.getOperationType(), userId, groupId); var group = getGroup(groupId); - group.setSingleAttribute("scim-dirty", "true"); + group.setSingleAttribute("scim-dirty", BooleanUtils.TRUE); var user = getUser(userId); dispatcher.run(ScimDispatcher.SCOPE_USER, (client) -> client.replace(UserAdapter.class, user)); } diff --git a/src/main/java/sh/libre/scim/storage/ScimStorageProviderFactory.java b/src/main/java/sh/libre/scim/storage/ScimStorageProviderFactory.java index 265c6c65ea..7b6336d9ae 100644 --- a/src/main/java/sh/libre/scim/storage/ScimStorageProviderFactory.java +++ b/src/main/java/sh/libre/scim/storage/ScimStorageProviderFactory.java @@ -5,6 +5,7 @@ import java.util.List; import jakarta.ws.rs.core.MediaType; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.jboss.logging.Logger; import org.keycloak.component.ComponentModel; @@ -74,14 +75,14 @@ public class ScimStorageProviderFactory .type(ProviderConfigProperty.BOOLEAN_TYPE) .label("Enable user propagation") .helpText("Should operation on users be propagated to this provider ?") - .defaultValue("true") + .defaultValue(BooleanUtils.TRUE) .add() .property() .name("propagation-group") .type(ProviderConfigProperty.BOOLEAN_TYPE) .label("Enable group propagation") .helpText("Should operation on groups be propagated to this provider ?") - .defaultValue("true") + .defaultValue(BooleanUtils.TRUE) .add() .property() .name("sync-import") @@ -132,10 +133,10 @@ public class ScimStorageProviderFactory var realm = session.realms().getRealm(realmId); session.getContext().setRealm(realm); var dispatcher = new ScimDispatcher(session); - if (StringUtils.equals(model.get("propagation-user"), "true")) { + if (BooleanUtils.TRUE.equals(model.get("propagation-user"))) { dispatcher.runOne(model, (client) -> client.sync(UserAdapter.class, result)); } - if (StringUtils.equals(model.get("propagation-group"), "true")) { + if (BooleanUtils.TRUE.equals(model.get("propagation-group"))) { dispatcher.runOne(model, (client) -> client.sync(GroupAdapter.class, result)); } } @@ -163,7 +164,7 @@ public class ScimStorageProviderFactory session.getContext().setRealm(realm); var dispatcher = new ScimDispatcher(session); for (var group : session.groups().getGroupsStream(realm) - .filter(x -> StringUtils.equals(x.getFirstAttribute("scim-dirty"), "true")).toList()) { + .filter(x -> BooleanUtils.TRUE.equals(x.getFirstAttribute("scim-dirty"))).toList()) { LOGGER.debug(group.getName() + " is dirty"); dispatcher.run(ScimDispatcher.SCOPE_GROUP, (client) -> client.replace(GroupAdapter.class, group));