From 01da1ef5c88ee5e91dbe9f110fcabed6f75b7239 Mon Sep 17 00:00:00 2001 From: egonzalez Date: Thu, 6 May 2021 10:38:57 +0200 Subject: [PATCH] fix LDAP validation problem in human-task-core --- .../services/task/identity/AbstractLDAPUserGroupInfo.java | 5 +---- .../services/task/identity/LDAPUserGroupCallbackImpl.java | 3 +++ .../org/jbpm/services/task/identity/LDAPUserInfoImpl.java | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/identity/AbstractLDAPUserGroupInfo.java b/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/identity/AbstractLDAPUserGroupInfo.java index 50210e86d6..73a2da8814 100644 --- a/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/identity/AbstractLDAPUserGroupInfo.java +++ b/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/identity/AbstractLDAPUserGroupInfo.java @@ -20,7 +20,6 @@ import javax.naming.Context; -import org.jbpm.services.task.utils.LdapSearcher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,9 +33,8 @@ abstract class AbstractLDAPUserGroupInfo extends AbstractUserGroupInfo { protected static final String DEFAULT_ROLE_ATTR_ID = "cn"; protected static final String DEFAULT_USER_ATTR_ID = "uid"; - private Properties config; + protected Properties config; - protected LdapSearcher ldapSearcher; protected AbstractLDAPUserGroupInfo(String[] requiredProperties, String defaultPropertiesName) { String propertiesLocation = System.getProperty(defaultPropertiesName); @@ -57,7 +55,6 @@ private void initialize(String[] requiredProperties, Properties config) { copyConfigProperty(BIND_USER, Context.SECURITY_PRINCIPAL); copyConfigProperty(BIND_PWD, Context.SECURITY_CREDENTIALS); - ldapSearcher = new LdapSearcher(this.config); } private void copyConfigProperty(String sourceKey, String targetKey) { diff --git a/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/identity/LDAPUserGroupCallbackImpl.java b/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/identity/LDAPUserGroupCallbackImpl.java index 440ef12010..e91a15caf5 100644 --- a/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/identity/LDAPUserGroupCallbackImpl.java +++ b/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/identity/LDAPUserGroupCallbackImpl.java @@ -23,6 +23,7 @@ import javax.naming.directory.SearchResult; +import org.jbpm.services.task.utils.LdapSearcher; import org.kie.api.task.UserGroupCallback; /** @@ -107,6 +108,7 @@ public boolean existsGroup(String groupId) { } private boolean existsEntity(String entityId, String context, String filter, String attributeId) { + LdapSearcher ldapSearcher = new LdapSearcher(this.config); entityId = escapeIllegalChars(entityId); String ldapEntityId = ldapSearcher.search(context, filter, entityId).getSingleAttributeResult(attributeId); return entityId.equals(ldapEntityId); @@ -114,6 +116,7 @@ private boolean existsEntity(String entityId, String context, String filter, Str @Override public List getGroupsForUser(String userId) { + LdapSearcher ldapSearcher = new LdapSearcher(this.config); String roleContext = getConfigProperty(USER_ROLES_CTX, getConfigProperty(ROLE_CTX)); String roleFilter = getConfigProperty(USER_ROLES_FILTER); String roleAttributeId = getConfigProperty(ROLE_ATTR_ID, DEFAULT_ROLE_ATTR_ID); diff --git a/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/identity/LDAPUserInfoImpl.java b/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/identity/LDAPUserInfoImpl.java index b00a70b082..56487c2f48 100644 --- a/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/identity/LDAPUserInfoImpl.java +++ b/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/identity/LDAPUserInfoImpl.java @@ -83,6 +83,7 @@ public String getDisplayName(OrganizationalEntity entity) { @Override public Iterator getMembersForGroup(Group group) { + LdapSearcher ldapSearcher = new LdapSearcher(this.config); String roleContext = getConfigProperty(ROLE_CTX); String roleFilter = getConfigProperty(ROLE_MEMBERS_FILTER, getConfigProperty(ROLE_FILTER)); String roleAttrId = getConfigProperty(MEMBER_ATTR_ID, DEFAULT_MEMBER_ATTR_ID); @@ -114,6 +115,7 @@ public String getLanguageForEntity(OrganizationalEntity entity) { } private String getAttributeValueForEntity(OrganizationalEntity entity, String attributeName, String defaultValue) { + LdapSearcher ldapSearcher = new LdapSearcher(this.config); String context = getConfigPropertyByEntity(entity, USER_CTX, ROLE_CTX); String filter = getConfigPropertyByEntity(entity, USER_FILTER, ROLE_FILTER); String attrId = getConfigProperty(attributeName, defaultValue); @@ -174,7 +176,8 @@ private boolean isEntityIdDn() { } @Override - public String getEntityForEmail(String email) { + public String getEntityForEmail(String email) { + LdapSearcher ldapSearcher = new LdapSearcher(this.config); String context = getConfigProperty(USER_CTX); String filter = getConfigProperty(EMAIL_FILTER); String attributeId = getConfigProperty(USER_ATTR_ID, DEFAULT_USER_ATTR_ID);