Package org.keycloak.storage.jpa
Class JpaHashUtils
java.lang.Object
org.keycloak.storage.jpa.JpaHashUtils
Create hashes for long values stored in the database. Offers different variants for exact and lowercase search.
Keycloak uses lowercase search to approximate a case-insensitive search.
The lowercase function always uses the English locale to avoid changing hashes due to changing locales which can be surprising and would be expensive to fix as all hashes would need to be re-calculated.
- Author:
- Alexander Schwartz
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
compareSourceValue
(String value1, String value2) static boolean
compareSourceValueLowerCase
(String value1, String value2) static byte[]
hashForAttributeValue
(String value) static byte[]
static Predicate<UserEntity>
predicateForFilteringUsersByAttributes
(Map<String, String> customLongValueSearchAttributes, BiPredicate<String, String> valueComparator) This method returns a predicate that returns true when user has all attributes specified incustomLongValueSearchAttributes
map
-
Constructor Details
-
JpaHashUtils
public JpaHashUtils()
-
-
Method Details
-
hashForAttributeValue
-
hashForAttributeValueLowerCase
-
compareSourceValueLowerCase
-
compareSourceValue
-
predicateForFilteringUsersByAttributes
public static Predicate<UserEntity> predicateForFilteringUsersByAttributes(Map<String, String> customLongValueSearchAttributes, BiPredicate<String, String> valueComparator) This method returns a predicate that returns true when user has all attributes specified incustomLongValueSearchAttributes
map The check is performed by exact comparison on attribute name the value This is necessary because database can return users without the searched attribute when a hash collision on long user attribute value occurs- Parameters:
customLongValueSearchAttributes
- required attributesvalueComparator
- comparator for comparing attribute values- Returns:
- predicate for filtering users based on attributes map
-