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

Upgrade org.apache.directory.api:api-all from 1.0.0-RC2 to 2.1.0 #20

Open
wants to merge 1 commit into
base: master
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
4 changes: 2 additions & 2 deletions source/ddc-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.imperva.ddc</groupId>
<artifactId>domain-directory-controller</artifactId>
<version>7.4.0.0.0.0</version>
<version>7.4.1.0.0.0</version>
</parent>

<artifactId>ddc-core</artifactId>
Expand All @@ -15,7 +15,7 @@
<dependency>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-all</artifactId>
<version>1.0.0-RC2</version> <!-- Mina version: 2.0.16 -->
<version>2.1.0</version> <!-- Mina version: 2.1.3 -->
</dependency>
<dependency>
<groupId>org.mockito</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
package com.imperva.ddc.core;

import com.imperva.ddc.core.exceptions.ProtocolException;
import com.imperva.ddc.core.query.*;
import org.apache.directory.api.ldap.model.entry.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import org.apache.directory.api.ldap.model.entry.Attribute;
import org.apache.directory.api.ldap.model.entry.DefaultModification;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.entry.Modification;
import org.apache.directory.api.ldap.model.entry.ModificationOperation;
import org.apache.directory.api.ldap.model.entry.Value;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.message.SearchRequest;
import org.apache.directory.api.ldap.model.message.SearchRequestImpl;
import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.api.ldap.model.message.controls.PagedResults;
import org.apache.directory.api.ldap.model.message.controls.PagedResultsImpl;
import org.apache.directory.api.ldap.model.message.controls.SortRequest;
import org.apache.directory.api.ldap.model.message.controls.SortRequestControlImpl;
import org.apache.directory.api.ldap.model.message.controls.SortRequestImpl;
import org.apache.directory.api.ldap.model.name.Dn;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import com.imperva.ddc.core.exceptions.ProtocolException;
import com.imperva.ddc.core.query.EntityResponse;
import com.imperva.ddc.core.query.Field;
import com.imperva.ddc.core.query.ModificationDetails;
import com.imperva.ddc.core.query.Operation;
import com.imperva.ddc.core.query.QueryRequest;
import com.imperva.ddc.core.query.ReferralsHandling;
import com.imperva.ddc.core.query.SortKey;

/**
* Created by gabi.beyo on 02/07/2015.
Expand All @@ -40,25 +52,37 @@ String[] toStringArray(List<Field> entities) {
}

public Modification toModification(ModificationDetails modificationDetails) {
final String value = null == modificationDetails.getValue()
final Object value = null == modificationDetails.getValue()
? null
: modificationDetails.getValue().toString();
: modificationDetails.getValue();
Operation operation = modificationDetails.getOperation();
String strAttribute = modificationDetails.getAttribute().getName();

switch (operation) {
case ADD:
return new DefaultModification(ModificationOperation.ADD_ATTRIBUTE, strAttribute, value);
return new DefaultModification(ModificationOperation.ADD_ATTRIBUTE, strAttribute, convertToValue(value));
case REMOVE:
return null == value
? new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, strAttribute)
: new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, strAttribute, value);
: new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, strAttribute, convertToValue(value));
case REPLACE:
return new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, strAttribute, value);
return new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, strAttribute, convertToValue(value));
default:
return null;
}
}

Value convertToValue(Object value) {
if (value instanceof String) {
return new Value((String) value);
}
if (value instanceof Number) {
return new Value(value.toString());
}
if (value instanceof byte[]) {
return new Value((byte[]) value);
}
return null;
}

List<EntityResponse> toEntityResponse(List<Entry> entries, List<Field> requestedFields) {
Expand All @@ -70,7 +94,7 @@ List<EntityResponse> toEntityResponse(List<Entry> entries, List<Field> requested
for (Field field : requestedFields) {
if (field.getName().equals("*") || field.getName().equalsIgnoreCase(att.getId())) {
att.iterator().forEachRemaining(value -> {
entResponse.addValue(value.getValue(), att.getId(), field.getType());
entResponse.addValue(value, att.getId(), field.getType());
});
}
}
Expand Down Expand Up @@ -100,7 +124,7 @@ SearchRequest toSearchRequest(QueryRequest queryRequest, String baseSearchPath)

List<SortKey> sortKeys = queryRequest.getSortKeys();
if (!Objects.isNull(sortKeys) && !sortKeys.isEmpty()) {
SortRequestControlImpl sortRequest = applySort(sortKeys);
SortRequestImpl sortRequest = applySort(sortKeys);
search.addControl(sortRequest);
}
return search;
Expand Down Expand Up @@ -130,11 +154,11 @@ SearchRequest toSearchRequest(QueryRequest queryRequest, String baseSearchPath,
// }


SortRequestControlImpl applySort(List<SortKey> sortKeys) {
SortRequestImpl applySort(List<SortKey> sortKeys) {
if (Objects.isNull(sortKeys) && sortKeys.isEmpty()) {
throw new ProtocolException("Sorting keys can't be empty");
}
SortRequestControlImpl sortRequest = new SortRequestControlImpl();
SortRequestImpl sortRequest = new SortRequestImpl();
sortRequest.setCritical(false);

for (SortKey sortKey : sortKeys) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.imperva.ddc.core.commons.Utils;
import com.imperva.ddc.core.exceptions.*;
import com.imperva.ddc.core.query.*;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.directory.api.ldap.model.exception.LdapAuthenticationException;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ Object retrieveCookie(SearchCursor cursor) {
if (resultCodeEnum == ResultCodeEnum.UNWILLING_TO_PERFORM || resultCodeEnum == ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION || pagedSearchControl == null) {
throw new QueryFailedException("AD can't handle paging. pagedSearchControl null?: " + (pagedSearchControl == null) + ", result.getLdapResult().getResultCode(): " + result.getLdapResult().getResultCode().name());
}
Object cookie = pagedSearchControl.getCookie();
byte[] cookie = pagedSearchControl.getCookie();
if (cookie != null && cookie.length == 0) {
cookie = null;
}
LOGGER.trace("Retrieving cookie. Cookie value: {}", cookie);
return cookie;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.imperva.ddc.core.language.searchcriteria;

import com.imperva.ddc.core.query.DirectoryType;
import org.apache.commons.lang.NotImplementedException;
import org.apache.commons.lang3.NotImplementedException;


/**
Expand All @@ -16,7 +16,7 @@ public static SearchCriteriaBuilder create(DirectoryType directoryType){
searchCriteriaBuilder = new ActiveDirectorySearchCriteriaBuilderImpl();
break;
default:
throw new NotImplementedException();
throw new NotImplementedException("Directory type not implemented");
}
return searchCriteriaBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.imperva.ddc.core.query;

import org.apache.commons.lang.NotImplementedException;
import org.apache.commons.lang3.NotImplementedException;

public class AddRequestBuilderFactory {

Expand All @@ -11,7 +11,7 @@ public static AddCriteriaBuilder create(DirectoryType directoryType){
addCriteriaBuilder = new AddCriteriaBuilder();
break;
default:
throw new NotImplementedException();
throw new NotImplementedException("Directory type not implemented");
}
return addCriteriaBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.imperva.ddc.core.query;

import org.apache.commons.lang.NotImplementedException;
import org.apache.commons.lang3.NotImplementedException;

public class ChangeRequestBuilderFactory {

Expand All @@ -11,7 +11,7 @@ public static ChangeCriteriaBuilder create(DirectoryType directoryType){
changeCriteriaBuilder = new ChangeCriteriaBuilder();
break;
default:
throw new NotImplementedException();
throw new NotImplementedException("Directory type not implemented");
}
return changeCriteriaBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.imperva.ddc.core.query;

import org.apache.commons.lang.NotImplementedException;
import org.apache.commons.lang3.NotImplementedException;

public class RemoveRequestBuilderFactory {

Expand All @@ -11,7 +11,7 @@ public static RemoveCriteriaBuilder create(DirectoryType directoryType){
removeCriteriaBuilder = new RemoveCriteriaBuilder();
break;
default:
throw new NotImplementedException();
throw new NotImplementedException("Directory type not implemented");
}
return removeCriteriaBuilder;
}
Expand Down
4 changes: 2 additions & 2 deletions source/ddc-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.imperva.ddc</groupId>
<artifactId>domain-directory-controller</artifactId>
<version>7.4.0.0.0.0</version>
<version>7.4.1.0.0.0</version>
</parent>

<artifactId>ddc-service</artifactId>
Expand All @@ -14,7 +14,7 @@
<dependency>
<groupId>com.imperva.ddc</groupId>
<artifactId>ddc-core</artifactId>
<version>7.4.0.0.0.0</version>
<version>7.4.1.0.0.0</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion source/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<packaging>pom</packaging>
<groupId>com.imperva.ddc</groupId>
<artifactId>domain-directory-controller</artifactId>
<version>7.4.0.0.0.0</version>
<version>7.4.1.0.0.0</version>
<name>Domain Directory Controller</name>
<description>
DDC is an Active Directory Java SDK designed to simplify AD interaction for small, medium and large projects.
Expand Down
2 changes: 1 addition & 1 deletion startingkit/ddckit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<dependency>
<groupId>com.imperva.ddc</groupId>
<artifactId>ddc-service</artifactId>
<version>7.3.7.0.0.0</version>
<version>7.4.0.0.0.0</version>
</dependency>
</dependencies>

Expand Down