From f7fa9806933c353c0007adecf8bf847c03bf1b75 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 06 Dec 2013 09:22:15 +0000
Subject: [PATCH] Fixed once and for all: privilige => privilege

---
 opendj-sdk/opends/src/server/org/opends/server/extensions/WhoAmIExtendedOperation.java                   |   42 +++++++--------------
 opendj-sdk/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java |   60 ++++++++++--------------------
 2 files changed, 34 insertions(+), 68 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/WhoAmIExtendedOperation.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/WhoAmIExtendedOperation.java
index cb1e61b..1b285be 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/WhoAmIExtendedOperation.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/WhoAmIExtendedOperation.java
@@ -29,6 +29,8 @@
 
 
 
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -43,10 +45,8 @@
 import org.opends.server.loggers.debug.DebugTracer;
 import org.opends.server.types.*;
 
-import static org.opends.messages.ExtensionMessages
-    .ERR_EXTOP_WHOAMI_PROXYAUTH_INSUFFICIENT_PRIVILEGES;
-import static org.opends.server.loggers.debug.DebugLogger.debugEnabled;
-import static org.opends.server.loggers.debug.DebugLogger.getTracer;
+import static org.opends.messages.ExtensionMessages.*;
+import static org.opends.server.loggers.debug.DebugLogger.*;
 import static org.opends.server.util.ServerConstants.*;
 
 
@@ -62,8 +62,10 @@
    */
   private static final DebugTracer TRACER = getTracer();
 
-  // The default set of supported control OIDs for this extended
-  private Set<String> supportedControlOIDs = new HashSet<String>(0);
+  /** The default set of supported control OIDs for this extended. */
+  private final Set<String> supportedControlOIDs =
+      Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
+          OID_PROXIED_AUTH_V1, OID_PROXIED_AUTH_V2)));
 
 
   /**
@@ -98,10 +100,6 @@
                    WhoAmIExtendedOperationHandlerCfg config)
          throws ConfigException, InitializationException
   {
-    supportedControlOIDs = new HashSet<String>(2);
-    supportedControlOIDs.add(OID_PROXIED_AUTH_V1);
-    supportedControlOIDs.add(OID_PROXIED_AUTH_V2);
-
     DirectoryServer.registerSupportedExtension(OID_WHO_AM_I_REQUEST, this);
 
     registerControlsAndFeatures();
@@ -121,22 +119,14 @@
     deregisterControlsAndFeatures();
   }
 
-
-
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override()
   public Set<String> getSupportedControls()
   {
     return supportedControlOIDs;
   }
 
-
-
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override()
   public void processExtendedOperation(ExtendedOperation operation)
   {
@@ -152,8 +142,8 @@
           operation.getRequestControl(ProxiedAuthV2Control.DECODER);
       if(proxyControlV1 != null || proxyControlV2 != null)
       {
-        // The requester must have the PROXIED_AUTH privilige in order to
-        // be able to use this control.
+        // The requester must have the PROXIED_AUTH privilege in order to be
+        // able to use this control.
         if (! clientConnection.hasPrivilege(Privilege.PROXIED_AUTH,
             operation))
         {
@@ -201,7 +191,7 @@
     }
     else
     {
-      authzID = "dn:" + authzDN.toString();
+      authzID = "dn:" + authzDN;
     }
 
     operation.setResponseValue(ByteString.valueOf(authzID));
@@ -210,11 +200,7 @@
     operation.setResultCode(ResultCode.SUCCESS);
   }
 
-
-
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public String getExtendedOperationName()
   {
diff --git a/opendj-sdk/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java b/opendj-sdk/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
index 1eb64b7..b1b943f 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/workflowelement/externalchangelog/ECLSearchOperation.java
@@ -228,7 +228,8 @@
       // search processing.
       baseDN = getBaseDN();
       filter = getFilter();
-      if ((baseDN == null) || (filter == null)){
+      if (baseDN == null || filter == null)
+      {
         break searchProcessing;
       }
 
@@ -367,11 +368,10 @@
    * @throws  DirectoryException  If there is a problem with any of the request
    *                              controls.
    */
-  private void handleRequestControls()
-  throws DirectoryException
+  private void handleRequestControls() throws DirectoryException
   {
     List<Control> requestControls  = getRequestControls();
-    if ((requestControls != null) && (! requestControls.isEmpty()))
+    if (requestControls != null && !requestControls.isEmpty())
     {
       for (Control c : requestControls)
       {
@@ -468,7 +468,7 @@
           addAdditionalLogItem(AdditionalLogItem.keyOnly(getClass(),
               "obsoleteProxiedAuthzV1Control"));
 
-          // The requester must have the PROXIED_AUTH privilige in order to be
+          // The requester must have the PROXIED_AUTH privilege in order to be
           // able to use this control.
           if (! clientConnection.hasPrivilege(Privilege.PROXIED_AUTH, this))
           {
@@ -492,7 +492,7 @@
         }
         else if (oid.equals(OID_PROXIED_AUTH_V2))
         {
-          // The requester must have the PROXIED_AUTH privilige in order to be
+          // The requester must have the PROXIED_AUTH privilege in order to be
           // able to use this control.
           if (! clientConnection.hasPrivilege(Privilege.PROXIED_AUTH, this))
           {
@@ -571,14 +571,12 @@
         }
 
         // TODO: Add support for additional controls, including VLV
-        else if (c.isCritical())
+        else if (c.isCritical()
+            && (replicationServer == null || !supportsControl(oid)))
         {
-          if ((replicationServer == null) || (! supportsControl(oid)))
-          {
-            throw new DirectoryException(
-                ResultCode.UNAVAILABLE_CRITICAL_EXTENSION,
-                ERR_SEARCH_UNSUPPORTED_CRITICAL_CONTROL.get(oid));
-          }
+          throw new DirectoryException(
+              ResultCode.UNAVAILABLE_CRITICAL_EXTENSION,
+              ERR_SEARCH_UNSUPPORTED_CRITICAL_CONTROL.get(oid));
         }
       }
     }
@@ -605,14 +603,11 @@
       if (CHANGELOG_ROOT_DN.matchesBaseAndScope(baseDN, getScope()))
       {
         final Entry entry = createRootEntry(update != null);
-        if (filter.matchesEntry(entry))
+        if (filter.matchesEntry(entry) && !returnEntry(entry, null))
         {
-          if (!returnEntry(entry, null))
-          {
-            // Abandon, Size limit reached.
-            abortECLSession = true;
-            return;
-          }
+          // Abandon, Size limit reached.
+          abortECLSession = true;
+          return;
         }
       }
 
@@ -707,11 +702,8 @@
    */
   private boolean matchScopeAndFilter(Entry entry) throws DirectoryException
   {
-    if (entry.matchesBaseAndScope(getBaseDN(), getScope()))
-    {
-      return getFilter().matchesEntry(entry);
-    }
-    return false;
+    return entry.matchesBaseAndScope(getBaseDN(), getScope())
+        && getFilter().matchesEntry(entry);
   }
 
   /**
@@ -1083,9 +1075,7 @@
         uAttrs, operationalAttrs);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public CancelResult cancel(CancelRequest cancelRequest)
   {
@@ -1095,9 +1085,7 @@
     return super.cancel(cancelRequest);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void abort(CancelRequest cancelRequest)
   {
@@ -1189,20 +1177,17 @@
       int sn = Integer.decode(
           sf.getAssertionValue().getNormalizedValue().toString());
       startCLmsg.setFirstChangeNumber(sn);
-      return startCLmsg;
     }
     else if (matches(sf, FilterType.LESS_OR_EQUAL, "changeNumber"))
     {
       int sn = Integer.decode(
           sf.getAssertionValue().getNormalizedValue().toString());
       startCLmsg.setLastChangeNumber(sn);
-      return startCLmsg;
     }
     else if (matches(sf, FilterType.EQUALITY, "replicationcsn"))
     {
       // == exact CSN
       startCLmsg.setCSN(new CSN(sf.getAssertionValue().toString()));
-      return startCLmsg;
     }
     else if (matches(sf, FilterType.EQUALITY, "changenumber"))
     {
@@ -1210,7 +1195,6 @@
           sf.getAssertionValue().getNormalizedValue().toString());
       startCLmsg.setFirstChangeNumber(sn);
       startCLmsg.setLastChangeNumber(sn);
-      return startCLmsg;
     }
     else if (sf.getFilterType() == FilterType.AND)
     {
@@ -1243,12 +1227,8 @@
         startCLmsg.setLastChangeNumber(Math.min(l1, l2));
 
       startCLmsg.setFirstChangeNumber(Math.max(f1,f2));
-      return startCLmsg;
     }
-    else
-    {
-      return startCLmsg;
-    }
+    return startCLmsg;
   }
 
   private static boolean matches(SearchFilter sf, FilterType filterType,

--
Gitblit v1.10.0