-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature 287 Add attributes to an OrganizationMembership #290
base: main
Are you sure you want to change the base?
Conversation
fd9648a
to
3d6aca4
Compare
@@ -330,4 +414,17 @@ public Stream<IdentityProviderModel> getIdentityProvidersStream() { | |||
return orgs.contains(getId()); | |||
}); | |||
} | |||
|
|||
private Predicate[] getSearchOptionPredicateArray(String value, CriteriaBuilder builder, From<?, UserEntity> from) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xgp maybe we could adapt our approach in the future to use the Keycloak default search filter org.keycloak.models.jpa.getSearchOptionPredicateArray. I think it covers more cases, and we will be consistent.
In the meantime the approach is not compatible with our test testSearchMembersWithMultipleNameParameter. If some clients are using it we will break their functionalities
private Predicate[] getSearchOptionPredicateArray(String value, CriteriaBuilder builder, From<?, UserEntity> from) {
value = value.trim().toLowerCase();List<Predicate> orPredicates = new ArrayList<>(); if (value.length() >= 2 && value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { // exact search value = value.substring(1, value.length() - 1); orPredicates.add(builder.equal(from.get(USERNAME), value)); orPredicates.add(builder.equal(from.get(EMAIL), value)); orPredicates.add(builder.equal(builder.lower(from.get(FIRST_NAME)), value)); orPredicates.add(builder.equal(builder.lower(from.get(LAST_NAME)), value)); } else { value = value.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_"); value = value.replace("*", "%"); if (value.isEmpty() || value.charAt(value.length() - 1) != '%') value += "%"; orPredicates.add(builder.like(from.get(USERNAME), value, ESCAPE_BACKSLASH)); orPredicates.add(builder.like(from.get(EMAIL), value, ESCAPE_BACKSLASH)); orPredicates.add(builder.like(builder.lower(from.get(FIRST_NAME)), value, ESCAPE_BACKSLASH)); orPredicates.add(builder.like(builder.lower(from.get(LAST_NAME)), value, ESCAPE_BACKSLASH)); } return orPredicates.toArray(Predicate[]::new);
}
No description provided.