Skip to content
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

Fix for issue JBPM-10238 adding case insensitive comparison for entity #2435

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* <li>ldap.user.id.dn (optional, is user id a DN, instructs the callback to query for user DN before searching for roles, default false)</li>
* <li>ldap.search.scope (optional, if not given 'ONELEVEL_SCOPE' will be used) possible values are: OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE</li>
* <li>ldap.name.escape (optional, instructs to escape - illegal character in user/group name before the query - currently escapes only comma) by default is set to true</li>
* <li>ldap.entity.ignore.case (optional, perform case insensitive comparison for entity) by default is set to false</li>
* <li>java.naming.factory.initial</li>
* <li>java.naming.security.authentication</li>
* <li>java.naming.security.protocol</li>
Expand All @@ -66,6 +67,7 @@ public class LDAPUserGroupCallbackImpl extends AbstractLDAPUserGroupInfo impleme
public static final String IS_USER_ID_DN = "ldap.user.id.dn";
public static final String SEARCH_SCOPE = "ldap.search.scope";
public static final String LDAP_NAME_ESCAPE = "ldap.name.escape";
public static final String LDAP_ENTIY_IGNORE_CASE = "ldap.entity.ignore.case";

private static final String[] REQUIRED_PROPERTIES = {USER_CTX, ROLE_CTX, USER_FILTER, ROLE_FILTER, USER_ROLES_FILTER};

Expand Down Expand Up @@ -109,6 +111,9 @@ public boolean existsGroup(String groupId) {
private boolean existsEntity(String entityId, String context, String filter, String attributeId) {
entityId = escapeIllegalChars(entityId);
String ldapEntityId = ldapSearcher.search(context, filter, entityId).getSingleAttributeResult(attributeId);
if(isIgnoreCase()){
return entityId.equalsIgnoreCase(ldapEntityId);
}
return entityId.equals(ldapEntityId);
sudhishmk marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down Expand Up @@ -139,6 +144,10 @@ private boolean isUserIdDn() {
private boolean escapeOn() {
return Boolean.parseBoolean(getConfigProperty(LDAP_NAME_ESCAPE, "true"));
}

private boolean isIgnoreCase() {
return Boolean.parseBoolean(getConfigProperty(LDAP_ENTIY_IGNORE_CASE, "false"));
}

protected String escapeIllegalChars(String entityId) {
if (!escapeOn()) {
Expand Down
Loading