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

jvergara
15.24.2008 0e3e85c1e7f2b457c46174c74bd112499d4dcdde
Fix for issue 2886 (Cannot get status from running server without authenticating)

The code has been modified (with no new arguments) in order to work in a best-effort mode. If the user does not provide authentication we will display the same information independently of whether the server is running or not. We still display the messages informing that authentication is required to display some monitoring data.

The status panel code has also been updated to have the same behavior.

However it will be required anyhow to provide authentication to display monitoring information since this information is available only through LDAP.

In addition to this changes the following issues have been fixed:

1. Close the ManagementContext created by the LDAPConsoleInteraction object so that we have only one open connection to the server.
2. Fix a bug when the user chose to accept automatically certificates (the default trust manager was used in this case and we could not connect).
5 files modified
97 ■■■■ changed files
opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java 16 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/statuspanel/ServerStatusPooler.java 9 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java 62 ●●●● patch | view | raw | blame | history
opends/src/messages/messages/admin_tool.properties 8 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java 2 ●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java
@@ -223,6 +223,22 @@
      {
        errorMessage = ERR_READING_CONFIG_LDAP.get(detail);
      }
      /*
       *  Display the information that we find in the off line configuration.
       */
      if (listeners.isEmpty())
      {
        listeners.addAll(offlineConf.getListeners());
      }
      if (databases.isEmpty())
      {
        databases.addAll(offlineConf.getDatabases());
      }
      if (administrativeUsers.isEmpty())
      {
        administrativeUsers.addAll(offlineConf.getAdministrativeUsers());
      }
    }
    catch (Throwable t)
    {
opends/src/guitools/org/opends/guitools/statuspanel/ServerStatusPooler.java
@@ -338,20 +338,17 @@
      {
        if ((dn == null) || (pwd == null))
        {
          desc.setAdministrativeUsers(new HashSet<String>());
          desc.setDatabases(new HashSet<DatabaseDescriptor>());
          desc.setListeners(new HashSet<ListenerDescriptor>());
          desc.setOpenConnections(-1);
          updateDescriptorWithOffLineInfo(desc);
        }
        else
        {
          updateDescriptorWithOnLineInfo(desc);
        }
      }
      catch (Exception ex)
      catch (Throwable t)
      {
        // Bug
        ex.printStackTrace();
        t.printStackTrace();
      }
    }
opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java
@@ -50,6 +50,7 @@
import static org.opends.quicksetup.util.Utils.*;
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode;
import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
import org.opends.server.core.DirectoryServer;
@@ -91,6 +92,8 @@
  private TrustManager interactiveTrustManager;
  private boolean useInteractiveTrustManager;
  /**
   * The enumeration containing the different return codes that the command-line
   * can have.
@@ -313,6 +316,7 @@
       */
      ConfigFromFile offLineConf = new ConfigFromFile();
      offLineConf.readConfiguration();
      boolean authProvided = false;
      try
      {
        if (isServerRunning)
@@ -323,6 +327,8 @@
          boolean useStartTLS = argParser.useStartTLS();
          if (argParser.isInteractive())
          {
            ManagementContext ctx = null;
            boolean canUseSSL = offLineConf.getLDAPSURL() != null;
            boolean canUseStartTLS = offLineConf.getStartTLSURL() != null;
            // This is done because we do not need to ask the user about these
@@ -388,8 +394,9 @@
              }
              LDAPManagementContextFactory factory =
                new LDAPManagementContextFactory();
              factory.getManagementContext(this, ci);
              ctx = factory.getManagementContext(this, ci);
              interactiveTrustManager = ci.getTrustManager();
              useInteractiveTrustManager = true;
            }
            catch (ConfigException ce)
            {
@@ -407,14 +414,35 @@
            }
            catch (ClientException e) {
              println(e.getMessageObject());
              // Display the information in the config file
              ServerStatusDescriptor desc = createServerStatusDescriptor(null,
                  null);
              updateDescriptorWithOffLineInfo(desc, offLineConf);
              writeStatus(desc);
              return
                ErrorReturnCode.USER_CANCELLED_OR_DATA_ERROR.getReturnCode();
            }
            finally
            {
              if (ctx != null)
              {
                try
                {
                  ctx.close();
                }
                catch (Throwable t)
                {
                }
              }
            }
          }
          else
          {
            bindDn = argParser.getBindDN();
            bindPwd = argParser.getBindPassword();
          }
          authProvided = bindPwd != null;
            if (bindDn == null)
            {
@@ -424,7 +452,9 @@
            {
              bindPwd = "";
            }
          }
          if (authProvided)
          {
          ServerStatusDescriptor desc = createServerStatusDescriptor(
              bindDn, bindPwd);
          ConfigFromLDAP onLineConf = new ConfigFromLDAP();
@@ -444,6 +474,16 @@
        }
        else
        {
            // The user did not provide authentication: just display the
            // information we can get reading the config file.
            ServerStatusDescriptor desc = createServerStatusDescriptor(null,
                null);
            updateDescriptorWithOffLineInfo(desc, offLineConf);
            writeStatus(desc);
          }
        }
        else
        {
          ServerStatusDescriptor desc = createServerStatusDescriptor(null,
              null);
          updateDescriptorWithOffLineInfo(desc, offLineConf);
@@ -647,7 +687,7 @@
      }
      else
      {
        if (!desc.isAuthenticated())
        if (!desc.isAuthenticated() || (desc.getErrorMessage() != null))
        {
          text = getNotAvailableBecauseAuthenticationIsRequiredText();
        }
@@ -714,7 +754,7 @@
    {
      if (desc.getStatus() == ServerStatusDescriptor.ServerStatus.STARTED)
      {
        if (!desc.isAuthenticated())
        if (!desc.isAuthenticated() || (desc.getErrorMessage() != null))
        {
          text = getNotAvailableBecauseAuthenticationIsRequiredText();
        }
@@ -778,7 +818,7 @@
      text = Message.raw(desc.getJavaVersion());
      if (text == null)
      {
        if (!desc.isAuthenticated())
        if (!desc.isAuthenticated() || (desc.getErrorMessage() != null))
        {
          text = getNotAvailableBecauseAuthenticationIsRequiredText();
        }
@@ -1006,7 +1046,7 @@
        }
        else
        {
          if (!desc.isAuthenticated())
          if (!desc.isAuthenticated() || (desc.getErrorMessage() != null))
          {
            s = getNotAvailableBecauseAuthenticationIsRequiredText();
          }
@@ -1101,7 +1141,7 @@
              {
                value = getNotAvailableBecauseServerIsDownText();
              }
              if (!desc.isAuthenticated())
              if (!desc.isAuthenticated() || (desc.getErrorMessage() != null))
              {
                value = getNotAvailableBecauseAuthenticationIsRequiredText();
              }
@@ -1127,7 +1167,7 @@
          {
            value = getNotAvailableBecauseServerIsDownText();
          }
          if (!desc.isAuthenticated())
          if (!desc.isAuthenticated() || (desc.getErrorMessage() != null))
          {
            value = getNotAvailableBecauseAuthenticationIsRequiredText();
          }
@@ -1193,13 +1233,13 @@
   */
  private TrustManager getTrustManager()
  {
    if (interactiveTrustManager == null)
    if (useInteractiveTrustManager)
    {
      return argParser.getTrustManager();
      return interactiveTrustManager;
    }
    else
    {
      return interactiveTrustManager;
      return argParser.getTrustManager();
    }
  }
opends/src/messages/messages/admin_tool.properties
@@ -233,14 +233,14 @@
INFO_NOT_AVAILABLE_AUTHENTICATION_REQUIRED_CLI_LABEL=<not available> (*)
INFO_NOT_AVAILABLE_SHORT_LABEL=N/A
INFO_NOT_AVAILABLE_AUTHENTICATION_REQUIRED_CLI_LEGEND=* Information only \
 available if you provide authentication information when launching the status \
 command.
 available if you provide valid authentication information when launching the \
 status command.
INFO_NOT_AVAILABLE_AUTHENTICATION_REQUIRED_TOOLTIP=<html>Information is only \
 available if you are authenticated<br>as an administrative user.
INFO_NOT_AVAILABLE_SERVER_DOWN_CLI_LABEL=<not available> (*)
INFO_NOT_AVAILABLE_SERVER_DOWN_CLI_LEGEND=* Information only available if \
 server is running and you provide authentication information when launching \
 the status command.
 server is running and you provide valid authentication information when \
 launching the status command.
INFO_NOT_AVAILABLE_SERVER_DOWN_TOOLTIP=<html>Information is only available if \
 server is running and you are authenticated<br>as an administrative user.
INFO_NOTHING_SELECTED_TO_UNINSTALL=You must select something to be \
opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -2213,8 +2213,8 @@
      if ((isADS || isSchema) && isVerbose())
      {
        notifyListeners(getFormattedDone());
      }
      notifyListeners(getLineBreak());
      }
      checkAbort();
    }
  }