private void validateSecurityConfig() {
   if (config.getSecurityInfo().isSecure() && securityManager == null) {
     throw new TCRuntimeException(
         "client configured as secure but was constructed without securityManager");
   }
   if (!config.getSecurityInfo().isSecure() && securityManager != null) {
     throw new TCRuntimeException(
         "client not configured as secure but was constructed with securityManager");
   }
 }
 private synchronized void openChannel(String serverHost, int serverPort)
     throws InterruptedException {
   while (!clientStopped.isSet()) {
     try {
       DSO_LOGGER.debug("Trying to open channel....");
       final char[] pw;
       if (config.getSecurityInfo().hasCredentials()) {
         Assert.assertNotNull(securityManager);
         pw =
             securityManager.getPasswordForTC(
                 config.getSecurityInfo().getUsername(), serverHost, serverPort);
       } else {
         pw = null;
       }
       this.channel.open(pw);
       DSO_LOGGER.debug("Channel open");
       break;
     } catch (final TCTimeoutException tcte) {
       CONSOLE_LOGGER.warn("Timeout connecting to server: " + tcte.getMessage());
       this.wait(5000);
     } catch (final ConnectException e) {
       CONSOLE_LOGGER.warn("Connection refused from server: " + e);
       this.wait(5000);
     } catch (final MaxConnectionsExceededException e) {
       DSO_LOGGER.fatal(e.getMessage());
       CONSOLE_LOGGER.fatal(e.getMessage());
       throw new IllegalStateException(e.getMessage(), e);
     } catch (final CommStackMismatchException e) {
       DSO_LOGGER.fatal(e.getMessage());
       CONSOLE_LOGGER.fatal(e.getMessage());
       throw new IllegalStateException(e.getMessage(), e);
     } catch (final IOException ioe) {
       CONSOLE_LOGGER.warn(
           "IOException connecting to server: "
               + serverHost
               + ":"
               + serverPort
               + ". "
               + ioe.getMessage());
       this.wait(5000);
     }
   }
 }