src/com/netscape/admin/dirserv/DSUtil.java | 58 ++++++++++++++++------------- 1 file changed, 33 insertions(+), 25 deletions(-)
New commits: commit fea27bc7a2a07d50b22ac26de6eabc055fa4b973 Author: Mark Reynolds mreynolds@redhat.com Date: Thu Aug 28 17:14:11 2014 -0400
Ticket 176 - DS Console should timeout when mismatched port and protocol combination is chosen
Bug Description: In the replication agreement wizard, if the SSL port is supplied, but the connection protocol is set to LDAP, the console will hang indefinitely trying to authenticate over that connection.
Fix Description: Add timeouts to the authentication operations. Also added a connection timeout.
https://fedorahosted.org/389/ticket/176
Reviewed by: nhosoi & rmeggins(Thanks!!)
diff --git a/src/com/netscape/admin/dirserv/DSUtil.java b/src/com/netscape/admin/dirserv/DSUtil.java index 1b497f9..5300569 100644 --- a/src/com/netscape/admin/dirserv/DSUtil.java +++ b/src/com/netscape/admin/dirserv/DSUtil.java @@ -168,9 +168,11 @@ public class DSUtil { status = reauthenticate(ldc, frame, listeners, authDN); } else { try { - oldDN = ldc.getAuthenticationDN(); - oldPwd = ldc.getAuthenticationPassword(); - ldc.authenticate( 3, authDN, authPassword ); + LDAPConstraints timeout = new LDAPConstraints(); + timeout.setTimeLimit(_authTimeout); + oldDN = ldc.getAuthenticationDN(); + oldPwd = ldc.getAuthenticationPassword(); + ldc.authenticate( 3, authDN, authPassword, timeout ); } catch ( LDAPException e ) { Debug.println("DSUtil.reauthenticate: " + authDN + " " + authPassword + " " + e); @@ -338,6 +340,8 @@ public class DSUtil { dlg.getUsername() + " oldname=" + oldUid);
if ( !dlg.isCancel() ) { + LDAPConstraints timeout = new LDAPConstraints(); + timeout.setTimeLimit(_authTimeout); _authName = dlg.getUsername(); String password = dlg.getPassword(); boolean done = false; @@ -345,7 +349,7 @@ public class DSUtil { while (!done && (tries < 2)) { try { tries++; - ldc.authenticate( 3, _authName, password ); + ldc.authenticate( 3, _authName, password, timeout ); setDefaultReferralCredentials( ldc ); Debug.println(9, "DSUtil.getNewAuthentication: new " + "credentials are <" + _authName + "> <" + @@ -381,7 +385,7 @@ public class DSUtil { // reset the old uid/password, if necessary try { if ( ldc.isConnected() ) - ldc.authenticate( 3, oldUid, oldPwd ); + ldc.authenticate( 3, oldUid, oldPwd, timeout ); } catch (LDAPException lde) { // do nothing } @@ -481,37 +485,39 @@ public class DSUtil { * @throws LDAPException on any failure */ public static LDAPConnection getLDAPConnection( String host, int port, - String authDN, - String authPassword, - boolean useSSL ) - throws LDAPException { - try { - LDAPConnection ldc = makeLDAPConnection( useSSL ); - if ( ldc == null ) { - return null; - } + String authDN, + String authPassword, + boolean useSSL ) + throws LDAPException { + try { + LDAPConnection ldc = makeLDAPConnection( useSSL ); + if ( ldc == null ) { + return null; + } Debug.println ("DSUtil: made valid conn object"); - ldc.connect(host, port); + ldc.setConnectTimeout(_connTimeout); + ldc.connect(host, port); Debug.println ("DSUtil: connection established");
if (authDN != null && !authDN.equals ("")){ - ldc.authenticate (3, authDN, authPassword ); + LDAPConstraints timeout = new LDAPConstraints(); + timeout.setTimeLimit(_authTimeout); + ldc.authenticate (3, authDN, authPassword, timeout ); Debug.println ("DSUtil: auth done"); }
Debug.println ("DSUtil: passed connect and auth"); - - setDefaultReferralCredentials( ldc ); + + setDefaultReferralCredentials( ldc );
Debug.println ("DSUtil: passed default referal");
- return ldc; - } catch ( LDAPException e ) { - Debug.println( "DSUtil.getLDAPConnection(" + host + ',' + - port + ',' + authDN + ',' + authPassword + "): " + - e ); - throw e; - } + return ldc; + } catch ( LDAPException e ) { + Debug.println( "DSUtil.getLDAPConnection(" + host + ',' + + port + ',' + authDN + ',' + authPassword + "): " + e ); + throw e; + } }
/** @@ -3230,6 +3236,8 @@ public class DSUtil { "com.netscape.management.client.ug.PickerEditorResource");
private static int _local = -1; + private static int _authTimeout = 5000; // milliseconds + private static int _connTimeout = 5; // seconds
static public final String CONFIG_BASE_DN = "cn=config"; static public final String PLUGIN_CONFIG_BASE_DN = "cn=plugins,cn=config";
389-commits@lists.fedoraproject.org