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

Gaetan Boismal
25.54.2016 7d245e6153d15095240d414f2e487a50d62a9580
OPENDJ-2701 Fix status tool

Allow an anonymous user to access basic server status if the command has
been ran in non interactive mode (-n option).
2 files modified
30 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java 4 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java 26 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java
@@ -98,6 +98,8 @@
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  private static final boolean ALLOW_ANONYMOUS_IF_NON_INTERACTIVE = true;
  private boolean displayMustAuthenticateLegend;
  private boolean displayMustStartLegend;
@@ -287,7 +289,7 @@
      // and if none of them can be used we will just not ask for the
      // protocol to be used.
      final LDAPConnectionConsoleInteraction ci =
          new LDAPConnectionConsoleInteraction(this, argParser.getSecureArgsList());
          new LDAPConnectionConsoleInteraction(this, argParser.getSecureArgsList(), ALLOW_ANONYMOUS_IF_NON_INTERACTIVE);
      try
      {
        ci.run(false);
opendj-server-legacy/src/main/java/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
@@ -77,6 +77,7 @@
  private static final boolean ALLOW_EMPTY_PATH = true;
  private static final boolean FILE_MUST_EXISTS = true;
  private boolean allowAnonymousIfNonInteractive;
  /**
   * Information from the latest console interaction.
@@ -280,7 +281,7 @@
  }
  /**
   * Constructs a parameterized instance.
   * Constructs a new console interaction.
   *
   * @param app
   *          console application
@@ -290,9 +291,28 @@
   */
  public LDAPConnectionConsoleInteraction(ConsoleApplication app, SecureConnectionCliArgs secureArgs)
  {
    this(app, secureArgs, false);
  }
  /**
   * Constructs a new console interaction.
   *
   * @param app
   *          console application
   * @param secureArgs
   *          existing set of arguments that have already been parsed and
   *          contain some potential command line specified LDAP arguments
   * @param allowAnonymousIfNonInteractive
   *          If this console interaction should allow anonymous user in non interactive mode.
   *          If console application is interactive, the user will always be prompted for credentials.
   */
  public LDAPConnectionConsoleInteraction(
      ConsoleApplication app, SecureConnectionCliArgs secureArgs, final boolean allowAnonymousIfNonInteractive)
  {
    this.app = app;
    this.secureArgsList = secureArgs;
    this.commandBuilder = new CommandBuilder();
    this.allowAnonymousIfNonInteractive = allowAnonymousIfNonInteractive;
    state = new State(secureArgs);
    copySecureArgsList = new SecureConnectionCliArgs(secureArgs.alwaysSSL());
    try
@@ -641,6 +661,10 @@
  {
    if (!app.isInteractive())
    {
      if (allowAnonymousIfNonInteractive)
      {
        return;
      }
      throw new ArgumentException(ERR_ERROR_BIND_PASSWORD_NONINTERACTIVE.get());
    }
    checkHeadingDisplayed();