From 208659d42e659ab213053cf9796cd232eb7b3171 Mon Sep 17 00:00:00 2001 From: Brendan Le Ny Date: Wed, 12 Jun 2024 15:38:47 +0200 Subject: [PATCH] Remove string comparaison using '==' --- src/main/java/sh/libre/scim/core/UserAdapter.java | 3 ++- src/main/java/sh/libre/scim/jpa/ScimResourceId.java | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/sh/libre/scim/core/UserAdapter.java b/src/main/java/sh/libre/scim/core/UserAdapter.java index 76ecb344fb..ca0abf841c 100644 --- a/src/main/java/sh/libre/scim/core/UserAdapter.java +++ b/src/main/java/sh/libre/scim/core/UserAdapter.java @@ -18,6 +18,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.stream.Stream; @@ -211,7 +212,7 @@ public class UserAdapter extends Adapter { sameEmailUser = session.users().getUserByEmail(realm, email); } if ((sameUsernameUser != null && sameEmailUser != null) - && (sameUsernameUser.getId() != sameEmailUser.getId())) { + && (!StringUtils.equals(sameUsernameUser.getId(), sameEmailUser.getId()))) { logger.warnf("found 2 possible users for remote user %s %s", username, email); return false; } diff --git a/src/main/java/sh/libre/scim/jpa/ScimResourceId.java b/src/main/java/sh/libre/scim/jpa/ScimResourceId.java index 1df199282b..99bce7673e 100644 --- a/src/main/java/sh/libre/scim/jpa/ScimResourceId.java +++ b/src/main/java/sh/libre/scim/jpa/ScimResourceId.java @@ -1,5 +1,7 @@ package sh.libre.scim.jpa; +import org.apache.commons.lang3.StringUtils; + import java.io.Serializable; import java.util.Objects; @@ -69,11 +71,11 @@ public class ScimResourceId implements Serializable { return false; ScimResourceId o = (ScimResourceId) other; // TODO - return (o.id == id && - o.realmId == realmId && - o.componentId == componentId && - o.type == type && - o.externalId == externalId); + return (StringUtils.equals(o.id, id) && + StringUtils.equals(o.realmId, realmId) && + StringUtils.equals(o.componentId, componentId) && + StringUtils.equals(o.type, type) && + StringUtils.equals(o.externalId, externalId)); } @Override