Skip to content

Commit

Permalink
Reflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed Feb 28, 2024
1 parent f17f2b7 commit db09568
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 163 deletions.
39 changes: 16 additions & 23 deletions src/main/java/net/tirasa/connid/bundles/ldap/commons/LdapUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.identityconnectors.framework.common.exceptions.ConnectorException;
import org.identityconnectors.framework.common.objects.AttributeDelta;
import org.identityconnectors.framework.common.objects.AttributeDeltaUtil;
import org.identityconnectors.framework.common.objects.ConnectorObject;
import org.identityconnectors.framework.common.objects.Name;

public class LdapUtil {
Expand All @@ -51,8 +50,7 @@ private LdapUtil() {
}

/**
* Returns true if the names of the given LDAP attributes are equal. Deals
* with null values as a convenience.
* @return @code true} if the names of the given LDAP attributes are equal. Deals with null values as a convenience.
*/
public static boolean attrNameEquals(String name1, String name2) {
if (name1 == null) {
Expand All @@ -62,8 +60,7 @@ public static boolean attrNameEquals(String name1, String name2) {
}

/**
* Returns {@code true} if the attribute has the binary option,
* e.g., {@code userCertificate;binary}.
* @return {@code true} if the attribute has the binary option, e.g., {@code userCertificate;binary}.
*/
public static boolean hasBinaryOption(String ldapAttrName) {
return ldapAttrName.toLowerCase(Locale.US).endsWith(LDAP_BINARY_OPTION);
Expand All @@ -89,22 +86,8 @@ public static String removeBinaryOption(String ldapAttrName) {
return ldapAttrName;
}

public static String getStringAttrValue(ConnectorObject object, String ldapAttrName) {
org.identityconnectors.framework.common.objects.Attribute attr = object.getAttributeByName(ldapAttrName);
if (attr != null) {
try {
return (String) attr.getValue().get(0);
} catch (IndexOutOfBoundsException e) {
return null;
} catch (Exception e) {
throw new ConnectorException(e);
}
}
return null;
}

/**
* Return the value of the {@code ldapAttrName} parameter cast to a String.
* @return the value of the {@code ldapAttrName} parameter cast to a String.
*/
public static String getStringAttrValue(Attributes ldapAttrs, String ldapAttrName) {
Attribute attr = ldapAttrs.get(ldapAttrName);
Expand All @@ -119,11 +102,11 @@ public static String getStringAttrValue(Attributes ldapAttrs, String ldapAttrNam
}

/**
* Return the <b>case insensitive</b> set of values of the {@code
* @return the <b>case insensitive</b> set of values of the {@code
* ldapAttrName} parameter cast to a String.
*/
public static Set<String> getStringAttrValues(Attributes ldapAttrs, String ldapAttrName) {
Set<String> result = new HashSet<String>();
Set<String> result = new HashSet<>();
addStringAttrValues(ldapAttrs, ldapAttrName, result);
return result;
}
Expand All @@ -145,7 +128,8 @@ public static void addStringAttrValues(Attributes ldapAttrs, String ldapAttrName

/**
* Escapes the given attribute value to the given {@code StringBuilder}.
* Returns {@code true} iff anything was written to the builder.
*
* @returns {@code true} iff anything was written to the builder.
*/
public static boolean escapeAttrValue(Object value, StringBuilder toBuilder) {
if (value == null) {
Expand Down Expand Up @@ -446,38 +430,47 @@ public ListItr(ListIterator iter) {
this.iter = iter;
}

@Override
public void add(E o) {
iter.add(o);
}

@Override
public boolean hasNext() {
return iter.hasNext();
}

@Override
public boolean hasPrevious() {
return iter.hasPrevious();
}

@Override
public E next() {
return cast(iter.next());
}

@Override
public int nextIndex() {
return iter.nextIndex();
}

@Override
public E previous() {
return cast(iter.previous());
}

@Override
public int previousIndex() {
return iter.previousIndex();
}

@Override
public void remove() {
iter.remove();
}

@Override
public void set(E o) {
iter.set(o);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ protected LdapInternalSearch getInternalSearch(final Set<String> attrsToGet) {
controls.setSearchScope(searchScope);

String optionsFilter = LdapConstants.getSearchFilter(options);
String finalFilter = "";

boolean ignoreBuiltInFilters;
if (options.getOptions().containsKey(OP_IGNORE_BUILT_IN_FILTERS)) {
Expand All @@ -219,6 +218,7 @@ protected LdapInternalSearch getInternalSearch(final Set<String> attrsToGet) {
ignoreBuiltInFilters = false;
}

String finalFilter;
if (ignoreBuiltInFilters) {
finalFilter = optionsFilter;
} else {
Expand All @@ -231,12 +231,10 @@ protected LdapInternalSearch getInternalSearch(final Set<String> attrsToGet) {
searchFilter = conn.getConfiguration().getAnyObjectSearchFilter();
}
String nativeFilter = filter == null ? null : filter.getNativeFilter();

finalFilter = getSearchFilter(optionsFilter, nativeFilter, searchFilter);
}
return new LdapInternalSearch(conn,
finalFilter,
dns, strategy, controls);
return new LdapInternalSearch(conn, finalFilter, dns, strategy, controls);
}

protected Set<String> getLdapAttributesToGet(final Set<String> attrsToGet) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
/*
* ====================
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
*
*
* The contents of this file are subject to the terms of the Common Development
* and Distribution License("CDDL") (the "License"). You may not use this file
* except in compliance with the License.
*
*
* You can obtain a copy of the License at
* http://opensource.org/licenses/cddl1.php
* See the License for the specific language governing permissions and limitations
* under the License.
*
*
* When distributing the Covered Code, include this CDDL Header Notice in each file
* and include the License file at http://opensource.org/licenses/cddl1.php.
* If applicable, add the following below this CDDL Header, with the fields
Expand Down
Loading

0 comments on commit db09568

Please sign in to comment.