You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ud...@apache.org on 2016/09/06 17:23:42 UTC

[18/18] incubator-geode git commit: GEODE-420: Amended Tests in ConnectToLocatorSSLDUnitTest.java to new ssl config

GEODE-420: Amended Tests in ConnectToLocatorSSLDUnitTest.java to new ssl config


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/6853f56d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/6853f56d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/6853f56d

Branch: refs/heads/feature/GEODE-420
Commit: 6853f56dd74383771f0c2d19506cabea6c0591f4
Parents: d4cca87
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Wed Sep 7 03:23:01 2016 +1000
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Wed Sep 7 03:23:01 2016 +1000

----------------------------------------------------------------------
 .../internal/DistributionConfigImpl.java        | 17 ++++++++--------
 .../gemfire/internal/AbstractConfig.java        |  5 +++++
 .../internal/security/SecurableComponent.java   |  6 ++----
 .../internal/JmxManagerLocatorRequest.java      |  8 ++------
 .../gemfire/distributed/LocatorDUnitTest.java   |  1 -
 .../ConnectToLocatorSSLDUnitTest.java           | 21 +++++++++++++++++---
 6 files changed, 36 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6853f56d/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
index 1ac92d0..c86b0e7 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
@@ -26,13 +26,11 @@ import java.lang.reflect.Method;
 import java.net.InetAddress;
 import java.net.URL;
 import java.net.UnknownHostException;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.Objects;
 import java.util.Properties;
 import java.util.Set;
 
@@ -305,8 +303,10 @@ public class DistributionConfigImpl extends AbstractDistributionConfig implement
    * The client Diffie-Hellman method name
    */
   private String securityClientDHAlgo = DEFAULT_SECURITY_CLIENT_DHALGO;
-  
-  /** The udp Diffie-Hellman method name*/
+
+  /**
+   * The udp Diffie-Hellman method name
+   */
   private String securityUDPDHAlgo = DEFAULT_SECURITY_UDP_DHALGO;
 
   /**
@@ -2118,17 +2118,17 @@ public class DistributionConfigImpl extends AbstractDistributionConfig implement
   public String getSecurityClientDHAlgo() {
     return securityClientDHAlgo;
   }
-  
+
   public void setSecurityClientDHAlgo(String value) {
     securityClientDHAlgo = (String) value;
   }
-  
+
   public String getSecurityUDPDHAlgo() {
     return securityUDPDHAlgo;
   }
 
   public void setSecurityUDPDHAlgo(String value) {
-    securityUDPDHAlgo = (String)checkAttribute(SECURITY_UDP_DHALGO, value);
+    securityUDPDHAlgo = (String) checkAttribute(SECURITY_UDP_DHALGO, value);
   }
 
   public String getSecurityPeerAuthInit() {
@@ -3060,7 +3060,8 @@ public class DistributionConfigImpl extends AbstractDistributionConfig implement
   /**
    * Used by gemfire build.xml to generate a default gemfire.properties
    * for use by applications. See bug 30995 for the feature request.
-   */ public static void main(String args[]) throws IOException {
+   */
+  public static void main(String args[]) throws IOException {
     DistributionConfigImpl cfg = new DistributionConfigImpl();
     String fileName = DistributionConfig.GEMFIRE_PREFIX + "properties";
     if (args != null && args.length > 0) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6853f56d/geode-core/src/main/java/com/gemstone/gemfire/internal/AbstractConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/AbstractConfig.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/AbstractConfig.java
index 6fd4ae6..28b0cac 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/AbstractConfig.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/AbstractConfig.java
@@ -322,6 +322,11 @@ public abstract class AbstractConfig implements Config {
       return "" + value[0] + "-" + value[1];
     }
 
+    if(result.getClass().isArray() && attName.startsWith("ssl-"))
+    {
+      return SystemAdmin.join((Object[]) result,",");
+    }
+
     if (result.getClass().isArray()) {
       return SystemAdmin.join((Object[]) result);
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6853f56d/geode-core/src/main/java/com/gemstone/gemfire/internal/security/SecurableComponent.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/SecurableComponent.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/SecurableComponent.java
index f14b268..439cde5 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/SecurableComponent.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/SecurableComponent.java
@@ -39,10 +39,8 @@ public enum SecurableComponent {
 
   public static SecurableComponent getEnum(String enumString) {
     for (SecurableComponent securableComponent : SecurableComponent.values()) {
-      if (!StringUtils.isEmpty(enumString)) {
-        if (securableComponent.constant.equalsIgnoreCase(enumString)) {
-          return securableComponent;
-        }
+      if (securableComponent.constant.equalsIgnoreCase(enumString)) {
+        return securableComponent;
       }
     }
     throw new GemFireConfigException("There is no registered component for the name: " + enumString);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6853f56d/geode-core/src/main/java/com/gemstone/gemfire/management/internal/JmxManagerLocatorRequest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/JmxManagerLocatorRequest.java b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/JmxManagerLocatorRequest.java
index 39f914f..7c9e6d9 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/JmxManagerLocatorRequest.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/JmxManagerLocatorRequest.java
@@ -23,6 +23,7 @@ import java.net.InetAddress;
 import java.util.Map;
 import java.util.Properties;
 
+import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
 import com.gemstone.gemfire.distributed.internal.tcpserver.TcpClient;
 import com.gemstone.gemfire.internal.DataSerializableFixedID;
 import com.gemstone.gemfire.internal.Version;
@@ -85,12 +86,7 @@ public class JmxManagerLocatorRequest implements DataSerializableFixedID {
         distributionConfigProps.putAll(sslConfigProps);
       }
 
-      // re-initialize the SocketCreator with the sslConfigProps. Note this initializes the SocketCreator with cluster-ssl-* settings since
-      // we are connecting to the locator only.
-      //TODO Udo: Look into this
-      // SocketCreator.getDefaultInstance(distributionConfigProps);
-
-      TcpClient client = new TcpClient();
+      TcpClient client = new TcpClient(new DistributionConfigImpl(distributionConfigProps));
       Object responseFromServer = client.requestToServer(networkAddress, locatorPort, SINGLETON, msTimeout);
 
       return (JmxManagerLocatorResponse) responseFromServer;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6853f56d/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
index fc0e93b..b68841a 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
@@ -55,7 +55,6 @@ import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.logging.InternalLogWriter;
 import com.gemstone.gemfire.internal.logging.LocalLogWriter;
-import com.gemstone.gemfire.internal.net.SocketCreatorFactory;
 import com.gemstone.gemfire.internal.security.SecurableComponent;
 import com.gemstone.gemfire.internal.tcp.Connection;
 import com.gemstone.gemfire.test.dunit.DistributedTestUtils;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6853f56d/geode-core/src/test/java/com/gemstone/gemfire/management/ConnectToLocatorSSLDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/ConnectToLocatorSSLDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/ConnectToLocatorSSLDUnitTest.java
index c90e157..75a0e82 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/ConnectToLocatorSSLDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/ConnectToLocatorSSLDUnitTest.java
@@ -36,6 +36,7 @@ import org.junit.rules.TemporaryFolder;
 
 import com.gemstone.gemfire.distributed.Locator;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.security.SecurableComponent;
 import com.gemstone.gemfire.management.cli.Result.Status;
 import com.gemstone.gemfire.management.internal.cli.CliUtil;
 import com.gemstone.gemfire.management.internal.cli.HeadlessGfsh;
@@ -72,7 +73,21 @@ public class ConnectToLocatorSSLDUnitTest extends JUnit4DistributedTestCase {
   }
 
   @Test
-  public void testConnectToLocatorWithClusterSSL() throws Exception{
+  public void testConnectToLocatorWithSSL() throws Exception{
+    Properties securityProps = new Properties();
+    securityProps.setProperty(SSL_ENABLED_COMPONENTS, SecurableComponent.LOCATOR.getConstant());
+    securityProps.setProperty(SSL_KEYSTORE, jks.getCanonicalPath());
+    securityProps.setProperty(SSL_KEYSTORE_PASSWORD, "password");
+    securityProps.setProperty(SSL_KEYSTORE_TYPE, "JKS");
+    securityProps.setProperty(SSL_TRUSTSTORE, jks.getCanonicalPath());
+    securityProps.setProperty(SSL_TRUSTSTORE_PASSWORD, "password");
+    securityProps.setProperty(SSL_PROTOCOLS, "TLSv1.2 TLSv1.1");
+
+    setUpLocatorAndConnect(securityProps);
+  }
+
+  @Test
+  public void testConnectToLocatorWithLegacyClusterSSL() throws Exception{
     Properties securityProps = new Properties();
     securityProps.setProperty(CLUSTER_SSL_ENABLED, "true");
     securityProps.setProperty(CLUSTER_SSL_KEYSTORE, jks.getCanonicalPath());
@@ -85,7 +100,7 @@ public class ConnectToLocatorSSLDUnitTest extends JUnit4DistributedTestCase {
   }
 
   @Test
-  public void testConnectToLocatorWithJMXSSL() throws Exception{
+  public void testConnectToLocatorWithLegacyJMXSSL() throws Exception{
     Properties securityProps = new Properties();
     securityProps.setProperty(JMX_MANAGER_SSL_ENABLED, "true");
     securityProps.setProperty(JMX_MANAGER_SSL_KEYSTORE, jks.getCanonicalPath());
@@ -129,7 +144,7 @@ public class ConnectToLocatorSSLDUnitTest extends JUnit4DistributedTestCase {
 
     gfsh.executeCommand(command.toString());
     CommandResult result = (CommandResult)gfsh.getResult();
-    assertEquals(result.getStatus(), Status.OK);
+    assertEquals(Status.OK,result.getStatus());
     assertTrue(result.getContent().toString().contains("Successfully connected to"));
   }