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 LDAP validation problem in human-task-core #1927

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -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