summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFraser Tweedale <ftweedal@redhat.com>2015-11-27 14:31:18 +1100
committerFraser Tweedale <ftweedal@redhat.com>2016-01-21 12:10:54 +1100
commit6ed6230c9bed4e2619467b7f9f422a52b07295b8 (patch)
tree3279b7b1e096839f12d42b7a2650fc528b87531d
parentd895ca41472112a3ef07486419d4580f6c9d0983 (diff)
downloadpki-6ed6230c9bed4e2619467b7f9f422a52b07295b8.tar.gz
pki-6ed6230c9bed4e2619467b7f9f422a52b07295b8.tar.xz
pki-6ed6230c9bed4e2619467b7f9f422a52b07295b8.zip
Extract LDAPControl search function to LDAPUtil
-rw-r--r--base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java15
-rw-r--r--base/util/src/com/netscape/cmsutil/ldap/LDAPUtil.java18
2 files changed, 22 insertions, 11 deletions
diff --git a/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java b/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java
index cc2e43dfa..7be70dff1 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java
@@ -25,7 +25,6 @@ import java.util.LinkedHashMap;
import netscape.ldap.LDAPAttribute;
import netscape.ldap.LDAPConnection;
-import netscape.ldap.LDAPControl;
import netscape.ldap.LDAPDN;
import netscape.ldap.LDAPEntry;
import netscape.ldap.LDAPException;
@@ -47,6 +46,7 @@ import com.netscape.certsrv.profile.IProfileSubsystem;
import com.netscape.certsrv.registry.IPluginInfo;
import com.netscape.certsrv.registry.IPluginRegistry;
import com.netscape.cmscore.base.LDAPConfigStore;
+import com.netscape.cmsutil.ldap.LDAPUtil;
public class LDAPProfileSubsystem
extends AbstractProfileSubsystem
@@ -290,16 +290,9 @@ public class LDAPProfileSubsystem
null, false, cons);
while (!stopped && results.hasMoreElements()) {
LDAPEntry entry = results.next();
- LDAPEntryChangeControl changeControl = null;
- LDAPControl[] changeControls = results.getResponseControls();
- if (changeControls != null) {
- for (LDAPControl control : changeControls) {
- if (control instanceof LDAPEntryChangeControl) {
- changeControl = (LDAPEntryChangeControl) control;
- break;
- }
- }
- }
+ LDAPEntryChangeControl changeControl = (LDAPEntryChangeControl)
+ LDAPUtil.getControl(
+ LDAPEntryChangeControl.class, results.getResponseControls());
CMS.debug("Profile change monitor: Processed change controls.");
if (changeControl != null) {
int changeType = changeControl.getChangeType();
diff --git a/base/util/src/com/netscape/cmsutil/ldap/LDAPUtil.java b/base/util/src/com/netscape/cmsutil/ldap/LDAPUtil.java
index b02ffee78..f8162235d 100644
--- a/base/util/src/com/netscape/cmsutil/ldap/LDAPUtil.java
+++ b/base/util/src/com/netscape/cmsutil/ldap/LDAPUtil.java
@@ -18,11 +18,13 @@
package com.netscape.cmsutil.ldap;
import java.io.IOException;
+import java.lang.Class;
import java.util.ArrayList;
import netscape.ldap.LDAPAttribute;
import netscape.ldap.LDAPAttributeSet;
import netscape.ldap.LDAPConnection;
+import netscape.ldap.LDAPControl;
import netscape.ldap.LDAPEntry;
import netscape.ldap.LDAPException;
import netscape.ldap.LDAPModification;
@@ -145,4 +147,20 @@ public class LDAPUtil {
}
}
}
+
+ /**
+ * Get the control of the specified class from the array of controls.
+ *
+ * @return the LDAPControl, or null if not found
+ */
+ public static LDAPControl getControl(
+ Class<? extends LDAPControl> cls, LDAPControl[] controls) {
+ if (controls != null) {
+ for (LDAPControl control : controls) {
+ if (cls.isInstance(control))
+ return control;
+ }
+ }
+ return null;
+ }
}