mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Violette Roche-Montane
01.58.2014 c59d27990c62b601813ace1f8fc2c1d456503480
Fix for OPENDJ-1387 Status cmd - an exception occurred when the credentials and no-prompt options are combined.
1 files modified
81 ■■■■■ changed files
opends/src/server/org/opends/server/tools/status/StatusCli.java 81 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/status/StatusCli.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2007-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2013 ForgeRock AS
 *      Portions Copyright 2011-2014 ForgeRock AS
 */
package org.opends.server.tools.status;
@@ -313,12 +313,12 @@
      controlInfo.setConnectTimeout(argParser.getConnectTimeout());
      controlInfo.regenerateDescriptor();
      boolean authProvided = false;
      if (controlInfo.getServerDescriptor().getStatus() ==
        ServerDescriptor.ServerStatus.STARTED) {
        String bindDn;
        String bindPwd;
        if (argParser.isInteractive()) {
          ManagementContext ctx = null;
      if (controlInfo.getServerDescriptor().getStatus()
          == ServerDescriptor.ServerStatus.STARTED)
      {
        String bindDn = null;
        String bindPwd = null;
        ManagementContext mContext = null;
          // This is done because we do not need to ask the user about these
          // parameters.  If we force their presence the class
@@ -350,44 +350,53 @@
          LDAPConnectionConsoleInteraction ci =
            new LDAPConnectionConsoleInteraction(
            this, argParser.getSecureArgsList());
          try {
        try
        {
            ci.run(true, false);
          if (argParser.isInteractive())
          {
            bindDn = ci.getBindDN();
            bindPwd = ci.getBindPassword();
            LDAPManagementContextFactory factory =
              new LDAPManagementContextFactory(alwaysSSL);
            ctx = factory.getManagementContext(this, ci);
            interactiveTrustManager = ci.getTrustManager();
            controlInfo.setTrustManager(interactiveTrustManager);
            useInteractiveTrustManager = true;
          } catch (ArgumentException e) {
            println(e.getMessageObject());
            return ErrorReturnCode.USER_CANCELLED_OR_DATA_ERROR.getReturnCode();
          } catch (ClientException e) {
            println(e.getMessageObject());
            writeStatus(controlInfo);
            return ErrorReturnCode.USER_CANCELLED_OR_DATA_ERROR.getReturnCode();
          } finally {
            if (ctx != null) {
              try {
                ctx.close();
              } catch (Throwable t) {
              }
            }
          }
        } else {
          else
          {
          bindDn = argParser.getBindDN();
          bindPwd = argParser.getBindPassword();
        }
        authProvided = bindPwd != null;
        if (bindDn == null) {
          bindDn = "";
          LDAPManagementContextFactory factory =
              new LDAPManagementContextFactory(alwaysSSL);
          mContext = factory.getManagementContext(this, ci);
          interactiveTrustManager = ci.getTrustManager();
          controlInfo.setTrustManager(interactiveTrustManager);
          useInteractiveTrustManager = true;
          authProvided = true;
        }
        if (bindPwd == null) {
          bindPwd = "";
        catch (ArgumentException e)
        {
          println(e.getMessageObject());
          return ErrorReturnCode.USER_CANCELLED_OR_DATA_ERROR.getReturnCode();
        }
        catch (ClientException e)
        {
          println(e.getMessageObject());
          writeStatus(controlInfo);
          return ErrorReturnCode.USER_CANCELLED_OR_DATA_ERROR.getReturnCode();
        }
        finally
        {
          if (mContext != null)
          {
            try
            {
              mContext.close();
            }
            catch (Throwable t)
            {
              // Nothing to do.
            }
          }
        }
        if (authProvided) {