From 3c13e8ae44d173cf77457747c2fc25dbc9e42b72 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Wed, 21 Mar 2007 04:36:37 +0000
Subject: [PATCH] Update the LDAP connection handler so that it will properly terminate the client connection if a problem occurs while attempting to assign the connection security provider for that connection.

---
 opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java |   28 +++++++++++++++++++++++-----
 1 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java b/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java
index 4eaf805..554f2dd 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/protocols/ldap/LDAPConnectionHandler.java
@@ -1485,11 +1485,29 @@
                   }
                   clientChannel.socket().setKeepAlive(useKeepAlive);
                   clientChannel.socket().setTcpNoDelay(useTCPNoDelay);
-                  ConnectionSecurityProvider connectionSecurityProvider =
-                       securityProvider.newInstance(clientConnection,
-                                                    clientChannel);
-                  clientConnection.setConnectionSecurityProvider(
-                       connectionSecurityProvider);
+
+                  try
+                  {
+                    ConnectionSecurityProvider connectionSecurityProvider =
+                         securityProvider.newInstance(clientConnection,
+                                                      clientChannel);
+                    clientConnection.setConnectionSecurityProvider(
+                         connectionSecurityProvider);
+                  }
+                  catch (Exception e)
+                  {
+                    if (debugEnabled())
+                    {
+                      debugCaught(DebugLogLevel.ERROR, e);
+                    }
+
+                    clientConnection.disconnect(
+                         DisconnectReason.SECURITY_PROBLEM, false,
+                         MSGID_LDAP_CONNHANDLER_CANNOT_SET_SECURITY_PROVIDER,
+                         String.valueOf(e));
+                    iterator.remove();
+                    continue;
+                  }
 
 
                   // Check to see if the core server rejected the connection

--
Gitblit v1.10.0