From 3aef5ff9705aca98c635d0d875dcdc845519e45d Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@gmail.com>
Date: Thu, 29 Oct 2015 11:27:15 +0000
Subject: [PATCH] Perform the same checks on ports that are using a Synchronous Strategy, than what is done with the default Strategy. Only difference is that LockDown mode will not be enforced then.

---
 opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java     |   18 ++++++++++--------
 opendj-server-legacy/src/main/java/org/opends/server/core/SynchronousStrategy.java |    3 ++-
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
index a081055..5d08ae7 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
@@ -5485,19 +5485,21 @@
    *
    * @param operation
    *          The operation to be added to the work queue.
+   * @param isAllowedInLockDownMode
+   *          Flag to indicate if the request can be added to the work queue regardless
+   *          of the server's lock down mode.
    * @throws DirectoryException
    *           If a check failed preventing the operation from being added to
    *           the queue
    */
-  private static void checkCanEnqueueRequest(Operation operation)
+  public static void checkCanEnqueueRequest(Operation operation, boolean isAllowedInLockDownMode)
          throws DirectoryException
   {
     ClientConnection clientConnection = operation.getClientConnection();
-    //Reject or accept the unauthenticated requests based on the configuration
-    // settings.
-    if ((directoryServer.rejectUnauthenticatedRequests ||
-         directoryServer.lockdownMode) &&
-        !clientConnection.getAuthenticationInfo().isAuthenticated())
+    //Reject or accept the unauthenticated requests based on the configuration settings.
+    if (!clientConnection.getAuthenticationInfo().isAuthenticated() &&
+        (directoryServer.rejectUnauthenticatedRequests ||
+        (directoryServer.lockdownMode && !isAllowedInLockDownMode)))
     {
       switch(operation.getOperationType())
       {
@@ -5608,7 +5610,7 @@
   public static void enqueueRequest(Operation operation)
       throws DirectoryException
   {
-    checkCanEnqueueRequest(operation);
+    checkCanEnqueueRequest(operation, false);
     directoryServer.workQueue.submitOperation(operation);
   }
 
@@ -5626,7 +5628,7 @@
   public static boolean tryEnqueueRequest(Operation operation)
       throws DirectoryException
   {
-    checkCanEnqueueRequest(operation);
+    checkCanEnqueueRequest(operation, false);
     return directoryServer.workQueue.trySubmitOperation(operation);
   }
 
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/SynchronousStrategy.java b/opendj-server-legacy/src/main/java/org/opends/server/core/SynchronousStrategy.java
index aa3e8b4..1e4842c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/SynchronousStrategy.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/SynchronousStrategy.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2006-2008 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2013 ForgeRock AS
+ *      Portions Copyright 2011-2015 ForgeRock AS
  */
 package org.opends.server.core;
 
@@ -45,6 +45,7 @@
    */
   @Override
   public void enqueueRequest(Operation operation) throws DirectoryException {
+    DirectoryServer.checkCanEnqueueRequest(operation, true);
     operation.run();
     operation.operationCompleted();
   }

--
Gitblit v1.10.0