directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject [directory-ldap-api] branch 1.0.1 updated: Some more LdapConnectionNetwork fixes
Date Fri, 20 Apr 2018 22:03:15 GMT
This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch 1.0.1
in repository https://gitbox.apache.org/repos/asf/directory-ldap-api.git


The following commit(s) were added to refs/heads/1.0.1 by this push:
     new 9475dc5  Some more LdapConnectionNetwork fixes
9475dc5 is described below

commit 9475dc5fb9bb6a2dddde539767c116a9fe9564bb
Author: Emmanuel L├ęcharny <elecharny@symas.com>
AuthorDate: Sat Apr 21 00:03:09 2018 +0200

    Some more LdapConnectionNetwork fixes
---
 .../ldap/client/api/LdapNetworkConnection.java     | 38 +++++++---------------
 1 file changed, 11 insertions(+), 27 deletions(-)

diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
index a139e7e..422d121 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
@@ -40,9 +40,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.ReentrantLock;
 
@@ -4063,10 +4061,6 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements
Lda
                     { "TLSv1", "TLSv1.1", "TLSv1.2" } );
             }
 
-            HandshakeFuture handshakeFuture = new HandshakeFuture();
-            ldapSession.setAttribute( SslFilter.USE_NOTIFICATION, Boolean.TRUE );
-            ldapSession.setAttribute( "HANDSHAKE_FUTURE", handshakeFuture );
-
             // for LDAPS
             if ( ( ldapSession == null ) || !connected.get() )
             {
@@ -4075,14 +4069,18 @@ public class LdapNetworkConnection extends AbstractLdapConnection
implements Lda
             else
             // for StartTLS
             {
+                HandshakeFuture handshakeFuture = new HandshakeFuture();
+                
+                ldapSession.setAttribute( SslFilter.USE_NOTIFICATION, Boolean.TRUE );
+                ldapSession.setAttribute( "HANDSHAKE_FUTURE", handshakeFuture );
                 ldapSession.getFilterChain().addFirst( SSL_FILTER_KEY, sslFilter );
-            }
 
-            boolean isSecured = handshakeFuture.get( timeout, TimeUnit.MILLISECONDS );
-            
-            if ( !isSecured )
-            {
-                throw new LdapOperationException( ResultCodeEnum.OTHER, I18n.err( I18n.ERR_4100_TLS_HANDSHAKE_ERROR
) );
+                boolean isSecured = handshakeFuture.get( timeout, TimeUnit.MILLISECONDS );
+                
+                if ( !isSecured )
+                {
+                    throw new LdapOperationException( ResultCodeEnum.OTHER, I18n.err( I18n.ERR_4100_TLS_HANDSHAKE_ERROR
) );
+                }
             }
         }
         catch ( Exception e )
@@ -4280,21 +4278,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements
Lda
         // throw immediately
         if ( config.isUseSsl() && !ldapSession.isSecured() )
         {
-            HandshakeFuture handshakeFuture =  ( HandshakeFuture ) ldapSession.getAttribute(
"HANDSHAKE_FUTURE" );
-            
-            try
-            {
-                boolean isSecured = handshakeFuture.get( timeout, TimeUnit.MILLISECONDS );
-                
-                if ( !isSecured )
-                {
-                    throw new LdapOperationException( ResultCodeEnum.OTHER, I18n.err( I18n.ERR_4100_TLS_HANDSHAKE_ERROR
) );
-                }
-            } 
-            catch ( TimeoutException | ExecutionException | InterruptedException e )
-            {
-                throw new InvalidConnectionException( e.getMessage(), e );
-            }
+            throw new InvalidConnectionException( "Attempting to send over an insecure connection"
);
         }
 
         // Send the request to the server

-- 
To stop receiving notification emails like this one, please contact
elecharny@apache.org.

Mime
View raw message