diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authSession/JpaRootAuthenticationSessionModelCriteriaBuilder.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authSession/JpaRootAuthenticationSessionModelCriteriaBuilder.java index 01e14176a9..f5a6605914 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authSession/JpaRootAuthenticationSessionModelCriteriaBuilder.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/authSession/JpaRootAuthenticationSessionModelCriteriaBuilder.java @@ -41,7 +41,7 @@ public class JpaRootAuthenticationSessionModelCriteriaBuilder extends JpaModelCr public JpaRootAuthenticationSessionModelCriteriaBuilder compare(SearchableModelField modelField, Operator op, Object... value) { switch (op) { case EQ: - if (modelField.equals(SearchableFields.REALM_ID)) { + if (modelField == SearchableFields.REALM_ID) { validateValue(value, modelField, op, String.class); @@ -53,7 +53,7 @@ public class JpaRootAuthenticationSessionModelCriteriaBuilder extends JpaModelCr } case LT: - if (modelField.equals(SearchableFields.EXPIRATION)) { + if (modelField == SearchableFields.EXPIRATION) { validateValue(value, modelField, op, Number.class); Number expiration = (Number) value[0]; diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/client/JpaClientModelCriteriaBuilder.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/client/JpaClientModelCriteriaBuilder.java index f9091a978c..9bdbfe791d 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/client/JpaClientModelCriteriaBuilder.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/client/JpaClientModelCriteriaBuilder.java @@ -44,21 +44,21 @@ public class JpaClientModelCriteriaBuilder extends JpaModelCriteriaBuilder modelField, Operator op, Object... value) { switch (op) { case EQ: - if (modelField.equals(SearchableFields.REALM_ID) || - modelField.equals(SearchableFields.CLIENT_ID)) { + if (modelField == SearchableFields.REALM_ID || + modelField == SearchableFields.CLIENT_ID) { validateValue(value, modelField, op, String.class); return new JpaClientModelCriteriaBuilder((cb, root) -> cb.equal(root.get(modelField.getName()), value[0]) ); - } else if (modelField.equals(SearchableFields.ENABLED)) { + } else if (modelField == SearchableFields.ENABLED) { validateValue(value, modelField, op, Boolean.class); return new JpaClientModelCriteriaBuilder((cb, root) -> cb.equal(root.get(modelField.getName()), value[0]) ); - } else if (modelField.equals(SearchableFields.SCOPE_MAPPING_ROLE)) { + } else if (modelField == SearchableFields.SCOPE_MAPPING_ROLE) { validateValue(value, modelField, op, String.class); return new JpaClientModelCriteriaBuilder((cb, root) -> @@ -67,7 +67,7 @@ public class JpaClientModelCriteriaBuilder extends JpaModelCriteriaBuilder", JsonbType.class, root.get("metadata"), cb.literal("fScopeMappings")), cb.literal(convertToJson(value[0])))) ); - } else if (modelField.equals(SearchableFields.ALWAYS_DISPLAY_IN_CONSOLE)) { + } else if (modelField == SearchableFields.ALWAYS_DISPLAY_IN_CONSOLE) { validateValue(value, modelField, op, Boolean.class); return new JpaClientModelCriteriaBuilder((cb, root) -> @@ -75,7 +75,7 @@ public class JpaClientModelCriteriaBuilder extends JpaModelCriteriaBuilder", JsonbType.class, root.get("metadata"), cb.literal("fAlwaysDisplayInConsole")), cb.literal(convertToJson(value[0]))) ); - } else if (modelField.equals(SearchableFields.ATTRIBUTE)) { + } else if (modelField == SearchableFields.ATTRIBUTE) { validateValue(value, modelField, op, String.class, String.class); return new JpaClientModelCriteriaBuilder((cb, root) -> { @@ -90,7 +90,7 @@ public class JpaClientModelCriteriaBuilder extends JpaModelCriteriaBuilder diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/clientscope/JpaClientScopeModelCriteriaBuilder.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/clientscope/JpaClientScopeModelCriteriaBuilder.java index eec1b1dd45..838644aba5 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/clientscope/JpaClientScopeModelCriteriaBuilder.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/clientscope/JpaClientScopeModelCriteriaBuilder.java @@ -41,8 +41,8 @@ public class JpaClientScopeModelCriteriaBuilder extends JpaModelCriteriaBuilder< public JpaClientScopeModelCriteriaBuilder compare(SearchableModelField modelField, Operator op, Object... value) { switch (op) { case EQ: - if (modelField.equals(SearchableFields.REALM_ID) || - modelField.equals(SearchableFields.NAME)) { + if (modelField == SearchableFields.REALM_ID || + modelField == SearchableFields.NAME) { validateValue(value, modelField, op, String.class); diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/group/JpaGroupModelCriteriaBuilder.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/group/JpaGroupModelCriteriaBuilder.java index 73b2578344..eafbdfa13e 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/group/JpaGroupModelCriteriaBuilder.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/group/JpaGroupModelCriteriaBuilder.java @@ -52,14 +52,14 @@ public class JpaGroupModelCriteriaBuilder extends JpaModelCriteriaBuilder modelField, Operator op, Object... value) { switch (op) { case EQ: - if (modelField.equals(GroupModel.SearchableFields.REALM_ID) || - modelField.equals(GroupModel.SearchableFields.NAME)) { + if (modelField == GroupModel.SearchableFields.REALM_ID || + modelField == GroupModel.SearchableFields.NAME) { validateValue(value, modelField, op, String.class); return new JpaGroupModelCriteriaBuilder((cb, root) -> cb.equal(root.get(modelField.getName()), value[0]) ); - } else if (modelField.equals(GroupModel.SearchableFields.PARENT_ID)) { + } else if (modelField == GroupModel.SearchableFields.PARENT_ID) { if (value.length == 1 && Objects.isNull(value[0])) { return new JpaGroupModelCriteriaBuilder((cb, root) -> cb.isNull(root.get("parentId")) @@ -71,7 +71,7 @@ public class JpaGroupModelCriteriaBuilder extends JpaModelCriteriaBuilder cb.equal(root.get("parentId"), value[0]) ); - } else if (modelField.equals(GroupModel.SearchableFields.ASSIGNED_ROLE)) { + } else if (modelField == GroupModel.SearchableFields.ASSIGNED_ROLE) { validateValue(value, modelField, op, String.class); return new JpaGroupModelCriteriaBuilder((cb, root) -> @@ -84,7 +84,7 @@ public class JpaGroupModelCriteriaBuilder extends JpaModelCriteriaBuilder collectionValues; @@ -125,7 +125,7 @@ public class JpaGroupModelCriteriaBuilder extends JpaModelCriteriaBuilder cb.isNull(root.get("parentId")) diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/loginFailure/JpaUserLoginFailureModelCriteriaBuilder.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/loginFailure/JpaUserLoginFailureModelCriteriaBuilder.java index fd82ed530d..09645a79a3 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/loginFailure/JpaUserLoginFailureModelCriteriaBuilder.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/loginFailure/JpaUserLoginFailureModelCriteriaBuilder.java @@ -47,8 +47,8 @@ public class JpaUserLoginFailureModelCriteriaBuilder extends JpaModelCriteriaBui public JpaUserLoginFailureModelCriteriaBuilder compare(SearchableModelField modelField, Operator op, Object... value) { switch (op) { case EQ: - if (modelField.equals(UserLoginFailureModel.SearchableFields.REALM_ID) || - modelField.equals(UserLoginFailureModel.SearchableFields.USER_ID)) { + if (modelField == UserLoginFailureModel.SearchableFields.REALM_ID || + modelField == UserLoginFailureModel.SearchableFields.USER_ID) { validateValue(value, modelField, op, String.class); diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/realm/JpaRealmModelCriteriaBuilder.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/realm/JpaRealmModelCriteriaBuilder.java index aab08945d0..3894d0f079 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/realm/JpaRealmModelCriteriaBuilder.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/realm/JpaRealmModelCriteriaBuilder.java @@ -54,12 +54,12 @@ public class JpaRealmModelCriteriaBuilder extends JpaModelCriteriaBuilder modelField, Operator op, Object... value) { switch(op) { case EQ: - if (modelField.equals(RealmModel.SearchableFields.NAME)) { + if (modelField == RealmModel.SearchableFields.NAME) { validateValue(value, modelField, op, String.class); return new JpaRealmModelCriteriaBuilder((cb, root) -> cb.equal(root.get(modelField.getName()), value[0]) ); - } else if (modelField.equals(RealmModel.SearchableFields.COMPONENT_PROVIDER_TYPE)) { + } else if (modelField == RealmModel.SearchableFields.COMPONENT_PROVIDER_TYPE) { validateValue(value, modelField, op, String.class); return new JpaRealmModelCriteriaBuilder((cb, root) -> cb.equal(root.join("components").get("providerType"), value[0]), true); @@ -67,7 +67,7 @@ public class JpaRealmModelCriteriaBuilder extends JpaModelCriteriaBuilder cb.isTrue(cb.function("->", JsonbType.class, root.get("metadata"), cb.literal("fClientInitialAccesses")).isNotNull()) diff --git a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/role/JpaRoleModelCriteriaBuilder.java b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/role/JpaRoleModelCriteriaBuilder.java index 30506589ef..a7027b1e7a 100644 --- a/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/role/JpaRoleModelCriteriaBuilder.java +++ b/model/map-jpa/src/main/java/org/keycloak/models/map/storage/jpa/role/JpaRoleModelCriteriaBuilder.java @@ -54,15 +54,17 @@ public class JpaRoleModelCriteriaBuilder extends JpaModelCriteriaBuilder modelField, Operator op, Object... value) { switch (op) { case EQ: - if (modelField.equals(SearchableFields.REALM_ID) || - modelField.equals(SearchableFields.CLIENT_ID) || - modelField.equals(SearchableFields.NAME)) { + if (modelField == SearchableFields.REALM_ID || + modelField == SearchableFields.CLIENT_ID || + modelField == SearchableFields.NAME) { + validateValue(value, modelField, op, String.class); return new JpaRoleModelCriteriaBuilder((cb, root) -> cb.equal(root.get(modelField.getName()), value[0]) ); - } else if (modelField == SearchableFields.COMPOSITE_ROLE){ + } else if (modelField == SearchableFields.COMPOSITE_ROLE) { + validateValue(value, modelField, op, String.class); return new JpaRoleModelCriteriaBuilder((cb, root) -> @@ -75,7 +77,7 @@ public class JpaRoleModelCriteriaBuilder extends JpaModelCriteriaBuilder collectionValues; @@ -127,8 +129,8 @@ public class JpaRoleModelCriteriaBuilder extends JpaModelCriteriaBuilder modelField, Operator op, Object... value) { switch (op) { case EQ: - if (modelField.equals(RoleModel.SearchableFields.IS_CLIENT_ROLE)) { + if (modelField == RoleModel.SearchableFields.IS_CLIENT_ROLE) { LdapRoleModelCriteriaBuilder result = new LdapRoleModelCriteriaBuilder(roleMapperConfig, StringBuilder::new); result.isClientRole = (boolean) value[0]; return result; - } else if (modelField.equals(RoleModel.SearchableFields.CLIENT_ID)) { + } else if (modelField == RoleModel.SearchableFields.CLIENT_ID) { LdapRoleModelCriteriaBuilder result = new LdapRoleModelCriteriaBuilder(roleMapperConfig, StringBuilder::new); result.clientId = (String) value[0]; return result; - } else if (modelField.equals(RoleModel.SearchableFields.REALM_ID)) { + } else if (modelField == RoleModel.SearchableFields.REALM_ID) { LdapRoleModelCriteriaBuilder result = new LdapRoleModelCriteriaBuilder(roleMapperConfig, StringBuilder::new); result.realmId = (String) value[0]; return result; - } else if (modelField.equals(RoleModel.SearchableFields.NAME)) { + } else if (modelField == RoleModel.SearchableFields.NAME) { // validateValue(value, modelField, op, String.class); String field = modelFieldNameToLdap(roleMapperConfig, modelField); return new LdapRoleModelCriteriaBuilder(roleMapperConfig, @@ -148,11 +148,11 @@ public class LdapRoleModelCriteriaBuilder extends LdapModelCriteriaBuilder { Object[] v; @@ -208,11 +208,11 @@ public class LdapRoleModelCriteriaBuilder extends LdapModelCriteriaBuilder modelField) { - if (modelField.equals(RoleModel.SearchableFields.NAME)) { + if (modelField == RoleModel.SearchableFields.NAME) { return roleMapperConfig.getRoleNameLdapAttribute(); - } else if (modelField.equals(RoleModel.SearchableFields.ID)) { + } else if (modelField == RoleModel.SearchableFields.ID) { return roleMapperConfig.getLdapMapConfig().getUuidLDAPAttributeName(); - } else if (modelField.equals(RoleModel.SearchableFields.DESCRIPTION)) { + } else if (modelField == RoleModel.SearchableFields.DESCRIPTION) { return "description"; } else { throw new CriterionNotSupportedException(modelField, null);