Skip to content

Commit

Permalink
fix LDAP validation problem in human-task-core
Browse files Browse the repository at this point in the history
  • Loading branch information
egonzalez committed Aug 17, 2021
1 parent d5ce79b commit 01da1ef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import javax.naming.Context;

import org.jbpm.services.task.utils.LdapSearcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -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);
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import javax.naming.directory.SearchResult;

import org.jbpm.services.task.utils.LdapSearcher;
import org.kie.api.task.UserGroupCallback;

/**
Expand Down Expand Up @@ -107,13 +108,15 @@ 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);
}

@Override
public List<String> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public String getDisplayName(OrganizationalEntity entity) {

@Override
public Iterator<OrganizationalEntity> 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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 01da1ef

Please sign in to comment.