From 7d42a4e1d2a811a93659c48e526ed540c51596d7 Mon Sep 17 00:00:00 2001 From: Brendan Le Ny Date: Wed, 12 Jun 2024 15:34:22 +0200 Subject: [PATCH] Remove pointless use of StringUtils --- src/main/java/sh/libre/scim/core/GroupAdapter.java | 5 +++-- src/main/java/sh/libre/scim/core/ScimDispatcher.java | 2 +- src/main/java/sh/libre/scim/core/UserAdapter.java | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/sh/libre/scim/core/GroupAdapter.java b/src/main/java/sh/libre/scim/core/GroupAdapter.java index aa42531bc2..31b25b5769 100644 --- a/src/main/java/sh/libre/scim/core/GroupAdapter.java +++ b/src/main/java/sh/libre/scim/core/GroupAdapter.java @@ -121,8 +121,9 @@ public class GroupAdapter extends Adapter { @Override public Boolean tryToMap() { - Optional group = session.groups().getGroupsStream(realm).filter( - x -> StringUtils.equals(x.getName(), externalId) || StringUtils.equals(x.getName(), displayName)) + Set names = Set.of(externalId, displayName); + Optional group = session.groups().getGroupsStream(realm) + .filter(groupModel -> names.contains(groupModel.getName())) .findFirst(); if (group.isPresent()) { setId(group.get().getId()); diff --git a/src/main/java/sh/libre/scim/core/ScimDispatcher.java b/src/main/java/sh/libre/scim/core/ScimDispatcher.java index 3858c1bd39..4b2beedf2c 100644 --- a/src/main/java/sh/libre/scim/core/ScimDispatcher.java +++ b/src/main/java/sh/libre/scim/core/ScimDispatcher.java @@ -25,7 +25,7 @@ public class ScimDispatcher { public void run(String scope, Consumer f) { session.getContext().getRealm().getComponentsStream() .filter((m) -> { - return StringUtils.equals(ScimStorageProviderFactory.ID, m.getProviderId()) + return ScimStorageProviderFactory.ID.equals(m.getProviderId()) && m.get("enabled", true) && m.get("propagation-" + scope, false); }) diff --git a/src/main/java/sh/libre/scim/core/UserAdapter.java b/src/main/java/sh/libre/scim/core/UserAdapter.java index 6f8677113d..8d527f8def 100644 --- a/src/main/java/sh/libre/scim/core/UserAdapter.java +++ b/src/main/java/sh/libre/scim/core/UserAdapter.java @@ -235,6 +235,6 @@ public class UserAdapter extends Adapter { @Override public Boolean skipRefresh() { - return StringUtils.equals(getUsername(), "admin"); + return "admin".equals(getUsername()); } }