This is an automated email from the ASF dual-hosted git repository.

sai_boorlagadda pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 7d7361c  GEODE-4691: Gfsh command Start Locator shows inconsistent 
behavior wi… (#1478)
7d7361c is described below

commit 7d7361cd1a211ce91f8aadc52deb7e6e63f8414c
Author: Sai Boorlagadda <sai.boorlaga...@gmail.com>
AuthorDate: Fri Feb 23 06:04:38 2018 -0800

    GEODE-4691: Gfsh command Start Locator shows inconsistent behavior wi… 
(#1478)
    
    ...th auto-connecting with a Security Manager
---
 .../cli/commands/StartLocatorAcceptanceTest.java       |  9 +++++++++
 .../internal/cli/commands/StartLocatorCommand.java     | 18 ++++++++++--------
 .../geode/management/internal/cli/i18n/CliStrings.java |  6 +++---
 3 files changed, 22 insertions(+), 11 deletions(-)

diff --git 
a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StartLocatorAcceptanceTest.java
 
b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StartLocatorAcceptanceTest.java
index 2fb904f..faa80d6 100644
--- 
a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StartLocatorAcceptanceTest.java
+++ 
b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StartLocatorAcceptanceTest.java
@@ -48,4 +48,13 @@ public class StartLocatorAcceptanceTest {
     assertThat(execution.getOutputText())
         .doesNotContain("Cluster configuration service is up and running.");
   }
+
+  @Test
+  public void startLocatorWithSecurityManagerShouldNotBeConnected() throws 
Exception {
+    GfshExecution execution = GfshScript
+        .of("start locator --name=locator1 
--J=-Dgemfire.security-manager=org.apache.geode.examples.SimpleSecurityManager")
+        .execute(gfshRule);
+    assertThat(execution.getOutputText())
+        .contains("Security Manager is enabled - unable to auto-connect.");
+  }
 }
diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommand.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommand.java
index 60c8c50..7232647 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommand.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommand.java
@@ -293,10 +293,11 @@ public class StartLocatorCommand implements GfshCommand {
     // If the connect succeeds add the connected message to the result,
     // Else, ask the user to use the "connect" command to connect to the 
Locator.
     if (shouldAutoConnect(connect)) {
-      doAutoConnect(locatorHostName, locatorPort, configProperties, 
infoResultData);
+      boolean connected =
+          doAutoConnect(locatorHostName, locatorPort, configProperties, 
infoResultData);
 
       // Report on the state of the Shared Configuration service if enabled...
-      if (enableSharedConfiguration) {
+      if (enableSharedConfiguration && connected) {
         
infoResultData.addLine(ClusterConfigurationStatusRetriever.fromLocator(locatorHostName,
             locatorPort, configProperties));
       }
@@ -314,7 +315,7 @@ public class StartLocatorCommand implements GfshCommand {
     return (connect && !isConnectedAndReady());
   }
 
-  private void doAutoConnect(final String locatorHostname, final int 
locatorPort,
+  private boolean doAutoConnect(final String locatorHostname, final int 
locatorPort,
       final Properties configurationProperties, final InfoResultData 
infoResultData) {
     boolean connectSuccess = false;
     boolean jmxManagerAuthEnabled = false;
@@ -375,27 +376,28 @@ public class StartLocatorCommand implements GfshCommand {
       infoResultData.addLine("\n");
       infoResultData.addLine(responseFailureMessage);
     }
-
+    return connectSuccess;
   }
 
   private void doOnConnectionFailure(final String locatorHostName, final int 
locatorPort,
       final boolean jmxManagerAuthEnabled, final boolean jmxManagerSslEnabled,
       final InfoResultData infoResultData) {
     infoResultData.addLine("\n");
-    
infoResultData.addLine(CliStrings.format(CliStrings.START_LOCATOR__USE__0__TO__CONNECT,
-        new CommandStringBuilder(CliStrings.CONNECT)
-            .addOption(CliStrings.CONNECT__LOCATOR, locatorHostName + "[" + 
locatorPort + "]")
-            .toString()));
+    CommandStringBuilder commandUsage = new 
CommandStringBuilder(CliStrings.CONNECT)
+        .addOption(CliStrings.CONNECT__LOCATOR, locatorHostName + "[" + 
locatorPort + "]");
 
     StringBuilder message = new StringBuilder();
 
     if (jmxManagerAuthEnabled) {
+      
commandUsage.addOption(CliStrings.CONNECT__USERNAME).addOption(CliStrings.CONNECT__PASSWORD);
       message.append("Authentication");
     }
     if (jmxManagerSslEnabled) {
       message.append(jmxManagerAuthEnabled ? " and " : StringUtils.EMPTY)
           .append("SSL configuration");
     }
+    infoResultData.addLine(CliStrings.format(
+        CliStrings.START_LOCATOR__USE__0__TO__CONNECT_WITH_SECURITY, 
commandUsage.toString()));
     if (jmxManagerAuthEnabled || jmxManagerSslEnabled) {
       message.append(" required to connect to the Manager.");
       infoResultData.addLine("\n");
diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
index f24eba1..4dd045a 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
@@ -2400,9 +2400,9 @@ public class CliStrings {
   public static final String START_LOCATOR__RUN_MESSAGE = "Starting a Geode 
Locator in %1$s...";
   public static final String START_LOCATOR__CONNECT = "connect";
   public static final String START_LOCATOR__CONNECT__HELP =
-      "When connect is set to false , Gfsh does not automatically connect to 
the locator which is started using this command.";
-  public static final String START_LOCATOR__USE__0__TO__CONNECT =
-      "Please use \"{0}\" to connect Gfsh to the locator.";
+      "When connect is set to false or when locator is started with a security 
manager using --J=-Dgemfire.security-manager option, Gfsh does not 
automatically connect to the locator which is started using this command.";
+  public static final String START_LOCATOR__USE__0__TO__CONNECT_WITH_SECURITY =
+      "Security Manager is enabled - unable to auto-connect. Please use 
\"{0}\" to connect Gfsh to the locator.";
   public static final String START_LOCATOR__ENABLE__SHARED__CONFIGURATION =
       ENABLE_CLUSTER_CONFIGURATION;
   public static final String 
START_LOCATOR__ENABLE__SHARED__CONFIGURATION__HELP =

-- 
To stop receiving notification emails like this one, please contact
sai_boorlaga...@apache.org.

Reply via email to