You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ji...@apache.org on 2016/04/12 23:16:39 UTC
[14/18] incubator-geode git commit: temp change
temp change
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/8c0532de
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/8c0532de
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/8c0532de
Branch: refs/heads/feature/GEODE-17-2
Commit: 8c0532dedf484069ef3a53a33db2864a29ef5cba
Parents: 7ec4bad
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Tue Apr 12 07:57:11 2016 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Tue Apr 12 07:57:11 2016 -0700
----------------------------------------------------------------------
.../internal/cli/commands/ShellCommands.java | 8 ++++---
.../cli/commands/CliCommandTestBase.java | 24 +++++++++++++++++---
.../ConfigCommandsSecurityDunitTest.java | 22 ++++++++++++++++++
3 files changed, 48 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8c0532de/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java
index f5e104c..0147d70 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java
@@ -194,7 +194,9 @@ public class ShellCommands implements CommandMarker {
} else if (useHttp) {
Gfsh gemfireShell = getGfsh();
try{
-
+
+ Map<String,String> securityProperties = new HashMap<String, String>();
+
if (userName != null && userName.length() > 0) {
if (passwordToUse == null || passwordToUse.length() == 0) {
passwordToUse = gemfireShell.readWithMask("http password: ", '*');
@@ -202,6 +204,8 @@ public class ShellCommands implements CommandMarker {
if (passwordToUse == null || passwordToUse.length() == 0) {
throw new IllegalArgumentException(CliStrings.CONNECT__MSG__JMX_PASSWORD_MUST_BE_SPECIFIED);
}
+ securityProperties.put("security-username", userName);
+ securityProperties.put("security-password", passwordToUse);
}
final Map<String, String> sslConfigProps = this.readSSLConfiguration(useSsl, keystoreToUse,keystorePasswordToUse,
@@ -214,8 +218,6 @@ public class ShellCommands implements CommandMarker {
}
}
- Map<String,String> securityProperties = new HashMap<String, String>();
-
Iterator<String> it = sslConfigProps.keySet().iterator();
while(it.hasNext()){
String secKey = it.next();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8c0532de/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
index 89069b4..21f9704 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
@@ -28,11 +28,12 @@ import com.gemstone.gemfire.management.internal.cli.parser.CommandTarget;
import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
import com.gemstone.gemfire.management.internal.cli.shell.Gfsh;
import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
+import com.gemstone.gemfire.management.internal.security.JSONAuthorization;
import com.gemstone.gemfire.test.dunit.Host;
import com.gemstone.gemfire.test.dunit.LogWriterUtils;
import com.gemstone.gemfire.test.dunit.SerializableCallable;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
-
+import org.json.JSONException;
import util.TestException;
import java.io.IOException;
@@ -59,7 +60,7 @@ public abstract class CliCommandTestBase extends CacheTestCase {
private transient HeadlessGfsh shell;
- private boolean useHttpOnConnect = Boolean.getBoolean("useHTTP");
+ private boolean useHttpOnConnect = true;
private int httpPort;
private int jmxPort;
@@ -91,7 +92,7 @@ public abstract class CliCommandTestBase extends CacheTestCase {
* @return the default testable GemFire shell.
*/
@SuppressWarnings("serial")
- protected final HeadlessGfsh createDefaultSetup(final Properties props) {
+ protected HeadlessGfsh createDefaultSetup( Properties props) {
Object[] result = (Object[]) Host.getHost(0).getVM(0).invoke(new SerializableCallable() {
public Object call() {
final Object[] result = new Object[3];
@@ -118,6 +119,21 @@ public abstract class CliCommandTestBase extends CacheTestCase {
localProps.setProperty(DistributionConfig.JMX_MANAGER_PORT_NAME, String.valueOf(jmxPort));
localProps.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(httpPort));
+ if(localProps.getProperty("jsonFile")!=null){
+ localProps.put(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME,
+ JSONAuthorization.class.getName() + ".create");
+ localProps.put(DistributionConfig.SECURITY_CLIENT_ACCESSOR_NAME, JSONAuthorization.class.getName() + ".create");
+
+ try {
+ JSONAuthorization.setUpWithJsonFile(localProps.getProperty("jsonFile"));
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ localProps.remove("jsonFile");
+ }
+
getSystem(localProps);
verifyManagementServiceStarted(getCache());
@@ -228,6 +244,8 @@ public abstract class CliCommandTestBase extends CacheTestCase {
endpoint = "http://" + host + ":" + httpPort + "/gemfire/v1";
command.addOption(CliStrings.CONNECT__USE_HTTP, Boolean.TRUE.toString());
command.addOption(CliStrings.CONNECT__URL, endpoint);
+ command.addOption(CliStrings.CONNECT__USERNAME, "super-user");
+ command.addOption(CliStrings.CONNECT__PASSWORD, "1234567");
} else {
endpoint = host + "[" + jmxPort + "]";
command.addOption(CliStrings.CONNECT__JMX_MANAGER, endpoint);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8c0532de/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ConfigCommandsSecurityDunitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ConfigCommandsSecurityDunitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ConfigCommandsSecurityDunitTest.java
new file mode 100644
index 0000000..db0e4b7
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ConfigCommandsSecurityDunitTest.java
@@ -0,0 +1,22 @@
+package com.gemstone.gemfire.management.internal.cli.commands;
+
+import com.gemstone.gemfire.management.internal.cli.HeadlessGfsh;
+
+import java.util.Properties;
+
+public class ConfigCommandsSecurityDunitTest extends ConfigCommandsDUnitTest {
+
+ public ConfigCommandsSecurityDunitTest(String name) {
+ super(name);
+ }
+
+ protected HeadlessGfsh createDefaultSetup(Properties props){
+ if (props==null) {
+ props = new Properties();
+ }
+ props.put("jsonFile", "cacheServer.json");
+
+
+ return super.createDefaultSetup(props);
+ }
+}