This is an automated email from the ASF dual-hosted git repository. bschuchardt pushed a commit to branch feature/GEODE-5085 in repository https://gitbox.apache.org/repos/asf/geode.git
commit 75ccfede2e559596cd6e0aedcf4b7e181e954920 Author: Bruce Schuchardt <bschucha...@pivotal.io> AuthorDate: Mon Apr 16 15:04:12 2018 -0700 GEODE-5085 authentication failure when auto-reconnecting Added DistributionConfig security properties to the props used to reconnect to the distributed system. Modified the getSecurityProps implementation to stop sharing the internal state of the configuration object and to convert values into external form. Security-log-level, for instance, was a number instead of the corresponding level name. Added a security manager to all of the ReconnectDUnitTest test cases. --- .../distributed/internal/DistributionConfigImpl.java | 11 ++++++++++- .../distributed/internal/InternalDistributedSystem.java | 2 ++ .../org/apache/geode/cache30/ReconnectDUnitTest.java | 12 +++++++++--- .../test/dunit/internal/JUnit4DistributedTestCase.java | 17 +++++++++++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java index 516140f..e146c05 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java @@ -2337,8 +2337,17 @@ public class DistributionConfigImpl extends AbstractDistributionConfig implement securityPeerMembershipTimeout = (Integer) value; } + @Override public Properties getSecurityProps() { - return security; + Properties result = new Properties(); + for (Object attName : security.keySet()) { + if (attName instanceof String) { + result.put(attName, getAttribute((String) attName)); + } else { + result.put(attName, security.get(attName)); + } + } + return result; } public String getSecurity(String attName) { diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java index 5d47d00..371c556 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java @@ -2610,6 +2610,8 @@ public class InternalDistributedSystem extends DistributedSystem DistributionConfig oldConfig = ids.getConfig(); Properties configProps = getProperties(); + configProps.putAll(getSecurityProperties()); + int timeOut = oldConfig.getMaxWaitTimeForReconnect(); int maxTries = oldConfig.getMaxNumReconnectTries(); diff --git a/geode-core/src/test/java/org/apache/geode/cache30/ReconnectDUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache30/ReconnectDUnitTest.java index e36dabb..f16bf4b 100755 --- a/geode-core/src/test/java/org/apache/geode/cache30/ReconnectDUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/cache30/ReconnectDUnitTest.java @@ -46,6 +46,7 @@ import org.apache.geode.distributed.internal.ServerLocator; import org.apache.geode.distributed.internal.membership.InternalDistributedMember; import org.apache.geode.distributed.internal.membership.gms.MembershipManagerHelper; import org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipManager; +import org.apache.geode.examples.SimpleSecurityManager; import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.AvailablePortHelper; import org.apache.geode.internal.cache.GemFireCacheImpl; @@ -111,7 +112,7 @@ public class ReconnectDUnitTest extends JUnit4CacheTestCase { finishCacheXml("MyDisconnect"); // Cache cache = getCache(); closeCache(); - getSystem().disconnect(); + basicGetSystem().disconnect(); LogWriterUtils.getLogWriter().fine("Cache Closed "); } @@ -127,6 +128,9 @@ public class ReconnectDUnitTest extends JUnit4CacheTestCase { dsProperties.put(MCAST_PORT, "0"); dsProperties.put(MEMBER_TIMEOUT, "1000"); dsProperties.put(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel()); + dsProperties.put(SECURITY_MANAGER, SimpleSecurityManager.class.getName()); + dsProperties.put("security-username", "clusterManage"); + dsProperties.put("security-password", "clusterManage"); addDSProps(dsProperties); } return dsProperties; @@ -632,7 +636,7 @@ public class ReconnectDUnitTest extends JUnit4CacheTestCase { Assert.fail("IOException during cache.xml generation to " + file, ex); } closeCache(); - getSystem().disconnect(); + basicGetSystem().disconnect(); LogWriterUtils.getLogWriter().info("disconnected from the system..."); Host host = Host.getHost(0); @@ -644,7 +648,9 @@ public class ReconnectDUnitTest extends JUnit4CacheTestCase { SerializableRunnable roleLoss = new CacheSerializableRunnable("ROLERECONNECTTESTS") { public void run2() throws RuntimeException { LogWriterUtils.getLogWriter().info("####### STARTING THE REAL TEST ##########"); + locatorPort = locPort; + dsProperties = null; Properties props = getDistributedSystemProperties(); props.put(CACHE_XML_FILE, xmlFileLoc + fileSeparator + "RoleReconnect-cache.xml"); props.put(MAX_WAIT_TIME_RECONNECT, "200"); @@ -660,7 +666,7 @@ public class ReconnectDUnitTest extends JUnit4CacheTestCase { basicGetSystem().getLogWriter().info( "<ExpectedException action=add>" + "CacheClosedException" + "</ExpectedException"); try { - getCache(); + getCache(props); throw new RuntimeException("The test should throw a CancelException "); } catch (CancelException ignor) { // can be caused by role loss during intialization. LogWriterUtils.getLogWriter().info("Got Expected CancelException "); diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/internal/JUnit4DistributedTestCase.java b/geode-core/src/test/java/org/apache/geode/test/dunit/internal/JUnit4DistributedTestCase.java index 5b38fdb..baf104c 100644 --- a/geode-core/src/test/java/org/apache/geode/test/dunit/internal/JUnit4DistributedTestCase.java +++ b/geode-core/src/test/java/org/apache/geode/test/dunit/internal/JUnit4DistributedTestCase.java @@ -219,6 +219,23 @@ public abstract class JUnit4DistributedTestCase implements DistributedTestFixtur Properties activeProps = system.getProperties(); for (Entry<Object, Object> entry : props.entrySet()) { String key = (String) entry.getKey(); + if (key.startsWith("security-")) { + continue; + } + String value = (String) entry.getValue(); + if (!value.equals(activeProps.getProperty(key))) { + needNewSystem = true; + getLogWriter().info("Forcing DS disconnect. For property " + key + " old value = " + + activeProps.getProperty(key) + " new value = " + value); + break; + } + } + activeProps = system.getSecurityProperties(); + for (Entry<Object, Object> entry : props.entrySet()) { + String key = (String) entry.getKey(); + if (!key.startsWith("security-")) { + continue; + } String value = (String) entry.getValue(); if (!value.equals(activeProps.getProperty(key))) { needNewSystem = true; -- To stop receiving notification emails like this one, please contact bschucha...@apache.org.