Use this. Before Member References

Closes gh-745
This commit is contained in:
Josh Cummings
2023-03-30 13:25:49 -06:00
parent 08b209fe5c
commit 5020af0837
133 changed files with 2364 additions and 2327 deletions

View File

@@ -68,11 +68,11 @@ public class DefaultValuesAuthenticationSourceDecorator implements Authenticatio
* <code>defaultPassword</code> otherwise.
*/
public String getCredentials() {
if (StringUtils.hasText(target.getPrincipal())) {
return target.getCredentials();
if (StringUtils.hasText(this.target.getPrincipal())) {
return this.target.getCredentials();
}
else {
return defaultPassword;
return this.defaultPassword;
}
}
@@ -83,12 +83,12 @@ public class DefaultValuesAuthenticationSourceDecorator implements Authenticatio
* otherwise.
*/
public String getPrincipal() {
String principal = target.getPrincipal();
String principal = this.target.getPrincipal();
if (StringUtils.hasText(principal)) {
return principal;
}
else {
return defaultUser;
return this.defaultUser;
}
}
@@ -123,15 +123,15 @@ public class DefaultValuesAuthenticationSourceDecorator implements Authenticatio
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
public void afterPropertiesSet() throws Exception {
if (target == null) {
if (this.target == null) {
throw new IllegalArgumentException("Property 'target' must be set.'");
}
if (defaultUser == null) {
if (this.defaultUser == null) {
throw new IllegalArgumentException("Property 'defaultUser' must be set.'");
}
if (defaultPassword == null) {
if (this.defaultPassword == null) {
throw new IllegalArgumentException("Property 'defaultPassword' must be set.'");
}
}

View File

@@ -101,20 +101,20 @@ public abstract class AbstractFallbackRequestAndResponseControlDirContextProcess
protected String fallbackResponseControl;
protected void loadControlClasses() {
Assert.notNull(defaultRequestControl, "defaultRequestControl must not be null");
Assert.notNull(defaultResponseControl, "defaultResponseControl must not be null");
Assert.notNull(fallbackRequestControl, "fallbackRequestControl must not be null");
Assert.notNull(fallbackResponseControl, "fallbackReponseControl must not be null");
Assert.notNull(this.defaultRequestControl, "defaultRequestControl must not be null");
Assert.notNull(this.defaultResponseControl, "defaultResponseControl must not be null");
Assert.notNull(this.fallbackRequestControl, "fallbackRequestControl must not be null");
Assert.notNull(this.fallbackResponseControl, "fallbackReponseControl must not be null");
try {
requestControlClass = Class.forName(defaultRequestControl);
responseControlClass = Class.forName(defaultResponseControl);
this.requestControlClass = Class.forName(this.defaultRequestControl);
this.responseControlClass = Class.forName(this.defaultResponseControl);
}
catch (ClassNotFoundException e) {
log.debug("Default control classes not found - falling back to LdapBP classes", e);
this.log.debug("Default control classes not found - falling back to LdapBP classes", e);
try {
requestControlClass = Class.forName(fallbackRequestControl);
responseControlClass = Class.forName(fallbackResponseControl);
this.requestControlClass = Class.forName(this.fallbackRequestControl);
this.responseControlClass = Class.forName(this.fallbackResponseControl);
}
catch (ClassNotFoundException e1) {
throw new UncategorizedLdapException(
@@ -155,7 +155,7 @@ public abstract class AbstractFallbackRequestAndResponseControlDirContextProcess
* @return Control to be used by the DirContextProcessor
*/
public Control createRequestControl(Class<?>[] paramTypes, Object[] params) {
Constructor<?> constructor = ClassUtils.getConstructorIfAvailable(requestControlClass, paramTypes);
Constructor<?> constructor = ClassUtils.getConstructorIfAvailable(this.requestControlClass, paramTypes);
if (constructor == null) {
throw new IllegalArgumentException("Failed to find an appropriate RequestControl constructor");
}
@@ -186,13 +186,13 @@ public abstract class AbstractFallbackRequestAndResponseControlDirContextProcess
// Go through response controls and get info, regardless of class
for (Control responseControl : responseControls) {
// check for match, try fallback otherwise
if (responseControl.getClass().isAssignableFrom(responseControlClass)) {
if (responseControl.getClass().isAssignableFrom(this.responseControlClass)) {
handleResponse(responseControl);
return;
}
}
log.info("No matching response control found - looking for '" + responseControlClass);
this.log.info("No matching response control found - looking for '" + this.responseControlClass);
}
/**

View File

@@ -47,7 +47,7 @@ public abstract class AbstractRequestControlDirContextProcessor implements DirCo
* @return true if an already existing control will be replaced
*/
public boolean isReplaceSameControlEnabled() {
return replaceSameControlEnabled;
return this.replaceSameControlEnabled;
}
/**
@@ -93,8 +93,8 @@ public abstract class AbstractRequestControlDirContextProcessor implements DirCo
Control[] newControls = new Control[requestControls.length + 1];
for (int i = 0; i < requestControls.length; i++) {
if (replaceSameControlEnabled && requestControls[i].getClass() == newControl.getClass()) {
log.debug("Replacing already existing control in context: " + newControl);
if (this.replaceSameControlEnabled && requestControls[i].getClass() == newControl.getClass()) {
this.log.debug("Replacing already existing control in context: " + newControl);
requestControls[i] = newControl;
ldapContext.setRequestControls(requestControls);
return;

View File

@@ -46,7 +46,7 @@ public class PagedResult {
* @return the cookie.
*/
public PagedResultsCookie getCookie() {
return cookie;
return this.cookie;
}
/**
@@ -54,7 +54,7 @@ public class PagedResult {
* @return the result list.
*/
public List<?> getResultList() {
return resultList;
return this.resultList;
}
@Override
@@ -66,9 +66,9 @@ public class PagedResult {
PagedResult that = (PagedResult) o;
if (cookie != null ? !cookie.equals(that.cookie) : that.cookie != null)
if (this.cookie != null ? !this.cookie.equals(that.cookie) : that.cookie != null)
return false;
if (resultList != null ? !resultList.equals(that.resultList) : that.resultList != null)
if (this.resultList != null ? !this.resultList.equals(that.resultList) : that.resultList != null)
return false;
return true;
@@ -76,8 +76,8 @@ public class PagedResult {
@Override
public int hashCode() {
int result = resultList != null ? resultList.hashCode() : 0;
result = 31 * result + (cookie != null ? cookie.hashCode() : 0);
int result = this.resultList != null ? this.resultList.hashCode() : 0;
result = 31 * result + (this.cookie != null ? this.cookie.hashCode() : 0);
return result;
}

View File

@@ -47,8 +47,8 @@ public class PagedResultsCookie {
* no more requests, or that the control wasn't supported by the server.
*/
public byte[] getCookie() {
if (cookie != null) {
return Arrays.copyOf(cookie, cookie.length);
if (this.cookie != null) {
return Arrays.copyOf(this.cookie, this.cookie.length);
}
else {
return null;
@@ -64,7 +64,7 @@ public class PagedResultsCookie {
PagedResultsCookie that = (PagedResultsCookie) o;
if (!Arrays.equals(cookie, that.cookie))
if (!Arrays.equals(this.cookie, that.cookie))
return false;
return true;
@@ -72,7 +72,7 @@ public class PagedResultsCookie {
@Override
public int hashCode() {
return cookie != null ? Arrays.hashCode(cookie) : 0;
return this.cookie != null ? Arrays.hashCode(this.cookie) : 0;
}
}

View File

@@ -68,10 +68,10 @@ public class PagedResultsDirContextProcessor extends AbstractFallbackRequestAndR
this.pageSize = pageSize;
this.cookie = cookie;
defaultRequestControl = DEFAULT_REQUEST_CONTROL;
defaultResponseControl = DEFAULT_RESPONSE_CONTROL;
fallbackRequestControl = FALLBACK_REQUEST_CONTROL;
fallbackResponseControl = FALLBACK_RESPONSE_CONTROL;
this.defaultRequestControl = DEFAULT_REQUEST_CONTROL;
this.defaultResponseControl = DEFAULT_RESPONSE_CONTROL;
this.fallbackRequestControl = FALLBACK_REQUEST_CONTROL;
this.fallbackResponseControl = FALLBACK_RESPONSE_CONTROL;
loadControlClasses();
}
@@ -84,7 +84,7 @@ public class PagedResultsDirContextProcessor extends AbstractFallbackRequestAndR
* @see #hasMore()
*/
public PagedResultsCookie getCookie() {
return cookie;
return this.cookie;
}
/**
@@ -92,7 +92,7 @@ public class PagedResultsDirContextProcessor extends AbstractFallbackRequestAndR
* @return the page size.
*/
public int getPageSize() {
return pageSize;
return this.pageSize;
}
/**
@@ -102,7 +102,7 @@ public class PagedResultsDirContextProcessor extends AbstractFallbackRequestAndR
* @return the estimated result size, if returned from the server.
*/
public int getResultSize() {
return resultSize;
return this.resultSize;
}
/*
@@ -111,11 +111,11 @@ public class PagedResultsDirContextProcessor extends AbstractFallbackRequestAndR
*/
public Control createRequestControl() {
byte[] actualCookie = null;
if (cookie != null) {
actualCookie = cookie.getCookie();
if (this.cookie != null) {
actualCookie = this.cookie.getCookie();
}
return super.createRequestControl(new Class<?>[] { int.class, byte[].class, boolean.class },
new Object[] { pageSize, actualCookie, critical });
new Object[] { this.pageSize, actualCookie, this.critical });
}
/**
@@ -127,7 +127,7 @@ public class PagedResultsDirContextProcessor extends AbstractFallbackRequestAndR
* @since 2.0
*/
public boolean hasMore() {
return more;
return this.more;
}
/*
@@ -136,12 +136,12 @@ public class PagedResultsDirContextProcessor extends AbstractFallbackRequestAndR
* #handleResponse(java.lang.Object)
*/
protected void handleResponse(Object control) {
byte[] result = (byte[]) invokeMethod("getCookie", responseControlClass, control);
byte[] result = (byte[]) invokeMethod("getCookie", this.responseControlClass, control);
if (result == null) {
more = false;
this.more = false;
}
this.cookie = new PagedResultsCookie(result);
this.resultSize = (Integer) invokeMethod("getResultSize", responseControlClass, control);
this.resultSize = (Integer) invokeMethod("getResultSize", this.responseControlClass, control);
}
}

View File

@@ -89,15 +89,15 @@ public class PagedResultsRequestControl extends AbstractRequestControlDirContext
private void loadControlClasses() {
try {
requestControlClass = Class.forName(DEFAULT_REQUEST_CONTROL);
responseControlClass = Class.forName(DEFAULT_RESPONSE_CONTROL);
this.requestControlClass = Class.forName(DEFAULT_REQUEST_CONTROL);
this.responseControlClass = Class.forName(DEFAULT_RESPONSE_CONTROL);
}
catch (ClassNotFoundException e) {
log.debug("Default control classes not found - falling back to LdapBP classes", e);
this.log.debug("Default control classes not found - falling back to LdapBP classes", e);
try {
requestControlClass = Class.forName(LDAPBP_REQUEST_CONTROL);
responseControlClass = Class.forName(LDAPBP_RESPONSE_CONTROL);
this.requestControlClass = Class.forName(LDAPBP_REQUEST_CONTROL);
this.responseControlClass = Class.forName(LDAPBP_RESPONSE_CONTROL);
}
catch (ClassNotFoundException e1) {
throw new UncategorizedLdapException(
@@ -112,7 +112,7 @@ public class PagedResultsRequestControl extends AbstractRequestControlDirContext
* @return the cookie.
*/
public PagedResultsCookie getCookie() {
return cookie;
return this.cookie;
}
/**
@@ -120,7 +120,7 @@ public class PagedResultsRequestControl extends AbstractRequestControlDirContext
* @return the page size.
*/
public int getPageSize() {
return pageSize;
return this.pageSize;
}
/**
@@ -130,7 +130,7 @@ public class PagedResultsRequestControl extends AbstractRequestControlDirContext
* @return the estimated result size, if returned from the server.
*/
public int getResultSize() {
return resultSize;
return this.resultSize;
}
/**
@@ -152,10 +152,10 @@ public class PagedResultsRequestControl extends AbstractRequestControlDirContext
public Control createRequestControl() {
byte[] actualCookie = null;
if (cookie != null) {
actualCookie = cookie.getCookie();
if (this.cookie != null) {
actualCookie = this.cookie.getCookie();
}
Constructor constructor = ClassUtils.getConstructorIfAvailable(requestControlClass,
Constructor constructor = ClassUtils.getConstructorIfAvailable(this.requestControlClass,
new Class[] { int.class, byte[].class, boolean.class });
if (constructor == null) {
throw new IllegalArgumentException("Failed to find an appropriate RequestControl constructor");
@@ -163,7 +163,7 @@ public class PagedResultsRequestControl extends AbstractRequestControlDirContext
Control result = null;
try {
result = (Control) constructor.newInstance(pageSize, actualCookie, critical);
result = (Control) constructor.newInstance(this.pageSize, actualCookie, this.critical);
}
catch (Exception e) {
ReflectionUtils.handleReflectionException(e);
@@ -190,17 +190,18 @@ public class PagedResultsRequestControl extends AbstractRequestControlDirContext
Control responseControl = responseControls[i];
// check for match, try fallback otherwise
if (responseControl.getClass().isAssignableFrom(responseControlClass)) {
if (responseControl.getClass().isAssignableFrom(this.responseControlClass)) {
Object control = responseControl;
byte[] result = (byte[]) invokeMethod("getCookie", responseControlClass, control);
byte[] result = (byte[]) invokeMethod("getCookie", this.responseControlClass, control);
this.cookie = new PagedResultsCookie(result);
Integer wrapper = (Integer) invokeMethod("getResultSize", responseControlClass, control);
Integer wrapper = (Integer) invokeMethod("getResultSize", this.responseControlClass, control);
this.resultSize = wrapper.intValue();
return;
}
}
log.error("No matching response control found for paged results - looking for '{}", responseControlClass);
this.log.error("No matching response control found for paged results - looking for '{}",
this.responseControlClass);
}
private Object invokeMethod(String method, Class clazz, Object control) {

View File

@@ -58,11 +58,11 @@ public class SortControlDirContextProcessor extends AbstractFallbackRequestAndRe
this.sorted = false;
this.resultCode = -1;
defaultRequestControl = DEFAULT_REQUEST_CONTROL;
defaultResponseControl = DEFAULT_RESPONSE_CONTROL;
this.defaultRequestControl = DEFAULT_REQUEST_CONTROL;
this.defaultResponseControl = DEFAULT_RESPONSE_CONTROL;
fallbackRequestControl = FALLBACK_REQUEST_CONTROL;
fallbackResponseControl = FALLBACK_RESPONSE_CONTROL;
this.fallbackRequestControl = FALLBACK_REQUEST_CONTROL;
this.fallbackResponseControl = FALLBACK_RESPONSE_CONTROL;
loadControlClasses();
}
@@ -72,7 +72,7 @@ public class SortControlDirContextProcessor extends AbstractFallbackRequestAndRe
* @return <code>true</code> if the result was sorted, <code>false</code> otherwise.
*/
public boolean isSorted() {
return sorted;
return this.sorted;
}
/**
@@ -80,7 +80,7 @@ public class SortControlDirContextProcessor extends AbstractFallbackRequestAndRe
* @return result code.
*/
public int getResultCode() {
return resultCode;
return this.resultCode;
}
/**
@@ -88,7 +88,7 @@ public class SortControlDirContextProcessor extends AbstractFallbackRequestAndRe
* @return the sort key.
*/
public String getSortKey() {
return sortKey;
return this.sortKey;
}
/*
@@ -97,7 +97,7 @@ public class SortControlDirContextProcessor extends AbstractFallbackRequestAndRe
*/
public Control createRequestControl() {
return super.createRequestControl(new Class<?>[] { String[].class, boolean.class },
new Object[] { new String[] { sortKey }, critical });
new Object[] { new String[] { this.sortKey }, this.critical });
}
/*
@@ -106,8 +106,8 @@ public class SortControlDirContextProcessor extends AbstractFallbackRequestAndRe
* #handleResponse(java.lang.Object)
*/
protected void handleResponse(Object control) {
this.sorted = (Boolean) invokeMethod("isSorted", responseControlClass, control);
this.resultCode = (Integer) invokeMethod("getResultCode", responseControlClass, control);
this.sorted = (Boolean) invokeMethod("isSorted", this.responseControlClass, control);
this.resultCode = (Integer) invokeMethod("getResultCode", this.responseControlClass, control);
}
}

View File

@@ -57,7 +57,7 @@ public class AttributesMapperCallbackHandler<T> extends CollectingNameClassPairC
SearchResult searchResult = (SearchResult) nameClassPair;
Attributes attributes = searchResult.getAttributes();
try {
return mapper.mapFromAttributes(attributes);
return this.mapper.mapFromAttributes(attributes);
}
catch (javax.naming.NamingException e) {
throw LdapUtils.convertLdapException(e);

View File

@@ -43,7 +43,7 @@ public final class CollectingAuthenticationErrorCallback implements Authenticati
* @return the collected exception
*/
public Exception getError() {
return error;
return this.error;
}
/**
@@ -52,7 +52,7 @@ public final class CollectingAuthenticationErrorCallback implements Authenticati
* otherwise.
*/
public boolean hasError() {
return error != null;
return this.error != null;
}
}

View File

@@ -35,7 +35,7 @@ public abstract class CollectingNameClassPairCallbackHandler<T> implements NameC
* @return the list of all assembled objects.
*/
public List<T> getList() {
return list;
return this.list;
}
/**
@@ -44,7 +44,7 @@ public abstract class CollectingNameClassPairCallbackHandler<T> implements NameC
* internal list.
*/
public final void handleNameClassPair(NameClassPair nameClassPair) throws NamingException {
list.add(getObjectFromNameClassPair(nameClassPair));
this.list.add(getObjectFromNameClassPair(nameClassPair));
}
/**

View File

@@ -61,7 +61,7 @@ public class ContextMapperCallbackHandler<T> extends CollectingNameClassPairCall
if (object == null) {
throw new ObjectRetrievalException("Binding did not contain any object.");
}
return mapper.mapFromContext(object);
return this.mapper.mapFromContext(object);
}
}

View File

@@ -279,7 +279,8 @@ class DefaultLdapClient implements LdapClient {
DirContext ctx = null;
try {
String password = (this.password != null) ? new String(this.password) : null;
ctx = contextSource.getContext(identification.get(0).getAbsoluteName().toString(), password);
ctx = DefaultLdapClient.this.contextSource
.getContext(identification.get(0).getAbsoluteName().toString(), password);
return mapper.mapWithContext(ctx, identification.get(0));
}
finally {
@@ -370,13 +371,13 @@ class DefaultLdapClient implements LdapClient {
controls.setReturningObjFlag(returnObjFlag);
controls.setReturningAttributes(this.query.attributes());
if (this.query.searchScope() != null) {
controls.setSearchScope(query.searchScope().getId());
controls.setSearchScope(this.query.searchScope().getId());
}
if (this.query.countLimit() != null) {
controls.setCountLimit(query.countLimit());
controls.setCountLimit(this.query.countLimit());
}
if (this.query.timeLimit() != null) {
controls.setTimeLimit(query.timeLimit());
controls.setTimeLimit(this.query.timeLimit());
}
return controls;
}
@@ -574,7 +575,7 @@ class DefaultLdapClient implements LdapClient {
return enumeration.hasMore();
}
catch (NamingException ex) {
namingExceptionHandler.accept(ex);
DefaultLdapClient.this.namingExceptionHandler.accept(ex);
return false;
}
}
@@ -585,7 +586,7 @@ class DefaultLdapClient implements LdapClient {
return enumeration.next();
}
catch (NamingException ex) {
namingExceptionHandler.accept(ex);
DefaultLdapClient.this.namingExceptionHandler.accept(ex);
throw new NoSuchElementException("no such element", ex);
}
}

View File

@@ -214,8 +214,8 @@ public class DirContextAdapter implements DirContextOperations {
*/
public void setUpdateMode(boolean mode) {
this.updateMode = mode;
if (updateMode) {
updatedAttrs = new NameAwareAttributes();
if (this.updateMode) {
this.updatedAttrs = new NameAwareAttributes();
}
}
@@ -224,7 +224,7 @@ public class DirContextAdapter implements DirContextOperations {
*/
@Override
public boolean isUpdateMode() {
return updateMode;
return this.updateMode;
}
/**
@@ -237,10 +237,10 @@ public class DirContextAdapter implements DirContextOperations {
NamingEnumeration<? extends Attribute> attributesEnumeration;
if (isUpdateMode()) {
attributesEnumeration = updatedAttrs.getAll();
attributesEnumeration = this.updatedAttrs.getAll();
}
else {
attributesEnumeration = originalAttrs.getAll();
attributesEnumeration = this.originalAttrs.getAll();
}
try {
@@ -275,14 +275,14 @@ public class DirContextAdapter implements DirContextOperations {
*/
@Override
public ModificationItem[] getModificationItems() {
if (!updateMode) {
if (!this.updateMode) {
return new ModificationItem[0];
}
List<ModificationItem> tmpList = new LinkedList<ModificationItem>();
NamingEnumeration<? extends Attribute> attributesEnumeration = null;
try {
attributesEnumeration = updatedAttrs.getAll();
attributesEnumeration = this.updatedAttrs.getAll();
// find attributes that have been changed, removed or added
while (attributesEnumeration.hasMore()) {
@@ -319,7 +319,7 @@ public class DirContextAdapter implements DirContextOperations {
*/
private void collectModifications(NameAwareAttribute changedAttr, List<ModificationItem> modificationList)
throws NamingException {
NameAwareAttribute currentAttribute = originalAttrs.get(changedAttr.getID());
NameAwareAttribute currentAttribute = this.originalAttrs.get(changedAttr.getID());
if (currentAttribute != null && changedAttr.hasValuesAsNames()) {
try {
currentAttribute.initValuesAsNames();
@@ -431,8 +431,8 @@ public class DirContextAdapter implements DirContextOperations {
*/
private boolean isChanged(String name, Object[] values, boolean orderMatters) {
NameAwareAttribute orig = originalAttrs.get(name);
NameAwareAttribute prev = updatedAttrs.get(name);
NameAwareAttribute orig = this.originalAttrs.get(name);
NameAwareAttribute prev = this.updatedAttrs.get(name);
// values == null and values.length == 0 is treated the same way
boolean emptyNewValue = (values == null || values.length == 0);
@@ -522,7 +522,7 @@ public class DirContextAdapter implements DirContextOperations {
* @return true if the attribute exists in the entry.
*/
protected final boolean exists(String attrId) {
return originalAttrs.get(attrId) != null;
return this.originalAttrs.get(attrId) != null;
}
/**
@@ -538,7 +538,7 @@ public class DirContextAdapter implements DirContextOperations {
*/
@Override
public Object getObjectAttribute(String name) {
Attribute oneAttr = originalAttrs.get(name);
Attribute oneAttr = this.originalAttrs.get(name);
if (oneAttr == null || oneAttr.size() == 0) { // LDAP-215
return null;
}
@@ -556,7 +556,7 @@ public class DirContextAdapter implements DirContextOperations {
@Override
// LDAP-215
public boolean attributeExists(String name) {
Attribute oneAttr = originalAttrs.get(name);
Attribute oneAttr = this.originalAttrs.get(name);
return oneAttr != null;
}
@@ -566,17 +566,17 @@ public class DirContextAdapter implements DirContextOperations {
@Override
public void setAttributeValue(String name, Object value) {
// new entry
if (!updateMode && value != null) {
originalAttrs.put(name, value);
if (!this.updateMode && value != null) {
this.originalAttrs.put(name, value);
}
// updating entry
if (updateMode) {
if (this.updateMode) {
Attribute attribute = new NameAwareAttribute(name);
if (value != null) {
attribute.add(value);
}
updatedAttrs.put(attribute);
this.updatedAttrs.put(attribute);
}
}
@@ -593,31 +593,31 @@ public class DirContextAdapter implements DirContextOperations {
*/
@Override
public void addAttributeValue(String name, Object value, boolean addIfDuplicateExists) {
if (!updateMode && value != null) {
Attribute attr = originalAttrs.get(name);
if (!this.updateMode && value != null) {
Attribute attr = this.originalAttrs.get(name);
if (attr == null) {
originalAttrs.put(name, value);
this.originalAttrs.put(name, value);
}
else {
attr.add(value);
}
}
else if (updateMode) {
Attribute attr = updatedAttrs.get(name);
else if (this.updateMode) {
Attribute attr = this.updatedAttrs.get(name);
if (attr == null) {
if (originalAttrs.get(name) == null) {
if (this.originalAttrs.get(name) == null) {
// No match in the original attributes -
// add a new Attribute to updatedAttrs
updatedAttrs.put(name, value);
this.updatedAttrs.put(name, value);
}
else {
// The attribute exists in the original attributes - clone
// that and add the new entry to it
attr = (Attribute) originalAttrs.get(name).clone();
attr = (Attribute) this.originalAttrs.get(name).clone();
if (addIfDuplicateExists || !attr.contains(value)) {
attr.add(value);
}
updatedAttrs.put(attr);
this.updatedAttrs.put(attr);
}
}
else {
@@ -631,22 +631,22 @@ public class DirContextAdapter implements DirContextOperations {
*/
@Override
public void removeAttributeValue(String name, Object value) {
if (!updateMode && value != null) {
Attribute attr = originalAttrs.get(name);
if (!this.updateMode && value != null) {
Attribute attr = this.originalAttrs.get(name);
if (attr != null) {
attr.remove(value);
if (attr.size() == 0) {
originalAttrs.remove(name);
this.originalAttrs.remove(name);
}
}
}
else if (updateMode) {
Attribute attr = updatedAttrs.get(name);
else if (this.updateMode) {
Attribute attr = this.updatedAttrs.get(name);
if (attr == null) {
if (originalAttrs.get(name) != null) {
attr = (Attribute) originalAttrs.get(name).clone();
if (this.originalAttrs.get(name) != null) {
attr = (Attribute) this.originalAttrs.get(name).clone();
attr.remove(value);
updatedAttrs.put(attr);
this.updatedAttrs.put(attr);
}
}
else {
@@ -675,14 +675,14 @@ public class DirContextAdapter implements DirContextOperations {
}
// only change the original attribute if not in update mode
if (!updateMode && values != null && values.length > 0) {
if (!this.updateMode && values != null && values.length > 0) {
// don't save empty arrays
originalAttrs.put(a);
this.originalAttrs.put(a);
}
// possible to set an already existing attribute to an empty array
if (updateMode && isChanged(name, values, orderMatters)) {
updatedAttrs.put(a);
if (this.updateMode && isChanged(name, values, orderMatters)) {
this.updatedAttrs.put(a);
}
}
@@ -694,7 +694,7 @@ public class DirContextAdapter implements DirContextOperations {
NamingEnumeration<? extends Attribute> attributesEnumeration = null;
try {
attributesEnumeration = updatedAttrs.getAll();
attributesEnumeration = this.updatedAttrs.getAll();
// find what to update
while (attributesEnumeration.hasMore()) {
@@ -702,11 +702,11 @@ public class DirContextAdapter implements DirContextOperations {
// if it does not exist it should be added
if (isEmptyAttribute(a)) {
originalAttrs.remove(a.getID());
this.originalAttrs.remove(a.getID());
}
else {
// Otherwise it should be set.
originalAttrs.put(a);
this.originalAttrs.put(a);
}
}
}
@@ -718,7 +718,7 @@ public class DirContextAdapter implements DirContextOperations {
}
// Reset the attributes to be updated
updatedAttrs = new NameAwareAttributes();
this.updatedAttrs = new NameAwareAttributes();
}
/**
@@ -753,7 +753,7 @@ public class DirContextAdapter implements DirContextOperations {
private <T> List<T> collectAttributeValuesAsList(String name, Class<T> clazz) {
List<T> list = new LinkedList<T>();
LdapUtils.collectAttributeValues(originalAttrs, name, list, clazz);
LdapUtils.collectAttributeValues(this.originalAttrs, name, list, clazz);
return list;
}
@@ -764,7 +764,7 @@ public class DirContextAdapter implements DirContextOperations {
public SortedSet<String> getAttributeSortedStringSet(String name) {
try {
TreeSet<String> attrSet = new TreeSet<String>();
LdapUtils.collectAttributeValues(originalAttrs, name, attrSet, String.class);
LdapUtils.collectAttributeValues(this.originalAttrs, name, attrSet, String.class);
return attrSet;
}
catch (NoSuchAttributeException e) {
@@ -778,11 +778,11 @@ public class DirContextAdapter implements DirContextOperations {
* @param attribute the attribute to set.
*/
public void setAttribute(Attribute attribute) {
if (!updateMode) {
originalAttrs.put(attribute);
if (!this.updateMode) {
this.originalAttrs.put(attribute);
}
else {
updatedAttrs.put(attribute);
this.updatedAttrs.put(attribute);
}
}
@@ -791,7 +791,7 @@ public class DirContextAdapter implements DirContextOperations {
* @return all attributes.
*/
public Attributes getAttributes() {
return originalAttrs;
return this.originalAttrs;
}
/**
@@ -810,7 +810,7 @@ public class DirContextAdapter implements DirContextOperations {
if (StringUtils.hasLength(name)) {
throw new NameNotFoundException();
}
return (Attributes) originalAttrs.clone();
return (Attributes) this.originalAttrs.clone();
}
/**
@@ -833,7 +833,7 @@ public class DirContextAdapter implements DirContextOperations {
Attributes a = new NameAwareAttributes();
Attribute target;
for (String attrId : attrIds) {
target = originalAttrs.get(attrId);
target = this.originalAttrs.get(attrId);
if (target != null) {
a.put(target);
}
@@ -1253,13 +1253,13 @@ public class DirContextAdapter implements DirContextOperations {
*/
@Override
public String getNameInNamespace() {
if (base.size() == 0) {
return dn.toString();
if (this.base.size() == 0) {
return this.dn.toString();
}
try {
LdapName result = (LdapName) dn.clone();
result.addAll(0, base);
LdapName result = (LdapName) this.dn.clone();
result.addAll(0, this.base);
return result.toString();
}
catch (InvalidNameException e) {
@@ -1272,7 +1272,7 @@ public class DirContextAdapter implements DirContextOperations {
*/
@Override
public Name getDn() {
return LdapUtils.newLdapName(dn);
return LdapUtils.newLdapName(this.dn);
}
/**
@@ -1280,7 +1280,7 @@ public class DirContextAdapter implements DirContextOperations {
*/
@Override
public final void setDn(Name dn) {
if (!updateMode) {
if (!this.updateMode) {
this.dn = LdapUtils.newLdapName(dn);
}
else {
@@ -1301,17 +1301,17 @@ public class DirContextAdapter implements DirContextOperations {
DirContextAdapter that = (DirContextAdapter) o;
if (updateMode != that.updateMode)
if (this.updateMode != that.updateMode)
return false;
if (base != null ? !base.equals(that.base) : that.base != null)
if (this.base != null ? !this.base.equals(that.base) : that.base != null)
return false;
if (dn != null ? !dn.equals(that.dn) : that.dn != null)
if (this.dn != null ? !this.dn.equals(that.dn) : that.dn != null)
return false;
if (originalAttrs != null ? !originalAttrs.equals(that.originalAttrs) : that.originalAttrs != null)
if (this.originalAttrs != null ? !this.originalAttrs.equals(that.originalAttrs) : that.originalAttrs != null)
return false;
if (referralUrl != null ? !referralUrl.equals(that.referralUrl) : that.referralUrl != null)
if (this.referralUrl != null ? !this.referralUrl.equals(that.referralUrl) : that.referralUrl != null)
return false;
if (updatedAttrs != null ? !updatedAttrs.equals(that.updatedAttrs) : that.updatedAttrs != null)
if (this.updatedAttrs != null ? !this.updatedAttrs.equals(that.updatedAttrs) : that.updatedAttrs != null)
return false;
return true;
@@ -1322,12 +1322,12 @@ public class DirContextAdapter implements DirContextOperations {
*/
@Override
public int hashCode() {
int result = originalAttrs != null ? originalAttrs.hashCode() : 0;
result = 31 * result + (dn != null ? dn.hashCode() : 0);
result = 31 * result + (base != null ? base.hashCode() : 0);
result = 31 * result + (updateMode ? 1 : 0);
result = 31 * result + (updatedAttrs != null ? updatedAttrs.hashCode() : 0);
result = 31 * result + (referralUrl != null ? referralUrl.hashCode() : 0);
int result = this.originalAttrs != null ? this.originalAttrs.hashCode() : 0;
result = 31 * result + (this.dn != null ? this.dn.hashCode() : 0);
result = 31 * result + (this.base != null ? this.base.hashCode() : 0);
result = 31 * result + (this.updateMode ? 1 : 0);
result = 31 * result + (this.updatedAttrs != null ? this.updatedAttrs.hashCode() : 0);
result = 31 * result + (this.referralUrl != null ? this.referralUrl.hashCode() : 0);
return result;
}
@@ -1339,13 +1339,13 @@ public class DirContextAdapter implements DirContextOperations {
StringBuilder builder = new StringBuilder();
builder.append(getClass().getName());
builder.append(":");
if (dn != null) {
builder.append(" dn=").append(dn);
if (this.dn != null) {
builder.append(" dn=").append(this.dn);
}
builder.append(" {");
try {
for (NamingEnumeration<NameAwareAttribute> i = originalAttrs.getAll(); i.hasMore();) {
for (NamingEnumeration<NameAwareAttribute> i = this.originalAttrs.getAll(); i.hasMore();) {
Attribute attribute = i.next();
if (attribute.size() == 1) {
builder.append(attribute.getID());
@@ -1390,7 +1390,7 @@ public class DirContextAdapter implements DirContextOperations {
*/
@Override
public String getReferralUrl() {
return referralUrl;
return this.referralUrl;
}
/**
@@ -1398,7 +1398,7 @@ public class DirContextAdapter implements DirContextOperations {
*/
@Override
public boolean isReferral() {
return StringUtils.hasLength(referralUrl);
return StringUtils.hasLength(this.referralUrl);
}
}

View File

@@ -164,7 +164,7 @@ public class DistinguishedName implements Name {
* Construct a new DistinguishedName with no components.
*/
public DistinguishedName() {
names = new LinkedList();
this.names = new LinkedList();
}
/**
@@ -173,7 +173,7 @@ public class DistinguishedName implements Name {
*/
public DistinguishedName(String path) {
if (!StringUtils.hasText(path)) {
names = new LinkedList();
this.names = new LinkedList();
}
else {
parse(path);
@@ -201,9 +201,9 @@ public class DistinguishedName implements Name {
parse(LdapUtils.convertCompositeNameToString((CompositeName) name));
return;
}
names = new LinkedList();
this.names = new LinkedList();
for (int i = 0; i < name.size(); i++) {
names.add(new LdapRdn(name.get(i)));
this.names.add(new LdapRdn(name.get(i)));
}
}
@@ -221,7 +221,7 @@ public class DistinguishedName implements Name {
catch (ParseException e) {
throw new BadLdapGrammarException("Failed to parse DN", e);
}
catch (TokenMgrError e) {
catch (org.springframework.ldap.core.TokenMgrError e) {
throw new BadLdapGrammarException("Failed to parse DN", e);
}
this.names = dn.names;
@@ -254,7 +254,7 @@ public class DistinguishedName implements Name {
* @return the {@link LdapRdn} at the requested position.
*/
public LdapRdn getLdapRdn(int index) {
return (LdapRdn) names.get(index);
return (LdapRdn) this.names.get(index);
}
/**
@@ -265,7 +265,7 @@ public class DistinguishedName implements Name {
* @throws IllegalArgumentException if no Rdn matches the given key.
*/
public LdapRdn getLdapRdn(String key) {
for (Iterator iter = names.iterator(); iter.hasNext();) {
for (Iterator iter = this.names.iterator(); iter.hasNext();) {
LdapRdn rdn = (LdapRdn) iter.next();
if (ObjectUtils.nullSafeEquals(rdn.getKey(), key)) {
return rdn;
@@ -293,7 +293,7 @@ public class DistinguishedName implements Name {
* consists of.
*/
public List getNames() {
return names;
return this.names;
}
/**
@@ -337,13 +337,13 @@ public class DistinguishedName implements Name {
private String format(boolean compact) {
// empty path
if (names.size() == 0) {
if (this.names.size() == 0) {
return "";
}
StringBuffer buffer = new StringBuffer(DEFAULT_BUFFER_SIZE);
ListIterator i = names.listIterator(names.size());
ListIterator i = this.names.listIterator(this.names.size());
while (i.hasPrevious()) {
LdapRdn rdn = (LdapRdn) i.previous();
buffer.append(rdn.getLdapEncoded());
@@ -370,8 +370,8 @@ public class DistinguishedName implements Name {
public String toUrl() {
StringBuffer buffer = new StringBuffer(DEFAULT_BUFFER_SIZE);
for (int i = names.size() - 1; i >= 0; i--) {
LdapRdn n = (LdapRdn) names.get(i);
for (int i = this.names.size() - 1; i >= 0; i--) {
LdapRdn n = (LdapRdn) this.names.get(i);
buffer.append(n.encodeUrl());
if (i > 0) {
buffer.append(",");
@@ -474,7 +474,7 @@ public class DistinguishedName implements Name {
public void prepend(DistinguishedName path) {
ListIterator i = path.getNames().listIterator(path.getNames().size());
while (i.hasPrevious()) {
names.add(0, i.previous());
this.names.add(0, i.previous());
}
}
@@ -483,7 +483,7 @@ public class DistinguishedName implements Name {
* @return the removed entry.
*/
public LdapRdn removeFirst() {
return (LdapRdn) names.remove(0);
return (LdapRdn) this.names.remove(0);
}
/**
@@ -506,7 +506,7 @@ public class DistinguishedName implements Name {
public Object clone() {
try {
DistinguishedName result = (DistinguishedName) super.clone();
result.names = new LinkedList(names);
result.names = new LinkedList(this.names);
return result;
}
catch (CloneNotSupportedException e) {
@@ -552,11 +552,11 @@ public class DistinguishedName implements Name {
}
public int size() {
return names.size();
return this.names.size();
}
public boolean isEmpty() {
return names.size() == 0;
return this.names.size() == 0;
}
/*
@@ -566,7 +566,7 @@ public class DistinguishedName implements Name {
*/
public Enumeration getAll() {
LinkedList strings = new LinkedList();
for (Iterator iter = names.iterator(); iter.hasNext();) {
for (Iterator iter = this.names.iterator(); iter.hasNext();) {
LdapRdn rdn = (LdapRdn) iter.next();
strings.add(rdn.getLdapEncoded());
}
@@ -580,7 +580,7 @@ public class DistinguishedName implements Name {
* @see javax.naming.Name#get(int)
*/
public String get(int index) {
LdapRdn rdn = (LdapRdn) names.get(index);
LdapRdn rdn = (LdapRdn) this.names.get(index);
return rdn.getLdapEncoded();
}
@@ -592,7 +592,7 @@ public class DistinguishedName implements Name {
public Name getPrefix(int index) {
LinkedList newNames = new LinkedList();
for (int i = 0; i < index; i++) {
newNames.add(names.get(i));
newNames.add(this.names.get(i));
}
return new DistinguishedName(newNames);
@@ -604,13 +604,13 @@ public class DistinguishedName implements Name {
* @see javax.naming.Name#getSuffix(int)
*/
public Name getSuffix(int index) {
if (index > names.size()) {
if (index > this.names.size()) {
throw new ArrayIndexOutOfBoundsException();
}
LinkedList newNames = new LinkedList();
for (int i = index; i < names.size(); i++) {
newNames.add(names.get(i));
for (int i = index; i < this.names.size(); i++) {
newNames.add(this.names.get(i));
}
return new DistinguishedName(newNames);
@@ -638,7 +638,7 @@ public class DistinguishedName implements Name {
return false;
}
Iterator longiter = names.iterator();
Iterator longiter = this.names.iterator();
Iterator shortiter = start.getNames().iterator();
while (shortiter.hasNext()) {
@@ -705,7 +705,7 @@ public class DistinguishedName implements Name {
* @see javax.naming.Name#addAll(javax.naming.Name)
*/
public Name addAll(Name name) throws InvalidNameException {
return addAll(names.size(), name);
return addAll(this.names.size(), name);
}
/*
@@ -722,7 +722,7 @@ public class DistinguishedName implements Name {
throw new InvalidNameException("Invalid name type");
}
names.addAll(arg0, distinguishedName.getNames());
this.names.addAll(arg0, distinguishedName.getNames());
return this;
}
@@ -732,7 +732,7 @@ public class DistinguishedName implements Name {
* @see javax.naming.Name#add(java.lang.String)
*/
public Name add(String string) throws InvalidNameException {
return add(names.size(), string);
return add(this.names.size(), string);
}
/*
@@ -742,7 +742,7 @@ public class DistinguishedName implements Name {
*/
public Name add(int index, String string) throws InvalidNameException {
try {
names.add(index, new LdapRdn(string));
this.names.add(index, new LdapRdn(string));
}
catch (BadLdapGrammarException e) {
throw new InvalidNameException("Failed to parse rdn '" + string + "'");
@@ -756,7 +756,7 @@ public class DistinguishedName implements Name {
* @see javax.naming.Name#remove(int)
*/
public Object remove(int arg0) throws InvalidNameException {
LdapRdn rdn = (LdapRdn) names.remove(arg0);
LdapRdn rdn = (LdapRdn) this.names.remove(arg0);
return rdn.getLdapEncoded();
}
@@ -765,7 +765,7 @@ public class DistinguishedName implements Name {
* @return the removed {@link LdapRdn}.
*/
public LdapRdn removeLast() {
return (LdapRdn) names.remove(names.size() - 1);
return (LdapRdn) this.names.remove(this.names.size() - 1);
}
/**
@@ -774,7 +774,7 @@ public class DistinguishedName implements Name {
* @param value the value of the {@link LdapRdn}.
*/
public void add(String key, String value) {
names.add(new LdapRdn(key, value));
this.names.add(new LdapRdn(key, value));
}
/**
@@ -782,7 +782,7 @@ public class DistinguishedName implements Name {
* @param rdn the {@link LdapRdn} to add.
*/
public void add(LdapRdn rdn) {
names.add(rdn);
this.names.add(rdn);
}
/**
@@ -791,7 +791,7 @@ public class DistinguishedName implements Name {
* @param rdn the LdapRdn to add.
*/
public void add(int idx, LdapRdn rdn) {
names.add(idx, rdn);
this.names.add(idx, rdn);
}
/**
@@ -802,8 +802,8 @@ public class DistinguishedName implements Name {
* @since 1.2
*/
public DistinguishedName immutableDistinguishedName() {
List listWithImmutableRdns = new ArrayList(names.size());
for (Iterator iterator = names.iterator(); iterator.hasNext();) {
List listWithImmutableRdns = new ArrayList(this.names.size());
for (Iterator iterator = this.names.iterator(); iterator.hasNext();) {
LdapRdn rdn = (LdapRdn) iterator.next();
listWithImmutableRdns.add(rdn.immutableLdapRdn());
}

View File

@@ -17,12 +17,12 @@ final class IterableNamingEnumeration<T> implements NamingEnumeration<T> {
@Override
public T next() {
return iterator.next();
return this.iterator.next();
}
@Override
public boolean hasMore() {
return iterator.hasNext();
return this.iterator.hasNext();
}
@Override

View File

@@ -178,7 +178,7 @@ public class LdapAttribute extends BasicAttribute {
* @return boolean indicating result.
*/
public boolean hasOptions() {
return !options.isEmpty();
return !this.options.isEmpty();
}
/**

View File

@@ -96,7 +96,7 @@ public class LdapAttributes extends BasicAttributes {
* deprecated as of 2.0}. use {@link #getName()} instead.
*/
public DistinguishedName getDN() {
return new DistinguishedName(dn);
return new DistinguishedName(this.dn);
}
/**
@@ -104,7 +104,7 @@ public class LdapAttributes extends BasicAttributes {
* @return {@link LdapName} specifying the name to which the object is bound.
*/
public LdapName getName() {
return LdapUtils.newLdapName(dn);
return LdapUtils.newLdapName(this.dn);
}
/**

View File

@@ -82,7 +82,7 @@ public class LdapEntryIdentification {
* @since 2.0
*/
public LdapName getAbsoluteName() {
return LdapUtils.newLdapName(absoluteDn);
return LdapUtils.newLdapName(this.absoluteDn);
}
/**
@@ -92,7 +92,7 @@ public class LdapEntryIdentification {
* @since 2.0
*/
public LdapName getRelativeName() {
return LdapUtils.newLdapName(relativeDn);
return LdapUtils.newLdapName(this.relativeDn);
}
/**
@@ -103,7 +103,7 @@ public class LdapEntryIdentification {
* deprecated as of 2.0. use {@link #getRelativeName()} instead.
*/
public DistinguishedName getRelativeDn() {
return new DistinguishedName(relativeDn);
return new DistinguishedName(this.relativeDn);
}
/**
@@ -114,7 +114,7 @@ public class LdapEntryIdentification {
* deprecated as of 2.0. use {@link #getAbsoluteName()} instead.
*/
public DistinguishedName getAbsoluteDn() {
return new DistinguishedName(absoluteDn);
return new DistinguishedName(this.absoluteDn);
}
public boolean equals(Object obj) {
@@ -127,7 +127,7 @@ public class LdapEntryIdentification {
}
public int hashCode() {
return absoluteDn.hashCode() ^ relativeDn.hashCode();
return this.absoluteDn.hashCode() ^ this.relativeDn.hashCode();
}
}

View File

@@ -65,7 +65,7 @@ public class LdapRdn implements Serializable, Comparable {
catch (ParseException e) {
throw new BadLdapGrammarException("Failed to parse Rdn", e);
}
catch (TokenMgrError e) {
catch (org.springframework.ldap.core.TokenMgrError e) {
throw new BadLdapGrammarException("Failed to parse Rdn", e);
}
this.components = rdn.components;
@@ -77,7 +77,7 @@ public class LdapRdn implements Serializable, Comparable {
* @param value the attribute value.
*/
public LdapRdn(String key, String value) {
components.put(key, new LdapRdnComponent(key, value));
this.components.put(key, new LdapRdnComponent(key, value));
}
/**
@@ -85,7 +85,7 @@ public class LdapRdn implements Serializable, Comparable {
* @param rdnComponent the LdapRdnComponent to add.s
*/
public void addComponent(LdapRdnComponent rdnComponent) {
components.put(rdnComponent.getKey(), rdnComponent);
this.components.put(rdnComponent.getKey(), rdnComponent);
}
/**
@@ -93,7 +93,7 @@ public class LdapRdn implements Serializable, Comparable {
* @return the List of all LdapRdnComponents composing this LdapRdn.
*/
public List getComponents() {
return new ArrayList(components.values());
return new ArrayList(this.components.values());
}
/**
@@ -102,11 +102,11 @@ public class LdapRdn implements Serializable, Comparable {
* @throws IndexOutOfBoundsException if there are no components in this Rdn.
*/
public LdapRdnComponent getComponent() {
if (components.size() == 0) {
if (this.components.size() == 0) {
throw new IndexOutOfBoundsException("No components");
}
return components.values().iterator().next();
return this.components.values().iterator().next();
}
/**
@@ -116,11 +116,11 @@ public class LdapRdn implements Serializable, Comparable {
* @throws IndexOutOfBoundsException if there are no components in this Rdn.
*/
public LdapRdnComponent getComponent(int idx) {
if (idx >= components.size()) {
if (idx >= this.components.size()) {
throw new IndexOutOfBoundsException();
}
return (LdapRdnComponent) new ArrayList(components.values()).get(idx);
return (LdapRdnComponent) new ArrayList(this.components.values()).get(idx);
}
/**
@@ -129,11 +129,11 @@ public class LdapRdn implements Serializable, Comparable {
* @throws IndexOutOfBoundsException if there are no components in this Rdn.
*/
public String getLdapEncoded() {
if (components.size() == 0) {
if (this.components.size() == 0) {
throw new IndexOutOfBoundsException("No components in Rdn.");
}
StringBuffer sb = new StringBuffer(DEFAULT_BUFFER_SIZE);
for (Iterator iter = components.values().iterator(); iter.hasNext();) {
for (Iterator iter = this.components.values().iterator(); iter.hasNext();) {
LdapRdnComponent component = (LdapRdnComponent) iter.next();
sb.append(component.encodeLdap());
if (iter.hasNext()) {
@@ -150,7 +150,7 @@ public class LdapRdn implements Serializable, Comparable {
*/
public String encodeUrl() {
StringBuffer sb = new StringBuffer(DEFAULT_BUFFER_SIZE);
for (Iterator iter = components.values().iterator(); iter.hasNext();) {
for (Iterator iter = this.components.values().iterator(); iter.hasNext();) {
LdapRdnComponent component = (LdapRdnComponent) iter.next();
sb.append(component.encodeUrl());
if (iter.hasNext()) {
@@ -262,7 +262,7 @@ public class LdapRdn implements Serializable, Comparable {
* @throws IllegalArgumentException if there is no component with the specified key.
*/
public String getValue(String key) {
for (Iterator iter = components.values().iterator(); iter.hasNext();) {
for (Iterator iter = this.components.values().iterator(); iter.hasNext();) {
LdapRdnComponent component = (LdapRdnComponent) iter.next();
if (ObjectUtils.nullSafeEquals(component.getKey(), key)) {
return component.getValue();
@@ -280,8 +280,8 @@ public class LdapRdn implements Serializable, Comparable {
*/
public LdapRdn immutableLdapRdn() {
Map<String, LdapRdnComponent> mapWithImmutableRdns = new LinkedHashMap<String, LdapRdnComponent>(
components.size());
for (Iterator iterator = components.values().iterator(); iterator.hasNext();) {
this.components.size());
for (Iterator iterator = this.components.values().iterator(); iterator.hasNext();) {
LdapRdnComponent rdnComponent = (LdapRdnComponent) iterator.next();
mapWithImmutableRdns.put(rdnComponent.getKey(), rdnComponent.immutableLdapRdnComponent());
}

View File

@@ -100,7 +100,7 @@ public class LdapRdnComponent implements Comparable, Serializable {
* @return the key.
*/
public String getKey() {
return key;
return this.key;
}
/**
@@ -119,7 +119,7 @@ public class LdapRdnComponent implements Comparable, Serializable {
* @return the value.
*/
public String getValue() {
return value;
return this.value;
}
/**
@@ -138,11 +138,11 @@ public class LdapRdnComponent implements Comparable, Serializable {
* @return Properly ldap escaped rdn.
*/
protected String encodeLdap() {
StringBuffer buff = new StringBuffer(key.length() + value.length() * 2);
StringBuffer buff = new StringBuffer(this.key.length() + this.value.length() * 2);
buff.append(key);
buff.append(this.key);
buff.append('=');
buff.append(LdapEncoder.nameEncode(value));
buff.append(LdapEncoder.nameEncode(this.value));
return buff.toString();
}
@@ -170,12 +170,12 @@ public class LdapRdnComponent implements Comparable, Serializable {
public String encodeUrl() {
// Use the URI class to properly URL encode the value.
try {
URI valueUri = new URI(null, null, value, null);
return key + "=" + valueUri.toString();
URI valueUri = new URI(null, null, this.value, null);
return this.key + "=" + valueUri.toString();
}
catch (URISyntaxException e) {
// This should really never happen...
return key + "=" + "value";
return this.key + "=" + "value";
}
}
@@ -185,7 +185,7 @@ public class LdapRdnComponent implements Comparable, Serializable {
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return key.toUpperCase().hashCode() ^ value.toUpperCase().hashCode();
return this.key.toUpperCase().hashCode() ^ this.value.toUpperCase().hashCode();
}
/*
@@ -235,7 +235,7 @@ public class LdapRdnComponent implements Comparable, Serializable {
* @since 1.3
*/
public LdapRdnComponent immutableLdapRdnComponent() {
return new ImmutableLdapRdnComponent(key, value);
return new ImmutableLdapRdnComponent(this.key, this.value);
}
private static class ImmutableLdapRdnComponent extends LdapRdnComponent {

View File

@@ -127,7 +127,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
*/
@Override
public ObjectDirectoryMapper getObjectDirectoryMapper() {
return odm;
return this.odm;
}
/**
@@ -144,7 +144,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
* @return the ContextSource.
*/
public ContextSource getContextSource() {
return contextSource;
return this.contextSource;
}
/**
@@ -342,7 +342,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
*/
@Override
public void search(SearchExecutor se, NameClassPairCallbackHandler handler, DirContextProcessor processor) {
DirContext ctx = contextSource.getReadOnlyContext();
DirContext ctx = this.contextSource.getReadOnlyContext();
NamingEnumeration results = null;
RuntimeException ex = null;
@@ -357,7 +357,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
}
catch (NameNotFoundException e) {
// It is possible to ignore errors caused by base not found
if (ignoreNameNotFoundException) {
if (this.ignoreNameNotFoundException) {
LOG.warn("Base context not found, ignoring: " + e.getMessage());
}
else {
@@ -366,7 +366,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
}
catch (PartialResultException e) {
// Workaround for AD servers not handling referrals correctly.
if (ignorePartialResultException) {
if (this.ignorePartialResultException) {
LOG.debug("PartialResultException encountered and ignored", e);
}
else {
@@ -374,7 +374,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
}
}
catch (SizeLimitExceededException e) {
if (ignoreSizeLimitExceededException) {
if (this.ignoreSizeLimitExceededException) {
LOG.debug("SizeLimitExceededException encountered and ignored", e);
}
else {
@@ -432,7 +432,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
@Override
public void search(Name base, String filter, NameClassPairCallbackHandler handler) {
SearchControls controls = getDefaultSearchControls(defaultSearchScope, DONT_RETURN_OBJ_FLAG, ALL_ATTRIBUTES);
SearchControls controls = getDefaultSearchControls(this.defaultSearchScope, DONT_RETURN_OBJ_FLAG,
ALL_ATTRIBUTES);
if (handler instanceof ContextMapperCallbackHandler) {
assureReturnObjFlagSet(controls);
}
@@ -445,7 +446,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
@Override
public void search(String base, String filter, NameClassPairCallbackHandler handler) {
SearchControls controls = getDefaultSearchControls(defaultSearchScope, DONT_RETURN_OBJ_FLAG, ALL_ATTRIBUTES);
SearchControls controls = getDefaultSearchControls(this.defaultSearchScope, DONT_RETURN_OBJ_FLAG,
ALL_ATTRIBUTES);
if (handler instanceof ContextMapperCallbackHandler) {
assureReturnObjFlagSet(controls);
}
@@ -489,7 +491,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
*/
@Override
public <T> List<T> search(Name base, String filter, AttributesMapper<T> mapper) {
return search(base, filter, defaultSearchScope, mapper);
return search(base, filter, this.defaultSearchScope, mapper);
}
/**
@@ -497,7 +499,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
*/
@Override
public <T> List<T> search(String base, String filter, AttributesMapper<T> mapper) {
return search(base, filter, defaultSearchScope, mapper);
return search(base, filter, this.defaultSearchScope, mapper);
}
/**
@@ -537,7 +539,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
*/
@Override
public <T> List<T> search(Name base, String filter, ContextMapper<T> mapper) {
return search(base, filter, defaultSearchScope, mapper);
return search(base, filter, this.defaultSearchScope, mapper);
}
/**
@@ -545,7 +547,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
*/
@Override
public <T> List<T> search(String base, String filter, ContextMapper<T> mapper) {
return search(base, filter, defaultSearchScope, mapper);
return search(base, filter, this.defaultSearchScope, mapper);
}
/**
@@ -789,7 +791,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
*/
@Override
public <T> T executeReadOnly(ContextExecutor<T> ce) {
DirContext ctx = contextSource.getReadOnlyContext();
DirContext ctx = this.contextSource.getReadOnlyContext();
return executeWithContext(ce, ctx);
}
@@ -798,7 +800,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
*/
@Override
public <T> T executeReadWrite(ContextExecutor<T> ce) {
DirContext ctx = contextSource.getReadWriteContext();
DirContext ctx = this.contextSource.getReadWriteContext();
return executeWithContext(ce, ctx);
}
@@ -1168,7 +1170,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
*/
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(contextSource, "Property 'contextSource' must be set.");
Assert.notNull(this.contextSource, "Property 'contextSource' must be set.");
}
private void closeContextAndNamingEnumeration(DirContext ctx, NamingEnumeration results) {
@@ -1212,8 +1214,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
private SearchControls getDefaultSearchControls(int searchScope, boolean returningObjFlag, String[] attrs) {
SearchControls controls = new SearchControls();
controls.setSearchScope(searchScope);
controls.setTimeLimit(defaultTimeLimit);
controls.setCountLimit(defaultCountLimit);
controls.setTimeLimit(this.defaultTimeLimit);
controls.setCountLimit(this.defaultCountLimit);
controls.setReturningObjFlag(returningObjFlag);
controls.setReturningAttributes(attrs);
return controls;
@@ -1271,7 +1273,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
*/
public T getObjectFromNameClassPair(NameClassPair nameClassPair) {
try {
return mapper.mapFromNameClassPair(nameClassPair);
return this.mapper.mapFromNameClassPair(nameClassPair);
}
catch (javax.naming.NamingException e) {
throw LdapUtils.convertLdapException(e);
@@ -1410,8 +1412,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
public boolean authenticate(Name base, String filter, String password,
final AuthenticatedLdapEntryContextCallback callback, final AuthenticationErrorCallback errorCallback) {
return authenticate(base, filter, password, getDefaultSearchControls(defaultSearchScope, RETURN_OBJ_FLAG, null),
callback, errorCallback).isSuccess();
return authenticate(base, filter, password,
getDefaultSearchControls(this.defaultSearchScope, RETURN_OBJ_FLAG, null), callback, errorCallback)
.isSuccess();
}
private AuthenticationStatus authenticate(Name base, String filter, String password, SearchControls searchControls,
@@ -1432,7 +1435,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
final LdapEntryIdentification entryIdentification = result.get(0);
try {
DirContext ctx = contextSource.getContext(entryIdentification.getAbsoluteName().toString(), password);
DirContext ctx = this.contextSource.getContext(entryIdentification.getAbsoluteName().toString(), password);
executeWithContext(new ContextExecutor<Object>() {
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
callback.executeWithContext(ctx, entryIdentification);
@@ -1495,7 +1498,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
@Override
public <T> T searchForObject(Name base, String filter, ContextMapper<T> mapper) {
return searchForObject(base, filter,
getDefaultSearchControls(defaultSearchScope, RETURN_OBJ_FLAG, ALL_ATTRIBUTES), mapper);
getDefaultSearchControls(this.defaultSearchScope, RETURN_OBJ_FLAG, ALL_ATTRIBUTES), mapper);
}
/**
@@ -1569,7 +1572,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
*/
@Override
public void executeWithContext(DirContext ctx, LdapEntryIdentification ldapEntryIdentification) {
collectedObject = mapper.mapWithContext(ctx, ldapEntryIdentification);
this.collectedObject = this.mapper.mapWithContext(ctx, ldapEntryIdentification);
}
}
@@ -1595,7 +1598,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
}
private SearchControls searchControlsForQuery(LdapQuery query, boolean returnObjFlag) {
SearchControls searchControls = getDefaultSearchControls(defaultSearchScope, returnObjFlag, query.attributes());
SearchControls searchControls = getDefaultSearchControls(this.defaultSearchScope, returnObjFlag,
query.attributes());
if (query.searchScope() != null) {
searchControls.setSearchScope(query.searchScope().getId());
@@ -1673,7 +1677,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
Name base = query.base();
Filter filter = query.filter();
SearchControls searchControls = searchControlsForQuery(query, RETURN_OBJ_FLAG);
DirContext ctx = contextSource.getReadOnlyContext();
DirContext ctx = this.contextSource.getReadOnlyContext();
String encodedFilter = filter.encode();
if (LOG.isDebugEnabled()) {
@@ -1704,12 +1708,12 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
}
// Make sure the class is OK before doing the lookup
String[] attributes = odm.manageClass(clazz);
String[] attributes = this.odm.manageClass(clazz);
T result = lookup(dn, attributes, new ContextMapper<T>() {
@Override
public T mapFromContext(Object ctx) throws javax.naming.NamingException {
return odm.mapFromLdapDataEntry((DirContextOperations) ctx, clazz);
return LdapTemplate.this.odm.mapFromLdapDataEntry((DirContextOperations) ctx, clazz);
}
});
@@ -1734,16 +1738,16 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
LOG.debug(String.format("Creating entry - %1$s", entry));
}
Name id = odm.getId(entry);
Name id = this.odm.getId(entry);
if (id == null) {
id = odm.getCalculatedId(entry);
odm.setId(entry, id);
id = this.odm.getCalculatedId(entry);
this.odm.setId(entry, id);
}
Assert.notNull(id, String.format("Unable to determine id for entry %s", entry.toString()));
DirContextAdapter context = new DirContextAdapter(id);
odm.mapToLdapDataEntry(entry, context);
this.odm.mapToLdapDataEntry(entry, context);
bind(context);
}
@@ -1758,8 +1762,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
LOG.debug(String.format("Updating entry - %1$s", entry));
}
Name originalId = odm.getId(entry);
Name calculatedId = odm.getCalculatedId(entry);
Name originalId = this.odm.getId(entry);
Name calculatedId = this.odm.getCalculatedId(entry);
if (originalId != null && calculatedId != null && !originalId.equals(calculatedId)) {
// The DN has changed - remove the original entry and bind the new one
@@ -1773,10 +1777,10 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
unbind(originalId);
DirContextAdapter context = new DirContextAdapter(calculatedId);
odm.mapToLdapDataEntry(entry, context);
this.odm.mapToLdapDataEntry(entry, context);
bind(context);
odm.setId(entry, calculatedId);
this.odm.setId(entry, calculatedId);
}
else {
// DN is the same, just modify the attributes
@@ -1784,13 +1788,13 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
Name id = originalId;
if (id == null) {
id = calculatedId;
odm.setId(entry, calculatedId);
this.odm.setId(entry, calculatedId);
}
Assert.notNull(id, String.format("Unable to determine id for entry %s", entry.toString()));
DirContextOperations context = lookupContext(id);
odm.mapToLdapDataEntry(entry, context);
this.odm.mapToLdapDataEntry(entry, context);
modifyAttributes(context);
}
}
@@ -1805,9 +1809,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
LOG.debug(String.format("Deleting %1$s", entry));
}
Name id = odm.getId(entry);
Name id = this.odm.getId(entry);
if (id == null) {
id = odm.getCalculatedId(entry);
id = this.odm.getCalculatedId(entry);
}
Assert.notNull(id, String.format("Unable to determine id for entry %s", entry.toString()));
@@ -1828,7 +1832,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
@Override
public <T> List<T> findAll(Class<T> clazz) {
return findAll(LdapUtils.emptyLdapName(),
getDefaultSearchControls(defaultSearchScope, RETURN_OBJ_FLAG, ALL_ATTRIBUTES), clazz);
getDefaultSearchControls(this.defaultSearchScope, RETURN_OBJ_FLAG, ALL_ATTRIBUTES), clazz);
}
/**
@@ -1836,7 +1840,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
*/
@Override
public <T> List<T> find(Name base, Filter filter, SearchControls searchControls, final Class<T> clazz) {
Filter finalFilter = odm.filterFor(clazz, filter);
Filter finalFilter = this.odm.filterFor(clazz, filter);
// Search from the root if we are not told where to search from
Name localBase = base;
@@ -1858,7 +1862,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
List<T> result = search(localBase, finalFilter.encode(), searchControls, new ContextMapper<T>() {
@Override
public T mapFromContext(Object ctx) throws javax.naming.NamingException {
return odm.mapFromLdapDataEntry((DirContextOperations) ctx, clazz);
return LdapTemplate.this.odm.mapFromLdapDataEntry((DirContextOperations) ctx, clazz);
}
});
result.remove(null);
@@ -1903,11 +1907,12 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
public <T> Stream<T> findForStream(LdapQuery query, Class<T> clazz) {
LdapQueryBuilder builder = LdapQueryBuilder.fromQuery(query);
if (query.attributes() == null) {
String[] attributes = odm.manageClass(clazz);
String[] attributes = this.odm.manageClass(clazz);
builder.attributes(attributes);
}
Filter includeClass = odm.filterFor(clazz, query.filter());
ContextMapper<T> contextMapper = (object) -> odm.mapFromLdapDataEntry((DirContextOperations) object, clazz);
Filter includeClass = this.odm.filterFor(clazz, query.filter());
ContextMapper<T> contextMapper = (object) -> this.odm.mapFromLdapDataEntry((DirContextOperations) object,
clazz);
return searchForStream(builder.filter(includeClass), contextMapper);
}
@@ -1917,20 +1922,20 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
}
catch (NameNotFoundException e) {
// It is possible to ignore errors caused by base not found
if (!ignoreNameNotFoundException) {
if (!this.ignoreNameNotFoundException) {
throw LdapUtils.convertLdapException(e);
}
LOG.warn("Base context not found, ignoring: " + e.getMessage());
}
catch (PartialResultException e) {
// Workaround for AD servers not handling referrals correctly.
if (!ignorePartialResultException) {
if (!this.ignorePartialResultException) {
throw LdapUtils.convertLdapException(e);
}
LOG.debug("PartialResultException encountered and ignored", e);
}
catch (SizeLimitExceededException e) {
if (!ignoreSizeLimitExceededException) {
if (!this.ignoreSizeLimitExceededException) {
throw LdapUtils.convertLdapException(e);
}
LOG.debug("SizeLimitExceededException encountered and ignored", e);
@@ -1978,7 +1983,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
* @return
*/
public boolean isSuccess() {
return success;
return this.success;
}
}

View File

@@ -57,7 +57,7 @@ public final class NameAwareAttribute implements Attribute, Iterable<Object> {
*/
public NameAwareAttribute(String id, Object value) {
this(id);
values.add(value);
this.values.add(value);
}
/**
@@ -103,31 +103,31 @@ public final class NameAwareAttribute implements Attribute, Iterable<Object> {
@Override
public NamingEnumeration<?> getAll() {
return new IterableNamingEnumeration<Object>(values);
return new IterableNamingEnumeration<Object>(this.values);
}
@Override
public Object get() {
if (values.isEmpty()) {
if (this.values.isEmpty()) {
return null;
}
return values.iterator().next();
return this.values.iterator().next();
}
@Override
public int size() {
return values.size();
return this.values.size();
}
@Override
public String getID() {
return id;
return this.id;
}
@Override
public boolean contains(Object attrVal) {
return values.contains(attrVal);
return this.values.contains(attrVal);
}
@Override
@@ -136,24 +136,24 @@ public final class NameAwareAttribute implements Attribute, Iterable<Object> {
initValuesAsNames();
Name name = LdapUtils.newLdapName((Name) attrVal);
String currentValue = valuesAsNames.get(name);
String currentValue = this.valuesAsNames.get(name);
String nameAsString = name.toString();
if (currentValue == null) {
valuesAsNames.put(name, name.toString());
values.add(nameAsString);
this.valuesAsNames.put(name, name.toString());
this.values.add(nameAsString);
return true;
}
else {
if (!currentValue.equals(nameAsString)) {
values.remove(currentValue);
values.add(nameAsString);
this.values.remove(currentValue);
this.values.add(nameAsString);
}
return false;
}
}
return values.add(attrVal);
return this.values.add(attrVal);
}
public void initValuesAsNames() {
@@ -162,7 +162,7 @@ public final class NameAwareAttribute implements Attribute, Iterable<Object> {
}
Map<Name, String> newValuesAsNames = new HashMap<Name, String>();
for (Object value : values) {
for (Object value : this.values) {
if (value instanceof String) {
String s = (String) value;
try {
@@ -188,7 +188,7 @@ public final class NameAwareAttribute implements Attribute, Iterable<Object> {
}
public boolean hasValuesAsNames() {
return !valuesAsNames.isEmpty();
return !this.valuesAsNames.isEmpty();
}
@Override
@@ -197,21 +197,21 @@ public final class NameAwareAttribute implements Attribute, Iterable<Object> {
initValuesAsNames();
Name name = LdapUtils.newLdapName((Name) attrval);
String removedValue = valuesAsNames.remove(name);
String removedValue = this.valuesAsNames.remove(name);
if (removedValue != null) {
values.remove(removedValue);
this.values.remove(removedValue);
return true;
}
return false;
}
return values.remove(attrval);
return this.values.remove(attrval);
}
@Override
public void clear() {
values.clear();
this.values.clear();
}
@Override
@@ -226,7 +226,7 @@ public final class NameAwareAttribute implements Attribute, Iterable<Object> {
@Override
public boolean isOrdered() {
return orderMatters;
return this.orderMatters;
}
/**
@@ -238,7 +238,7 @@ public final class NameAwareAttribute implements Attribute, Iterable<Object> {
*/
@Override
public Object get(int ix) throws NamingException {
Iterator<Object> iterator = values.iterator();
Iterator<Object> iterator = this.values.iterator();
try {
Object value = iterator.next();
@@ -255,7 +255,7 @@ public final class NameAwareAttribute implements Attribute, Iterable<Object> {
@Override
public Object remove(int ix) {
Iterator<Object> iterator = values.iterator();
Iterator<Object> iterator = this.values.iterator();
try {
Object value = iterator.next();
@@ -265,7 +265,7 @@ public final class NameAwareAttribute implements Attribute, Iterable<Object> {
iterator.remove();
if (value instanceof String) {
try {
valuesAsNames.remove(new LdapName((String) value));
this.valuesAsNames.remove(new LdapName((String) value));
}
catch (javax.naming.InvalidNameException ignored) {
}
@@ -308,7 +308,7 @@ public final class NameAwareAttribute implements Attribute, Iterable<Object> {
NameAwareAttribute that = (NameAwareAttribute) o;
if (id != null ? !id.equals(that.id) : that.id != null)
if (this.id != null ? !this.id.equals(that.id) : that.id != null)
return false;
if (this.values.size() != that.values.size()) {
return false;
@@ -332,7 +332,7 @@ public final class NameAwareAttribute implements Attribute, Iterable<Object> {
theirValues = that.valuesAsNames.keySet();
}
if (orderMatters) {
if (this.orderMatters) {
Iterator<?> thisIterator = myValues.iterator();
Iterator<?> thatIterator = theirValues.iterator();
while (thisIterator.hasNext()) {
@@ -356,12 +356,12 @@ public final class NameAwareAttribute implements Attribute, Iterable<Object> {
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
int result = this.id != null ? this.id.hashCode() : 0;
int valuesHash = 7;
Set<?> myValues = this.values;
if (hasValuesAsNames()) {
myValues = valuesAsNames.keySet();
myValues = this.valuesAsNames.keySet();
}
for (Object value : myValues) {
@@ -374,13 +374,13 @@ public final class NameAwareAttribute implements Attribute, Iterable<Object> {
@Override
public String toString() {
return String.format("NameAwareAttribute; id: %s; hasValuesAsNames: %s; orderMatters: %s; values: %s", id,
hasValuesAsNames(), orderMatters, values);
return String.format("NameAwareAttribute; id: %s; hasValuesAsNames: %s; orderMatters: %s; values: %s", this.id,
hasValuesAsNames(), this.orderMatters, this.values);
}
@Override
public Iterator<Object> iterator() {
return values.iterator();
return this.values.iterator();
}
}

View File

@@ -60,30 +60,30 @@ public final class NameAwareAttributes implements Attributes {
@Override
public int size() {
return attributes.size();
return this.attributes.size();
}
@Override
public NameAwareAttribute get(String attrID) {
Assert.hasLength(attrID, "Attribute ID must not be empty");
return attributes.get(attrID.toLowerCase());
return this.attributes.get(attrID.toLowerCase());
}
@Override
public NamingEnumeration<NameAwareAttribute> getAll() {
return new IterableNamingEnumeration<NameAwareAttribute>(attributes.values());
return new IterableNamingEnumeration<NameAwareAttribute>(this.attributes.values());
}
@Override
public NamingEnumeration<String> getIDs() {
return new IterableNamingEnumeration<String>(attributes.keySet());
return new IterableNamingEnumeration<String>(this.attributes.keySet());
}
@Override
public Attribute put(String attrID, Object val) {
Assert.hasLength(attrID, "Attribute ID must not be empty");
NameAwareAttribute newAttribute = new NameAwareAttribute(attrID, val);
attributes.put(attrID.toLowerCase(), newAttribute);
this.attributes.put(attrID.toLowerCase(), newAttribute);
return newAttribute;
}
@@ -92,7 +92,7 @@ public final class NameAwareAttributes implements Attributes {
public Attribute put(Attribute attr) {
Assert.notNull(attr, "Attribute must not be null");
NameAwareAttribute newAttribute = new NameAwareAttribute(attr);
attributes.put(attr.getID().toLowerCase(), newAttribute);
this.attributes.put(attr.getID().toLowerCase(), newAttribute);
return newAttribute;
}
@@ -100,7 +100,7 @@ public final class NameAwareAttributes implements Attributes {
@Override
public Attribute remove(String attrID) {
Assert.hasLength(attrID, "Attribute ID must not be empty");
return attributes.remove(attrID.toLowerCase());
return this.attributes.remove(attrID.toLowerCase());
}
@Override
@@ -117,7 +117,7 @@ public final class NameAwareAttributes implements Attributes {
NameAwareAttributes that = (NameAwareAttributes) o;
if (attributes != null ? !attributes.equals(that.attributes) : that.attributes != null)
if (this.attributes != null ? !this.attributes.equals(that.attributes) : that.attributes != null)
return false;
return true;
@@ -125,12 +125,12 @@ public final class NameAwareAttributes implements Attributes {
@Override
public int hashCode() {
return attributes != null ? attributes.hashCode() : 0;
return this.attributes != null ? this.attributes.hashCode() : 0;
}
@Override
public String toString() {
return String.format("NameAwareAttribute; attributes: %s", attributes.toString());
return String.format("NameAwareAttribute; attributes: %s", this.attributes.toString());
}
}

View File

@@ -125,7 +125,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
public AbstractContextSource() {
try {
contextFactory = Class.forName(DEFAULT_CONTEXT_FACTORY);
this.contextFactory = Class.forName(DEFAULT_CONTEXT_FACTORY);
}
catch (ClassNotFoundException e) {
LOG.trace("The default for contextFactory cannot be resolved", e);
@@ -148,7 +148,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
DirContext ctx = createContext(env);
try {
DirContext processedDirContext = authenticationStrategy.processContextAfterCreation(ctx, principal,
DirContext processedDirContext = this.authenticationStrategy.processContextAfterCreation(ctx, principal,
credentials);
return processedDirContext;
}
@@ -164,8 +164,8 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
* @see org.springframework.ldap.core.ContextSource#getReadOnlyContext()
*/
public DirContext getReadOnlyContext() {
if (!anonymousReadOnly) {
return doGetContext(authenticationSource.getPrincipal(), authenticationSource.getCredentials(),
if (!this.anonymousReadOnly) {
return doGetContext(this.authenticationSource.getPrincipal(), this.authenticationSource.getCredentials(),
DONT_DISABLE_POOLING);
}
else {
@@ -179,7 +179,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
* @see org.springframework.ldap.core.ContextSource#getReadWriteContext()
*/
public DirContext getReadWriteContext() {
return doGetContext(authenticationSource.getPrincipal(), authenticationSource.getCredentials(),
return doGetContext(this.authenticationSource.getPrincipal(), this.authenticationSource.getCredentials(),
DONT_DISABLE_POOLING);
}
@@ -196,7 +196,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
*/
protected void setupAuthenticatedEnvironment(Hashtable<String, Object> env, String principal, String credentials) {
try {
authenticationStrategy.setupEnvironment(env, principal, credentials);
this.authenticationStrategy.setupEnvironment(env, principal, credentials);
}
catch (NamingException e) {
throw LdapUtils.convertLdapException(e);
@@ -228,12 +228,12 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
StringBuilder providerUrlBuffer = new StringBuilder(DEFAULT_BUFFER_SIZE);
for (String ldapUrl : ldapUrls) {
providerUrlBuffer.append(ldapUrl);
if (!base.isEmpty()) {
if (!this.base.isEmpty()) {
if (!ldapUrl.endsWith("/")) {
providerUrlBuffer.append("/");
}
}
providerUrlBuffer.append(formatForUrl(base));
providerUrlBuffer.append(formatForUrl(this.base));
providerUrlBuffer.append(' ');
}
return providerUrlBuffer.toString().trim();
@@ -324,12 +324,12 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
*/
@Override
public DistinguishedName getBaseLdapPath() {
return new DistinguishedName(base);
return new DistinguishedName(this.base);
}
@Override
public LdapName getBaseLdapName() {
return (LdapName) base.clone();
return (LdapName) this.base.clone();
}
@Override
@@ -376,7 +376,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
* @return the context factory used when creating Contexts.
*/
public Class<?> getContextFactory() {
return contextFactory;
return this.contextFactory;
}
/**
@@ -397,7 +397,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
* DirObjectFactory will be used.
*/
public Class<?> getDirObjectFactory() {
return dirObjectFactory;
return this.dirObjectFactory;
}
/**
@@ -407,65 +407,65 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
* Spring Context.
*/
public void afterPropertiesSet() {
if (ObjectUtils.isEmpty(urls)) {
if (ObjectUtils.isEmpty(this.urls)) {
throw new IllegalArgumentException("At least one server url must be set");
}
if (contextFactory == null) {
if (this.contextFactory == null) {
throw new IllegalArgumentException("contextFactory must be set");
}
if (authenticationSource == null) {
if (this.authenticationSource == null) {
LOG.debug("AuthenticationSource not set - " + "using default implementation");
if (!StringUtils.hasText(userDn)) {
if (!StringUtils.hasText(this.userDn)) {
LOG.info("Property 'userDn' not set - " + "anonymous context will be used for read-write operations");
anonymousReadOnly = true;
this.anonymousReadOnly = true;
}
if (!anonymousReadOnly) {
if (password == null) {
if (!this.anonymousReadOnly) {
if (this.password == null) {
throw new IllegalArgumentException(
"Property 'password' cannot be null. To use a blank password, please ensure it is set to \"\"");
}
if (!StringUtils.hasText(password)) {
if (!StringUtils.hasText(this.password)) {
LOG.info("Property 'password' not set - " + "blank password will be used");
}
}
authenticationSource = new SimpleAuthenticationSource();
this.authenticationSource = new SimpleAuthenticationSource();
}
if (cacheEnvironmentProperties) {
anonymousEnv = setupAnonymousEnv();
if (this.cacheEnvironmentProperties) {
this.anonymousEnv = setupAnonymousEnv();
}
}
@SuppressWarnings("deprecation")
private Hashtable<String, Object> setupAnonymousEnv() {
if (pooled) {
baseEnv.put(SUN_LDAP_POOLING_FLAG, "true");
if (this.pooled) {
this.baseEnv.put(SUN_LDAP_POOLING_FLAG, "true");
LOG.debug("Using LDAP pooling.");
}
else {
baseEnv.remove(SUN_LDAP_POOLING_FLAG);
this.baseEnv.remove(SUN_LDAP_POOLING_FLAG);
LOG.debug("Not using LDAP pooling");
}
Hashtable<String, Object> env = new Hashtable<String, Object>(baseEnv);
Hashtable<String, Object> env = new Hashtable<String, Object>(this.baseEnv);
env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory.getName());
env.put(Context.PROVIDER_URL, assembleProviderUrlString(urls));
env.put(Context.INITIAL_CONTEXT_FACTORY, this.contextFactory.getName());
env.put(Context.PROVIDER_URL, assembleProviderUrlString(this.urls));
if (dirObjectFactory != null) {
env.put(Context.OBJECT_FACTORIES, dirObjectFactory.getName());
if (this.dirObjectFactory != null) {
env.put(Context.OBJECT_FACTORIES, this.dirObjectFactory.getName());
}
if (StringUtils.hasText(referral)) {
env.put(Context.REFERRAL, referral);
if (StringUtils.hasText(this.referral)) {
env.put(Context.REFERRAL, this.referral);
}
if (!base.isEmpty()) {
if (!this.base.isEmpty()) {
// Save the base path for use in the DefaultDirObjectFactory.
env.put(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY, base);
env.put(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY, this.base);
}
LOG.debug("Trying provider Urls: " + assembleProviderUrlString(urls));
LOG.debug("Trying provider Urls: " + assembleProviderUrlString(this.urls));
return env;
}
@@ -483,7 +483,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
* @return the password
*/
public String getPassword() {
return password;
return this.password;
}
/**
@@ -517,7 +517,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
* @return the urls of all servers.
*/
public String[] getUrls() {
return urls.clone();
return this.urls.clone();
}
/**
@@ -553,7 +553,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
* @return whether Contexts should be pooled.
*/
public boolean isPooled() {
return pooled;
return this.pooled;
}
/**
@@ -567,8 +567,8 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
}
protected Hashtable<String, Object> getAnonymousEnv() {
if (cacheEnvironmentProperties) {
return anonymousEnv;
if (this.cacheEnvironmentProperties) {
return this.anonymousEnv;
}
else {
return setupAnonymousEnv();
@@ -597,7 +597,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
* @return the {@link AuthenticationSource} that will provide user info.
*/
public AuthenticationSource getAuthenticationSource() {
return authenticationSource;
return this.authenticationSource;
}
/**
@@ -630,7 +630,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
* operations, <code>false</code> otherwise.
*/
public boolean isAnonymousReadOnly() {
return anonymousReadOnly;
return this.anonymousReadOnly;
}
/**
@@ -667,11 +667,11 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
class SimpleAuthenticationSource implements AuthenticationSource {
public String getPrincipal() {
return userDn;
return AbstractContextSource.this.userDn;
}
public String getCredentials() {
return password;
return AbstractContextSource.this.password;
}
}

View File

@@ -130,14 +130,14 @@ public abstract class AbstractTlsDirContextAuthenticationStrategy implements Dir
final LdapContext ldapCtx = (LdapContext) ctx;
final StartTlsResponse tlsResponse = (StartTlsResponse) ldapCtx.extendedOperation(new StartTlsRequest());
try {
if (hostnameVerifier != null) {
tlsResponse.setHostnameVerifier(hostnameVerifier);
if (this.hostnameVerifier != null) {
tlsResponse.setHostnameVerifier(this.hostnameVerifier);
}
tlsResponse.negotiate(sslSocketFactory); // If null, the default SSL
// socket factory is used
tlsResponse.negotiate(this.sslSocketFactory); // If null, the default SSL
// socket factory is used
applyAuthentication(ldapCtx, userDn, password);
if (shutdownTlsGracefully) {
if (this.shutdownTlsGracefully) {
// Wrap the target context in a proxy to intercept any calls
// to 'close', so that we can shut down the TLS connection
// gracefully first.
@@ -187,19 +187,19 @@ public abstract class AbstractTlsDirContextAuthenticationStrategy implements Dir
}
public DirContext getTargetContext() {
return target;
return this.target;
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().equals(CLOSE_METHOD_NAME)) {
tlsResponse.close();
return method.invoke(target, args);
this.tlsResponse.close();
return method.invoke(this.target, args);
}
else if (method.getName().equals(GET_TARGET_CONTEXT_METHOD_NAME)) {
return target;
return this.target;
}
else {
return method.invoke(target, args);
return method.invoke(this.target, args);
}
}

View File

@@ -41,7 +41,7 @@ public class AggregateDirContextProcessor implements DirContextProcessor {
* @param processor the DirContextpProcessor to add.
*/
public void addDirContextProcessor(DirContextProcessor processor) {
dirContextProcessors.add(processor);
this.dirContextProcessors.add(processor);
}
/**
@@ -49,7 +49,7 @@ public class AggregateDirContextProcessor implements DirContextProcessor {
* @return the managed list of {@link DirContextProcessor} instances.
*/
public List<DirContextProcessor> getDirContextProcessors() {
return dirContextProcessors;
return this.dirContextProcessors;
}
/**
@@ -67,7 +67,7 @@ public class AggregateDirContextProcessor implements DirContextProcessor {
* .DirContext)
*/
public void preProcess(DirContext ctx) throws NamingException {
for (DirContextProcessor processor : dirContextProcessors) {
for (DirContextProcessor processor : this.dirContextProcessors) {
processor.preProcess(ctx);
}
}
@@ -77,7 +77,7 @@ public class AggregateDirContextProcessor implements DirContextProcessor {
* directory.DirContext)
*/
public void postProcess(DirContext ctx) throws NamingException {
for (DirContextProcessor processor : dirContextProcessors) {
for (DirContextProcessor processor : this.dirContextProcessors) {
processor.postProcess(ctx);
}
}

View File

@@ -65,8 +65,8 @@ public class BaseLdapPathBeanPostProcessor implements BeanPostProcessor, Applica
if (bean instanceof BaseLdapNameAware) {
BaseLdapNameAware baseLdapNameAware = (BaseLdapNameAware) bean;
if (basePath != null) {
baseLdapNameAware.setBaseLdapPath(LdapUtils.newLdapName(basePath));
if (this.basePath != null) {
baseLdapNameAware.setBaseLdapPath(LdapUtils.newLdapName(this.basePath));
}
else {
BaseLdapPathSource ldapPathSource = getBaseLdapPathSourceFromApplicationContext();
@@ -76,8 +76,8 @@ public class BaseLdapPathBeanPostProcessor implements BeanPostProcessor, Applica
else if (bean instanceof BaseLdapPathAware) {
BaseLdapPathAware baseLdapPathAware = (BaseLdapPathAware) bean;
if (basePath != null) {
baseLdapPathAware.setBaseLdapPath(new DistinguishedName(basePath));
if (this.basePath != null) {
baseLdapPathAware.setBaseLdapPath(new DistinguishedName(this.basePath));
}
else {
BaseLdapPathSource ldapPathSource = getBaseLdapPathSourceFromApplicationContext();
@@ -88,11 +88,12 @@ public class BaseLdapPathBeanPostProcessor implements BeanPostProcessor, Applica
}
BaseLdapPathSource getBaseLdapPathSourceFromApplicationContext() {
if (StringUtils.hasLength(baseLdapPathSourceName)) {
return applicationContext.getBean(baseLdapPathSourceName, BaseLdapPathSource.class);
if (StringUtils.hasLength(this.baseLdapPathSourceName)) {
return this.applicationContext.getBean(this.baseLdapPathSourceName, BaseLdapPathSource.class);
}
Collection<BaseLdapPathSource> beans = applicationContext.getBeansOfType(BaseLdapPathSource.class).values();
Collection<BaseLdapPathSource> beans = this.applicationContext.getBeansOfType(BaseLdapPathSource.class)
.values();
if (beans.isEmpty()) {
throw new NoSuchBeanDefinitionException("No BaseLdapPathSource implementation definition found");
}
@@ -178,7 +179,7 @@ public class BaseLdapPathBeanPostProcessor implements BeanPostProcessor, Applica
}
public int getOrder() {
return order;
return this.order;
}
}

View File

@@ -60,10 +60,10 @@ public class ContextMapperCallbackHandlerWithControls<T> extends ContextMapperCa
}
T result;
if (nameClassPair instanceof HasControls) {
result = mapper.mapFromContextWithControls(object, (HasControls) nameClassPair);
result = this.mapper.mapFromContextWithControls(object, (HasControls) nameClassPair);
}
else {
result = mapper.mapFromContext(object);
result = this.mapper.mapFromContext(object);
}
return result;
}

View File

@@ -34,7 +34,7 @@ public class CountNameClassPairCallbackHandler implements NameClassPairCallbackH
* @return the number of entries that have been handled.
*/
public int getNoOfRows() {
return noOfRows;
return this.noOfRows;
}
/*
@@ -44,7 +44,7 @@ public class CountNameClassPairCallbackHandler implements NameClassPairCallbackH
* naming.directory.SearchResult)
*/
public void handleNameClassPair(NameClassPair nameClassPair) {
noOfRows++;
this.noOfRows++;
}
}

View File

@@ -169,7 +169,7 @@ public class DefaultIncrementalAttributesMapper
}
// Reset the affected attributes.
rangedAttributesInNextIteration = new HashSet<String>();
this.rangedAttributesInNextIteration = new HashSet<String>();
NamingEnumeration<String> attributeNameEnum = attributes.getIDs();
while (attributeNameEnum.hasMore()) {
@@ -189,7 +189,7 @@ public class DefaultIncrementalAttributesMapper
state.processValues(attributes, attributeName);
state.calculateNextRange(responseRange);
if (state.hasMore()) {
rangedAttributesInNextIteration.add(state.getRequestedAttributeName());
this.rangedAttributesInNextIteration.add(state.getRequestedAttributeName());
}
}
}
@@ -200,7 +200,7 @@ public class DefaultIncrementalAttributesMapper
}
private IncrementalAttributeState getState(String attributeName) {
Object mappedState = stateMap.get(attributeName);
Object mappedState = this.stateMap.get(attributeName);
if (mappedState == null) {
LOG.warn("Attribute '" + attributeName + "' is not handled by this instance");
mappedState = NOT_FOUND_ATTRIBUTE_STATE;
@@ -218,7 +218,7 @@ public class DefaultIncrementalAttributesMapper
public final Attributes getCollectedAttributes() {
BasicAttributes attributes = new BasicAttributes();
Set<String> attributeNames = stateMap.keySet();
Set<String> attributeNames = this.stateMap.keySet();
for (String attributeName : attributeNames) {
BasicAttribute oneAttribute = new BasicAttribute(attributeName);
List<Object> values = getValues(attributeName);
@@ -236,15 +236,15 @@ public class DefaultIncrementalAttributesMapper
@Override
public final boolean hasMore() {
return rangedAttributesInNextIteration.size() > 0;
return this.rangedAttributesInNextIteration.size() > 0;
}
@Override
public final String[] getAttributesForLookup() {
String[] result = new String[rangedAttributesInNextIteration.size()];
String[] result = new String[this.rangedAttributesInNextIteration.size()];
int index = 0;
for (String next : rangedAttributesInNextIteration) {
IncrementalAttributeState state = stateMap.get(next);
for (String next : this.rangedAttributesInNextIteration) {
IncrementalAttributeState state = this.stateMap.get(next);
result[index++] = state.getAttributeNameForQuery();
}
@@ -373,30 +373,30 @@ public class DefaultIncrementalAttributesMapper
@Override
public boolean hasMore() {
return more;
return this.more;
}
@Override
public String getRequestedAttributeName() {
return actualAttributeName;
return this.actualAttributeName;
}
@Override
public void calculateNextRange(RangeOption responseRange) {
more = requestRange.compareTo(responseRange) > 0;
this.more = this.requestRange.compareTo(responseRange) > 0;
if (more) {
requestRange = responseRange.nextRange(pageSize);
if (this.more) {
this.requestRange = responseRange.nextRange(this.pageSize);
}
}
@Override
public String getAttributeNameForQuery() {
StringBuilder attributeBuilder = new StringBuilder(actualAttributeName);
StringBuilder attributeBuilder = new StringBuilder(this.actualAttributeName);
if (!(requestRange.isFullRange())) {
if (!(this.requestRange.isFullRange())) {
attributeBuilder.append(';');
requestRange.appendTo(attributeBuilder);
this.requestRange.appendTo(attributeBuilder);
}
return attributeBuilder.toString();
@@ -409,20 +409,20 @@ public class DefaultIncrementalAttributesMapper
initValuesIfApplicable();
while (valueEnum.hasMore()) {
values.add(valueEnum.next());
this.values.add(valueEnum.next());
}
}
private void initValuesIfApplicable() {
if (values == null) {
values = new LinkedList<Object>();
if (this.values == null) {
this.values = new LinkedList<Object>();
}
}
@Override
public List<Object> getValues() {
if (values != null) {
return new ArrayList<Object>(values);
if (this.values != null) {
return new ArrayList<Object>(this.values);
}
else {
return null;

View File

@@ -63,19 +63,19 @@ class RangeOption implements Comparable<RangeOption> {
}
public boolean isTerminalEndOfRange() {
return terminal == TERMINAL_END_OF_RANGE;
return this.terminal == TERMINAL_END_OF_RANGE;
}
public boolean isTerminalMissing() {
return terminal == TERMINAL_MISSING;
return this.terminal == TERMINAL_MISSING;
}
public int getInitial() {
return initial;
return this.initial;
}
public int getTerminal() {
return terminal;
return this.terminal;
}
public boolean isFullRange() {
@@ -90,7 +90,7 @@ class RangeOption implements Comparable<RangeOption> {
}
public void appendTo(StringBuilder rangeBuilder) {
rangeBuilder.append("Range=").append(initial);
rangeBuilder.append("Range=").append(this.initial);
if (!isTerminalMissing()) {
rangeBuilder.append('-');
@@ -99,7 +99,7 @@ class RangeOption implements Comparable<RangeOption> {
rangeBuilder.append('*');
}
else {
rangeBuilder.append(terminal);
rangeBuilder.append(this.terminal);
}
}
}
@@ -169,9 +169,9 @@ class RangeOption implements Comparable<RangeOption> {
RangeOption that = (RangeOption) o;
if (initial != that.initial)
if (this.initial != that.initial)
return false;
if (terminal != that.terminal)
if (this.terminal != that.terminal)
return false;
return true;
@@ -179,8 +179,8 @@ class RangeOption implements Comparable<RangeOption> {
@Override
public int hashCode() {
int result = initial;
result = 31 * result + terminal;
int result = this.initial;
result = 31 * result + this.terminal;
return result;
}

View File

@@ -60,14 +60,14 @@ public class SingleContextSource implements ContextSource, DisposableBean {
* @see org.springframework.ldap.ContextSource#getReadOnlyContext()
*/
public DirContext getReadOnlyContext() {
return getNonClosingDirContextProxy(ctx);
return getNonClosingDirContextProxy(this.ctx);
}
/*
* @see org.springframework.ldap.ContextSource#getReadWriteContext()
*/
public DirContext getReadWriteContext() {
return getNonClosingDirContextProxy(ctx);
return getNonClosingDirContextProxy(this.ctx);
}
private DirContext getNonClosingDirContextProxy(DirContext context) {
@@ -87,7 +87,7 @@ public class SingleContextSource implements ContextSource, DisposableBean {
*/
public void destroy() {
try {
ctx.close();
this.ctx.close();
}
catch (javax.naming.NamingException e) {
LOG.warn("Error when closing", e);
@@ -186,7 +186,7 @@ public class SingleContextSource implements ContextSource, DisposableBean {
String methodName = method.getName();
if (methodName.equals("getTargetContext")) {
return target;
return this.target;
}
else if (methodName.equals("equals")) {
// Only consider equal when proxies are identical.
@@ -203,7 +203,7 @@ public class SingleContextSource implements ContextSource, DisposableBean {
}
try {
return method.invoke(target, args);
return method.invoke(this.target, args);
}
catch (InvocationTargetException e) {
throw e.getTargetException();

View File

@@ -30,23 +30,23 @@ public abstract class BinaryLogicalFilter extends AbstractFilter {
private List<Filter> queryList = new LinkedList<Filter>();
public StringBuffer encode(StringBuffer buff) {
if (queryList.size() <= 0) {
if (this.queryList.size() <= 0) {
// only output query if contains anything
return buff;
}
else if (queryList.size() == 1) {
else if (this.queryList.size() == 1) {
// don't add the &
Filter query = queryList.get(0);
Filter query = this.queryList.get(0);
return query.encode(buff);
}
else {
buff.append("(").append(getLogicalOperator());
for (Filter query : queryList) {
for (Filter query : this.queryList) {
query.encode(buff);
}
@@ -72,7 +72,7 @@ public abstract class BinaryLogicalFilter extends AbstractFilter {
BinaryLogicalFilter that = (BinaryLogicalFilter) o;
if (queryList != null ? !queryList.equals(that.queryList) : that.queryList != null)
if (this.queryList != null ? !this.queryList.equals(that.queryList) : that.queryList != null)
return false;
return true;
@@ -80,7 +80,7 @@ public abstract class BinaryLogicalFilter extends AbstractFilter {
@Override
public int hashCode() {
return queryList != null ? queryList.hashCode() : 0;
return this.queryList != null ? this.queryList.hashCode() : 0;
}
/**
@@ -89,12 +89,12 @@ public abstract class BinaryLogicalFilter extends AbstractFilter {
* @return This instance.
*/
public final BinaryLogicalFilter append(Filter query) {
queryList.add(query);
this.queryList.add(query);
return this;
}
public final BinaryLogicalFilter appendAll(Collection<Filter> subQueries) {
queryList.addAll(subQueries);
this.queryList.addAll(subQueries);
return this;
}

View File

@@ -41,7 +41,7 @@ public abstract class CompareFilter extends AbstractFilter {
* @return the encoded value.
*/
String getEncodedValue() {
return encodedValue;
return this.encodedValue;
}
/**
@@ -69,7 +69,7 @@ public abstract class CompareFilter extends AbstractFilter {
*/
public StringBuffer encode(StringBuffer buff) {
buff.append('(');
buff.append(attribute).append(getCompareString()).append(encodedValue);
buff.append(this.attribute).append(getCompareString()).append(this.encodedValue);
buff.append(')');
return buff;
@@ -84,9 +84,9 @@ public abstract class CompareFilter extends AbstractFilter {
CompareFilter that = (CompareFilter) o;
if (attribute != null ? !attribute.equals(that.attribute) : that.attribute != null)
if (this.attribute != null ? !this.attribute.equals(that.attribute) : that.attribute != null)
return false;
if (value != null ? !value.equals(that.value) : that.value != null)
if (this.value != null ? !this.value.equals(that.value) : that.value != null)
return false;
return true;
@@ -94,8 +94,8 @@ public abstract class CompareFilter extends AbstractFilter {
@Override
public int hashCode() {
int result = attribute != null ? attribute.hashCode() : 0;
result = 31 * result + (value != null ? value.hashCode() : 0);
int result = this.attribute != null ? this.attribute.hashCode() : 0;
result = 31 * result + (this.value != null ? this.value.hashCode() : 0);
return result;
}

View File

@@ -57,11 +57,11 @@ public class HardcodedFilter extends AbstractFilter {
}
public StringBuffer encode(StringBuffer buff) {
if (!StringUtils.hasLength(filter)) {
if (!StringUtils.hasLength(this.filter)) {
return buff;
}
buff.append(filter);
buff.append(this.filter);
return buff;
}
@@ -74,7 +74,7 @@ public class HardcodedFilter extends AbstractFilter {
HardcodedFilter that = (HardcodedFilter) o;
if (filter != null ? !filter.equals(that.filter) : that.filter != null)
if (this.filter != null ? !this.filter.equals(that.filter) : that.filter != null)
return false;
return true;
@@ -82,7 +82,7 @@ public class HardcodedFilter extends AbstractFilter {
@Override
public int hashCode() {
return filter != null ? filter.hashCode() : 0;
return this.filter != null ? this.filter.hashCode() : 0;
}
}

View File

@@ -50,7 +50,7 @@ public class NotFilter extends AbstractFilter {
public StringBuffer encode(StringBuffer buff) {
buff.append("(!");
filter.encode(buff);
this.filter.encode(buff);
buff.append(')');
return buff;
@@ -65,7 +65,7 @@ public class NotFilter extends AbstractFilter {
NotFilter notFilter = (NotFilter) o;
if (filter != null ? !filter.equals(notFilter.filter) : notFilter.filter != null)
if (this.filter != null ? !this.filter.equals(notFilter.filter) : notFilter.filter != null)
return false;
return true;
@@ -73,7 +73,7 @@ public class NotFilter extends AbstractFilter {
@Override
public int hashCode() {
return filter != null ? filter.hashCode() : 0;
return this.filter != null ? this.filter.hashCode() : 0;
}
}

View File

@@ -48,7 +48,7 @@ public class NotPresentFilter extends AbstractFilter {
public StringBuffer encode(StringBuffer buff) {
buff.append("(!(");
buff.append(attribute);
buff.append(this.attribute);
buff.append("=*))");
return buff;
}
@@ -62,7 +62,7 @@ public class NotPresentFilter extends AbstractFilter {
NotPresentFilter that = (NotPresentFilter) o;
if (attribute != null ? !attribute.equals(that.attribute) : that.attribute != null)
if (this.attribute != null ? !this.attribute.equals(that.attribute) : that.attribute != null)
return false;
return true;
@@ -70,7 +70,7 @@ public class NotPresentFilter extends AbstractFilter {
@Override
public int hashCode() {
return attribute != null ? attribute.hashCode() : 0;
return this.attribute != null ? this.attribute.hashCode() : 0;
}
}

View File

@@ -49,7 +49,7 @@ public class PresentFilter extends AbstractFilter {
public StringBuffer encode(StringBuffer buff) {
buff.append("(");
buff.append(attribute);
buff.append(this.attribute);
buff.append("=*)");
return buff;
}
@@ -63,7 +63,7 @@ public class PresentFilter extends AbstractFilter {
PresentFilter that = (PresentFilter) o;
if (attribute != null ? !attribute.equals(that.attribute) : that.attribute != null)
if (this.attribute != null ? !this.attribute.equals(that.attribute) : that.attribute != null)
return false;
return true;
@@ -71,7 +71,7 @@ public class PresentFilter extends AbstractFilter {
@Override
public int hashCode() {
return attribute != null ? attribute.hashCode() : 0;
return this.attribute != null ? this.attribute.hashCode() : 0;
}
}

View File

@@ -86,13 +86,13 @@ import java.util.TreeSet;
// syntax, isBinary, isObjectClass and name.
private boolean processAttributeAnnotation(Field field) {
// Default to no syntax specified
syntax = "";
this.syntax = "";
// Default to a String based attribute
isBinary = false;
this.isBinary = false;
// Default name of attribute to the name of the field
name = new CaseIgnoreString(field.getName());
this.name = new CaseIgnoreString(field.getName());
// We have not yet found the @Attribute annotation
boolean foundAnnotation = false;
@@ -110,16 +110,16 @@ import java.util.TreeSet;
// Would be more efficient to use !isEmpty - but that then makes us Java 6
// dependent
if (localAttributeName != null && localAttributeName.length() > 0) {
name = new CaseIgnoreString(localAttributeName);
this.name = new CaseIgnoreString(localAttributeName);
attrList.add(localAttributeName);
}
syntax = attribute.syntax();
isBinary = attribute.type() == Attribute.Type.BINARY;
isReadOnly = attribute.readonly();
this.syntax = attribute.syntax();
this.isBinary = attribute.type() == Attribute.Type.BINARY;
this.isReadOnly = attribute.readonly();
}
attributes = attrList.toArray(new String[attrList.size()]);
this.attributes = attrList.toArray(new String[attrList.size()]);
isObjectClass = name.equals(OBJECT_CLASS_ATTRIBUTE_CI);
this.isObjectClass = this.name.equals(OBJECT_CLASS_ATTRIBUTE_CI);
return foundAnnotation;
}
@@ -130,12 +130,12 @@ import java.util.TreeSet;
// Determine the class of data stored in the field
Class<?> fieldType = field.getType();
isCollection = Collection.class.isAssignableFrom(fieldType);
this.isCollection = Collection.class.isAssignableFrom(fieldType);
valueClass = null;
if (!isCollection) {
this.valueClass = null;
if (!this.isCollection) {
// It's not a list so assume its single valued - so just take the field type
valueClass = fieldType;
this.valueClass = fieldType;
}
else {
determineCollectionClass(fieldType);
@@ -155,14 +155,14 @@ import java.util.TreeSet;
Type[] actualParamArguments = paramType.getActualTypeArguments();
if (actualParamArguments.length == 1) {
if (actualParamArguments[0] instanceof Class) {
valueClass = (Class<?>) actualParamArguments[0];
this.valueClass = (Class<?>) actualParamArguments[0];
}
else {
if (actualParamArguments[0] instanceof GenericArrayType) {
// Deal with arrays
Type type = ((GenericArrayType) actualParamArguments[0]).getGenericComponentType();
if (type instanceof Class) {
valueClass = Array.newInstance((Class<?>) type, 0).getClass();
this.valueClass = Array.newInstance((Class<?>) type, 0).getClass();
}
}
}
@@ -170,7 +170,7 @@ import java.util.TreeSet;
}
// Check we have been able to determine the value class
if (valueClass == null) {
if (this.valueClass == null) {
throw new MetaDataException(String.format("Can't determine destination type for field %1$s in class %2$s",
field, field.getDeclaringClass()));
}
@@ -180,27 +180,27 @@ import java.util.TreeSet;
private void determineCollectionClass(Class<?> fieldType) {
if (fieldType.isInterface()) {
if (Collection.class.equals(fieldType) || List.class.equals(fieldType)) {
collectionClass = ArrayList.class;
this.collectionClass = ArrayList.class;
}
else if (SortedSet.class.equals(fieldType)) {
collectionClass = TreeSet.class;
this.collectionClass = TreeSet.class;
}
else if (Set.class.isAssignableFrom(fieldType)) {
collectionClass = LinkedHashSet.class;
this.collectionClass = LinkedHashSet.class;
}
else {
throw new MetaDataException(String.format("Collection class %s is not supported", fieldType));
}
}
else {
collectionClass = (Class<? extends Collection>) fieldType;
this.collectionClass = (Class<? extends Collection>) fieldType;
}
}
@SuppressWarnings("unchecked")
public Collection<Object> newCollectionInstance() {
try {
return (Collection<Object>) collectionClass.newInstance();
return (Collection<Object>) this.collectionClass.newInstance();
}
catch (Exception e) {
throw new UncategorizedLdapException("Failed to instantiate collection class", e);
@@ -211,9 +211,9 @@ import java.util.TreeSet;
// isId
private boolean processIdAnnotation(Field field, Class<?> fieldType) {
// Are we dealing with the Id field?
isId = field.getAnnotation(Id.class) != null;
this.isId = field.getAnnotation(Id.class) != null;
if (isId) {
if (this.isId) {
// It must be of type Name or a subclass of that of
if (!Name.class.isAssignableFrom(fieldType)) {
throw new MetaDataException(String.format(
@@ -222,7 +222,7 @@ import java.util.TreeSet;
}
}
return isId;
return this.isId;
}
// Extract meta-data from the given field
@@ -249,7 +249,7 @@ import java.util.TreeSet;
boolean foundAttributeAnnotation = processAttributeAnnotation(field);
// Data from the @Id annotation
boolean foundIdAnnoation = processIdAnnotation(field, valueClass);
boolean foundIdAnnoation = processIdAnnotation(field, this.valueClass);
// Check that the field has not been annotated with both @Attribute and with @Id
if (foundAttributeAnnotation && foundIdAnnoation) {
@@ -259,7 +259,7 @@ import java.util.TreeSet;
}
// If this is the objectclass attribute then it must be of type List<String>
if (isObjectClass() && (!isCollection() || valueClass != String.class)) {
if (isObjectClass() && (!isCollection() || this.valueClass != String.class)) {
throw new MetaDataException(
String.format("The type of the objectclass attribute must be List<String> in classs %1$s",
field.getDeclaringClass()));
@@ -267,62 +267,62 @@ import java.util.TreeSet;
}
public String getSyntax() {
return syntax;
return this.syntax;
}
public boolean isBinary() {
return isBinary;
return this.isBinary;
}
public Field getField() {
return field;
return this.field;
}
public CaseIgnoreString getName() {
return name;
return this.name;
}
public boolean isCollection() {
return isCollection;
return this.isCollection;
}
public boolean isId() {
return isId;
return this.isId;
}
public boolean isReadOnly() {
return isReadOnly;
return this.isReadOnly;
}
public boolean isTransient() {
return isTransient;
return this.isTransient;
}
public DnAttribute getDnAttribute() {
return dnAttribute;
return this.dnAttribute;
}
public boolean isDnAttribute() {
return dnAttribute != null;
return this.dnAttribute != null;
}
public boolean isObjectClass() {
return isObjectClass;
return this.isObjectClass;
}
public Class<?> getValueClass() {
return valueClass;
return this.valueClass;
}
public String[] getAttributes() {
return attributes;
return this.attributes;
}
public Class<?> getJndiClass() {
if (isBinary()) {
return byte[].class;
}
else if (Name.class.isAssignableFrom(valueClass)) {
else if (Name.class.isAssignableFrom(this.valueClass)) {
return Name.class;
}
else {

View File

@@ -28,24 +28,24 @@ import org.springframework.util.Assert;
public CaseIgnoreString(String string) {
Assert.notNull(string, "string must not be null");
this.string = string;
hashCode = string.toUpperCase().hashCode();
this.hashCode = string.toUpperCase().hashCode();
}
public boolean equals(Object other) {
return other instanceof CaseIgnoreString && ((CaseIgnoreString) other).string.equalsIgnoreCase(string);
return other instanceof CaseIgnoreString && ((CaseIgnoreString) other).string.equalsIgnoreCase(this.string);
}
public int hashCode() {
return hashCode;
return this.hashCode;
}
public int compareTo(CaseIgnoreString other) {
CaseIgnoreString cis = other;
return String.CASE_INSENSITIVE_ORDER.compare(string, cis.string);
return String.CASE_INSENSITIVE_ORDER.compare(this.string, cis.string);
}
public String toString() {
return string;
return this.string;
}
}

View File

@@ -72,7 +72,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
private static final CaseIgnoreString OBJECT_CLASS_ATTRIBUTE_CI = new CaseIgnoreString(OBJECT_CLASS_ATTRIBUTE);
public DefaultObjectDirectoryMapper() {
converterManager = createDefaultConverterManager();
this.converterManager = createDefaultConverterManager();
}
private static ConverterManager createDefaultConverterManager() {
@@ -111,7 +111,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
private final ConcurrentMap<Class<?>, EntityData> metaDataMap = new ConcurrentHashMap<Class<?>, EntityData>();
private EntityData getEntityData(Class<?> managedClass) {
EntityData result = metaDataMap.get(managedClass);
EntityData result = this.metaDataMap.get(managedClass);
if (result == null) {
return addManagedClass(managedClass);
}
@@ -185,7 +185,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
}
EntityData newValue = new EntityData(metaData, ocFilter);
EntityData previousValue = metaDataMap.putIfAbsent(managedClass, newValue);
EntityData previousValue = this.metaDataMap.putIfAbsent(managedClass, newValue);
// Just in case someone beat us to it
if (previousValue != null) {
return previousValue;
@@ -197,13 +197,13 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
private void verifyConversion(Class<?> managedClass, Field field, AttributeMetaData attributeInfo) {
Class<?> jndiClass = attributeInfo.getJndiClass();
Class<?> javaClass = attributeInfo.getValueClass();
if (!converterManager.canConvert(jndiClass, attributeInfo.getSyntax(), javaClass)) {
if (!this.converterManager.canConvert(jndiClass, attributeInfo.getSyntax(), javaClass)) {
throw new InvalidEntryException(
String.format("Missing converter from %1$s to %2$s, this is needed for field %3$s on Entry %4$s",
jndiClass, javaClass, field.getName(), managedClass));
}
if (!attributeInfo.isReadOnly()
&& !converterManager.canConvert(javaClass, attributeInfo.getSyntax(), jndiClass)) {
&& !this.converterManager.canConvert(javaClass, attributeInfo.getSyntax(), jndiClass)) {
throw new InvalidEntryException(
String.format("Missing converter from %1$s to %2$s, this is needed for field %3$s on Entry %4$s",
javaClass, jndiClass, field.getName(), managedClass));
@@ -273,7 +273,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
for (final Object o : fieldValues) {
// Ignore null values
if (o != null) {
attributeValues.add(converterManager.convert(o, attributeInfo.getSyntax(), targetClass));
attributeValues.add(this.converterManager.convert(o, attributeInfo.getSyntax(), targetClass));
}
}
context.setAttributeValues(attributeInfo.getName().toString(), attributeValues.toArray());
@@ -289,7 +289,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
// Convert the field value to the required type and write it into the JNDI
// context
context.setAttributeValue(attributeInfo.getName().toString(),
converterManager.convert(fieldValue, attributeInfo.getSyntax(), targetClass));
this.converterManager.convert(fieldValue, attributeInfo.getSyntax(), targetClass));
}
else {
context.setAttributeValue(attributeInfo.getName().toString(), null);
@@ -367,8 +367,8 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
}
}
else if (attributeInfo.isId()) { // The id field
field.set(result,
converterManager.convert(dn, attributeInfo.getSyntax(), attributeInfo.getValueClass()));
field.set(result, this.converterManager.convert(dn, attributeInfo.getSyntax(),
attributeInfo.getValueClass()));
}
DnAttribute dnAttribute = attributeInfo.getDnAttribute();
@@ -423,8 +423,8 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
if (value != null) {
// Convert the value to its Java representation and add it to our
// working list
fieldValues.add(
converterManager.convert(value, attributeInfo.getSyntax(), attributeInfo.getValueClass()));
fieldValues.add(this.converterManager.convert(value, attributeInfo.getSyntax(),
attributeInfo.getValueClass()));
}
}
}
@@ -445,7 +445,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
// Convert the JNDI value to its Java representation - this will throw if
// the
// conversion fails
Object convertedValue = converterManager.convert(value, attributeInfo.getSyntax(),
Object convertedValue = this.converterManager.convert(value, attributeInfo.getSyntax(),
attributeInfo.getValueClass());
// Set it in the Java version
field.set(result, convertedValue);
@@ -529,7 +529,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
// For testing purposes
ConcurrentMap<Class<?>, EntityData> getMetaDataMap() {
return metaDataMap;
return this.metaDataMap;
}
static boolean collectionContainsAll(Collection<?> collection, Set<?> shouldBePresent) {

View File

@@ -66,11 +66,11 @@ import java.util.TreeSet;
private Name base = LdapUtils.emptyLdapName();
public Set<CaseIgnoreString> getObjectClasses() {
return objectClasses;
return this.objectClasses;
}
public AttributeMetaData getIdAttribute() {
return idAttribute;
return this.idAttribute;
}
/*
@@ -79,11 +79,11 @@ import java.util.TreeSet;
* @see java.lang.Iterable#iterator()
*/
public Iterator<Field> iterator() {
return fieldToAttribute.keySet().iterator();
return this.fieldToAttribute.keySet().iterator();
}
public AttributeMetaData getAttribute(Field field) {
return fieldToAttribute.get(field);
return this.fieldToAttribute.get(field);
}
public ObjectMetaData(Class<?> clazz) {
@@ -99,11 +99,11 @@ import java.util.TreeSet;
String[] localObjectClasses = entity.objectClasses();
if (localObjectClasses != null && localObjectClasses.length > 0 && localObjectClasses[0].length() > 0) {
for (String localObjectClass : localObjectClasses) {
objectClasses.add(new CaseIgnoreString(localObjectClass));
this.objectClasses.add(new CaseIgnoreString(localObjectClass));
}
}
else {
objectClasses.add(new CaseIgnoreString(clazz.getSimpleName()));
this.objectClasses.add(new CaseIgnoreString(clazz.getSimpleName()));
}
String base = entity.base();
@@ -134,21 +134,21 @@ import java.util.TreeSet;
AttributeMetaData currentAttributeMetaData = new AttributeMetaData(field);
if (currentAttributeMetaData.isId()) {
if (idAttribute != null) {
if (this.idAttribute != null) {
// There can be only one id field
throw new MetaDataException(String.format(
"You man have only one field with the %1$s annotation in class %2$s", Id.class, clazz));
}
idAttribute = currentAttributeMetaData;
this.idAttribute = currentAttributeMetaData;
}
fieldToAttribute.put(field, currentAttributeMetaData);
this.fieldToAttribute.put(field, currentAttributeMetaData);
if (currentAttributeMetaData.isDnAttribute()) {
dnAttributes.add(currentAttributeMetaData);
this.dnAttributes.add(currentAttributeMetaData);
}
}
if (idAttribute == null) {
if (this.idAttribute == null) {
throw new MetaDataException(
String.format("All Entry classes must define a field with the %1$s annotation, error in class %2$s",
Id.class, clazz));
@@ -165,7 +165,7 @@ import java.util.TreeSet;
boolean hasIndexed = false;
boolean hasNonIndexed = false;
for (AttributeMetaData dnAttribute : dnAttributes) {
for (AttributeMetaData dnAttribute : this.dnAttributes) {
int declaredIndex = dnAttribute.getDnAttribute().index();
if (declaredIndex != -1) {
@@ -182,23 +182,23 @@ import java.util.TreeSet;
+ "which means that all DnAttributes must be indexed", clazz.toString()));
}
indexedDnAttributes = hasIndexed;
this.indexedDnAttributes = hasIndexed;
}
int size() {
return fieldToAttribute.size();
return this.fieldToAttribute.size();
}
boolean canCalculateDn() {
return dnAttributes.size() > 0 && indexedDnAttributes;
return this.dnAttributes.size() > 0 && this.indexedDnAttributes;
}
public Set<AttributeMetaData> getDnAttributes() {
return dnAttributes;
return this.dnAttributes;
}
Name getBase() {
return base;
return this.base;
}
/*
@@ -208,8 +208,8 @@ import java.util.TreeSet;
*/
@Override
public String toString() {
return String.format("objectsClasses=%1$s | idField=%2$s | attributes=%3$s", objectClasses,
idAttribute.getName(), fieldToAttribute);
return String.format("objectsClasses=%1$s | idField=%2$s | attributes=%3$s", this.objectClasses,
this.idAttribute.getName(), this.fieldToAttribute);
}
}

View File

@@ -43,31 +43,31 @@ public class ConversionServiceConverterManager implements ConverterManager {
if (ClassUtils.isPresent(DEFAULT_CONVERSION_SERVICE_CLASS, defaultClassLoader)) {
try {
Class<?> clazz = ClassUtils.forName(DEFAULT_CONVERSION_SERVICE_CLASS, defaultClassLoader);
conversionService = (GenericConversionService) clazz.newInstance();
this.conversionService = (GenericConversionService) clazz.newInstance();
}
catch (Exception e) {
ReflectionUtils.handleReflectionException(e);
}
}
else {
conversionService = new GenericConversionService();
this.conversionService = new GenericConversionService();
}
prePopulateWithNameConverter();
}
private void prePopulateWithNameConverter() {
conversionService.addConverter(new StringToNameConverter());
this.conversionService.addConverter(new StringToNameConverter());
}
@Override
public boolean canConvert(Class<?> fromClass, String syntax, Class<?> toClass) {
return conversionService.canConvert(fromClass, toClass);
return this.conversionService.canConvert(fromClass, toClass);
}
@Override
public <T> T convert(Object source, String syntax, Class<T> toClass) {
return conversionService.convert(source, toClass);
return this.conversionService.convert(source, toClass);
}
public final static class NameToStringConverter

View File

@@ -149,8 +149,8 @@ public final class ConverterManagerFactoryBean implements FactoryBean {
@Override
public String toString() {
return String.format("fromClasses=%1$s, syntax=%2$s, toClasses=%3$s, converter=%4$s", fromClasses, syntax,
toClasses, converter);
return String.format("fromClasses=%1$s, syntax=%2$s, toClasses=%3$s, converter=%4$s", this.fromClasses,
this.syntax, this.toClasses, this.converter);
}
}
@@ -175,12 +175,12 @@ public final class ConverterManagerFactoryBean implements FactoryBean {
* @see org.springframework.beans.factory.FactoryBean#getObject()
*/
public Object getObject() throws Exception {
if (converterConfigList == null) {
if (this.converterConfigList == null) {
throw new FactoryBeanNotInitializedException("converterConfigList has not been set");
}
ConverterManagerImpl result = new ConverterManagerImpl();
for (ConverterConfig converterConfig : converterConfigList) {
for (ConverterConfig converterConfig : this.converterConfigList) {
if (converterConfig.fromClasses == null || converterConfig.toClasses == null
|| converterConfig.converter == null) {

View File

@@ -109,8 +109,8 @@ public final class ConverterManagerImpl implements ConverterManager {
fixedFromClass = primitiveTypeMap.get(fromClass);
}
return fixedToClass.isAssignableFrom(fixedFromClass)
|| (converters.get(makeConverterKey(fixedFromClass, syntax, fixedToClass)) != null)
|| (converters.get(makeConverterKey(fixedFromClass, null, fixedToClass)) != null);
|| (this.converters.get(makeConverterKey(fixedFromClass, syntax, fixedToClass)) != null)
|| (this.converters.get(makeConverterKey(fixedFromClass, null, fixedToClass)) != null);
}
/*
@@ -134,7 +134,7 @@ public final class ConverterManagerImpl implements ConverterManager {
}
// Try to convert with any syntax we have been given
Converter syntaxConverter = converters.get(makeConverterKey(fromClass, syntax, targetClass));
Converter syntaxConverter = this.converters.get(makeConverterKey(fromClass, syntax, targetClass));
if (syntaxConverter != null) {
try {
result = syntaxConverter.convert(source, targetClass);
@@ -152,7 +152,7 @@ public final class ConverterManagerImpl implements ConverterManager {
// If we were given a syntax and we failed to convert drop back to any mapping
// that will work from class -> to class
if (result == null && syntax != null) {
Converter nullSyntaxConverter = converters.get(makeConverterKey(fromClass, null, targetClass));
Converter nullSyntaxConverter = this.converters.get(makeConverterKey(fromClass, null, targetClass));
if (nullSyntaxConverter != null) {
try {
result = nullSyntaxConverter.convert(source, targetClass);
@@ -183,7 +183,7 @@ public final class ConverterManagerImpl implements ConverterManager {
* @param converter The <code>Converter</code> to add.
*/
public void addConverter(Class<?> fromClass, String syntax, Class<?> toClass, Converter converter) {
converters.put(makeConverterKey(fromClass, syntax, toClass), converter);
this.converters.put(makeConverterKey(fromClass, syntax, toClass), converter);
}
}

View File

@@ -35,7 +35,7 @@ public final class DirContextType {
}
public String toString() {
return name;
return this.name;
}
/**

View File

@@ -14,7 +14,7 @@ public enum PoolExhaustedAction {
}
public byte getValue() {
return value;
return this.value;
}
}

View File

@@ -242,23 +242,23 @@ class DirContextPoolableObjectFactory extends BaseKeyedPoolableObjectFactory {
String methodName = method.getName();
if (methodName.equals("getTargetContext")) {
return target;
return this.target;
}
else if (methodName.equals("hasFailed")) {
return hasFailed;
return this.hasFailed;
}
try {
return method.invoke(target, args);
return method.invoke(this.target, args);
}
catch (InvocationTargetException e) {
Throwable targetException = e.getTargetException();
Class<? extends Throwable> targetExceptionClass = targetException.getClass();
boolean nonTransientEncountered = false;
for (Class<? extends Throwable> clazz : nonTransientExceptions) {
for (Class<? extends Throwable> clazz : DirContextPoolableObjectFactory.this.nonTransientExceptions) {
if (clazz.isAssignableFrom(targetExceptionClass)) {
logger.info(String.format(
DirContextPoolableObjectFactory.this.logger.info(String.format(
"An %s - explicitly configured to be a non-transient exception - encountered; eagerly invalidating the target context.",
targetExceptionClass));
nonTransientEncountered = true;
@@ -267,11 +267,11 @@ class DirContextPoolableObjectFactory extends BaseKeyedPoolableObjectFactory {
}
if (nonTransientEncountered) {
hasFailed = true;
this.hasFailed = true;
}
else {
if (logger.isDebugEnabled()) {
logger.debug(String.format(
if (DirContextPoolableObjectFactory.this.logger.isDebugEnabled()) {
DirContextPoolableObjectFactory.this.logger.debug(String.format(
"An %s - not explicitly configured to be a non-transient exception - encountered; ignoring.",
targetExceptionClass));
}

View File

@@ -35,7 +35,7 @@ public final class DirContextType {
}
public String toString() {
return name;
return this.name;
}
/**

View File

@@ -265,24 +265,24 @@ class DirContextPooledObjectFactory extends BaseKeyedPooledObjectFactory<Object,
String methodName = method.getName();
if (methodName.equals("getTargetContext")) {
return target;
return this.target;
}
else if (methodName.equals("hasFailed")) {
return hasFailed;
return this.hasFailed;
}
try {
return method.invoke(target, args);
return method.invoke(this.target, args);
}
catch (InvocationTargetException e) {
Throwable targetException = e.getTargetException();
Class<? extends Throwable> targetExceptionClass = targetException.getClass();
boolean nonTransientEncountered = false;
for (Class<? extends Throwable> clazz : nonTransientExceptions) {
for (Class<? extends Throwable> clazz : DirContextPooledObjectFactory.this.nonTransientExceptions) {
if (clazz.isAssignableFrom(targetExceptionClass)) {
if (logger.isDebugEnabled()) {
logger.debug(String.format(
if (DirContextPooledObjectFactory.this.logger.isDebugEnabled()) {
DirContextPooledObjectFactory.this.logger.debug(String.format(
"A %s - explicitly configured to be a non-transient exception - encountered; eagerly invalidating the target context.",
targetExceptionClass));
}
@@ -292,11 +292,11 @@ class DirContextPooledObjectFactory extends BaseKeyedPooledObjectFactory<Object,
}
if (nonTransientEncountered) {
hasFailed = true;
this.hasFailed = true;
}
else {
if (logger.isDebugEnabled()) {
logger.debug(String.format(
if (DirContextPooledObjectFactory.this.logger.isDebugEnabled()) {
DirContextPooledObjectFactory.this.logger.debug(String.format(
"A %s - not explicitly configured to be a non-transient exception - encountered; ignoring.",
targetExceptionClass));
}

View File

@@ -212,140 +212,140 @@ public class PoolConfig {
* @see GenericKeyedObjectPoolConfig#getMaxIdlePerKey()
*/
public int getMaxIdlePerKey() {
return maxIdlePerKey;
return this.maxIdlePerKey;
}
/**
* @see GenericKeyedObjectPoolConfig#getMaxTotal()
*/
public int getMaxTotal() {
return maxTotal;
return this.maxTotal;
}
/**
* @see GenericKeyedObjectPoolConfig#getMaxIdlePerKey()
*/
public int getMaxTotalPerKey() {
return maxTotalPerKey;
return this.maxTotalPerKey;
}
/**
* @see GenericKeyedObjectPoolConfig#getMinIdlePerKey()
*/
public int getMinIdlePerKey() {
return minIdlePerKey;
return this.minIdlePerKey;
}
/**
* @see GenericKeyedObjectPoolConfig#getBlockWhenExhausted()
*/
public boolean isBlockWhenExhausted() {
return blockWhenExhausted;
return this.blockWhenExhausted;
}
/**
* @see GenericKeyedObjectPoolConfig#getEvictionPolicyClassName()
*/
public String getEvictionPolicyClassName() {
return evictionPolicyClassName;
return this.evictionPolicyClassName;
}
/**
* @see GenericKeyedObjectPoolConfig#getFairness()
*/
public boolean isFairness() {
return fairness;
return this.fairness;
}
/**
* @see GenericKeyedObjectPoolConfig#getJmxEnabled()
*/
public boolean isJmxEnabled() {
return jmxEnabled;
return this.jmxEnabled;
}
/**
* @see GenericKeyedObjectPoolConfig#getJmxNameBase()
*/
public String getJmxNameBase() {
return jmxNameBase;
return this.jmxNameBase;
}
/**
* @see GenericKeyedObjectPoolConfig#getJmxNamePrefix()
*/
public String getJmxNamePrefix() {
return jmxNamePrefix;
return this.jmxNamePrefix;
}
/**
* @see GenericKeyedObjectPoolConfig#getLifo()
*/
public boolean isLifo() {
return lifo;
return this.lifo;
}
/**
* @see GenericKeyedObjectPoolConfig#getMaxWaitMillis()
*/
public long getMaxWaitMillis() {
return maxWaitMillis;
return this.maxWaitMillis;
}
/**
* @see GenericKeyedObjectPoolConfig#getMinEvictableIdleTimeMillis()
*/
public long getMinEvictableIdleTimeMillis() {
return minEvictableIdleTimeMillis;
return this.minEvictableIdleTimeMillis;
}
/**
* @see GenericKeyedObjectPoolConfig#getNumTestsPerEvictionRun()
*/
public int getNumTestsPerEvictionRun() {
return numTestsPerEvictionRun;
return this.numTestsPerEvictionRun;
}
/**
* @see GenericKeyedObjectPoolConfig#getSoftMinEvictableIdleTimeMillis()
*/
public long getSoftMinEvictableIdleTimeMillis() {
return softMinEvictableIdleTimeMillis;
return this.softMinEvictableIdleTimeMillis;
}
/**
* @see GenericKeyedObjectPoolConfig#getTestOnBorrow()
*/
public boolean isTestOnBorrow() {
return testOnBorrow;
return this.testOnBorrow;
}
/**
* @see GenericKeyedObjectPoolConfig#getTestOnCreate()
*/
public boolean isTestOnCreate() {
return testOnCreate;
return this.testOnCreate;
}
/**
* @see GenericKeyedObjectPoolConfig#getTestOnReturn()
*/
public boolean isTestOnReturn() {
return testOnReturn;
return this.testOnReturn;
}
/**
* @see GenericKeyedObjectPoolConfig#getTestWhileIdle()
*/
public boolean isTestWhileIdle() {
return testWhileIdle;
return this.testWhileIdle;
}
/**
* @see GenericKeyedObjectPoolConfig#getTimeBetweenEvictionRunsMillis()
*/
public long getTimeBetweenEvictionRunsMillis() {
return timeBetweenEvictionRunsMillis;
return this.timeBetweenEvictionRunsMillis;
}
}

View File

@@ -113,7 +113,7 @@ public class PooledContextSource extends DelegatingBaseLdapPathContextSourceSupp
* @return the poolConfig
*/
public PoolConfig getPoolConfig() {
return poolConfig;
return this.poolConfig;
}
/**

View File

@@ -44,40 +44,40 @@ class DefaultConditionCriteria implements ConditionCriteria {
@Override
public ContainerCriteria is(String value) {
return appendToParent(new EqualsFilter(attribute, value));
return appendToParent(new EqualsFilter(this.attribute, value));
}
@Override
public ContainerCriteria gte(String value) {
return appendToParent(new GreaterThanOrEqualsFilter(attribute, value));
return appendToParent(new GreaterThanOrEqualsFilter(this.attribute, value));
}
@Override
public ContainerCriteria lte(String value) {
return appendToParent(new LessThanOrEqualsFilter(attribute, value));
return appendToParent(new LessThanOrEqualsFilter(this.attribute, value));
}
@Override
public ContainerCriteria like(String value) {
return appendToParent(new LikeFilter(attribute, value));
return appendToParent(new LikeFilter(this.attribute, value));
}
@Override
public ContainerCriteria whitespaceWildcardsLike(String value) {
return appendToParent(new WhitespaceWildcardsFilter(attribute, value));
return appendToParent(new WhitespaceWildcardsFilter(this.attribute, value));
}
@Override
public ContainerCriteria isPresent() {
return appendToParent(new PresentFilter(attribute));
return appendToParent(new PresentFilter(this.attribute));
}
private ContainerCriteria appendToParent(Filter filter) {
return parent.append(negateIfApplicable(filter));
return this.parent.append(negateIfApplicable(filter));
}
private Filter negateIfApplicable(Filter myFilter) {
if (negated) {
if (this.negated) {
return new NotFilter(myFilter);
}
@@ -86,7 +86,7 @@ class DefaultConditionCriteria implements ConditionCriteria {
@Override
public DefaultConditionCriteria not() {
negated = !negated;
this.negated = !this.negated;
return this;
}

View File

@@ -54,27 +54,28 @@ class DefaultContainerCriteria implements AppendableContainerCriteria {
@Override
public ConditionCriteria and(String attribute) {
AND.validateSameType(type);
type = AND;
AND.validateSameType(this.type);
this.type = AND;
return new DefaultConditionCriteria(this, attribute);
}
@Override
public ConditionCriteria or(String attribute) {
OR.validateSameType(type);
type = OR;
OR.validateSameType(this.type);
this.type = OR;
return new DefaultConditionCriteria(this, attribute);
}
@Override
public ContainerCriteria and(ContainerCriteria nested) {
if (type == OR) {
return new DefaultContainerCriteria(topQuery).withType(AND).append(this.filter()).append(nested.filter());
if (this.type == OR) {
return new DefaultContainerCriteria(this.topQuery).withType(AND).append(this.filter())
.append(nested.filter());
}
else {
type = AND;
this.type = AND;
this.filters.add(nested.filter());
return this;
}
@@ -82,11 +83,12 @@ class DefaultContainerCriteria implements AppendableContainerCriteria {
@Override
public ContainerCriteria or(ContainerCriteria nested) {
if (type == AND) {
return new DefaultContainerCriteria(topQuery).withType(OR).append(this.filter()).append(nested.filter());
if (this.type == AND) {
return new DefaultContainerCriteria(this.topQuery).withType(OR).append(this.filter())
.append(nested.filter());
}
else {
type = OR;
this.type = OR;
this.filters.add(nested.filter());
return this;
}
@@ -94,37 +96,37 @@ class DefaultContainerCriteria implements AppendableContainerCriteria {
@Override
public Filter filter() {
if (filters.size() == 1) {
if (this.filters.size() == 1) {
// No need to wrap in And/OrFilter if there's just one condition.
return filters.iterator().next();
return this.filters.iterator().next();
}
return type.constructFilter().appendAll(filters);
return this.type.constructFilter().appendAll(this.filters);
}
@Override
public Name base() {
return topQuery.base();
return this.topQuery.base();
}
@Override
public SearchScope searchScope() {
return topQuery.searchScope();
return this.topQuery.searchScope();
}
@Override
public Integer timeLimit() {
return topQuery.timeLimit();
return this.topQuery.timeLimit();
}
@Override
public Integer countLimit() {
return topQuery.countLimit();
return this.topQuery.countLimit();
}
@Override
public String[] attributes() {
return topQuery.attributes();
return this.topQuery.attributes();
}
}

View File

@@ -184,13 +184,13 @@ public final class LdapQueryBuilder implements LdapQuery {
*/
public ConditionCriteria where(String attribute) {
initRootContainer();
return new DefaultConditionCriteria(rootContainer, attribute);
return new DefaultConditionCriteria(this.rootContainer, attribute);
}
private void initRootContainer() {
assertFilterNotStarted();
rootContainer = new DefaultContainerCriteria(this);
isFilterStarted = true;
this.rootContainer = new DefaultContainerCriteria(this);
this.isFilterStarted = true;
}
/**
@@ -207,7 +207,7 @@ public final class LdapQueryBuilder implements LdapQuery {
*/
public LdapQuery filter(String hardcodedFilter) {
initRootContainer();
rootContainer.append(new HardcodedFilter(hardcodedFilter));
this.rootContainer.append(new HardcodedFilter(hardcodedFilter));
return this;
}
@@ -219,7 +219,7 @@ public final class LdapQueryBuilder implements LdapQuery {
*/
public LdapQuery filter(Filter filter) {
initRootContainer();
rootContainer.append(filter);
this.rootContainer.append(filter);
return this;
}
@@ -246,40 +246,40 @@ public final class LdapQueryBuilder implements LdapQuery {
}
private void assertFilterNotStarted() {
Assert.state(!isFilterStarted, "Invalid operation - filter condition specification already started");
Assert.state(!this.isFilterStarted, "Invalid operation - filter condition specification already started");
}
@Override
public Name base() {
return base;
return this.base;
}
@Override
public SearchScope searchScope() {
return searchScope;
return this.searchScope;
}
@Override
public Integer countLimit() {
return countLimit;
return this.countLimit;
}
@Override
public Integer timeLimit() {
return timeLimit;
return this.timeLimit;
}
@Override
public String[] attributes() {
return attributes;
return this.attributes;
}
@Override
public Filter filter() {
if (rootContainer == null) {
if (this.rootContainer == null) {
throw new IllegalStateException("No filter conditions have been specified");
}
return rootContainer.filter();
return this.rootContainer.filter();
}
}

View File

@@ -46,7 +46,7 @@ public enum SearchScope {
}
public int getId() {
return id;
return this.id;
}
}

View File

@@ -81,7 +81,7 @@ public final class LdapNameBuilder {
Assert.notNull(value, "value must not be null");
try {
ldapName.add(new Rdn(key, value));
this.ldapName.add(new Rdn(key, value));
return this;
}
catch (InvalidNameException e) {
@@ -98,7 +98,7 @@ public final class LdapNameBuilder {
Assert.notNull(name, "name must not be null");
try {
ldapName.addAll(ldapName.size(), name);
this.ldapName.addAll(this.ldapName.size(), name);
return this;
}
catch (InvalidNameException e) {
@@ -123,7 +123,7 @@ public final class LdapNameBuilder {
* @return the LdapName instance that has been built.
*/
public LdapName build() {
return LdapUtils.newLdapName(ldapName);
return LdapUtils.newLdapName(this.ldapName);
}
}

View File

@@ -338,8 +338,8 @@ public final class LdapUtils {
}
public void handleAttributeValue(String attributeName, Object attributeValue, int index) {
Assert.isTrue(attributeName == null || clazz.isAssignableFrom(attributeValue.getClass()));
collection.add(clazz.cast(attributeValue));
Assert.isTrue(attributeName == null || this.clazz.isAssignableFrom(attributeValue.getClass()));
this.collection.add(this.clazz.cast(attributeValue));
}
}

View File

@@ -69,10 +69,10 @@ public class BindOperationExecutor implements CompensatingTransactionOperationEx
*/
public void rollback() {
try {
ldapOperations.unbind(dn);
this.ldapOperations.unbind(this.dn);
}
catch (Exception e) {
log.warn("Failed to rollback, dn:" + dn.toString(), e);
log.warn("Failed to rollback, dn:" + this.dn.toString(), e);
}
}
@@ -94,7 +94,7 @@ public class BindOperationExecutor implements CompensatingTransactionOperationEx
*/
public void performOperation() {
log.debug("Performing bind operation");
ldapOperations.bind(dn, originalObject, originalAttributes);
this.ldapOperations.bind(this.dn, this.originalObject, this.originalAttributes);
}
/**
@@ -102,7 +102,7 @@ public class BindOperationExecutor implements CompensatingTransactionOperationEx
* @return the target DN.
*/
Name getDn() {
return dn;
return this.dn;
}
/**
@@ -110,15 +110,15 @@ public class BindOperationExecutor implements CompensatingTransactionOperationEx
* @return the LdapOperations.
*/
LdapOperations getLdapOperations() {
return ldapOperations;
return this.ldapOperations;
}
Attributes getOriginalAttributes() {
return originalAttributes;
return this.originalAttributes;
}
Object getOriginalObject() {
return originalObject;
return this.originalObject;
}
}

View File

@@ -60,7 +60,7 @@ public class BindOperationRecorder implements CompensatingTransactionOperationRe
attributes = (Attributes) args[2];
}
return new BindOperationExecutor(ldapOperations, dn, object, attributes);
return new BindOperationExecutor(this.ldapOperations, dn, object, attributes);
}
/**
@@ -68,7 +68,7 @@ public class BindOperationRecorder implements CompensatingTransactionOperationRe
* @return the LdapOperations.
*/
LdapOperations getLdapOperations() {
return ldapOperations;
return this.ldapOperations;
}
}

View File

@@ -59,7 +59,8 @@ public class LdapCompensatingTransactionOperationFactory implements Compensating
}
else if (ObjectUtils.nullSafeEquals(operation, LdapTransactionUtils.REBIND_METHOD_NAME)) {
log.debug("Rebind operation recorded");
return new RebindOperationRecorder(createLdapOperationsInstance((DirContext) resource), renamingStrategy);
return new RebindOperationRecorder(createLdapOperationsInstance((DirContext) resource),
this.renamingStrategy);
}
else if (ObjectUtils.nullSafeEquals(operation, LdapTransactionUtils.RENAME_METHOD_NAME)) {
log.debug("Rename operation recorded");
@@ -69,7 +70,8 @@ public class LdapCompensatingTransactionOperationFactory implements Compensating
return new ModifyAttributesOperationRecorder(createLdapOperationsInstance((DirContext) resource));
}
else if (ObjectUtils.nullSafeEquals(operation, LdapTransactionUtils.UNBIND_METHOD_NAME)) {
return new UnbindOperationRecorder(createLdapOperationsInstance((DirContext) resource), renamingStrategy);
return new UnbindOperationRecorder(createLdapOperationsInstance((DirContext) resource),
this.renamingStrategy);
}
log.warn("No suitable CompensatingTransactionOperationRecorder found for method " + operation

View File

@@ -69,10 +69,10 @@ public class ModifyAttributesOperationExecutor implements CompensatingTransactio
public void rollback() {
try {
log.debug("Rolling back modifyAttributes operation");
ldapOperations.modifyAttributes(dn, compensatingModifications);
this.ldapOperations.modifyAttributes(this.dn, this.compensatingModifications);
}
catch (Exception e) {
log.warn("Failed to rollback ModifyAttributes operation, dn: " + dn);
log.warn("Failed to rollback ModifyAttributes operation, dn: " + this.dn);
}
}
@@ -90,23 +90,23 @@ public class ModifyAttributesOperationExecutor implements CompensatingTransactio
*/
public void performOperation() {
log.debug("Performing modifyAttributes operation");
ldapOperations.modifyAttributes(dn, actualModifications);
this.ldapOperations.modifyAttributes(this.dn, this.actualModifications);
}
Name getDn() {
return dn;
return this.dn;
}
LdapOperations getLdapOperations() {
return ldapOperations;
return this.ldapOperations;
}
ModificationItem[] getActualModifications() {
return actualModifications;
return this.actualModifications;
}
ModificationItem[] getCompensatingModifications() {
return compensatingModifications;
return this.compensatingModifications;
}
}

View File

@@ -76,7 +76,7 @@ public class ModifyAttributesOperationRecorder implements CompensatingTransactio
// by one query.
IncrementalAttributesMapper<?> attributesMapper = getAttributesMapper(attributeNameArray);
while (attributesMapper.hasMore()) {
ldapOperations.lookup(dn, attributesMapper.getAttributesForLookup(), attributesMapper);
this.ldapOperations.lookup(dn, attributesMapper.getAttributesForLookup(), attributesMapper);
}
Attributes currentAttributes = attributesMapper.getCollectedAttributes();
@@ -88,7 +88,7 @@ public class ModifyAttributesOperationRecorder implements CompensatingTransactio
rollbackItems[i] = getCompensatingModificationItem(currentAttributes, incomingModifications[i]);
}
return new ModifyAttributesOperationExecutor(ldapOperations, dn, incomingModifications, rollbackItems);
return new ModifyAttributesOperationExecutor(this.ldapOperations, dn, incomingModifications, rollbackItems);
}
/**
@@ -154,7 +154,7 @@ public class ModifyAttributesOperationRecorder implements CompensatingTransactio
}
LdapOperations getLdapOperations() {
return ldapOperations;
return this.ldapOperations;
}
}

View File

@@ -72,7 +72,7 @@ public class RebindOperationExecutor implements CompensatingTransactionOperation
* @return the LdapOperations.
*/
LdapOperations getLdapOperations() {
return ldapOperations;
return this.ldapOperations;
}
/*
@@ -82,11 +82,13 @@ public class RebindOperationExecutor implements CompensatingTransactionOperation
public void rollback() {
log.debug("Rolling back rebind operation");
try {
ldapOperations.unbind(originalDn);
ldapOperations.rename(temporaryDn, originalDn);
this.ldapOperations.unbind(this.originalDn);
this.ldapOperations.rename(this.temporaryDn, this.originalDn);
}
catch (Exception e) {
log.warn("Failed to rollback operation, dn: " + originalDn + "; temporary DN: " + temporaryDn, e);
log.warn(
"Failed to rollback operation, dn: " + this.originalDn + "; temporary DN:this. " + this.temporaryDn,
e);
}
}
@@ -96,7 +98,7 @@ public class RebindOperationExecutor implements CompensatingTransactionOperation
*/
public void commit() {
log.debug("Committing rebind operation");
ldapOperations.unbind(temporaryDn);
this.ldapOperations.unbind(this.temporaryDn);
}
/*
@@ -105,24 +107,24 @@ public class RebindOperationExecutor implements CompensatingTransactionOperation
*/
public void performOperation() {
log.debug("Performing rebind operation - " + "renaming original entry and " + "binding new contents to entry.");
ldapOperations.rename(originalDn, temporaryDn);
ldapOperations.bind(originalDn, originalObject, originalAttributes);
this.ldapOperations.rename(this.originalDn, this.temporaryDn);
this.ldapOperations.bind(this.originalDn, this.originalObject, this.originalAttributes);
}
Attributes getOriginalAttributes() {
return originalAttributes;
return this.originalAttributes;
}
Name getOriginalDn() {
return originalDn;
return this.originalDn;
}
Object getOriginalObject() {
return originalObject;
return this.originalObject;
}
Name getTemporaryDn() {
return temporaryDn;
return this.temporaryDn;
}
}

View File

@@ -65,9 +65,9 @@ public class RebindOperationRecorder implements CompensatingTransactionOperation
attributes = (Attributes) args[2];
}
Name temporaryName = renamingStrategy.getTemporaryName(dn);
Name temporaryName = this.renamingStrategy.getTemporaryName(dn);
return new RebindOperationExecutor(ldapOperations, dn, temporaryName, object, attributes);
return new RebindOperationExecutor(this.ldapOperations, dn, temporaryName, object, attributes);
}
/**
@@ -75,11 +75,11 @@ public class RebindOperationRecorder implements CompensatingTransactionOperation
* @return the LdapOperations.
*/
LdapOperations getLdapOperations() {
return ldapOperations;
return this.ldapOperations;
}
public TempEntryRenamingStrategy getRenamingStrategy() {
return renamingStrategy;
return this.renamingStrategy;
}
}

View File

@@ -60,10 +60,11 @@ public class RenameOperationExecutor implements CompensatingTransactionOperation
public void rollback() {
log.debug("Rolling back rename operation");
try {
ldapOperations.rename(newDn, originalDn);
this.ldapOperations.rename(this.newDn, this.originalDn);
}
catch (Exception e) {
log.warn("Unable to rollback rename operation. " + "originalDn: " + newDn + "; newDn: " + originalDn);
log.warn("Unable to rollback rename operation. " + "originalDn: " + this.newDn + "; newDn:this. "
+ this.originalDn);
}
}
@@ -81,19 +82,19 @@ public class RenameOperationExecutor implements CompensatingTransactionOperation
*/
public void performOperation() {
log.debug("Performing rename operation");
ldapOperations.rename(originalDn, newDn);
this.ldapOperations.rename(this.originalDn, this.newDn);
}
Name getNewDn() {
return newDn;
return this.newDn;
}
LdapOperations getLdapOperations() {
return ldapOperations;
return this.ldapOperations;
}
Name getOriginalDn() {
return originalDn;
return this.originalDn;
}
}

View File

@@ -59,11 +59,11 @@ public class RenameOperationRecorder implements CompensatingTransactionOperation
}
Name oldDn = LdapTransactionUtils.getArgumentAsName(args[0]);
Name newDn = LdapTransactionUtils.getArgumentAsName(args[1]);
return new RenameOperationExecutor(ldapOperations, oldDn, newDn);
return new RenameOperationExecutor(this.ldapOperations, oldDn, newDn);
}
LdapOperations getLdapOperations() {
return ldapOperations;
return this.ldapOperations;
}
}

View File

@@ -62,10 +62,11 @@ public class UnbindOperationExecutor implements CompensatingTransactionOperation
*/
public void rollback() {
try {
ldapOperations.rename(temporaryDn, originalDn);
this.ldapOperations.rename(this.temporaryDn, this.originalDn);
}
catch (Exception e) {
log.warn("Filed to rollback unbind operation, temporaryDn: " + temporaryDn + "; originalDn: " + originalDn);
log.warn("Filed to rollback unbind operation, temporaryDn: " + this.temporaryDn + "; originalDn:this. "
+ this.originalDn);
}
}
@@ -75,7 +76,7 @@ public class UnbindOperationExecutor implements CompensatingTransactionOperation
*/
public void commit() {
log.debug("Committing unbind operation - unbinding temporary entry");
ldapOperations.unbind(temporaryDn);
this.ldapOperations.unbind(this.temporaryDn);
}
/*
@@ -84,19 +85,19 @@ public class UnbindOperationExecutor implements CompensatingTransactionOperation
*/
public void performOperation() {
log.debug("Performing operation for unbind -" + " renaming to temporary entry.");
ldapOperations.rename(originalDn, temporaryDn);
this.ldapOperations.rename(this.originalDn, this.temporaryDn);
}
LdapOperations getLdapOperations() {
return ldapOperations;
return this.ldapOperations;
}
Name getOriginalDn() {
return originalDn;
return this.originalDn;
}
Name getTemporaryDn() {
return temporaryDn;
return this.temporaryDn;
}
}

View File

@@ -53,17 +53,17 @@ public class UnbindOperationRecorder implements CompensatingTransactionOperation
*/
public CompensatingTransactionOperationExecutor recordOperation(Object[] args) {
Name dn = LdapTransactionUtils.getFirstArgumentAsName(args);
Name temporaryDn = renamingStrategy.getTemporaryName(dn);
Name temporaryDn = this.renamingStrategy.getTemporaryName(dn);
return new UnbindOperationExecutor(ldapOperations, dn, temporaryDn);
return new UnbindOperationExecutor(this.ldapOperations, dn, temporaryDn);
}
LdapOperations getLdapOperations() {
return ldapOperations;
return this.ldapOperations;
}
public TempEntryRenamingStrategy getRenamingStrategy() {
return renamingStrategy;
return this.renamingStrategy;
}
}

View File

@@ -65,7 +65,7 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran
*/
protected Object doGetTransaction() {
Object dataSourceTransactionObject = super.doGetTransaction();
Object contextSourceTransactionObject = ldapManagerDelegate.doGetTransaction();
Object contextSourceTransactionObject = this.ldapManagerDelegate.doGetTransaction();
return new ContextSourceAndDataSourceTransactionObject(contextSourceTransactionObject,
dataSourceTransactionObject);
@@ -81,7 +81,7 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran
super.doBegin(actualTransactionObject.getDataSourceTransactionObject(), definition);
try {
ldapManagerDelegate.doBegin(actualTransactionObject.getLdapTransactionObject(), definition);
this.ldapManagerDelegate.doBegin(actualTransactionObject.getLdapTransactionObject(), definition);
}
catch (TransactionException e) {
// Failed to start LDAP transaction - make sure we clean up properly
@@ -98,7 +98,7 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran
ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) transaction;
super.doCleanupAfterCompletion(actualTransactionObject.getDataSourceTransactionObject());
ldapManagerDelegate.doCleanupAfterCompletion(actualTransactionObject.getLdapTransactionObject());
this.ldapManagerDelegate.doCleanupAfterCompletion(actualTransactionObject.getLdapTransactionObject());
}
/*
@@ -128,9 +128,9 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran
+ " proceeding to commit ldap resource.");
}
}
ldapManagerDelegate.doCommit(new DefaultTransactionStatus(actualTransactionObject.getLdapTransactionObject(),
status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(),
status.getSuspendedResources()));
this.ldapManagerDelegate.doCommit(new DefaultTransactionStatus(
actualTransactionObject.getLdapTransactionObject(), status.isNewTransaction(),
status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources()));
}
/*
@@ -145,21 +145,21 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran
super.doRollback(new DefaultTransactionStatus(actualTransactionObject.getDataSourceTransactionObject(),
status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(),
status.getSuspendedResources()));
ldapManagerDelegate.doRollback(new DefaultTransactionStatus(actualTransactionObject.getLdapTransactionObject(),
status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(),
status.getSuspendedResources()));
this.ldapManagerDelegate.doRollback(new DefaultTransactionStatus(
actualTransactionObject.getLdapTransactionObject(), status.isNewTransaction(),
status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources()));
}
public ContextSource getContextSource() {
return ldapManagerDelegate.getContextSource();
return this.ldapManagerDelegate.getContextSource();
}
public void setContextSource(ContextSource contextSource) {
ldapManagerDelegate.setContextSource(contextSource);
this.ldapManagerDelegate.setContextSource(contextSource);
}
public void setRenamingStrategy(TempEntryRenamingStrategy renamingStrategy) {
ldapManagerDelegate.setRenamingStrategy(renamingStrategy);
this.ldapManagerDelegate.setRenamingStrategy(renamingStrategy);
}
private final static class ContextSourceAndDataSourceTransactionObject {
@@ -175,11 +175,11 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran
}
public Object getDataSourceTransactionObject() {
return dataSourceTransactionObject;
return this.dataSourceTransactionObject;
}
public Object getLdapTransactionObject() {
return ldapTransactionObject;
return this.ldapTransactionObject;
}
}
@@ -206,7 +206,7 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran
public void afterPropertiesSet() {
super.afterPropertiesSet();
ldapManagerDelegate.checkRenamingStrategy();
this.ldapManagerDelegate.checkRenamingStrategy();
}
}

View File

@@ -66,7 +66,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
*/
protected Object doGetTransaction() {
Object dataSourceTransactionObject = super.doGetTransaction();
Object contextSourceTransactionObject = ldapManagerDelegate.doGetTransaction();
Object contextSourceTransactionObject = this.ldapManagerDelegate.doGetTransaction();
return new ContextSourceAndHibernateTransactionObject(contextSourceTransactionObject,
dataSourceTransactionObject);
@@ -82,7 +82,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
super.doBegin(actualTransactionObject.getHibernateTransactionObject(), definition);
try {
ldapManagerDelegate.doBegin(actualTransactionObject.getLdapTransactionObject(), definition);
this.ldapManagerDelegate.doBegin(actualTransactionObject.getLdapTransactionObject(), definition);
}
catch (TransactionException e) {
// Failed to start LDAP transaction - make sure we clean up properly
@@ -99,7 +99,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) transaction;
super.doCleanupAfterCompletion(actualTransactionObject.getHibernateTransactionObject());
ldapManagerDelegate.doCleanupAfterCompletion(actualTransactionObject.getLdapTransactionObject());
this.ldapManagerDelegate.doCleanupAfterCompletion(actualTransactionObject.getLdapTransactionObject());
}
/*
@@ -129,9 +129,9 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
+ " proceeding to commit ldap resource.");
}
}
ldapManagerDelegate.doCommit(new DefaultTransactionStatus(actualTransactionObject.getLdapTransactionObject(),
status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(),
status.getSuspendedResources()));
this.ldapManagerDelegate.doCommit(new DefaultTransactionStatus(
actualTransactionObject.getLdapTransactionObject(), status.isNewTransaction(),
status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources()));
}
/*
@@ -145,21 +145,21 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
super.doRollback(new DefaultTransactionStatus(actualTransactionObject.getHibernateTransactionObject(),
status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(),
status.getSuspendedResources()));
ldapManagerDelegate.doRollback(new DefaultTransactionStatus(actualTransactionObject.getLdapTransactionObject(),
status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(),
status.getSuspendedResources()));
this.ldapManagerDelegate.doRollback(new DefaultTransactionStatus(
actualTransactionObject.getLdapTransactionObject(), status.isNewTransaction(),
status.isNewSynchronization(), status.isReadOnly(), status.isDebug(), status.getSuspendedResources()));
}
public ContextSource getContextSource() {
return ldapManagerDelegate.getContextSource();
return this.ldapManagerDelegate.getContextSource();
}
public void setContextSource(ContextSource contextSource) {
ldapManagerDelegate.setContextSource(contextSource);
this.ldapManagerDelegate.setContextSource(contextSource);
}
public void setRenamingStrategy(TempEntryRenamingStrategy renamingStrategy) {
ldapManagerDelegate.setRenamingStrategy(renamingStrategy);
this.ldapManagerDelegate.setRenamingStrategy(renamingStrategy);
}
private static final class ContextSourceAndHibernateTransactionObject {
@@ -175,11 +175,11 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
}
public Object getHibernateTransactionObject() {
return hibernateTransactionObject;
return this.hibernateTransactionObject;
}
public Object getLdapTransactionObject() {
return ldapTransactionObject;
return this.ldapTransactionObject;
}
}
@@ -206,7 +206,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
public void afterPropertiesSet() {
super.afterPropertiesSet();
ldapManagerDelegate.checkRenamingStrategy();
this.ldapManagerDelegate.checkRenamingStrategy();
}
}

View File

@@ -112,7 +112,7 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction
* java.lang.Object, org.springframework.transaction.TransactionDefinition)
*/
protected void doBegin(Object transaction, TransactionDefinition definition) {
delegate.doBegin(transaction, definition);
this.delegate.doBegin(transaction, definition);
}
/*
@@ -120,7 +120,7 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction
* doCleanupAfterCompletion(java.lang.Object)
*/
protected void doCleanupAfterCompletion(Object transaction) {
delegate.doCleanupAfterCompletion(transaction);
this.delegate.doCleanupAfterCompletion(transaction);
}
/*
@@ -129,7 +129,7 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction
* (org.springframework.transaction.support.DefaultTransactionStatus)
*/
protected void doCommit(DefaultTransactionStatus status) {
delegate.doCommit(status);
this.delegate.doCommit(status);
}
/*
@@ -137,7 +137,7 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction
* doGetTransaction()
*/
protected Object doGetTransaction() {
return delegate.doGetTransaction();
return this.delegate.doGetTransaction();
}
/*
@@ -145,7 +145,7 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction
* doRollback(org.springframework.transaction.support.DefaultTransactionStatus)
*/
protected void doRollback(DefaultTransactionStatus status) {
delegate.doRollback(status);
this.delegate.doRollback(status);
}
/**
@@ -154,7 +154,7 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction
* @see ContextSourceTransactionManagerDelegate#getContextSource()
*/
public ContextSource getContextSource() {
return delegate.getContextSource();
return this.delegate.getContextSource();
}
/**
@@ -163,7 +163,7 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction
* @see ContextSourceTransactionManagerDelegate#setContextSource(ContextSource)
*/
public void setContextSource(ContextSource contextSource) {
delegate.setContextSource(contextSource);
this.delegate.setContextSource(contextSource);
}
/**
@@ -172,11 +172,11 @@ public class ContextSourceTransactionManager extends AbstractPlatformTransaction
* @see ContextSourceTransactionManagerDelegate#setRenamingStrategy(TempEntryRenamingStrategy)
*/
public void setRenamingStrategy(TempEntryRenamingStrategy renamingStrategy) {
delegate.setRenamingStrategy(renamingStrategy);
this.delegate.setRenamingStrategy(renamingStrategy);
}
public void afterPropertiesSet() throws Exception {
delegate.checkRenamingStrategy();
this.delegate.checkRenamingStrategy();
}
@Override

View File

@@ -75,7 +75,7 @@ public class ContextSourceTransactionManagerDelegate extends AbstractCompensatin
}
public ContextSource getContextSource() {
return contextSource;
return this.contextSource;
}
/*
@@ -93,7 +93,7 @@ public class ContextSourceTransactionManagerDelegate extends AbstractCompensatin
protected CompensatingTransactionHolderSupport getNewHolder() {
DirContext newCtx = getContextSource().getReadWriteContext();
return new DirContextHolder(new DefaultCompensatingTransactionOperationManager(
new LdapCompensatingTransactionOperationFactory(renamingStrategy)), newCtx);
new LdapCompensatingTransactionOperationFactory(this.renamingStrategy)), newCtx);
}
/*
@@ -126,7 +126,7 @@ public class ContextSourceTransactionManagerDelegate extends AbstractCompensatin
}
void checkRenamingStrategy() {
Assert.notNull(renamingStrategy, "RenamingStrategy must be specified");
Assert.notNull(this.renamingStrategy, "RenamingStrategy must be specified");
}
}

View File

@@ -55,7 +55,7 @@ public class DirContextHolder extends CompensatingTransactionHolderSupport {
* Return the DirContext associated with the current transaction.
*/
public DirContext getCtx() {
return ctx;
return this.ctx;
}
/*
@@ -63,7 +63,7 @@ public class DirContextHolder extends CompensatingTransactionHolderSupport {
* CompensatingTransactionHolderSupport#getTransactedResource()
*/
protected Object getTransactedResource() {
return ctx;
return this.ctx;
}
}

View File

@@ -49,7 +49,7 @@ public class TransactionAwareContextSourceProxy extends DelegatingBaseLdapPathCo
@Override
public ContextSource getTarget() {
return target;
return this.target;
}
@Override
@@ -66,7 +66,7 @@ public class TransactionAwareContextSourceProxy extends DelegatingBaseLdapPathCo
@Override
public DirContext getReadWriteContext() {
DirContextHolder contextHolder = (DirContextHolder) TransactionSynchronizationManager.getResource(target);
DirContextHolder contextHolder = (DirContextHolder) TransactionSynchronizationManager.getResource(this.target);
DirContext ctx = null;
if (contextHolder != null) {
@@ -74,17 +74,17 @@ public class TransactionAwareContextSourceProxy extends DelegatingBaseLdapPathCo
}
if (ctx == null) {
ctx = target.getReadWriteContext();
ctx = this.target.getReadWriteContext();
if (contextHolder != null) {
contextHolder.setCtx(ctx);
}
}
return getTransactionAwareDirContextProxy(ctx, target);
return getTransactionAwareDirContextProxy(ctx, this.target);
}
@Override
public DirContext getContext(String principal, String credentials) {
return target.getContext(principal, credentials);
return this.target.getContext(principal, credentials);
}
}

View File

@@ -63,7 +63,7 @@ public class TransactionAwareDirContextInvocationHandler implements InvocationHa
String methodName = method.getName();
if (methodName.equals("getTargetContext")) {
return target;
return this.target;
}
else if (methodName.equals("equals")) {
// Only consider equal when proxies are identical.
@@ -74,17 +74,17 @@ public class TransactionAwareDirContextInvocationHandler implements InvocationHa
return hashCode();
}
else if (methodName.equals("close")) {
doCloseConnection(target, contextSource);
doCloseConnection(this.target, this.contextSource);
return null;
}
else if (LdapTransactionUtils.isSupportedWriteTransactionOperation(methodName)) {
// Store transaction data and allow operation to proceed.
CompensatingTransactionUtils.performOperation(contextSource, target, method, args);
CompensatingTransactionUtils.performOperation(this.contextSource, this.target, method, args);
return null;
}
else {
try {
return method.invoke(target, args);
return method.invoke(this.target, args);
}
catch (InvocationTargetException e) {
throw e.getTargetException();

View File

@@ -64,7 +64,7 @@ public class DefaultTempEntryRenamingStrategy implements TempEntryRenamingStrate
// Add tempSuffix to the leaf node name.
try {
String leafNode = (String) temporaryName.remove(temporaryName.size() - 1);
temporaryName.add(new Rdn(leafNode + tempSuffix));
temporaryName.add(new Rdn(leafNode + this.tempSuffix));
}
catch (InvalidNameException e) {
throw new org.springframework.ldap.InvalidNameException(e);
@@ -78,7 +78,7 @@ public class DefaultTempEntryRenamingStrategy implements TempEntryRenamingStrate
* @return the suffix.
*/
public String getTempSuffix() {
return tempSuffix;
return this.tempSuffix;
}
/**

View File

@@ -56,7 +56,7 @@ public class DifferentSubtreeTempEntryRenamingStrategy implements TempEntryRenam
}
public Name getSubtreeNode() {
return subtreeNode;
return this.subtreeNode;
}
public void setSubtreeNode(Name subtreeNode) {
@@ -77,7 +77,7 @@ public class DifferentSubtreeTempEntryRenamingStrategy implements TempEntryRenam
LdapName tempName = LdapUtils.newLdapName(originalName);
try {
String leafNode = tempName.get(tempName.size() - 1) + thisSequenceNo;
LdapName newName = LdapUtils.newLdapName(subtreeNode);
LdapName newName = LdapUtils.newLdapName(this.subtreeNode);
newName.add(leafNode);
return newName;

View File

@@ -48,7 +48,7 @@ public abstract class CompensatingTransactionHolderSupport extends ResourceHolde
*/
public void clear() {
super.clear();
transactionOperationManager = null;
this.transactionOperationManager = null;
}
/**
@@ -57,7 +57,7 @@ public abstract class CompensatingTransactionHolderSupport extends ResourceHolde
* @return the CompensatingTransactionOperationManager.
*/
public CompensatingTransactionOperationManager getTransactionOperationManager() {
return transactionOperationManager;
return this.transactionOperationManager;
}
/**

View File

@@ -41,7 +41,7 @@ public class CompensatingTransactionObject {
* @return the DirContextHolder.
*/
public CompensatingTransactionHolderSupport getHolder() {
return holder;
return this.holder;
}
/**

View File

@@ -55,14 +55,14 @@ public class DefaultCompensatingTransactionOperationManager implements Compensat
* java.lang.String, java.lang.Object[])
*/
public void performOperation(Object resource, String operation, Object[] args) {
CompensatingTransactionOperationRecorder recorder = operationFactory.createRecordingOperation(resource,
CompensatingTransactionOperationRecorder recorder = this.operationFactory.createRecordingOperation(resource,
operation);
CompensatingTransactionOperationExecutor executor = recorder.recordOperation(args);
executor.performOperation();
// Don't push the executor until the actual operation passed.
operationExecutors.push(executor);
this.operationExecutors.push(executor);
}
/*
@@ -71,8 +71,8 @@ public class DefaultCompensatingTransactionOperationManager implements Compensat
*/
public void rollback() {
log.debug("Performing rollback");
while (!operationExecutors.isEmpty()) {
CompensatingTransactionOperationExecutor rollbackOperation = operationExecutors.pop();
while (!this.operationExecutors.isEmpty()) {
CompensatingTransactionOperationExecutor rollbackOperation = this.operationExecutors.pop();
try {
rollbackOperation.rollback();
}
@@ -87,7 +87,7 @@ public class DefaultCompensatingTransactionOperationManager implements Compensat
* @return the rollback operations.
*/
protected Stack<CompensatingTransactionOperationExecutor> getOperationExecutors() {
return operationExecutors;
return this.operationExecutors;
}
/**
@@ -104,7 +104,7 @@ public class DefaultCompensatingTransactionOperationManager implements Compensat
*/
public void commit() {
log.debug("Performing commit");
for (CompensatingTransactionOperationExecutor operationExecutor : operationExecutors) {
for (CompensatingTransactionOperationExecutor operationExecutor : this.operationExecutors) {
try {
operationExecutor.commit();
}

View File

@@ -50,7 +50,7 @@ public class NamingExceptionTest {
}
private NamingException readFromStream() throws IOException, ClassNotFoundException {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(this.byteArrayOutputStream.toByteArray());
ObjectInputStream in = new ObjectInputStream(byteArrayInputStream);
NamingException deSerializedException;
try {
@@ -63,8 +63,8 @@ public class NamingExceptionTest {
}
private void writeToStream(NamingException exception) throws IOException {
byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(byteArrayOutputStream);
this.byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(this.byteArrayOutputStream);
try {
out.writeObject(exception);
out.flush();

View File

@@ -36,55 +36,55 @@ public class DefaultValuesAuthenticationSourceDecoratorTest {
@Before
public void setUp() throws Exception {
authenticationSourceMock = mock(AuthenticationSource.class);
tested = new DefaultValuesAuthenticationSourceDecorator();
tested.setDefaultUser(DEFAULT_USER);
tested.setDefaultPassword(DEFAULT_PASSWORD);
tested.setTarget(authenticationSourceMock);
this.authenticationSourceMock = mock(AuthenticationSource.class);
this.tested = new DefaultValuesAuthenticationSourceDecorator();
this.tested.setDefaultUser(DEFAULT_USER);
this.tested.setDefaultPassword(DEFAULT_PASSWORD);
this.tested.setTarget(this.authenticationSourceMock);
}
@Test
public void testGetPrincipal_TargetHasPrincipal() {
when(authenticationSourceMock.getPrincipal()).thenReturn("cn=someUser");
String principal = tested.getPrincipal();
when(this.authenticationSourceMock.getPrincipal()).thenReturn("cn=someUser");
String principal = this.tested.getPrincipal();
assertThat(principal).isEqualTo("cn=someUser");
}
@Test
public void testGetPrincipal_TargetHasNoPrincipal() {
when(authenticationSourceMock.getPrincipal()).thenReturn("");
when(this.authenticationSourceMock.getPrincipal()).thenReturn("");
String principal = tested.getPrincipal();
String principal = this.tested.getPrincipal();
assertThat(principal).isEqualTo(DEFAULT_USER);
}
@Test
public void testGetCredentials_TargetHasPrincipal() {
when(authenticationSourceMock.getPrincipal()).thenReturn("cn=someUser");
when(authenticationSourceMock.getCredentials()).thenReturn("somepassword");
when(this.authenticationSourceMock.getPrincipal()).thenReturn("cn=someUser");
when(this.authenticationSourceMock.getCredentials()).thenReturn("somepassword");
String credentials = tested.getCredentials();
String credentials = this.tested.getCredentials();
assertThat(credentials).isEqualTo("somepassword");
}
@Test
public void testGetCredentials_TargetHasNoPrincipal() {
when(authenticationSourceMock.getPrincipal()).thenReturn("");
when(authenticationSourceMock.getCredentials()).thenReturn("somepassword");
when(this.authenticationSourceMock.getPrincipal()).thenReturn("");
when(this.authenticationSourceMock.getCredentials()).thenReturn("somepassword");
String credentials = tested.getCredentials();
String credentials = this.tested.getCredentials();
assertThat(credentials).isEqualTo(DEFAULT_PASSWORD);
}
@Test
public void testAfterPropertiesSet_noTarget() throws Exception {
tested.setTarget(null);
this.tested.setTarget(null);
try {
tested.afterPropertiesSet();
this.tested.afterPropertiesSet();
fail("IllegalArgumentException expected");
}
catch (IllegalArgumentException expected) {
@@ -94,9 +94,9 @@ public class DefaultValuesAuthenticationSourceDecoratorTest {
@Test
public void testAfterPropertiesSet_noDefaultUser() throws Exception {
tested.setDefaultUser(null);
this.tested.setDefaultUser(null);
try {
tested.afterPropertiesSet();
this.tested.afterPropertiesSet();
fail("IllegalArgumentException expected");
}
catch (IllegalArgumentException expected) {
@@ -106,9 +106,9 @@ public class DefaultValuesAuthenticationSourceDecoratorTest {
@Test
public void testAfterPropertiesSet_noDefaultPassword() throws Exception {
tested.setDefaultPassword(null);
this.tested.setDefaultPassword(null);
try {
tested.afterPropertiesSet();
this.tested.afterPropertiesSet();
fail("IllegalArgumentException expected");
}
catch (IllegalArgumentException expected) {

View File

@@ -33,12 +33,12 @@ public class MockFactoryBean extends AbstractFactoryBean<Object> {
@Override
public Class<?> getObjectType() {
return clazz;
return this.clazz;
}
@Override
protected Object createInstance() throws Exception {
return mock(clazz);
return mock(this.clazz);
}
}

View File

@@ -42,22 +42,22 @@ public class PagedResultsDirContextProcessorTest {
@Before
public void setUp() throws Exception {
tested = new PagedResultsDirContextProcessor(20);
this.tested = new PagedResultsDirContextProcessor(20);
// Create ldapContext mock
ldapContextMock = mock(LdapContext.class);
this.ldapContextMock = mock(LdapContext.class);
}
@After
public void tearDown() throws Exception {
tested = null;
ldapContextMock = null;
this.tested = null;
this.ldapContextMock = null;
}
@Test
public void testCreateRequestControl() throws Exception {
PagedResultsControl control = (PagedResultsControl) tested.createRequestControl();
PagedResultsControl control = (PagedResultsControl) this.tested.createRequestControl();
assertThat(control).isNotNull();
}
@@ -80,13 +80,13 @@ public class PagedResultsDirContextProcessorTest {
byte[] cookie = encodeValue(resultSize, value);
PagedResultsResponseControl control = new PagedResultsResponseControl("dummy", true, cookie);
when(ldapContextMock.getResponseControls()).thenReturn(new Control[] { control });
tested.postProcess(ldapContextMock);
when(this.ldapContextMock.getResponseControls()).thenReturn(new Control[] { control });
this.tested.postProcess(this.ldapContextMock);
PagedResultsCookie returnedCookie = tested.getCookie();
PagedResultsCookie returnedCookie = this.tested.getCookie();
assertThat(returnedCookie.getCookie()[0]).isEqualTo((byte) 8);
assertThat(tested.getPageSize()).isEqualTo(20);
assertThat(tested.getResultSize()).isEqualTo(50);
assertThat(this.tested.getPageSize()).isEqualTo(20);
assertThat(this.tested.getResultSize()).isEqualTo(50);
}
@Test
@@ -101,23 +101,23 @@ public class PagedResultsDirContextProcessorTest {
// Using another response control to verify that it is ignored
DirSyncResponseControl control = new DirSyncResponseControl("dummy", true, cookie);
when(ldapContextMock.getResponseControls()).thenReturn(new Control[] { control });
tested.postProcess(ldapContextMock);
when(this.ldapContextMock.getResponseControls()).thenReturn(new Control[] { control });
this.tested.postProcess(this.ldapContextMock);
assertThat(tested.getCookie()).isNull();
assertThat(tested.getPageSize()).isEqualTo(20);
assertThat(tested.getResultSize()).isEqualTo(0);
assertThat(this.tested.getCookie()).isNull();
assertThat(this.tested.getPageSize()).isEqualTo(20);
assertThat(this.tested.getResultSize()).isEqualTo(0);
}
@Test
public void testPostProcess_NoResponseControls() throws Exception {
when(ldapContextMock.getResponseControls()).thenReturn(null);
when(this.ldapContextMock.getResponseControls()).thenReturn(null);
tested.postProcess(ldapContextMock);
this.tested.postProcess(this.ldapContextMock);
assertThat(tested.getCookie()).isNull();
assertThat(tested.getPageSize()).isEqualTo(20);
assertThat(tested.getResultSize()).isEqualTo(0);
assertThat(this.tested.getCookie()).isNull();
assertThat(this.tested.getPageSize()).isEqualTo(20);
assertThat(this.tested.getResultSize()).isEqualTo(0);
}
@Test

View File

@@ -44,21 +44,21 @@ public class RequestControlDirContextProcessorTest {
@Before
public void setUp() throws Exception {
// Create requestControl mock
requestControlMock = mock(Control.class);
this.requestControlMock = mock(Control.class);
// Create requestControl2 mock
requestControl2Mock = mock(Control.class);
this.requestControl2Mock = mock(Control.class);
// Create ldapContext mock
ldapContextMock = mock(LdapContext.class);
this.ldapContextMock = mock(LdapContext.class);
// Create dirContext mock
dirContextMock = mock(DirContext.class);
this.dirContextMock = mock(DirContext.class);
tested = new AbstractRequestControlDirContextProcessor() {
this.tested = new AbstractRequestControlDirContextProcessor() {
public Control createRequestControl() {
return requestControlMock;
return RequestControlDirContextProcessorTest.this.requestControlMock;
}
public void postProcess(DirContext ctx) throws NamingException {
@@ -69,63 +69,64 @@ public class RequestControlDirContextProcessorTest {
@After
public void tearDown() throws Exception {
requestControlMock = null;
requestControl2Mock = null;
ldapContextMock = null;
dirContextMock = null;
this.requestControlMock = null;
this.requestControl2Mock = null;
this.ldapContextMock = null;
this.dirContextMock = null;
}
@Test
public void testPreProcessWithExistingControlOfDifferentClassShouldAdd() throws Exception {
SortControl existingControl = new SortControl(new String[] { "cn" }, true);
when(ldapContextMock.getRequestControls()).thenReturn(new Control[] { existingControl });
when(this.ldapContextMock.getRequestControls()).thenReturn(new Control[] { existingControl });
tested.preProcess(ldapContextMock);
this.tested.preProcess(this.ldapContextMock);
verify(ldapContextMock).setRequestControls(new Control[] { existingControl, requestControlMock });
verify(this.ldapContextMock).setRequestControls(new Control[] { existingControl, this.requestControlMock });
}
@Test
public void testPreProcessWithExistingControlOfSameClassShouldReplace() throws Exception {
when(ldapContextMock.getRequestControls()).thenReturn(new Control[] { requestControl2Mock });
when(this.ldapContextMock.getRequestControls()).thenReturn(new Control[] { this.requestControl2Mock });
tested.preProcess(ldapContextMock);
this.tested.preProcess(this.ldapContextMock);
verify(ldapContextMock).setRequestControls(new Control[] { requestControlMock });
verify(this.ldapContextMock).setRequestControls(new Control[] { this.requestControlMock });
}
@Test
public void testPreProcessWithExistingControlOfSameClassAndPropertyFalseShouldAdd() throws Exception {
when(ldapContextMock.getRequestControls()).thenReturn(new Control[] { requestControl2Mock });
when(this.ldapContextMock.getRequestControls()).thenReturn(new Control[] { this.requestControl2Mock });
tested.setReplaceSameControlEnabled(false);
tested.preProcess(ldapContextMock);
this.tested.setReplaceSameControlEnabled(false);
this.tested.preProcess(this.ldapContextMock);
verify(ldapContextMock).setRequestControls(new Control[] { requestControl2Mock, requestControlMock });
verify(this.ldapContextMock)
.setRequestControls(new Control[] { this.requestControl2Mock, this.requestControlMock });
}
@Test
public void testPreProcessWithNoExistingControlsShouldAdd() throws NamingException {
when(ldapContextMock.getRequestControls()).thenReturn(new Control[0]);
when(this.ldapContextMock.getRequestControls()).thenReturn(new Control[0]);
tested.preProcess(ldapContextMock);
this.tested.preProcess(this.ldapContextMock);
verify(ldapContextMock).setRequestControls(new Control[] { requestControlMock });
verify(this.ldapContextMock).setRequestControls(new Control[] { this.requestControlMock });
}
@Test
public void testPreProcessWithNullControlsShouldAdd() throws NamingException {
when(ldapContextMock.getRequestControls()).thenReturn(null);
when(this.ldapContextMock.getRequestControls()).thenReturn(null);
tested.preProcess(ldapContextMock);
this.tested.preProcess(this.ldapContextMock);
verify(ldapContextMock).setRequestControls(new Control[] { requestControlMock });
verify(this.ldapContextMock).setRequestControls(new Control[] { this.requestControlMock });
}
@Test(expected = IllegalArgumentException.class)
public void testPreProcessWhenNotLdapContextShouldFail() throws Exception {
tested.preProcess(dirContextMock);
this.tested.preProcess(this.dirContextMock);
}
}

View File

@@ -45,15 +45,15 @@ public class SortControlDirContextProcessorTest {
@Before
public void setUp() throws Exception {
tested = new SortControlDirContextProcessor("key");
this.tested = new SortControlDirContextProcessor("key");
// Create ldapContext mock
ldapContextMock = mock(LdapContext.class);
this.ldapContextMock = mock(LdapContext.class);
}
@Test
public void testCreateRequestControl() throws Exception {
SortControl result = (SortControl) tested.createRequestControl();
SortControl result = (SortControl) this.tested.createRequestControl();
assertThat(result).isNotNull();
assertThat(result.getID()).isEqualTo("1.2.840.113556.1.4.473");
assertThat(result.getEncodedValue().length).isEqualTo(9);
@@ -66,12 +66,12 @@ public class SortControlDirContextProcessorTest {
byte[] value = encodeValue(sortResult);
SortResponseControl control = new SortResponseControl("dummy", true, value);
when(ldapContextMock.getResponseControls()).thenReturn(new Control[] { control });
when(this.ldapContextMock.getResponseControls()).thenReturn(new Control[] { control });
tested.postProcess(ldapContextMock);
this.tested.postProcess(this.ldapContextMock);
assertThat(tested.isSorted()).isEqualTo(true);
assertThat(tested.getResultCode()).isEqualTo(0);
assertThat(this.tested.isSorted()).isEqualTo(true);
assertThat(this.tested.getResultCode()).isEqualTo(0);
}
@Test
@@ -81,12 +81,12 @@ public class SortControlDirContextProcessorTest {
byte[] value = encodeValue(sortResult);
SortResponseControl control = new SortResponseControl("dummy", true, value);
when(ldapContextMock.getResponseControls()).thenReturn(new Control[] { control });
when(this.ldapContextMock.getResponseControls()).thenReturn(new Control[] { control });
tested.postProcess(ldapContextMock);
this.tested.postProcess(this.ldapContextMock);
assertThat(tested.isSorted()).isEqualTo(false);
assertThat(tested.getResultCode()).isEqualTo(1);
assertThat(this.tested.isSorted()).isEqualTo(false);
assertThat(this.tested.getResultCode()).isEqualTo(1);
}
@Test
@@ -101,11 +101,11 @@ public class SortControlDirContextProcessorTest {
// Using another response control to verify that it is ignored
DirSyncResponseControl control = new DirSyncResponseControl("dummy", true, cookie);
when(ldapContextMock.getResponseControls()).thenReturn(new Control[] { control });
when(this.ldapContextMock.getResponseControls()).thenReturn(new Control[] { control });
tested.postProcess(ldapContextMock);
this.tested.postProcess(this.ldapContextMock);
assertThat(tested.isSorted()).isEqualTo(false);
assertThat(this.tested.isSorted()).isEqualTo(false);
}
@Test

View File

@@ -36,22 +36,23 @@ public class CollectingNameClassPairCallbackHandlerTest {
@Before
public void setUp() throws Exception {
expectedResult = new Object();
expectedNameClassPair = new NameClassPair(null, null);
tested = new CollectingNameClassPairCallbackHandler() {
this.expectedResult = new Object();
this.expectedNameClassPair = new NameClassPair(null, null);
this.tested = new CollectingNameClassPairCallbackHandler() {
public Object getObjectFromNameClassPair(NameClassPair nameClassPair) {
assertThat(nameClassPair).isSameAs(expectedNameClassPair);
return expectedResult;
assertThat(nameClassPair)
.isSameAs(CollectingNameClassPairCallbackHandlerTest.this.expectedNameClassPair);
return CollectingNameClassPairCallbackHandlerTest.this.expectedResult;
}
};
}
@Test
public void testHandleNameClassPair() throws NamingException {
tested.handleNameClassPair(expectedNameClassPair);
List result = tested.getList();
this.tested.handleNameClassPair(this.expectedNameClassPair);
List result = this.tested.getList();
assertThat(result).hasSize(1);
assertThat(result.get(0)).isSameAs(expectedResult);
assertThat(result.get(0)).isSameAs(this.expectedResult);
}
}

View File

@@ -33,8 +33,8 @@ public class ContextMapperCallbackHandlerTest {
@Before
public void setUp() throws Exception {
mapperMock = mock(ContextMapper.class);
tested = new ContextMapperCallbackHandler(mapperMock);
this.mapperMock = mock(ContextMapper.class);
this.tested = new ContextMapperCallbackHandler(this.mapperMock);
}
@Test(expected = IllegalArgumentException.class)
@@ -48,15 +48,15 @@ public class ContextMapperCallbackHandlerTest {
Object expectedResult = "result";
Binding expectedBinding = new Binding("some name", expectedObject);
when(mapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult);
Object actualResult = tested.getObjectFromNameClassPair(expectedBinding);
when(this.mapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult);
Object actualResult = this.tested.getObjectFromNameClassPair(expectedBinding);
assertThat(actualResult).isEqualTo(expectedResult);
}
@Test(expected = ObjectRetrievalException.class)
public void testGetObjectFromNameClassPairObjectRetrievalException() throws NamingException {
Binding expectedBinding = new Binding("some name", null);
tested.getObjectFromNameClassPair(expectedBinding);
this.tested.getObjectFromNameClassPair(expectedBinding);
}
}

View File

@@ -67,38 +67,38 @@ public class DefaultLdapClientListTest {
@Before
public void setUp() throws Exception {
// Setup ContextSource mock
contextSourceMock = mock(ContextSource.class);
this.contextSourceMock = mock(ContextSource.class);
// Setup LdapContext mock
dirContextMock = mock(LdapContext.class);
this.dirContextMock = mock(LdapContext.class);
// Setup NamingEnumeration mock
namingEnumerationMock = mock(NamingEnumeration.class);
this.namingEnumerationMock = mock(NamingEnumeration.class);
contextMapperMock = mock(ContextMapper.class);
this.contextMapperMock = mock(ContextMapper.class);
tested = (DefaultLdapClient) LdapClient.create(contextSourceMock);
this.tested = (DefaultLdapClient) LdapClient.create(this.contextSourceMock);
}
private void expectGetReadOnlyContext() {
when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock);
when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock);
}
private void setupListAndNamingEnumeration(NameClassPair listResult) throws NamingException {
when(dirContextMock.list(nameMock)).thenReturn(namingEnumerationMock);
when(this.dirContextMock.list(this.nameMock)).thenReturn(this.namingEnumerationMock);
setupNamingEnumeration(listResult);
}
private void setupListBindingsAndNamingEnumeration(NameClassPair listResult) throws NamingException {
when(dirContextMock.listBindings(nameMock)).thenReturn(namingEnumerationMock);
when(this.dirContextMock.listBindings(this.nameMock)).thenReturn(this.namingEnumerationMock);
setupNamingEnumeration(listResult);
}
private void setupNamingEnumeration(NameClassPair listResult) throws NamingException {
when(namingEnumerationMock.hasMore()).thenReturn(true, false);
when(namingEnumerationMock.next()).thenReturn(listResult);
when(this.namingEnumerationMock.hasMore()).thenReturn(true, false);
when(this.namingEnumerationMock.next()).thenReturn(listResult);
}
@Test
@@ -109,10 +109,10 @@ public class DefaultLdapClientListTest {
setupListAndNamingEnumeration(listResult);
List<String> list = tested.list(nameMock).toList(NameClassPair::getName);
List<String> list = this.tested.list(this.nameMock).toList(NameClassPair::getName);
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
assertThat(list).isNotNull();
assertThat(list).hasSize(1);
@@ -127,10 +127,10 @@ public class DefaultLdapClientListTest {
setupListAndNamingEnumeration(listResult);
List<String> list = tested.list(NAME).toList(NameClassPair::getName);
List<String> list = this.tested.list(NAME).toList(NameClassPair::getName);
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
assertThat(list).isNotNull();
assertThat(list).hasSize(1);
@@ -141,24 +141,24 @@ public class DefaultLdapClientListTest {
public void testList_PartialResultException() throws NamingException {
expectGetReadOnlyContext();
javax.naming.PartialResultException pre = new javax.naming.PartialResultException();
when(dirContextMock.list(nameMock)).thenThrow(pre);
when(this.dirContextMock.list(this.nameMock)).thenThrow(pre);
assertThatExceptionOfType(PartialResultException.class)
.isThrownBy(() -> tested.list(NAME).toList(NameClassPair::getName));
.isThrownBy(() -> this.tested.list(NAME).toList(NameClassPair::getName));
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
public void testList_Stream_PartialResultException() throws NamingException {
expectGetReadOnlyContext();
javax.naming.PartialResultException pre = new javax.naming.PartialResultException();
when(dirContextMock.list(nameMock)).thenThrow(pre);
when(this.dirContextMock.list(this.nameMock)).thenThrow(pre);
assertThatExceptionOfType(PartialResultException.class)
.isThrownBy(() -> tested.list(NAME).toStream(NameClassPair::getName).collect(Collectors.toList()));
.isThrownBy(() -> this.tested.list(NAME).toStream(NameClassPair::getName).collect(Collectors.toList()));
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
@@ -166,13 +166,13 @@ public class DefaultLdapClientListTest {
expectGetReadOnlyContext();
javax.naming.PartialResultException pre = new javax.naming.PartialResultException();
when(dirContextMock.list(this.nameMock)).thenThrow(pre);
when(this.dirContextMock.list(this.nameMock)).thenThrow(pre);
tested.setIgnorePartialResultException(true);
this.tested.setIgnorePartialResultException(true);
List<String> list = tested.list(NAME).toList(NameClassPair::getName);
List<String> list = this.tested.list(NAME).toList(NameClassPair::getName);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(list).isNotNull();
assertThat(list).isEmpty();
@@ -183,37 +183,37 @@ public class DefaultLdapClientListTest {
expectGetReadOnlyContext();
javax.naming.PartialResultException pre = new javax.naming.PartialResultException();
when(dirContextMock.list(this.nameMock)).thenThrow(pre);
when(this.dirContextMock.list(this.nameMock)).thenThrow(pre);
tested.setIgnorePartialResultException(true);
this.tested.setIgnorePartialResultException(true);
try (Stream<String> results = tested.list(NAME).toStream(NameClassPair::getName)) {
try (Stream<String> results = this.tested.list(NAME).toStream(NameClassPair::getName)) {
List<String> list = results.collect(Collectors.toList());
assertThat(list).isNotNull();
assertThat(list).isEmpty();
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
public void testList_NamingException() throws NamingException {
expectGetReadOnlyContext();
javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException();
when(dirContextMock.list(nameMock)).thenThrow(ne);
when(this.dirContextMock.list(this.nameMock)).thenThrow(ne);
assertThatExceptionOfType(LimitExceededException.class)
.isThrownBy(() -> tested.list(NAME).toList(NameClassPair::getName));
verify(dirContextMock).close();
.isThrownBy(() -> this.tested.list(NAME).toList(NameClassPair::getName));
verify(this.dirContextMock).close();
}
@Test
public void testList_AsStream_NamingException() throws NamingException {
expectGetReadOnlyContext();
javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException();
when(dirContextMock.list(nameMock)).thenThrow(ne);
when(this.dirContextMock.list(this.nameMock)).thenThrow(ne);
assertThatExceptionOfType(LimitExceededException.class)
.isThrownBy(() -> tested.list(NAME).toStream(NameClassPair::getName).collect(Collectors.toList()));
verify(dirContextMock).close();
.isThrownBy(() -> this.tested.list(NAME).toStream(NameClassPair::getName).collect(Collectors.toList()));
verify(this.dirContextMock).close();
}
// Tests for listBindings
@@ -226,10 +226,10 @@ public class DefaultLdapClientListTest {
setupListBindingsAndNamingEnumeration(listResult);
List<String> list = tested.listBindings(NAME).toList(NameClassPair::getName);
List<String> list = this.tested.listBindings(NAME).toList(NameClassPair::getName);
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
assertThat(list).isNotNull();
assertThat(list).hasSize(1);
@@ -244,15 +244,15 @@ public class DefaultLdapClientListTest {
setupListBindingsAndNamingEnumeration(listResult);
try (Stream<String> results = tested.listBindings(NAME).toStream(NameClassPair::getName)) {
try (Stream<String> results = this.tested.listBindings(NAME).toStream(NameClassPair::getName)) {
List<String> list = results.collect(Collectors.toList());
assertThat(list).isNotNull();
assertThat(list).hasSize(1);
assertThat(list.get(0)).isSameAs(NAME);
}
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
}
@Test
@@ -263,10 +263,10 @@ public class DefaultLdapClientListTest {
setupListBindingsAndNamingEnumeration(listResult);
List<String> list = tested.listBindings(nameMock).toList(NameClassPair::getName);
List<String> list = this.tested.listBindings(this.nameMock).toList(NameClassPair::getName);
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
assertThat(list).isNotNull();
assertThat(list).hasSize(1);
@@ -281,15 +281,15 @@ public class DefaultLdapClientListTest {
setupListBindingsAndNamingEnumeration(listResult);
try (Stream<String> results = tested.listBindings(nameMock).toStream(NameClassPair::getName)) {
try (Stream<String> results = this.tested.listBindings(this.nameMock).toStream(NameClassPair::getName)) {
List<String> list = results.collect(Collectors.toList());
assertThat(list).isNotNull();
assertThat(list).hasSize(1);
assertThat(list.get(0)).isSameAs(NAME);
}
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
}
@Test
@@ -302,12 +302,12 @@ public class DefaultLdapClientListTest {
setupListBindingsAndNamingEnumeration(listResult);
Object expectedResult = expectedObject;
when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult);
when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult);
List list = tested.listBindings(NAME).toList(contextMapperMock);
List list = this.tested.listBindings(NAME).toList(this.contextMapperMock);
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
assertThat(list).isNotNull();
assertThat(list).hasSize(1);
@@ -324,17 +324,17 @@ public class DefaultLdapClientListTest {
setupListBindingsAndNamingEnumeration(listResult);
Object expectedResult = expectedObject;
when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult);
when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult);
try (Stream<Object> results = tested.listBindings(NAME).toStream(contextMapperMock)) {
try (Stream<Object> results = this.tested.listBindings(NAME).toStream(this.contextMapperMock)) {
List<Object> list = results.collect(Collectors.toList());
assertThat(list).isNotNull();
assertThat(list).hasSize(1);
assertThat(list.get(0)).isSameAs(expectedResult);
}
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
}
@Test
@@ -347,12 +347,12 @@ public class DefaultLdapClientListTest {
setupListBindingsAndNamingEnumeration(listResult);
Object expectedResult = expectedObject;
when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult);
when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult);
List list = tested.listBindings(nameMock).toList(contextMapperMock);
List list = this.tested.listBindings(this.nameMock).toList(this.contextMapperMock);
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
assertThat(list).isNotNull();
assertThat(list).hasSize(1);
@@ -369,17 +369,17 @@ public class DefaultLdapClientListTest {
setupListBindingsAndNamingEnumeration(listResult);
Object expectedResult = expectedObject;
when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult);
when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult);
try (Stream<Object> results = tested.listBindings(nameMock).toStream(contextMapperMock)) {
try (Stream<Object> results = this.tested.listBindings(this.nameMock).toStream(this.contextMapperMock)) {
List<Object> list = results.collect(Collectors.toList());
assertThat(list).isNotNull();
assertThat(list).hasSize(1);
assertThat(list.get(0)).isSameAs(expectedResult);
}
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
}
}

View File

@@ -58,13 +58,13 @@ public class DefaultLdapClientLookupTest {
@Before
public void setUp() throws Exception {
contextSourceMock = mock(ContextSource.class);
dirContextMock = mock(LdapContext.class);
tested = LdapClient.create(contextSourceMock);
this.contextSourceMock = mock(ContextSource.class);
this.dirContextMock = mock(LdapContext.class);
this.tested = LdapClient.create(this.contextSourceMock);
}
private void expectGetReadOnlyContext() {
when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock);
when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock);
}
@Test
@@ -72,11 +72,11 @@ public class DefaultLdapClientLookupTest {
expectGetReadOnlyContext();
LdapDataEntry expected = new DirContextAdapter();
whenSearching(name).thenReturn(result(expected, null));
whenSearching(this.name).thenReturn(result(expected, null));
LdapDataEntry actual = tested.search().name(name).toEntry();
LdapDataEntry actual = this.tested.search().name(this.name).toEntry();
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(expected);
}
@@ -87,9 +87,9 @@ public class DefaultLdapClientLookupTest {
LdapDataEntry expected = new DirContextAdapter();
whenSearching(DEFAULT_BASE).thenReturn(result(expected, null));
LdapDataEntry actual = tested.search().name(DEFAULT_BASE.toString()).toEntry();
LdapDataEntry actual = this.tested.search().name(DEFAULT_BASE.toString()).toEntry();
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(expected);
}
@@ -98,11 +98,11 @@ public class DefaultLdapClientLookupTest {
expectGetReadOnlyContext();
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
whenSearching(name).thenThrow(ne);
whenSearching(this.name).thenThrow(ne);
assertThatExceptionOfType(NameNotFoundException.class).describedAs("NameNotFoundException expected")
.isThrownBy(() -> tested.search().name(name).toEntry());
verify(dirContextMock).close();
.isThrownBy(() -> this.tested.search().name(this.name).toEntry());
verify(this.dirContextMock).close();
}
@Test
@@ -110,12 +110,12 @@ public class DefaultLdapClientLookupTest {
expectGetReadOnlyContext();
Attributes expected = new BasicAttributes();
whenSearching(name).thenReturn(result(null, expected));
whenSearching(this.name).thenReturn(result(null, expected));
AttributesMapper<Attributes> mapper = (attributes) -> attributes;
Attributes actual = tested.search().name(name).toObject(mapper);
Attributes actual = this.tested.search().name(this.name).toObject(mapper);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(expected);
}
@@ -127,9 +127,9 @@ public class DefaultLdapClientLookupTest {
whenSearching(DEFAULT_BASE).thenReturn(result(null, expected));
AttributesMapper<Attributes> mapper = (attributes) -> attributes;
Attributes actual = tested.search().name(DEFAULT_BASE.toString()).toObject(mapper);
Attributes actual = this.tested.search().name(DEFAULT_BASE.toString()).toObject(mapper);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(expected);
}
@@ -138,12 +138,12 @@ public class DefaultLdapClientLookupTest {
expectGetReadOnlyContext();
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
whenSearching(name).thenThrow(ne);
whenSearching(this.name).thenThrow(ne);
AttributesMapper<?> mapper = (attributes) -> attributes;
assertThatExceptionOfType(NameNotFoundException.class).describedAs("NameNotFoundException expected")
.isThrownBy(() -> tested.search().name(name).toObject(mapper));
verify(dirContextMock).close();
.isThrownBy(() -> this.tested.search().name(this.name).toObject(mapper));
verify(this.dirContextMock).close();
}
// Tests for lookup(name, ContextMapper)
@@ -153,12 +153,12 @@ public class DefaultLdapClientLookupTest {
expectGetReadOnlyContext();
Object expected = new Object();
whenSearching(name).thenReturn(result(expected, null));
whenSearching(this.name).thenReturn(result(expected, null));
ContextMapper<?> mapper = (ctx) -> ctx;
Object actual = tested.search().name(name).toObject(mapper);
Object actual = this.tested.search().name(this.name).toObject(mapper);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(expected);
}
@@ -170,9 +170,9 @@ public class DefaultLdapClientLookupTest {
whenSearching(DEFAULT_BASE).thenReturn(result(expected, null));
ContextMapper<?> mapper = (ctx) -> ctx;
Object actual = tested.search().name(DEFAULT_BASE.toString()).toObject(mapper);
Object actual = this.tested.search().name(DEFAULT_BASE.toString()).toObject(mapper);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(expected);
}
@@ -181,12 +181,12 @@ public class DefaultLdapClientLookupTest {
expectGetReadOnlyContext();
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
whenSearching(name).thenThrow(ne);
whenSearching(this.name).thenThrow(ne);
ContextMapper<?> mapper = (ctx) -> ctx;
assertThatExceptionOfType(NameNotFoundException.class).describedAs("NameNotFoundException expected")
.isThrownBy(() -> tested.search().name(name).toObject(mapper));
verify(dirContextMock).close();
.isThrownBy(() -> this.tested.search().name(this.name).toObject(mapper));
verify(this.dirContextMock).close();
}
private static NamingEnumeration result(Object object, Attributes attributes) {
@@ -198,7 +198,7 @@ public class DefaultLdapClientLookupTest {
}
private OngoingStubbing<javax.naming.NamingEnumeration<SearchResult>> whenSearching(Name name) throws Exception {
return when(dirContextMock.search(eq(name), anyString(), any()));
return when(this.dirContextMock.search(eq(name), anyString(), any()));
}
private static class NamingEnumeration implements javax.naming.NamingEnumeration<SearchResult> {
@@ -206,7 +206,7 @@ public class DefaultLdapClientLookupTest {
private final Iterator<SearchResult> names;
public NamingEnumeration(SearchResult... results) {
names = Arrays.asList(results).iterator();
this.names = Arrays.asList(results).iterator();
}
@Override

View File

@@ -54,26 +54,26 @@ public class DefaultLdapClientRenameTest {
@Before
public void setUp() throws Exception {
// Setup ContextSource mock
contextSourceMock = mock(ContextSource.class);
this.contextSourceMock = mock(ContextSource.class);
// Setup LdapContext mock
dirContextMock = mock(LdapContext.class);
this.dirContextMock = mock(LdapContext.class);
tested = LdapClient.create(contextSourceMock);
this.tested = LdapClient.create(this.contextSourceMock);
}
private void expectGetReadWriteContext() {
when(contextSourceMock.getReadWriteContext()).thenReturn(dirContextMock);
when(this.contextSourceMock.getReadWriteContext()).thenReturn(this.dirContextMock);
}
@Test
public void testRename() throws Exception {
expectGetReadWriteContext();
tested.modify(oldName).name(newName).execute();
this.tested.modify(this.oldName).name(this.newName).execute();
verify(dirContextMock).rename(oldName, newName);
verify(dirContextMock).close();
verify(this.dirContextMock).rename(this.oldName, this.newName);
verify(this.dirContextMock).close();
}
@Test
@@ -81,17 +81,17 @@ public class DefaultLdapClientRenameTest {
expectGetReadWriteContext();
javax.naming.NameAlreadyBoundException ne = new javax.naming.NameAlreadyBoundException();
doThrow(ne).when(dirContextMock).rename(oldName, newName);
doThrow(ne).when(this.dirContextMock).rename(this.oldName, this.newName);
try {
tested.modify(oldName).name(newName).execute();
this.tested.modify(this.oldName).name(this.newName).execute();
fail("NameAlreadyBoundException expected");
}
catch (NameAlreadyBoundException expected) {
assertThat(true).isTrue();
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
@@ -100,28 +100,28 @@ public class DefaultLdapClientRenameTest {
javax.naming.NamingException ne = new javax.naming.NamingException();
doThrow(ne).when(dirContextMock).rename(oldName, newName);
doThrow(ne).when(this.dirContextMock).rename(this.oldName, this.newName);
try {
tested.modify(oldName).name(newName).execute();
this.tested.modify(this.oldName).name(this.newName).execute();
fail("UncategorizedLdapException expected");
}
catch (UncategorizedLdapException expected) {
assertThat(true).isTrue();
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
public void testRename_String() throws Exception {
expectGetReadWriteContext();
tested.modify("o=example.com").name("o=somethingelse.com").execute();
this.tested.modify("o=example.com").name("o=somethingelse.com").execute();
verify(dirContextMock).rename(LdapUtils.newLdapName("o=example.com"),
verify(this.dirContextMock).rename(LdapUtils.newLdapName("o=example.com"),
LdapUtils.newLdapName("o=somethingelse.com"));
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
}

View File

@@ -106,36 +106,36 @@ public class DefaultLdapClientTest {
public void setUp() throws Exception {
// Setup ContextSource mock
contextSourceMock = mock(ContextSource.class);
this.contextSourceMock = mock(ContextSource.class);
// Setup LdapContext mock
dirContextMock = mock(LdapContext.class);
this.dirContextMock = mock(LdapContext.class);
// Setup NamingEnumeration mock
namingEnumerationMock = mock(NamingEnumeration.class);
this.namingEnumerationMock = mock(NamingEnumeration.class);
// Setup Name mock
nameMock = LdapUtils.emptyLdapName();
this.nameMock = LdapUtils.emptyLdapName();
// Setup Handler mock
handlerMock = mock(NameClassPairCallbackHandler.class);
contextMapperMock = mock(ContextMapper.class);
attributesMapperMock = mock(AttributesMapper.class);
contextExecutorMock = mock(ContextExecutor.class);
searchExecutorMock = mock(SearchExecutor.class);
dirContextProcessorMock = mock(DirContextProcessor.class);
dirContextOperationsMock = mock(DirContextOperations.class);
authenticatedContextMock = mock(DirContext.class);
entryContextCallbackMock = mock(AuthenticatedLdapEntryContextCallback.class);
odmMock = mock(ObjectDirectoryMapper.class);
query = LdapQueryBuilder.query().base("ou=spring").filter("ou=user");
authContextMapperMock = mock(AuthenticatedLdapEntryContextMapper.class);
this.handlerMock = mock(NameClassPairCallbackHandler.class);
this.contextMapperMock = mock(ContextMapper.class);
this.attributesMapperMock = mock(AttributesMapper.class);
this.contextExecutorMock = mock(ContextExecutor.class);
this.searchExecutorMock = mock(SearchExecutor.class);
this.dirContextProcessorMock = mock(DirContextProcessor.class);
this.dirContextOperationsMock = mock(DirContextOperations.class);
this.authenticatedContextMock = mock(DirContext.class);
this.entryContextCallbackMock = mock(AuthenticatedLdapEntryContextCallback.class);
this.odmMock = mock(ObjectDirectoryMapper.class);
this.query = LdapQueryBuilder.query().base("ou=spring").filter("ou=user");
this.authContextMapperMock = mock(AuthenticatedLdapEntryContextMapper.class);
tested = LdapClient.create(contextSourceMock);
this.tested = LdapClient.create(this.contextSourceMock);
}
private void expectGetReadWriteContext() {
when(contextSourceMock.getReadWriteContext()).thenReturn(dirContextMock);
when(this.contextSourceMock.getReadWriteContext()).thenReturn(this.dirContextMock);
}
private void expectGetReadOnlyContext() {
when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock);
when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock);
}
@Test
@@ -146,12 +146,12 @@ public class DefaultLdapClientTest {
singleSearchResult(searchControlsOneLevel(), searchResult);
tested.search()
.query((builder) -> builder.base(nameMock).searchScope(SearchScope.ONELEVEL).filter("(ou=somevalue)"))
.toObject(contextMapperMock);
this.tested.search().query(
(builder) -> builder.base(this.nameMock).searchScope(SearchScope.ONELEVEL).filter("(ou=somevalue)"))
.toObject(this.contextMapperMock);
verify(contextMapperMock).mapFromContext(any());
verify(dirContextMock).close();
verify(this.contextMapperMock).mapFromContext(any());
verify(this.dirContextMock).close();
}
@Test
@@ -164,11 +164,11 @@ public class DefaultLdapClientTest {
singleSearchResultWithStringBase(controls, searchResult);
tested.search().query((builder) -> builder.base(DEFAULT_BASE.toString()).searchScope(SearchScope.ONELEVEL)
.filter("(ou=somevalue)")).toObject(contextMapperMock);
this.tested.search().query((builder) -> builder.base(DEFAULT_BASE.toString()).searchScope(SearchScope.ONELEVEL)
.filter("(ou=somevalue)")).toObject(this.contextMapperMock);
verify(contextMapperMock).mapFromContext(any());
verify(dirContextMock).close();
verify(this.contextMapperMock).mapFromContext(any());
verify(this.dirContextMock).close();
}
@Test
@@ -182,12 +182,12 @@ public class DefaultLdapClientTest {
singleSearchResult(controls, searchResult);
tested.search()
.query((builder) -> builder.base(nameMock).searchScope(SearchScope.SUBTREE).filter("(ou=somevalue)"))
.toObject(attributesMapperMock);
this.tested.search().query(
(builder) -> builder.base(this.nameMock).searchScope(SearchScope.SUBTREE).filter("(ou=somevalue)"))
.toObject(this.attributesMapperMock);
verify(attributesMapperMock).mapFromAttributes(any());
verify(dirContextMock).close();
verify(this.attributesMapperMock).mapFromAttributes(any());
verify(this.dirContextMock).close();
}
@Test
@@ -201,11 +201,11 @@ public class DefaultLdapClientTest {
singleSearchResultWithStringBase(controls, searchResult);
tested.search().query((builder) -> builder.base(DEFAULT_BASE.toString()).searchScope(SearchScope.SUBTREE)
.filter("(ou=somevalue)")).toObject(attributesMapperMock);
this.tested.search().query((builder) -> builder.base(DEFAULT_BASE.toString()).searchScope(SearchScope.SUBTREE)
.filter("(ou=somevalue)")).toObject(this.attributesMapperMock);
verify(attributesMapperMock).mapFromAttributes(any());
verify(dirContextMock).close();
verify(this.attributesMapperMock).mapFromAttributes(any());
verify(this.dirContextMock).close();
}
@Test
@@ -216,19 +216,19 @@ public class DefaultLdapClientTest {
controls.setReturningObjFlag(false);
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException("some text");
when(dirContextMock.search(eq(nameMock), eq("(ou=somevalue)"), argThat(new SearchControlsMatcher(controls))))
.thenThrow(ne);
when(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).thenThrow(ne);
try {
tested.search().query(
(builder) -> builder.base(nameMock).searchScope(SearchScope.SUBTREE).filter("(ou=somevalue)"))
.toObject(attributesMapperMock);
this.tested.search().query(
(builder) -> builder.base(this.nameMock).searchScope(SearchScope.SUBTREE).filter("(ou=somevalue)"))
.toObject(this.attributesMapperMock);
fail("NameNotFoundException expected");
}
catch (NameNotFoundException expected) {
assertThat(true).isTrue();
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
@@ -239,36 +239,36 @@ public class DefaultLdapClientTest {
controls.setReturningObjFlag(false);
javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException();
when(dirContextMock.search(eq(nameMock), eq("(ou=somevalue)"), argThat(new SearchControlsMatcher(controls))))
.thenThrow(ne);
when(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).thenThrow(ne);
try {
tested.search().query((builder) -> builder.base(nameMock).filter("(ou=somevalue)"))
.toObject(attributesMapperMock);
this.tested.search().query((builder) -> builder.base(this.nameMock).filter("(ou=somevalue)"))
.toObject(this.attributesMapperMock);
fail("LimitExceededException expected");
}
catch (LimitExceededException expected) {
// expected
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
public void verifyThatDefaultSearchControlParametersAreAutomaticallyAppliedInSearch() throws Exception {
Supplier<SearchControls> defaults = mock(Supplier.class);
when(defaults.get()).thenReturn(new SearchControls());
LdapClient tested = LdapClient.builder().contextSource(contextSourceMock).defaultSearchControls(defaults)
LdapClient tested = LdapClient.builder().contextSource(this.contextSourceMock).defaultSearchControls(defaults)
.build();
expectGetReadOnlyContext();
when(dirContextMock.search(eq(nameMock), anyString(), any())).thenReturn(namingEnumerationMock);
tested.search().name(nameMock).toEntry();
when(this.dirContextMock.search(eq(this.nameMock), anyString(), any())).thenReturn(this.namingEnumerationMock);
tested.search().name(this.nameMock).toEntry();
verify(defaults).get();
verify(namingEnumerationMock).close();
verify(dirContextMock).close();
verify(this.namingEnumerationMock).close();
verify(this.dirContextMock).close();
}
@Test
@@ -277,10 +277,10 @@ public class DefaultLdapClientTest {
ModificationItem[] mods = new ModificationItem[1];
tested.modify(nameMock).attributes(mods).execute();
this.tested.modify(this.nameMock).attributes(mods).execute();
verify(dirContextMock).modifyAttributes(nameMock, mods);
verify(dirContextMock).close();
verify(this.dirContextMock).modifyAttributes(this.nameMock, mods);
verify(this.dirContextMock).close();
}
@Test
@@ -289,10 +289,10 @@ public class DefaultLdapClientTest {
ModificationItem[] mods = new ModificationItem[1];
tested.modify(DEFAULT_BASE.toString()).attributes(mods).execute();
this.tested.modify(DEFAULT_BASE.toString()).attributes(mods).execute();
verify(dirContextMock).modifyAttributes(DEFAULT_BASE, mods);
verify(dirContextMock).close();
verify(this.dirContextMock).modifyAttributes(DEFAULT_BASE, mods);
verify(this.dirContextMock).close();
}
@Test
@@ -302,17 +302,17 @@ public class DefaultLdapClientTest {
ModificationItem[] mods = new ModificationItem[1];
javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException();
doThrow(ne).when(dirContextMock).modifyAttributes(nameMock, mods);
doThrow(ne).when(this.dirContextMock).modifyAttributes(this.nameMock, mods);
try {
tested.modify(nameMock).attributes(mods).execute();
this.tested.modify(this.nameMock).attributes(mods).execute();
fail("LimitExceededException expected");
}
catch (LimitExceededException expected) {
assertThat(true).isTrue();
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
@@ -322,10 +322,10 @@ public class DefaultLdapClientTest {
Object expectedObject = new Object();
BasicAttributes expectedAttributes = new BasicAttributes();
tested.bind(nameMock).object(expectedObject).attributes(expectedAttributes).execute();
this.tested.bind(this.nameMock).object(expectedObject).attributes(expectedAttributes).execute();
verify(dirContextMock).bind(nameMock, expectedObject, expectedAttributes);
verify(dirContextMock).close();
verify(this.dirContextMock).bind(this.nameMock, expectedObject, expectedAttributes);
verify(this.dirContextMock).close();
}
@@ -336,10 +336,10 @@ public class DefaultLdapClientTest {
Object expectedObject = new Object();
BasicAttributes expectedAttributes = new BasicAttributes();
tested.bind(DEFAULT_BASE.toString()).object(expectedObject).attributes(expectedAttributes).execute();
this.tested.bind(DEFAULT_BASE.toString()).object(expectedObject).attributes(expectedAttributes).execute();
verify(dirContextMock).bind(DEFAULT_BASE, expectedObject, expectedAttributes);
verify(dirContextMock).close();
verify(this.dirContextMock).bind(DEFAULT_BASE, expectedObject, expectedAttributes);
verify(this.dirContextMock).close();
}
@Test
@@ -349,43 +349,43 @@ public class DefaultLdapClientTest {
Object expectedObject = new Object();
BasicAttributes expectedAttributes = new BasicAttributes();
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
doThrow(ne).when(dirContextMock).bind(nameMock, expectedObject, expectedAttributes);
doThrow(ne).when(this.dirContextMock).bind(this.nameMock, expectedObject, expectedAttributes);
try {
tested.bind(nameMock).object(expectedObject).attributes(expectedAttributes).execute();
this.tested.bind(this.nameMock).object(expectedObject).attributes(expectedAttributes).execute();
fail("NameNotFoundException expected");
}
catch (NameNotFoundException expected) {
assertThat(true).isTrue();
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
public void testBindWithContext() throws Exception {
expectGetReadWriteContext();
when(dirContextOperationsMock.getDn()).thenReturn(nameMock);
when(dirContextOperationsMock.isUpdateMode()).thenReturn(false);
when(this.dirContextOperationsMock.getDn()).thenReturn(this.nameMock);
when(this.dirContextOperationsMock.isUpdateMode()).thenReturn(false);
tested.bind(nameMock).object(dirContextOperationsMock).execute();
this.tested.bind(this.nameMock).object(this.dirContextOperationsMock).execute();
verify(dirContextMock).bind(nameMock, dirContextOperationsMock, null);
verify(dirContextMock).close();
verify(this.dirContextMock).bind(this.nameMock, this.dirContextOperationsMock, null);
verify(this.dirContextMock).close();
}
@Test
public void testRebindWithContext() throws Exception {
expectGetReadWriteContext();
when(dirContextOperationsMock.getDn()).thenReturn(nameMock);
when(dirContextOperationsMock.isUpdateMode()).thenReturn(false);
when(this.dirContextOperationsMock.getDn()).thenReturn(this.nameMock);
when(this.dirContextOperationsMock.isUpdateMode()).thenReturn(false);
tested.bind(nameMock).object(dirContextOperationsMock).replaceExisting(true).execute();
this.tested.bind(this.nameMock).object(this.dirContextOperationsMock).replaceExisting(true).execute();
verify(dirContextMock).rebind(nameMock, dirContextOperationsMock, null);
verify(dirContextMock).close();
verify(this.dirContextMock).rebind(this.nameMock, this.dirContextOperationsMock, null);
verify(this.dirContextMock).close();
}
@Test
@@ -395,10 +395,11 @@ public class DefaultLdapClientTest {
Object expectedObject = new Object();
BasicAttributes expectedAttributes = new BasicAttributes();
tested.bind(nameMock).object(expectedObject).attributes(expectedAttributes).replaceExisting(true).execute();
this.tested.bind(this.nameMock).object(expectedObject).attributes(expectedAttributes).replaceExisting(true)
.execute();
verify(dirContextMock).rebind(nameMock, expectedObject, expectedAttributes);
verify(dirContextMock).close();
verify(this.dirContextMock).rebind(this.nameMock, expectedObject, expectedAttributes);
verify(this.dirContextMock).close();
}
@Test
@@ -408,73 +409,73 @@ public class DefaultLdapClientTest {
Object expectedObject = new Object();
BasicAttributes expectedAttributes = new BasicAttributes();
tested.bind(DEFAULT_BASE.toString()).object(expectedObject).attributes(expectedAttributes).replaceExisting(true)
.execute();
this.tested.bind(DEFAULT_BASE.toString()).object(expectedObject).attributes(expectedAttributes)
.replaceExisting(true).execute();
verify(dirContextMock).rebind(DEFAULT_BASE, expectedObject, expectedAttributes);
verify(dirContextMock).close();
verify(this.dirContextMock).rebind(DEFAULT_BASE, expectedObject, expectedAttributes);
verify(this.dirContextMock).close();
}
@Test
public void testUnbind() throws Exception {
expectGetReadWriteContext();
tested.unbind(nameMock).execute();
this.tested.unbind(this.nameMock).execute();
verify(dirContextMock).unbind(nameMock);
verify(dirContextMock).close();
verify(this.dirContextMock).unbind(this.nameMock);
verify(this.dirContextMock).close();
}
@Test
public void testUnbind_String() throws Exception {
expectGetReadWriteContext();
tested.unbind(DEFAULT_BASE.toString()).execute();
this.tested.unbind(DEFAULT_BASE.toString()).execute();
verify(dirContextMock).unbind(DEFAULT_BASE);
verify(dirContextMock).close();
verify(this.dirContextMock).unbind(DEFAULT_BASE);
verify(this.dirContextMock).close();
}
@Test
public void testUnbindRecursive() throws Exception {
expectGetReadWriteContext();
when(namingEnumerationMock.hasMore()).thenReturn(true, false, false);
when(this.namingEnumerationMock.hasMore()).thenReturn(true, false, false);
Binding binding = new Binding("cn=Some name", null);
when(namingEnumerationMock.next()).thenReturn(binding);
when(this.namingEnumerationMock.next()).thenReturn(binding);
LdapName listDn = LdapUtils.newLdapName(DEFAULT_BASE);
when(dirContextMock.listBindings(listDn)).thenReturn(namingEnumerationMock);
when(this.dirContextMock.listBindings(listDn)).thenReturn(this.namingEnumerationMock);
LdapName subListDn = LdapUtils.newLdapName("cn=Some name, o=example.com");
when(dirContextMock.listBindings(subListDn)).thenReturn(namingEnumerationMock);
when(this.dirContextMock.listBindings(subListDn)).thenReturn(this.namingEnumerationMock);
tested.unbind(new CompositeName(DEFAULT_BASE.toString())).recursive(true).execute();
this.tested.unbind(new CompositeName(DEFAULT_BASE.toString())).recursive(true).execute();
verify(dirContextMock).unbind(subListDn);
verify(dirContextMock).unbind(listDn);
verify(namingEnumerationMock, times(2)).close();
verify(dirContextMock).close();
verify(this.dirContextMock).unbind(subListDn);
verify(this.dirContextMock).unbind(listDn);
verify(this.namingEnumerationMock, times(2)).close();
verify(this.dirContextMock).close();
}
@Test
public void testUnbindRecursive_String() throws Exception {
expectGetReadWriteContext();
when(namingEnumerationMock.hasMore()).thenReturn(true, false, false);
when(this.namingEnumerationMock.hasMore()).thenReturn(true, false, false);
Binding binding = new Binding("cn=Some name", null);
when(namingEnumerationMock.next()).thenReturn(binding);
when(this.namingEnumerationMock.next()).thenReturn(binding);
LdapName listDn = LdapUtils.newLdapName(DEFAULT_BASE);
when(dirContextMock.listBindings(listDn)).thenReturn(namingEnumerationMock);
when(this.dirContextMock.listBindings(listDn)).thenReturn(this.namingEnumerationMock);
LdapName subListDn = LdapUtils.newLdapName("cn=Some name, o=example.com");
when(dirContextMock.listBindings(subListDn)).thenReturn(namingEnumerationMock);
when(this.dirContextMock.listBindings(subListDn)).thenReturn(this.namingEnumerationMock);
tested.unbind(DEFAULT_BASE.toString()).recursive(true).execute();
this.tested.unbind(DEFAULT_BASE.toString()).recursive(true).execute();
verify(dirContextMock).unbind(subListDn);
verify(dirContextMock).unbind(listDn);
verify(namingEnumerationMock, times(2)).close();
verify(dirContextMock).close();
verify(this.dirContextMock).unbind(subListDn);
verify(this.dirContextMock).unbind(listDn);
verify(this.namingEnumerationMock, times(2)).close();
verify(this.dirContextMock).close();
}
@Test
@@ -482,17 +483,17 @@ public class DefaultLdapClientTest {
expectGetReadWriteContext();
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
doThrow(ne).when(dirContextMock).unbind(nameMock);
doThrow(ne).when(this.dirContextMock).unbind(this.nameMock);
try {
tested.unbind(nameMock).execute();
this.tested.unbind(this.nameMock).execute();
fail("NameNotFoundException expected");
}
catch (NameNotFoundException expected) {
assertThat(true).isTrue();
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
@@ -500,32 +501,32 @@ public class DefaultLdapClientTest {
expectGetReadOnlyContext();
javax.naming.PartialResultException ex = new javax.naming.PartialResultException();
when(dirContextMock.search(eq(nameMock), anyString(), any())).thenThrow(ex);
when(this.dirContextMock.search(eq(this.nameMock), anyString(), any())).thenThrow(ex);
try {
tested.search().name(nameMock).toEntryList();
this.tested.search().name(this.nameMock).toEntryList();
fail("PartialResultException expected");
}
catch (PartialResultException expected) {
assertThat(true).isTrue();
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
public void testSearch_PartialResult_IgnoreSet() throws Exception {
LdapClient tested = LdapClient.builder().contextSource(contextSourceMock).ignorePartialResultException(true)
.build();
LdapClient tested = LdapClient.builder().contextSource(this.contextSourceMock)
.ignorePartialResultException(true).build();
expectGetReadOnlyContext();
when(dirContextMock.search(eq(nameMock), anyString(), any()))
when(this.dirContextMock.search(eq(this.nameMock), anyString(), any()))
.thenThrow(javax.naming.PartialResultException.class);
tested.search().name(nameMock).toEntryStream();
tested.search().name(this.nameMock).toEntryStream();
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
@@ -533,28 +534,28 @@ public class DefaultLdapClientTest {
AuthenticatedLdapEntryContextMapper<Object> entryContextMapper = mock(
AuthenticatedLdapEntryContextMapper.class);
when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock);
when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock);
Object expectedObject = new DirContextAdapter(new BasicAttributes(), LdapUtils.newLdapName("cn=john doe"),
LdapUtils.newLdapName("dc=jayway, dc=se"));
SearchResult searchResult = new SearchResult("", expectedObject, new BasicAttributes());
singleSearchResult(searchControlsRecursive(), searchResult);
when(contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password"))
.thenReturn(authenticatedContextMock);
when(this.contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password"))
.thenReturn(this.authenticatedContextMock);
when(entryContextMapper.mapWithContext(any(), any())).thenReturn(new Object());
LdapQuery query = LdapQueryBuilder.query().base(nameMock).filter("(ou=somevalue)");
Object result = tested.authenticate().query(query).password("password").execute(entryContextMapper);
LdapQuery query = LdapQueryBuilder.query().base(this.nameMock).filter("(ou=somevalue)");
Object result = this.tested.authenticate().query(query).password("password").execute(entryContextMapper);
verify(authenticatedContextMock).close();
verify(dirContextMock).close();
verify(this.authenticatedContextMock).close();
verify(this.dirContextMock).close();
assertThat(result).isNotNull();
}
@Test
public void testAuthenticateWithTwoUsersFoundShouldThrowException() throws Exception {
when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock);
when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock);
Object expectedObject = new DirContextAdapter(new BasicAttributes(), LdapUtils.newLdapName("cn=john doe"),
LdapUtils.newLdapName("dc=jayway, dc=se"));
@@ -564,47 +565,47 @@ public class DefaultLdapClientTest {
setupSearchResults(searchControlsRecursive(), new SearchResult[] { searchResult1, searchResult2 });
try {
LdapQuery query = LdapQueryBuilder.query().base(nameMock).filter("(ou=somevalue)");
tested.authenticate().query(query).password("password").execute();
LdapQuery query = LdapQueryBuilder.query().base(this.nameMock).filter("(ou=somevalue)");
this.tested.authenticate().query(query).password("password").execute();
fail("IncorrectResultSizeDataAccessException expected");
}
catch (IncorrectResultSizeDataAccessException expected) {
// expected
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
public void testAuthenticateWhenNoUserWasFoundShouldFail() throws Exception {
when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock);
when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock);
noSearchResults(searchControlsRecursive());
LdapQuery query = LdapQueryBuilder.query().base(nameMock).filter("(ou=somevalue)");
LdapQuery query = LdapQueryBuilder.query().base(this.nameMock).filter("(ou=somevalue)");
assertThatExceptionOfType(EmptyResultDataAccessException.class)
.isThrownBy(() -> tested.authenticate().query(query).password("password").execute());
.isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute());
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
@SuppressWarnings("unchecked")
public void testAuthenticateQueryPasswordWhenNoUserWasFoundShouldThrowEmptyResult() throws Exception {
when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock);
when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock);
noSearchResults(searchControlsRecursive());
LdapQuery query = LdapQueryBuilder.query().base(nameMock).filter("(ou=somevalue)");
assertThatExceptionOfType(EmptyResultDataAccessException.class).isThrownBy(
() -> tested.authenticate().query(query).password("password").execute((ctx, entry) -> new Object()));
LdapQuery query = LdapQueryBuilder.query().base(this.nameMock).filter("(ou=somevalue)");
assertThatExceptionOfType(EmptyResultDataAccessException.class).isThrownBy(() -> this.tested.authenticate()
.query(query).password("password").execute((ctx, entry) -> new Object()));
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
public void testAuthenticateWithFailedAuthenticationShouldFail() throws Exception {
when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock);
when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock);
Object expectedObject = new DirContextAdapter(new BasicAttributes(), LdapUtils.newLdapName("cn=john doe"),
LdapUtils.newLdapName("dc=jayway, dc=se"));
@@ -612,20 +613,20 @@ public class DefaultLdapClientTest {
singleSearchResult(searchControlsRecursive(), searchResult);
when(contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password"))
when(this.contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password"))
.thenThrow(new UncategorizedLdapException("Authentication failed"));
LdapQuery query = LdapQueryBuilder.query().base(nameMock).filter("(ou=somevalue)");
LdapQuery query = LdapQueryBuilder.query().base(this.nameMock).filter("(ou=somevalue)");
assertThatExceptionOfType(UncategorizedLdapException.class)
.isThrownBy(() -> tested.authenticate().query(query).password("password").execute());
verify(dirContextMock).close();
.isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute());
verify(this.dirContextMock).close();
}
private void noSearchResults(SearchControls controls) throws Exception {
when(dirContextMock.search(eq(nameMock), eq("(ou=somevalue)"), argThat(new SearchControlsMatcher(controls))))
.thenReturn(namingEnumerationMock);
when(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).thenReturn(this.namingEnumerationMock);
when(namingEnumerationMock.hasMore()).thenReturn(false);
when(this.namingEnumerationMock.hasMore()).thenReturn(false);
}
private void singleSearchResult(SearchControls controls, SearchResult searchResult) throws Exception {
@@ -633,16 +634,16 @@ public class DefaultLdapClientTest {
}
private void setupSearchResults(SearchControls controls, SearchResult... searchResults) throws Exception {
when(dirContextMock.search(eq(nameMock), eq("(ou=somevalue)"), argThat(new SearchControlsMatcher(controls))))
.thenReturn(namingEnumerationMock);
when(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).thenReturn(this.namingEnumerationMock);
if (searchResults.length == 1) {
when(namingEnumerationMock.hasMore()).thenReturn(true, false);
when(namingEnumerationMock.next()).thenReturn(searchResults[0]);
when(this.namingEnumerationMock.hasMore()).thenReturn(true, false);
when(this.namingEnumerationMock.next()).thenReturn(searchResults[0]);
}
else if (searchResults.length == 2) {
when(namingEnumerationMock.hasMore()).thenReturn(true, true, false);
when(namingEnumerationMock.next()).thenReturn(searchResults[0], searchResults[1]);
when(this.namingEnumerationMock.hasMore()).thenReturn(true, true, false);
when(this.namingEnumerationMock.next()).thenReturn(searchResults[0], searchResults[1]);
}
else {
throw new IllegalArgumentException("Cannot handle " + searchResults.length + " search results");
@@ -650,11 +651,11 @@ public class DefaultLdapClientTest {
}
private void singleSearchResultWithStringBase(SearchControls controls, SearchResult searchResult) throws Exception {
when(dirContextMock.search(eq(DEFAULT_BASE), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).thenReturn(namingEnumerationMock);
when(this.dirContextMock.search(eq(DEFAULT_BASE), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).thenReturn(this.namingEnumerationMock);
when(namingEnumerationMock.hasMore()).thenReturn(true, false);
when(namingEnumerationMock.next()).thenReturn(searchResult);
when(this.namingEnumerationMock.hasMore()).thenReturn(true, false);
when(this.namingEnumerationMock.next()).thenReturn(searchResult);
}
private SearchControls searchControlsRecursive() {
@@ -684,12 +685,12 @@ public class DefaultLdapClientTest {
if (item instanceof SearchControls) {
SearchControls s1 = item;
return controls.getSearchScope() == s1.getSearchScope()
&& controls.getReturningObjFlag() == s1.getReturningObjFlag()
&& controls.getDerefLinkFlag() == s1.getDerefLinkFlag()
&& controls.getCountLimit() == s1.getCountLimit()
&& controls.getTimeLimit() == s1.getTimeLimit()
&& controls.getReturningAttributes() == s1.getReturningAttributes();
return this.controls.getSearchScope() == s1.getSearchScope()
&& this.controls.getReturningObjFlag() == s1.getReturningObjFlag()
&& this.controls.getDerefLinkFlag() == s1.getDerefLinkFlag()
&& this.controls.getCountLimit() == s1.getCountLimit()
&& this.controls.getTimeLimit() == s1.getTimeLimit()
&& this.controls.getReturningAttributes() == s1.getReturningAttributes();
}
else {
throw new IllegalArgumentException();

View File

@@ -32,15 +32,15 @@ public class DistinguishedNameEditorTest {
@Before
public void setUp() throws Exception {
tested = new DistinguishedNameEditor();
this.tested = new DistinguishedNameEditor();
}
@Test
public void testSetAsText() throws Exception {
String expectedDn = "dc=jayway, dc=se";
tested.setAsText(expectedDn);
DistinguishedName result = (DistinguishedName) tested.getValue();
this.tested.setAsText(expectedDn);
DistinguishedName result = (DistinguishedName) this.tested.getValue();
assertThat(result).isEqualTo(new DistinguishedName(expectedDn));
try {
@@ -54,23 +54,23 @@ public class DistinguishedNameEditorTest {
@Test
public void testSetAsTextNullValue() throws Exception {
tested.setAsText(null);
Object result = tested.getValue();
this.tested.setAsText(null);
Object result = this.tested.getValue();
assertThat(result).isNull();
}
@Test
public void testGetAsText() throws Exception {
String expectedDn = "dc=jayway,dc=se";
tested.setValue(new DistinguishedName(expectedDn));
String text = tested.getAsText();
this.tested.setValue(new DistinguishedName(expectedDn));
String text = this.tested.getAsText();
assertThat(text).isEqualTo(expectedDn);
}
@Test
public void testGetAsTextNullValue() throws Exception {
tested.setValue(null);
String text = tested.getAsText();
this.tested.setValue(null);
String text = this.tested.getAsText();
assertThat(text).isNull();
}

View File

@@ -64,56 +64,56 @@ public class LdapTemplateListTest {
@Before
public void setUp() throws Exception {
// Setup ContextSource mock
contextSourceMock = mock(ContextSource.class);
this.contextSourceMock = mock(ContextSource.class);
// Setup LdapContext mock
dirContextMock = mock(LdapContext.class);
this.dirContextMock = mock(LdapContext.class);
// Setup NamingEnumeration mock
namingEnumerationMock = mock(NamingEnumeration.class);
this.namingEnumerationMock = mock(NamingEnumeration.class);
// Setup Name mock
nameMock = mock(Name.class);
this.nameMock = mock(Name.class);
// Setup Handler mock
handlerMock = mock(NameClassPairCallbackHandler.class);
this.handlerMock = mock(NameClassPairCallbackHandler.class);
contextMapperMock = mock(ContextMapper.class);
this.contextMapperMock = mock(ContextMapper.class);
tested = new LdapTemplate(contextSourceMock);
this.tested = new LdapTemplate(this.contextSourceMock);
}
private void expectGetReadOnlyContext() {
when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock);
when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock);
}
private void setupStringListAndNamingEnumeration(NameClassPair listResult) throws NamingException {
when(dirContextMock.list(NAME)).thenReturn(namingEnumerationMock);
when(this.dirContextMock.list(NAME)).thenReturn(this.namingEnumerationMock);
setupNamingEnumeration(listResult);
}
private void setupListAndNamingEnumeration(NameClassPair listResult) throws NamingException {
when(dirContextMock.list(nameMock)).thenReturn(namingEnumerationMock);
when(this.dirContextMock.list(this.nameMock)).thenReturn(this.namingEnumerationMock);
setupNamingEnumeration(listResult);
}
private void setupStringListBindingsAndNamingEnumeration(NameClassPair listResult) throws NamingException {
when(dirContextMock.listBindings(NAME)).thenReturn(namingEnumerationMock);
when(this.dirContextMock.listBindings(NAME)).thenReturn(this.namingEnumerationMock);
setupNamingEnumeration(listResult);
}
private void setupListBindingsAndNamingEnumeration(NameClassPair listResult) throws NamingException {
when(dirContextMock.listBindings(nameMock)).thenReturn(namingEnumerationMock);
when(this.dirContextMock.listBindings(this.nameMock)).thenReturn(this.namingEnumerationMock);
setupNamingEnumeration(listResult);
}
private void setupNamingEnumeration(NameClassPair listResult) throws NamingException {
when(namingEnumerationMock.hasMore()).thenReturn(true, false);
when(namingEnumerationMock.next()).thenReturn(listResult);
when(this.namingEnumerationMock.hasMore()).thenReturn(true, false);
when(this.namingEnumerationMock.next()).thenReturn(listResult);
}
@Test
@@ -124,10 +124,10 @@ public class LdapTemplateListTest {
setupListAndNamingEnumeration(listResult);
List list = tested.list(nameMock);
List list = this.tested.list(this.nameMock);
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
assertThat(list).isNotNull();
assertThat(list).hasSize(1);
@@ -142,10 +142,10 @@ public class LdapTemplateListTest {
setupStringListAndNamingEnumeration(listResult);
List list = tested.list(NAME);
List list = this.tested.list(NAME);
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
assertThat(list).isNotNull();
assertThat(list).hasSize(1);
@@ -160,11 +160,11 @@ public class LdapTemplateListTest {
setupListAndNamingEnumeration(listResult);
tested.list(nameMock, handlerMock);
this.tested.list(this.nameMock, this.handlerMock);
verify(handlerMock).handleNameClassPair(listResult);
verify(namingEnumerationMock).close();
verify(dirContextMock).close();
verify(this.handlerMock).handleNameClassPair(listResult);
verify(this.namingEnumerationMock).close();
verify(this.dirContextMock).close();
}
@Test
@@ -175,11 +175,11 @@ public class LdapTemplateListTest {
setupStringListAndNamingEnumeration(listResult);
tested.list("o=example.com", handlerMock);
this.tested.list("o=example.com", this.handlerMock);
verify(handlerMock).handleNameClassPair(listResult);
verify(namingEnumerationMock).close();
verify(dirContextMock).close();
verify(this.handlerMock).handleNameClassPair(listResult);
verify(this.namingEnumerationMock).close();
verify(this.dirContextMock).close();
}
@Test
@@ -187,17 +187,17 @@ public class LdapTemplateListTest {
expectGetReadOnlyContext();
javax.naming.PartialResultException pre = new javax.naming.PartialResultException();
when(dirContextMock.list(NAME)).thenThrow(pre);
when(this.dirContextMock.list(NAME)).thenThrow(pre);
try {
tested.list(NAME);
this.tested.list(NAME);
fail("PartialResultException expected");
}
catch (PartialResultException expected) {
assertThat(true).isTrue();
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
@@ -205,13 +205,13 @@ public class LdapTemplateListTest {
expectGetReadOnlyContext();
javax.naming.PartialResultException pre = new javax.naming.PartialResultException();
when(dirContextMock.list(NAME)).thenThrow(pre);
when(this.dirContextMock.list(NAME)).thenThrow(pre);
tested.setIgnorePartialResultException(true);
this.tested.setIgnorePartialResultException(true);
List list = tested.list(NAME);
List list = this.tested.list(NAME);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(list).isNotNull();
assertThat(list).isEmpty();
@@ -222,17 +222,17 @@ public class LdapTemplateListTest {
expectGetReadOnlyContext();
javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException();
when(dirContextMock.list(NAME)).thenThrow(ne);
when(this.dirContextMock.list(NAME)).thenThrow(ne);
try {
tested.list(NAME);
this.tested.list(NAME);
fail("LimitExceededException expected");
}
catch (LimitExceededException expected) {
assertThat(true).isTrue();
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
// Tests for listBindings
@@ -245,10 +245,10 @@ public class LdapTemplateListTest {
setupStringListBindingsAndNamingEnumeration(listResult);
List list = tested.listBindings(NAME);
List list = this.tested.listBindings(NAME);
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
assertThat(list).isNotNull();
assertThat(list).hasSize(1);
@@ -263,10 +263,10 @@ public class LdapTemplateListTest {
setupListBindingsAndNamingEnumeration(listResult);
List list = tested.listBindings(nameMock);
List list = this.tested.listBindings(this.nameMock);
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
assertThat(list).isNotNull();
assertThat(list).hasSize(1);
@@ -283,12 +283,12 @@ public class LdapTemplateListTest {
setupStringListBindingsAndNamingEnumeration(listResult);
Object expectedResult = expectedObject;
when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult);
when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult);
List list = tested.listBindings(NAME, contextMapperMock);
List list = this.tested.listBindings(NAME, this.contextMapperMock);
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
assertThat(list).isNotNull();
assertThat(list).hasSize(1);
@@ -305,12 +305,12 @@ public class LdapTemplateListTest {
setupListBindingsAndNamingEnumeration(listResult);
Object expectedResult = expectedObject;
when(contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult);
when(this.contextMapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult);
List list = tested.listBindings(nameMock, contextMapperMock);
List list = this.tested.listBindings(this.nameMock, this.contextMapperMock);
verify(dirContextMock).close();
verify(namingEnumerationMock).close();
verify(this.dirContextMock).close();
verify(this.namingEnumerationMock).close();
assertThat(list).isNotNull();
assertThat(list).hasSize(1);

View File

@@ -58,23 +58,23 @@ public class LdapTemplateLookupTest {
@Before
public void setUp() throws Exception {
// Setup ContextSource mock
contextSourceMock = mock(ContextSource.class);
this.contextSourceMock = mock(ContextSource.class);
// Setup LdapContext mock
dirContextMock = mock(LdapContext.class);
this.dirContextMock = mock(LdapContext.class);
// Setup Name mock
nameMock = mock(Name.class);
contextMapperMock = mock(ContextMapper.class);
attributesMapperMock = mock(AttributesMapper.class);
odmMock = mock(ObjectDirectoryMapper.class);
this.nameMock = mock(Name.class);
this.contextMapperMock = mock(ContextMapper.class);
this.attributesMapperMock = mock(AttributesMapper.class);
this.odmMock = mock(ObjectDirectoryMapper.class);
tested = new LdapTemplate(contextSourceMock);
tested.setObjectDirectoryMapper(odmMock);
this.tested = new LdapTemplate(this.contextSourceMock);
this.tested.setObjectDirectoryMapper(this.odmMock);
}
private void expectGetReadOnlyContext() {
when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock);
when(this.contextSourceMock.getReadOnlyContext()).thenReturn(this.dirContextMock);
}
// Tests for lookup(name)
@@ -84,11 +84,11 @@ public class LdapTemplateLookupTest {
expectGetReadOnlyContext();
Object expected = new Object();
when(dirContextMock.lookup(nameMock)).thenReturn(expected);
when(this.dirContextMock.lookup(this.nameMock)).thenReturn(expected);
Object actual = tested.lookup(nameMock);
Object actual = this.tested.lookup(this.nameMock);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(expected);
}
@@ -98,11 +98,11 @@ public class LdapTemplateLookupTest {
expectGetReadOnlyContext();
Object expected = new Object();
when(dirContextMock.lookup(DEFAULT_BASE_STRING)).thenReturn(expected);
when(this.dirContextMock.lookup(DEFAULT_BASE_STRING)).thenReturn(expected);
Object actual = tested.lookup(DEFAULT_BASE_STRING);
Object actual = this.tested.lookup(DEFAULT_BASE_STRING);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(expected);
}
@@ -112,17 +112,17 @@ public class LdapTemplateLookupTest {
expectGetReadOnlyContext();
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
when(dirContextMock.lookup(nameMock)).thenThrow(ne);
when(this.dirContextMock.lookup(this.nameMock)).thenThrow(ne);
try {
tested.lookup(nameMock);
this.tested.lookup(this.nameMock);
fail("NameNotFoundException expected");
}
catch (NameNotFoundException expected) {
assertThat(true).isTrue();
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
// Tests for lookup(name, AttributesMapper)
@@ -132,14 +132,14 @@ public class LdapTemplateLookupTest {
expectGetReadOnlyContext();
BasicAttributes expectedAttributes = new BasicAttributes();
when(dirContextMock.getAttributes(nameMock)).thenReturn(expectedAttributes);
when(this.dirContextMock.getAttributes(this.nameMock)).thenReturn(expectedAttributes);
Object expected = new Object();
when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected);
when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected);
Object actual = tested.lookup(nameMock, attributesMapperMock);
Object actual = this.tested.lookup(this.nameMock, this.attributesMapperMock);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(expected);
}
@@ -149,14 +149,14 @@ public class LdapTemplateLookupTest {
expectGetReadOnlyContext();
BasicAttributes expectedAttributes = new BasicAttributes();
when(dirContextMock.getAttributes(DEFAULT_BASE_STRING)).thenReturn(expectedAttributes);
when(this.dirContextMock.getAttributes(DEFAULT_BASE_STRING)).thenReturn(expectedAttributes);
Object expected = new Object();
when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected);
when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected);
Object actual = tested.lookup(DEFAULT_BASE_STRING, attributesMapperMock);
Object actual = this.tested.lookup(DEFAULT_BASE_STRING, this.attributesMapperMock);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(expected);
}
@@ -166,17 +166,17 @@ public class LdapTemplateLookupTest {
expectGetReadOnlyContext();
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
when(dirContextMock.getAttributes(nameMock)).thenThrow(ne);
when(this.dirContextMock.getAttributes(this.nameMock)).thenThrow(ne);
try {
tested.lookup(nameMock, attributesMapperMock);
this.tested.lookup(this.nameMock, this.attributesMapperMock);
fail("NameNotFoundException expected");
}
catch (NameNotFoundException expected) {
assertThat(true).isTrue();
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
// Tests for lookup(name, ContextMapper)
@@ -187,13 +187,13 @@ public class LdapTemplateLookupTest {
Object transformed = new Object();
Object expected = new Object();
when(dirContextMock.lookup(nameMock)).thenReturn(expected);
when(this.dirContextMock.lookup(this.nameMock)).thenReturn(expected);
when(contextMapperMock.mapFromContext(expected)).thenReturn(transformed);
when(this.contextMapperMock.mapFromContext(expected)).thenReturn(transformed);
Object actual = tested.lookup(nameMock, contextMapperMock);
Object actual = this.tested.lookup(this.nameMock, this.contextMapperMock);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(transformed);
}
@@ -206,15 +206,15 @@ public class LdapTemplateLookupTest {
Class<Object> expectedClass = Object.class;
DirContextAdapter expectedContext = new DirContextAdapter();
when(dirContextMock.lookup(nameMock)).thenReturn(expectedContext);
when(odmMock.mapFromLdapDataEntry(expectedContext, expectedClass)).thenReturn(transformed);
when(this.dirContextMock.lookup(this.nameMock)).thenReturn(expectedContext);
when(this.odmMock.mapFromLdapDataEntry(expectedContext, expectedClass)).thenReturn(transformed);
when(nameMock.getAll()).thenReturn(Collections.<String>enumeration(Collections.<String>emptyList()));
when(this.nameMock.getAll()).thenReturn(Collections.<String>enumeration(Collections.<String>emptyList()));
// Perform test
Object result = tested.findByDn(nameMock, expectedClass);
Object result = this.tested.findByDn(this.nameMock, expectedClass);
assertThat(result).isSameAs(transformed);
verify(odmMock).manageClass(expectedClass);
verify(this.odmMock).manageClass(expectedClass);
}
@Test
@@ -223,13 +223,13 @@ public class LdapTemplateLookupTest {
Object transformed = new Object();
Object expected = new Object();
when(dirContextMock.lookup(DEFAULT_BASE_STRING)).thenReturn(expected);
when(this.dirContextMock.lookup(DEFAULT_BASE_STRING)).thenReturn(expected);
when(contextMapperMock.mapFromContext(expected)).thenReturn(transformed);
when(this.contextMapperMock.mapFromContext(expected)).thenReturn(transformed);
Object actual = tested.lookup(DEFAULT_BASE_STRING, contextMapperMock);
Object actual = this.tested.lookup(DEFAULT_BASE_STRING, this.contextMapperMock);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(transformed);
}
@@ -239,17 +239,17 @@ public class LdapTemplateLookupTest {
expectGetReadOnlyContext();
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
when(dirContextMock.lookup(nameMock)).thenThrow(ne);
when(this.dirContextMock.lookup(this.nameMock)).thenThrow(ne);
try {
tested.lookup(nameMock, contextMapperMock);
this.tested.lookup(this.nameMock, this.contextMapperMock);
fail("NameNotFoundException expected");
}
catch (NameNotFoundException expected) {
assertThat(true).isTrue();
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
// Tests for lookup(name, attributes, AttributesMapper)
@@ -263,14 +263,14 @@ public class LdapTemplateLookupTest {
BasicAttributes expectedAttributes = new BasicAttributes();
expectedAttributes.put("cn", "Some Name");
when(dirContextMock.getAttributes(nameMock, attributeNames)).thenReturn(expectedAttributes);
when(this.dirContextMock.getAttributes(this.nameMock, attributeNames)).thenReturn(expectedAttributes);
Object expected = new Object();
when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected);
when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected);
Object actual = tested.lookup(nameMock, attributeNames, attributesMapperMock);
Object actual = this.tested.lookup(this.nameMock, attributeNames, this.attributesMapperMock);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(expected);
}
@@ -284,14 +284,14 @@ public class LdapTemplateLookupTest {
BasicAttributes expectedAttributes = new BasicAttributes();
expectedAttributes.put("cn", "Some Name");
when(dirContextMock.getAttributes(DEFAULT_BASE_STRING, attributeNames)).thenReturn(expectedAttributes);
when(this.dirContextMock.getAttributes(DEFAULT_BASE_STRING, attributeNames)).thenReturn(expectedAttributes);
Object expected = new Object();
when(attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected);
when(this.attributesMapperMock.mapFromAttributes(expectedAttributes)).thenReturn(expected);
Object actual = tested.lookup(DEFAULT_BASE_STRING, attributeNames, attributesMapperMock);
Object actual = this.tested.lookup(DEFAULT_BASE_STRING, attributeNames, this.attributesMapperMock);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(expected);
}
@@ -310,14 +310,14 @@ public class LdapTemplateLookupTest {
LdapName name = LdapUtils.newLdapName(DEFAULT_BASE_STRING);
DirContextAdapter adapter = new DirContextAdapter(expectedAttributes, name);
when(dirContextMock.getAttributes(name, attributeNames)).thenReturn(expectedAttributes);
when(this.dirContextMock.getAttributes(name, attributeNames)).thenReturn(expectedAttributes);
Object transformed = new Object();
when(contextMapperMock.mapFromContext(adapter)).thenReturn(transformed);
when(this.contextMapperMock.mapFromContext(adapter)).thenReturn(transformed);
Object actual = tested.lookup(name, attributeNames, contextMapperMock);
Object actual = this.tested.lookup(name, attributeNames, this.contextMapperMock);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(transformed);
}
@@ -331,17 +331,17 @@ public class LdapTemplateLookupTest {
BasicAttributes expectedAttributes = new BasicAttributes();
expectedAttributes.put("cn", "Some Name");
when(dirContextMock.getAttributes(DEFAULT_BASE_STRING, attributeNames)).thenReturn(expectedAttributes);
when(this.dirContextMock.getAttributes(DEFAULT_BASE_STRING, attributeNames)).thenReturn(expectedAttributes);
LdapName name = LdapUtils.newLdapName(DEFAULT_BASE_STRING);
DirContextAdapter adapter = new DirContextAdapter(expectedAttributes, name);
Object transformed = new Object();
when(contextMapperMock.mapFromContext(adapter)).thenReturn(transformed);
when(this.contextMapperMock.mapFromContext(adapter)).thenReturn(transformed);
Object actual = tested.lookup(DEFAULT_BASE_STRING, attributeNames, contextMapperMock);
Object actual = this.tested.lookup(DEFAULT_BASE_STRING, attributeNames, this.contextMapperMock);
verify(dirContextMock).close();
verify(this.dirContextMock).close();
assertThat(actual).isSameAs(transformed);
}

View File

@@ -19,12 +19,12 @@ public class LdapTemplateOdmTest {
@Before
public void prepareTestedClass() {
tested = mock(LdapTemplate.class);
this.tested = mock(LdapTemplate.class);
doCallRealMethod().when(tested).setObjectDirectoryMapper(any(ObjectDirectoryMapper.class));
odmMock = mock(ObjectDirectoryMapper.class);
doCallRealMethod().when(this.tested).setObjectDirectoryMapper(any(ObjectDirectoryMapper.class));
this.odmMock = mock(ObjectDirectoryMapper.class);
tested.setObjectDirectoryMapper(odmMock);
this.tested.setObjectDirectoryMapper(this.odmMock);
}
@Test

View File

@@ -52,32 +52,32 @@ public class LdapTemplateRenameTest {
@Before
public void setUp() throws Exception {
// Setup ContextSource mock
contextSourceMock = mock(ContextSource.class);
this.contextSourceMock = mock(ContextSource.class);
// Setup LdapContext mock
dirContextMock = mock(LdapContext.class);
this.dirContextMock = mock(LdapContext.class);
// Setup Name mock for old name
oldNameMock = mock(Name.class);
this.oldNameMock = mock(Name.class);
// Setup Name mock for new name
newNameMock = mock(Name.class);
this.newNameMock = mock(Name.class);
tested = new LdapTemplate(contextSourceMock);
this.tested = new LdapTemplate(this.contextSourceMock);
}
private void expectGetReadWriteContext() {
when(contextSourceMock.getReadWriteContext()).thenReturn(dirContextMock);
when(this.contextSourceMock.getReadWriteContext()).thenReturn(this.dirContextMock);
}
@Test
public void testRename() throws Exception {
expectGetReadWriteContext();
tested.rename(oldNameMock, newNameMock);
this.tested.rename(this.oldNameMock, this.newNameMock);
verify(dirContextMock).rename(oldNameMock, newNameMock);
verify(dirContextMock).close();
verify(this.dirContextMock).rename(this.oldNameMock, this.newNameMock);
verify(this.dirContextMock).close();
}
@Test
@@ -85,17 +85,17 @@ public class LdapTemplateRenameTest {
expectGetReadWriteContext();
javax.naming.NameAlreadyBoundException ne = new javax.naming.NameAlreadyBoundException();
doThrow(ne).when(dirContextMock).rename(oldNameMock, newNameMock);
doThrow(ne).when(this.dirContextMock).rename(this.oldNameMock, this.newNameMock);
try {
tested.rename(oldNameMock, newNameMock);
this.tested.rename(this.oldNameMock, this.newNameMock);
fail("NameAlreadyBoundException expected");
}
catch (NameAlreadyBoundException expected) {
assertThat(true).isTrue();
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
@@ -104,27 +104,27 @@ public class LdapTemplateRenameTest {
javax.naming.NamingException ne = new javax.naming.NamingException();
doThrow(ne).when(dirContextMock).rename(oldNameMock, newNameMock);
doThrow(ne).when(this.dirContextMock).rename(this.oldNameMock, this.newNameMock);
try {
tested.rename(oldNameMock, newNameMock);
this.tested.rename(this.oldNameMock, this.newNameMock);
fail("UncategorizedLdapException expected");
}
catch (UncategorizedLdapException expected) {
assertThat(true).isTrue();
}
verify(dirContextMock).close();
verify(this.dirContextMock).close();
}
@Test
public void testRename_String() throws Exception {
expectGetReadWriteContext();
tested.rename("o=example.com", "o=somethingelse.com");
this.tested.rename("o=example.com", "o=somethingelse.com");
verify(dirContextMock).rename("o=example.com", "o=somethingelse.com");
verify(dirContextMock).close();
verify(this.dirContextMock).rename("o=example.com", "o=somethingelse.com");
verify(this.dirContextMock).close();
}
}

Some files were not shown because too many files have changed in this diff Show More