You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2017/01/13 18:09:18 UTC

svn commit: r1778644 - /directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java

Author: elecharny
Date: Fri Jan 13 18:09:18 2017
New Revision: 1778644

URL: http://svn.apache.org/viewvc?rev=1778644&view=rev
Log:
o Added a isSecured() method
o Always try to connect for each operation if we weren't connected before

Modified:
    directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java

Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=1778644&r1=1778643&r2=1778644&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java Fri Jan 13 18:09:18 2017
@@ -464,6 +464,17 @@ public class LdapNetworkConnection exten
 
 
     /**
+     * Tells if the connection is using a secured channel
+     * 
+     * @return <tt>true</tt> if the session is using a secured channel
+     */
+    public boolean isSecured()
+    {
+        return isConnected() && ldapSession.isSecured();
+    }
+
+
+    /**
      * Check that a session is valid, ie we can send requests to the
      * server
      *
@@ -1023,6 +1034,9 @@ public class LdapNetworkConnection exten
             throw new IllegalArgumentException( msg );
         }
 
+        // try to connect, if we aren't already connected.
+        connect();
+
         checkSession();
 
         int newId = messageId.incrementAndGet();
@@ -1800,6 +1814,9 @@ public class LdapNetworkConnection exten
             throw new IllegalArgumentException( msg );
         }
 
+        // try to connect, if we aren't already connected.
+        connect();
+
         // If the session has not been establish, or is closed, we get out immediately
         checkSession();
 
@@ -2482,6 +2499,9 @@ public class LdapNetworkConnection exten
             throw new IllegalArgumentException( msg );
         }
 
+        // try to connect, if we aren't already connected.
+        connect();
+
         checkSession();
 
         int newId = messageId.incrementAndGet();
@@ -2811,6 +2831,9 @@ public class LdapNetworkConnection exten
             throw new IllegalArgumentException( msg );
         }
 
+        // try to connect, if we aren't already connected.
+        connect();
+
         checkSession();
 
         int newId = messageId.incrementAndGet();
@@ -2997,6 +3020,9 @@ public class LdapNetworkConnection exten
             throw new IllegalArgumentException( msg );
         }
 
+        // try to connect, if we aren't already connected.
+        connect();
+
         checkSession();
 
         int newId = messageId.incrementAndGet();
@@ -3180,6 +3206,9 @@ public class LdapNetworkConnection exten
             LOG.debug( msg );
             throw new IllegalArgumentException( msg );
         }
+        
+        // try to connect, if we aren't already connected.
+        connect();
 
         checkSession();
 
@@ -3328,6 +3357,9 @@ public class LdapNetworkConnection exten
             throw new IllegalArgumentException( msg );
         }
 
+        // try to connect, if we aren't already connected.
+        connect();
+
         checkSession();
 
         int newId = messageId.incrementAndGet();
@@ -3927,9 +3959,13 @@ public class LdapNetworkConnection exten
                 throw new LdapException( "Cannot use TLS when the useSsl flag is set true in the configuration" );
             }
 
+            // try to connect, if we aren't already connected.
+            connect();
+
             checkSession();
 
             IoFilter sslFilter = ldapSession.getFilterChain().get( SSL_FILTER_KEY );
+            
             if ( sslFilter != null )
             {
                 LOG.debug( "LDAP session already using startTLS" );