From f3612b1aa023f12906a71cb12c6ca1cae12aa5dd Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 22 Mar 2013 13:01:05 +0000
Subject: [PATCH] Partial fix for OPENDJ-694: Implement HTTP BASIC authentication

---
 opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Context.java |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Context.java b/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Context.java
index 4136956..f6c9579 100644
--- a/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Context.java
+++ b/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Context.java
@@ -205,7 +205,10 @@
     Context(final Config config, final ServerContext context) {
         this.config = config;
         this.context = context;
-        if (context.containsContext(AuthenticatedConnectionContext.class)) {
+
+        // Re-use the pre-authenticated connection if available and the authorization policy allows.
+        if (config.getAuthorizationPolicy() != AuthorizationPolicy.NONE
+                && context.containsContext(AuthenticatedConnectionContext.class)) {
             final Connection connection =
                     context.asContext(AuthenticatedConnectionContext.class).getConnection();
             this.preAuthenticatedConnection = connection != null ? wrap(connection) : null;
@@ -265,7 +268,8 @@
          * cached connection since cached connections are supposed to have been
          * pre-authenticated and therefore do not require proxied authorization.
          */
-        if (preAuthenticatedConnection == null && config.useProxiedAuthorization()) {
+        if (preAuthenticatedConnection == null
+                && config.getAuthorizationPolicy() == AuthorizationPolicy.PROXY) {
             if (context.containsContext(SecurityContext.class)) {
                 try {
                     final SecurityContext securityContext =

--
Gitblit v1.10.0