geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [11/11] geode git commit: GEODE-2632: use immutable SecurityService impls to improve performance
Date Fri, 09 Jun 2017 17:17:36 GMT
GEODE-2632: use immutable SecurityService impls to improve performance

* misc code clean up in classes touched by changes
* new unit tests for SecurityService


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

Branch: refs/heads/develop
Commit: 0211029baf497bbcca2670dbabe610d84bc626a5
Parents: 3f12fd4
Author: Kirk Lund <klund@apache.org>
Authored: Wed May 31 16:13:20 2017 -0700
Committer: Kirk Lund <klund@apache.org>
Committed: Fri Jun 9 10:17:12 2017 -0700

----------------------------------------------------------------------
 .../RestAPIsAndInterOpsDUnitTest.java           | 846 ++++++++-----------
 .../org/apache/geode/cache/CacheFactory.java    |  46 +-
 .../geode/cache/client/ClientCacheFactory.java  |   4 +-
 .../geode/distributed/LocatorLauncher.java      |   1 -
 .../geode/distributed/ServerLauncher.java       |   1 -
 .../internal/DistributionManager.java           |   4 +-
 .../internal/InternalDistributedSystem.java     |  53 +-
 .../distributed/internal/SecurityConfig.java    |  51 ++
 .../internal/membership/MemberFactory.java      |  16 +-
 .../internal/membership/MemberServices.java     |   4 +-
 .../membership/gms/GMSMemberFactory.java        |  11 +-
 .../internal/membership/gms/Services.java       | 127 +--
 .../membership/gms/auth/GMSAuthenticator.java   |  41 +-
 .../apache/geode/internal/ClassLoadUtil.java    |  75 +-
 .../internal/cache/AbstractLRURegionMap.java    |   1 -
 .../geode/internal/cache/CacheServerImpl.java   |   4 +
 .../geode/internal/cache/DiskStoreImpl.java     |   1 -
 .../geode/internal/cache/GemFireCacheImpl.java  |  36 +-
 .../geode/internal/cache/InternalCache.java     |   3 +
 .../cache/PartitionedRegionDataStore.java       |   2 -
 .../cache/partitioned/FetchEntriesMessage.java  |  45 +-
 .../geode/internal/cache/tier/Command.java      |   4 +-
 .../cache/tier/sockets/AcceptorImpl.java        |  80 +-
 .../cache/tier/sockets/BaseCommand.java         |  52 +-
 .../cache/tier/sockets/BaseCommandQuery.java    |  64 +-
 .../cache/tier/sockets/CacheClientNotifier.java |  47 +-
 .../cache/tier/sockets/CacheClientProxy.java    |   7 +-
 .../internal/cache/tier/sockets/HandShake.java  |  43 +-
 .../cache/tier/sockets/ServerConnection.java    |  44 +-
 .../tier/sockets/ServerHandShakeProcessor.java  |  11 +-
 .../cache/tier/sockets/command/AddPdxEnum.java  |   4 +-
 .../cache/tier/sockets/command/AddPdxType.java  |   4 +-
 .../cache/tier/sockets/command/ClearRegion.java |   7 +-
 .../cache/tier/sockets/command/ClientReady.java |   5 +-
 .../tier/sockets/command/CloseConnection.java   |   5 +-
 .../tier/sockets/command/CommitCommand.java     |   8 +-
 .../cache/tier/sockets/command/ContainsKey.java |   9 +-
 .../tier/sockets/command/ContainsKey66.java     |  10 +-
 .../tier/sockets/command/CreateRegion.java      |  10 +-
 .../cache/tier/sockets/command/Default.java     |   5 +-
 .../cache/tier/sockets/command/Destroy.java     |   6 +-
 .../cache/tier/sockets/command/Destroy65.java   |   9 +-
 .../tier/sockets/command/DestroyRegion.java     |   9 +-
 .../tier/sockets/command/ExecuteFunction.java   |  62 +-
 .../tier/sockets/command/ExecuteFunction65.java |  67 +-
 .../tier/sockets/command/ExecuteFunction66.java |  83 +-
 .../tier/sockets/command/ExecuteFunction70.java |   7 +-
 .../sockets/command/ExecuteRegionFunction.java  |  66 +-
 .../command/ExecuteRegionFunction61.java        |  64 +-
 .../command/ExecuteRegionFunction65.java        |  89 +-
 .../command/ExecuteRegionFunction66.java        | 102 +--
 .../command/ExecuteRegionFunctionSingleHop.java |  90 +-
 .../sockets/command/GatewayReceiverCommand.java |   6 +-
 .../cache/tier/sockets/command/Get70.java       |   9 +-
 .../cache/tier/sockets/command/GetAll.java      |  15 +-
 .../cache/tier/sockets/command/GetAll651.java   |  17 +-
 .../cache/tier/sockets/command/GetAll70.java    |  16 +-
 .../sockets/command/GetAllWithCallback.java     |  19 +-
 .../command/GetClientPRMetadataCommand.java     |   4 +-
 .../command/GetClientPRMetadataCommand66.java   |   4 +-
 .../GetClientPartitionAttributesCommand.java    |   4 +-
 .../GetClientPartitionAttributesCommand66.java  |   4 +-
 .../sockets/command/GetFunctionAttribute.java   |   5 +-
 .../tier/sockets/command/GetPDXEnumById.java    |   4 +-
 .../tier/sockets/command/GetPDXIdForEnum.java   |   4 +-
 .../tier/sockets/command/GetPDXIdForType.java   |   4 +-
 .../tier/sockets/command/GetPDXTypeById.java    |   4 +-
 .../tier/sockets/command/GetPdxEnums70.java     |   4 +-
 .../tier/sockets/command/GetPdxTypes70.java     |   4 +-
 .../cache/tier/sockets/command/Invalid.java     |   5 +-
 .../cache/tier/sockets/command/Invalidate.java  |   9 +-
 .../cache/tier/sockets/command/KeySet.java      |   7 +-
 .../cache/tier/sockets/command/MakePrimary.java |   5 +-
 .../tier/sockets/command/ManagementCommand.java |   4 +-
 .../cache/tier/sockets/command/PeriodicAck.java |   5 +-
 .../cache/tier/sockets/command/Ping.java        |   8 +-
 .../cache/tier/sockets/command/Put.java         |  11 +-
 .../cache/tier/sockets/command/Put61.java       |  11 +-
 .../cache/tier/sockets/command/Put65.java       |   8 +-
 .../cache/tier/sockets/command/PutAll.java      |  12 +-
 .../cache/tier/sockets/command/PutAll70.java    |  13 +-
 .../cache/tier/sockets/command/PutAll80.java    |  12 +-
 .../sockets/command/PutUserCredentials.java     |   4 +-
 .../cache/tier/sockets/command/Query.java       |   7 +-
 .../cache/tier/sockets/command/Query651.java    |   7 +-
 .../command/RegisterDataSerializers.java        |   5 +-
 .../sockets/command/RegisterInstantiators.java  |   5 +-
 .../tier/sockets/command/RegisterInterest.java  |   9 +-
 .../sockets/command/RegisterInterest61.java     |  12 +-
 .../sockets/command/RegisterInterestList.java   |  27 +-
 .../sockets/command/RegisterInterestList61.java |  25 +-
 .../sockets/command/RegisterInterestList66.java |  63 +-
 .../cache/tier/sockets/command/RemoveAll.java   |  14 +-
 .../tier/sockets/command/RemoveUserAuth.java    |   4 +-
 .../cache/tier/sockets/command/Request.java     |  10 +-
 .../tier/sockets/command/RequestEventValue.java |   5 +-
 .../tier/sockets/command/RollbackCommand.java   |   4 +-
 .../cache/tier/sockets/command/Size.java        |  11 +-
 .../tier/sockets/command/TXFailoverCommand.java |   4 +-
 .../command/TXSynchronizationCommand.java       |   4 +-
 .../sockets/command/UnregisterInterest.java     |  12 +-
 .../sockets/command/UnregisterInterestList.java |   6 +-
 .../command/UpdateClientNotification.java       |  61 +-
 .../internal/cache/xmlcache/CacheCreation.java  |  56 +-
 .../internal/security/CallbackInstantiator.java |  89 ++
 .../geode/internal/security/Credentials.java    |  36 +
 .../security/CustomSecurityService.java         | 341 ++++++++
 .../security/DisabledSecurityService.java       | 206 +++++
 .../security/EnabledSecurityService.java        | 387 +++++++++
 .../security/IntegratedSecurityService.java     | 472 -----------
 .../security/LegacySecurityService.java         | 204 +++++
 .../internal/security/SecurityService.java      |  93 +-
 .../security/SecurityServiceFactory.java        | 204 +++++
 .../internal/security/SecurityServiceType.java  |  28 +
 .../security/shiro/ConfigInitializer.java       |  43 +
 .../security/shiro/CustomAuthRealm.java         |   7 +-
 .../security/shiro/JMXShiroAuthenticator.java   |  22 +-
 .../security/shiro/RealmInitializer.java        |  54 ++
 .../geode/management/cli/CommandService.java    |   3 +-
 .../management/internal/ManagementAgent.java    |  11 +-
 .../internal/SystemManagementService.java       |   2 +-
 .../CreateAlterDestroyRegionCommands.java       |   7 +-
 .../internal/cli/commands/DataCommands.java     |  53 +-
 .../internal/cli/commands/DeployCommands.java   |  21 +-
 .../internal/cli/commands/GfshCommand.java      |  19 +-
 .../internal/cli/commands/IndexCommands.java    |  40 +-
 .../cli/functions/DataCommandFunction.java      |  37 +-
 .../internal/cli/remote/CommandProcessor.java   |  12 +-
 .../cli/remote/MemberCommandService.java        |  19 +-
 .../functions/RecreateCacheFunction.java        |   4 +-
 .../internal/security/AccessControlMBean.java   |   7 +-
 .../internal/security/MBeanServerWrapper.java   |  20 +-
 .../controllers/AbstractCommandsController.java |   8 +-
 .../support/LoginHandlerInterceptor.java        |  24 +-
 .../apache/geode/security/PostProcessor.java    |   2 +-
 .../AnalyzeSerializablesJUnitTest.java          |  54 +-
 .../membership/MembershipJUnitTest.java         |  80 +-
 .../auth/AbstractGMSAuthenticatorTestCase.java  |  33 +-
 .../GMSAuthenticatorWithAuthenticatorTest.java  |  76 +-
 ...GMSAuthenticatorWithSecurityManagerTest.java |  62 +-
 .../locator/GMSLocatorRecoveryJUnitTest.java    |  70 +-
 .../cache/ha/BlockingHARegionJUnitTest.java     |   9 +-
 .../sockets/HAStartupAndFailoverDUnitTest.java  |  57 +-
 .../tier/sockets/ServerConnectionTest.java      |   7 +-
 .../tier/sockets/command/ContainsKey66Test.java |  10 +-
 .../tier/sockets/command/ContainsKeyTest.java   |  10 +-
 .../tier/sockets/command/CreateRegionTest.java  |  10 +-
 .../tier/sockets/command/Destroy65Test.java     |  10 +-
 .../tier/sockets/command/DestroyRegionTest.java |  10 +-
 .../cache/tier/sockets/command/DestroyTest.java |  10 +-
 .../sockets/command/ExecuteFunction65Test.java  |  11 +-
 .../sockets/command/ExecuteFunction66Test.java  |  16 +-
 .../sockets/command/ExecuteFunctionTest.java    |  11 +-
 .../cache/tier/sockets/command/Get70Test.java   |  10 +-
 .../tier/sockets/command/GetAll651Test.java     |  10 +-
 .../tier/sockets/command/GetAll70Test.java      |  10 +-
 .../cache/tier/sockets/command/GetAllTest.java  |  10 +-
 .../sockets/command/GetAllWithCallbackTest.java |  10 +-
 ...tClientPartitionAttributesCommand66Test.java |   3 +-
 ...GetClientPartitionAttributesCommandTest.java |   5 +-
 .../tier/sockets/command/InvalidateTest.java    |  10 +-
 .../cache/tier/sockets/command/KeySetTest.java  |  10 +-
 .../cache/tier/sockets/command/Put61Test.java   |  10 +-
 .../cache/tier/sockets/command/Put65Test.java   |  10 +-
 .../cache/tier/sockets/command/PutTest.java     |  10 +-
 .../sockets/command/RegisterInterest61Test.java |  15 +-
 .../command/RegisterInterestList61Test.java     |  15 +-
 .../command/RegisterInterestList66Test.java     |  15 +-
 .../command/RegisterInterestListTest.java       |  15 +-
 .../sockets/command/RegisterInterestTest.java   |  10 +-
 .../tier/sockets/command/RemoveAllTest.java     |  10 +-
 .../cache/tier/sockets/command/RequestTest.java |  10 +-
 .../sockets/command/UnregisterInterestTest.java |  15 +-
 .../security/CallbackInstantiatorTest.java      |  98 +++
 .../security/DisabledSecurityServiceTest.java   | 164 ++++
 .../security/EnabledSecurityServiceTest.java    | 184 ++++
 .../internal/security/FakePostProcessor.java    | 103 +++
 .../internal/security/FakeSecurityManager.java  | 103 +++
 .../security/IntegratedSecurityServiceTest.java | 222 -----
 ...urityServiceFactoryShiroIntegrationTest.java |  93 ++
 .../security/SecurityServiceFactoryTest.java    | 280 ++++++
 .../internal/security/SecurityServiceTest.java  | 136 +++
 .../shiro/ConfigInitializerIntegrationTest.java |  91 ++
 .../cli/commands/CliCommandTestBase.java        | 133 +--
 .../commands/DiskStoreCommandsDUnitTest.java    |   3 +-
 .../cli/commands/MemberCommandsDUnitTest.java   |   6 +
 .../cli/commands/QueueCommandsDUnitTest.java    |   2 +-
 .../RebalanceCommandDistributedTest.java        | 153 ++++
 .../security/AccessControlMBeanJUnitTest.java   |   1 +
 .../CacheServerMBeanShiroJUnitTest.java         | 109 ---
 ...eServerMBeanWithShiroIniIntegrationTest.java | 109 +++
 ...atedSecurityServiceCustomRealmJUnitTest.java |  44 -
 ...atedSecurityServiceWithIniFileJUnitTest.java | 152 ----
 .../security/MBeanSecurityJUnitTest.java        |   1 +
 .../security/MemberMBeanSecurityJUnitTest.java  |   1 +
 ...tyServiceWithCustomRealmIntegrationTest.java |  44 +
 ...urityServiceWithShiroIniIntegrationTest.java | 148 ++++
 .../CacheFactoryWithSecurityObjectTest.java     |  57 +-
 .../ClusterConfigWithoutSecurityDUnitTest.java  |  48 +-
 ...edSecurityCacheLifecycleIntegrationTest.java |  74 --
 .../geode/security/OtherPDXPostProcessor.java   |  18 +
 .../security/OtherSimplySecurityManager.java    |  18 +
 .../PDXGfshPostProcessorOnRemoteServerTest.java |  24 +-
 .../apache/geode/security/PDXPostProcessor.java |  28 +-
 .../security/PDXPostProcessorDUnitTest.java     | 101 +--
 .../SecurityClusterConfigDUnitTest.java         |  91 +-
 ...SecurityManagerCallbacksDistributedTest.java | 132 ---
 ...SecurityManagerLifecycleDistributedTest.java | 143 ++++
 ...SecurityManagerLifecycleIntegrationTest.java |  73 ++
 .../security/SimpleSecurityManagerTest.java     |   1 -
 .../security/SimpleTestSecurityManager.java     |  13 +-
 .../geode/security/SpySecurityManager.java      |  19 +-
 .../geode/test/dunit/DistributedTestUtils.java  |  10 +-
 .../test/dunit/rules/ServerStarterRule.java     |   8 +-
 .../java/org/apache/geode/test/fake/Fakes.java  |   3 +
 .../codeAnalysis/sanctionedSerializables.txt    |   1 +
 ...curityServiceFactoryShiroIntegrationTest.ini |  30 +
 .../shiro/ConfigInitializerIntegrationTest.ini  |  30 +
 .../cache/tier/sockets/command/CloseCQ.java     |  41 +-
 .../cache/tier/sockets/command/ExecuteCQ.java   |  35 +-
 .../cache/tier/sockets/command/ExecuteCQ61.java |  40 +-
 .../cache/tier/sockets/command/GetCQStats.java  |  25 +-
 .../tier/sockets/command/GetDurableCQs.java     |  30 +-
 .../cache/tier/sockets/command/MonitorCQ.java   |  23 +-
 .../cache/tier/sockets/command/StopCQ.java      |  35 +-
 .../security/CQPDXPostProcessorDUnitTest.java   |   2 +-
 .../security/ClientAuthzObjectModDUnitTest.java |  22 +-
 .../internal/cli/LuceneIndexCommands.java       |   8 +-
 .../cli/LuceneIndexCommandsJUnitTest.java       |  43 +-
 .../apache/geode/tools/pulse/tests/Server.java  |  43 +-
 .../tools/pulse/tests/rules/ServerRule.java     |   4 +-
 .../apache/geode/cache/util/AutoBalancer.java   |   6 +-
 .../security/GeodeAuthenticationProvider.java   |  24 +-
 .../web/security/RestSecurityConfiguration.java |   7 +-
 .../web/security/RestSecurityService.java       |  16 +-
 .../DataCommandsOverHttpDistributedTest.java    | 155 ----
 ...RebalanceCommandOverHttpDistributedTest.java |  29 +
 ...andlerInterceptorRequestHeaderJUnitTest.java |   3 +-
 238 files changed, 6221 insertions(+), 3943 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java
index 45e7a61..b127884 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/controllers/RestAPIsAndInterOpsDUnitTest.java
@@ -14,37 +14,15 @@
  */
 package org.apache.geode.rest.internal.web.controllers;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.junit.Assert.*;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_BIND_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_START;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_REST_API;
+import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.geode.cache.AttributesFactory;
 import org.apache.geode.cache.Cache;
@@ -72,6 +50,32 @@ import org.apache.geode.test.dunit.NetworkUtils;
 import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
 
 /**
  * Dunit Test containing inter - operations between REST Client and Gemfire cache client
@@ -81,10 +85,9 @@ import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactor
 @Category(DistributedTest.class)
 @RunWith(Parameterized.class)
 @Parameterized.UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
-@SuppressWarnings("serial")
 public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase {
 
-  public static final String PEOPLE_REGION_NAME = "People";
+  private static final String PEOPLE_REGION_NAME = "People";
 
   private static final String findAllPeopleQuery =
       "/queries?id=findAllPeople&q=SELECT%20*%20FROM%20/People";
@@ -96,19 +99,10 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase {
   private static final String[] PARAM_QUERY_IDS_ARRAY =
       {"findAllPeople", "filterByGender", "filterByLastName"};
 
-  final static String QUERY_ARGS =
+  private static final String QUERY_ARGS =
       "[" + "{" + "\"@type\": \"string\"," + "\"@value\": \"Patel\"" + "}" + "]";
 
-  final static String PERSON_AS_JSON_CAS = "{" + "\"@old\" :" + "{"
-      + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," + "\"id\": 101,"
-      + " \"firstName\": \"Mithali\"," + " \"middleName\": \"Dorai\"," + " \"lastName\": \"Raj\","
-      + " \"birthDate\": \"12/04/1982\"," + "\"gender\": \"FEMALE\"" + "}," + "\"@new\" :" + "{"
-      + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," + "\"id\": 1101,"
-      + " \"firstName\": \"Virat\"," + " \"middleName\": \"Premkumar\","
-      + " \"lastName\": \"Kohli\"," + " \"birthDate\": \"08/11/1988\"," + "\"gender\": \"MALE\""
-      + "}" + "}";
-
-  final static String PERSON_AS_JSON_REPLACE =
+  private static final String PERSON_AS_JSON_REPLACE =
       "{" + "\"@type\": \"org.apache.geode.rest.internal.web.controllers.Person\"," + "\"id\": 501,"
           + " \"firstName\": \"Barack\"," + " \"middleName\": \"Hussein\","
           + " \"lastName\": \"Obama\"," + " \"birthDate\": \"04/08/1961\"," + "\"gender\": \"MALE\""
@@ -155,19 +149,20 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase {
     return Arrays.asList("/geode", "/gemfire-api");
   }
 
-  public String startBridgeServerWithRestService(final String hostName, final String[] groups,
-      final String locators, final String[] regions, final ServerLoadProbe probe) {
+  private String startBridgeServerWithRestService(final String hostName, final String[] groups,
+      final String locators, final String[] regions, final ServerLoadProbe probe)
+      throws IOException {
     final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
 
     // create Cache of given VM and start HTTP service with REST APIs service
     startBridgeServer(hostName, serverPort, groups, locators, regions, probe);
 
-    return "http://" + hostName + ":" + serverPort + urlContext + "/v1";
+    return "http://" + hostName + ":" + serverPort + this.urlContext + "/v1";
   }
 
-  @SuppressWarnings("deprecation")
-  protected int startBridgeServer(String hostName, int restServicerPort, final String[] groups,
-      final String locators, final String[] regions, final ServerLoadProbe probe) {
+  private int startBridgeServer(String hostName, int restServicerPort, final String[] groups,
+      final String locators, final String[] regions, final ServerLoadProbe probe)
+      throws IOException {
 
     Properties props = new Properties();
     props.setProperty(MCAST_PORT, String.valueOf(0));
@@ -192,18 +187,15 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase {
     server.setPort(0);
     server.setGroups(groups);
     server.setLoadProbe(probe);
-    try {
-      server.start();
-    } catch (IOException e) {
-      e.printStackTrace();
-    }
+    server.start();
+
     remoteObjects.put(CACHE_KEY, cache);
-    return new Integer(server.getPort());
+    return server.getPort();
   }
 
-  public void doPutsInClientCache() {
+  private void doPutsInClientCache() {
     ClientCache cache = GemFireCacheImpl.getInstance();
-    assertNotNull(cache);
+    assertThat(cache).isNotNull();
     Region<String, Object> region = cache.getRegion(PEOPLE_REGION_NAME);
 
     // put person object
@@ -263,484 +255,351 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase {
 
     region.putAll(userMap);
 
-    if (cache != null)
-      cache.getLogger().info("Gemfire Cache Client: Puts successfully done");
-
+    cache.getLogger().info("Gemfire Cache Client: Puts successfully done");
   }
 
-  public void doQueryOpsUsingRestApis(String restEndpoint) {
-    String currentQueryOp = null;
-    try {
-      // Query TestCase-1 :: Prepare parameterized Queries
-      {
-        currentQueryOp = "findAllPeopleQuery";
-        CloseableHttpClient httpclient = HttpClients.createDefault();
-        HttpPost post = new HttpPost(restEndpoint + findAllPeopleQuery);
-        post.addHeader("Content-Type", "application/json");
-        post.addHeader("Accept", "application/json");
-        CloseableHttpResponse createNamedQueryResponse = httpclient.execute(post);
-        assertEquals(createNamedQueryResponse.getStatusLine().getStatusCode(), 201);
-        assertNotNull(createNamedQueryResponse.getEntity());
-        createNamedQueryResponse.close();
-
-        post = new HttpPost(restEndpoint + findPeopleByGenderQuery);
-        post.addHeader("Content-Type", "application/json");
-        post.addHeader("Accept", "application/json");
-        createNamedQueryResponse = httpclient.execute(post);
-        assertEquals(createNamedQueryResponse.getStatusLine().getStatusCode(), 201);
-        assertNotNull(createNamedQueryResponse.getEntity());
-        createNamedQueryResponse.close();
-
-        post = new HttpPost(restEndpoint + findPeopleByLastNameQuery);
-        post.addHeader("Content-Type", "application/json");
-        post.addHeader("Accept", "application/json");
-        createNamedQueryResponse = httpclient.execute(post);
-        assertEquals(createNamedQueryResponse.getStatusLine().getStatusCode(), 201);
-        assertNotNull(createNamedQueryResponse.getEntity());
-        createNamedQueryResponse.close();
-      }
-
-      // Query TestCase-2 :: List all parameterized queries
-      {
-        currentQueryOp = "listAllQueries";
-        HttpGet get = new HttpGet(restEndpoint + "/queries");
-        CloseableHttpClient httpclient = HttpClients.createDefault();
-        CloseableHttpResponse listAllQueriesResponse = httpclient.execute(get);
-        assertEquals(listAllQueriesResponse.getStatusLine().getStatusCode(), 200);
-        assertNotNull(listAllQueriesResponse.getEntity());
-
-        HttpEntity entity = listAllQueriesResponse.getEntity();
-        InputStream content = entity.getContent();
-        BufferedReader reader = new BufferedReader(new InputStreamReader(content));
-        String line;
-        StringBuffer sb = new StringBuffer();
-        while ((line = reader.readLine()) != null) {
-          sb.append(line);
-        }
-        listAllQueriesResponse.close();
-
-        // Check whether received response contains expected query IDs.
-
-        JSONObject jsonObject = new JSONObject(sb.toString());
-        JSONArray jsonArray = jsonObject.getJSONArray("queries");
-        for (int i = 0; i < jsonArray.length(); i++) {
-          assertTrue("PREPARE_PARAMETERIZED_QUERY: function IDs are not matched", Arrays
-              .asList(PARAM_QUERY_IDS_ARRAY).contains(jsonArray.getJSONObject(i).getString("id")));
-        }
-      }
-
-      // Query TestCase-3 :: Run the specified named query passing in scalar values for query
-      // parameters.
-      {
-        currentQueryOp = "filterByLastName";
-        CloseableHttpClient httpclient = HttpClients.createDefault();
-        HttpPost post = new HttpPost(restEndpoint + "/queries/filterByLastName");
-        post.addHeader("Content-Type", "application/json");
-        post.addHeader("Accept", "application/json");
-        StringEntity entity = new StringEntity(QUERY_ARGS);
-        post.setEntity(entity);
-        CloseableHttpResponse runNamedQueryResponse = httpclient.execute(post);
-
-        assertEquals(200, runNamedQueryResponse.getStatusLine().getStatusCode());
-        assertNotNull(runNamedQueryResponse.getEntity());
-      }
-    } catch (Exception e) {
-      throw new RuntimeException("unexpected exception", e);
+  private void doQueryOpsUsingRestApis(String restEndpoint) throws IOException {
+    // Query TestCase-1 :: Prepare parameterized Queries
+
+    CloseableHttpClient httpclient = HttpClients.createDefault();
+    HttpPost post = new HttpPost(restEndpoint + findAllPeopleQuery);
+    post.addHeader("Content-Type", "application/json");
+    post.addHeader("Accept", "application/json");
+    CloseableHttpResponse createNamedQueryResponse = httpclient.execute(post);
+    assertThat(createNamedQueryResponse.getStatusLine().getStatusCode()).isEqualTo(201);
+    assertThat(createNamedQueryResponse.getEntity()).isNotNull();
+    createNamedQueryResponse.close();
+
+    post = new HttpPost(restEndpoint + findPeopleByGenderQuery);
+    post.addHeader("Content-Type", "application/json");
+    post.addHeader("Accept", "application/json");
+    createNamedQueryResponse = httpclient.execute(post);
+    assertThat(createNamedQueryResponse.getStatusLine().getStatusCode()).isEqualTo(201);
+    assertThat(createNamedQueryResponse.getEntity()).isNotNull();
+    createNamedQueryResponse.close();
+
+    post = new HttpPost(restEndpoint + findPeopleByLastNameQuery);
+    post.addHeader("Content-Type", "application/json");
+    post.addHeader("Accept", "application/json");
+    createNamedQueryResponse = httpclient.execute(post);
+    assertThat(createNamedQueryResponse.getStatusLine().getStatusCode()).isEqualTo(201);
+    assertThat(createNamedQueryResponse.getEntity()).isNotNull();
+    createNamedQueryResponse.close();
+
+    // Query TestCase-2 :: List all parameterized queries
+
+    HttpGet get = new HttpGet(restEndpoint + "/queries");
+    httpclient = HttpClients.createDefault();
+    CloseableHttpResponse listAllQueriesResponse = httpclient.execute(get);
+    assertThat(listAllQueriesResponse.getStatusLine().getStatusCode()).isEqualTo(200);
+    assertThat(listAllQueriesResponse.getEntity()).isNotNull();
+
+    HttpEntity entity = listAllQueriesResponse.getEntity();
+    InputStream content = entity.getContent();
+    BufferedReader reader = new BufferedReader(new InputStreamReader(content));
+    String line;
+    StringBuilder sb = new StringBuilder();
+    while ((line = reader.readLine()) != null) {
+      sb.append(line);
+    }
+    listAllQueriesResponse.close();
+
+    // Check whether received response contains expected query IDs.
+
+    JSONObject jsonObject = new JSONObject(sb.toString());
+    JSONArray jsonArray = jsonObject.getJSONArray("queries");
+    for (int i = 0; i < jsonArray.length(); i++) {
+      assertThat(Arrays.asList(PARAM_QUERY_IDS_ARRAY))
+          .contains(jsonArray.getJSONObject(i).getString("id"));
     }
+
+    // Query TestCase-3 :: Run the specified named query passing in scalar values for query
+    // parameters.
+
+    httpclient = HttpClients.createDefault();
+    post = new HttpPost(restEndpoint + "/queries/filterByLastName");
+    post.addHeader("Content-Type", "application/json");
+    post.addHeader("Accept", "application/json");
+    entity = new StringEntity(QUERY_ARGS);
+    post.setEntity(entity);
+    CloseableHttpResponse runNamedQueryResponse = httpclient.execute(post);
+
+    assertThat(runNamedQueryResponse.getStatusLine().getStatusCode()).isEqualTo(200);
+    assertThat(runNamedQueryResponse.getEntity()).isNotNull();
   }
 
-  public void verifyUpdatesInClientCache() {
+  private void verifyUpdatesInClientCache() {
     ClientCache cache = GemFireCacheImpl.getInstance();
-    assertNotNull(cache);
+    assertThat(cache).isNotNull();
     Region<String, Object> region = cache.getRegion(PEOPLE_REGION_NAME);
 
-    {
-      Person expectedPerson = new Person(3L, "Nishka3", "Nilkanth3", "Patel3",
-          DateTimeUtils.createDate(2009, Calendar.JULY, 31), Gender.FEMALE);
-      Object value = region.get("3");
-      if (value instanceof PdxInstance) {
-        PdxInstance pi3 = (PdxInstance) value;
-        Person actualPerson = (Person) pi3.getObject();
-        assertEquals(actualPerson.getId(), expectedPerson.getId());
-        assertEquals(actualPerson.getFirstName(), expectedPerson.getFirstName());
-        assertEquals(actualPerson.getMiddleName(), expectedPerson.getMiddleName());
-        assertEquals(actualPerson.getLastName(), expectedPerson.getLastName());
-        assertEquals(actualPerson.getBirthDate(), expectedPerson.getBirthDate());
-        assertEquals(actualPerson.getGender(), expectedPerson.getGender());
-      } else if (value instanceof Person) {
-        fail(
-            "VerifyUpdatesInClientCache, Get on key 3, Expected to get value of type PdxInstance ");
-      }
-    }
+    Person expectedPerson = new Person(3L, "Nishka3", "Nilkanth3", "Patel3",
+        DateTimeUtils.createDate(2009, Calendar.JULY, 31), Gender.FEMALE);
+    Object value = region.get("3");
+
+    assertThat(value).isInstanceOf(PdxInstance.class);
 
-    // TODO: uncomment it once following issue encountered in put?op=CAS is fixed or document the
-    // issue
-    // CAS functionality is not working in following test case
-    // step-1: Java client, Region.put("K", A);
-    // Step-2: Rest CAS request for key "K" with data "@old" = A. CAS is failing as existing
-    // PdxInstance in cache and
-    // PdxInstance generated from JSON (CAS request) does not match as their value's type are
-    // getting changed
-    /*
-     * //verify update on key "1" { Object obj = region.get("1"); if (obj instanceof PdxInstance) {
-     * PdxInstance pi = (PdxInstance)obj; Person p1 = (Person)pi.getObject();
-     * System.out.println("Nilkanth1 : verifyUpdatesInClientCache() : GET ON KEY=1" +
-     * p1.toString()); }else {
-     * System.out.println("Nilkanth1 : verifyUpdatesInClientCache() GET ON KEY=1  returned OBJECT: "
-     * + obj.toString()); } }
-     */
+    PdxInstance pi3 = (PdxInstance) value;
+    Person actualPerson = (Person) pi3.getObject();
+    assertThat(actualPerson.getId()).isEqualTo(expectedPerson.getId());
+    assertThat(actualPerson.getFirstName()).isEqualTo(expectedPerson.getFirstName());
+    assertThat(actualPerson.getMiddleName()).isEqualTo(expectedPerson.getMiddleName());
+    assertThat(actualPerson.getLastName()).isEqualTo(expectedPerson.getLastName());
+    assertThat(actualPerson.getBirthDate()).isEqualTo(expectedPerson.getBirthDate());
+    assertThat(actualPerson.getGender()).isEqualTo(expectedPerson.getGender());
 
     // verify update on key "2"
-    {
-      Person expectedPerson = new Person(501L, "Barack", "Hussein", "Obama",
-          DateTimeUtils.createDate(1961, Calendar.APRIL, 8), Gender.MALE);
-      Object value = region.get("2");
-      if (value instanceof PdxInstance) {
-        PdxInstance pi3 = (PdxInstance) value;
-        Person actualPerson = (Person) pi3.getObject();
-        assertEquals(actualPerson.getId(), expectedPerson.getId());
-        assertEquals(actualPerson.getFirstName(), expectedPerson.getFirstName());
-        assertEquals(actualPerson.getMiddleName(), expectedPerson.getMiddleName());
-        assertEquals(actualPerson.getLastName(), expectedPerson.getLastName());
-        assertEquals(actualPerson.getBirthDate(), expectedPerson.getBirthDate());
-        assertEquals(actualPerson.getGender(), expectedPerson.getGender());
-      } else {
-        fail(
-            "VerifyUpdatesInClientCache, Get on key 2, Expected to get value of type PdxInstance ");
-      }
-    }
+
+    expectedPerson = new Person(501L, "Barack", "Hussein", "Obama",
+        DateTimeUtils.createDate(1961, Calendar.APRIL, 8), Gender.MALE);
+    value = region.get("2");
+
+    assertThat(value).isInstanceOf(PdxInstance.class);
+
+    pi3 = (PdxInstance) value;
+    actualPerson = (Person) pi3.getObject();
+    assertThat(actualPerson.getId()).isEqualTo(expectedPerson.getId());
+    assertThat(actualPerson.getFirstName()).isEqualTo(expectedPerson.getFirstName());
+    assertThat(actualPerson.getMiddleName()).isEqualTo(expectedPerson.getMiddleName());
+    assertThat(actualPerson.getLastName()).isEqualTo(expectedPerson.getLastName());
+    assertThat(actualPerson.getBirthDate()).isEqualTo(expectedPerson.getBirthDate());
+    assertThat(actualPerson.getGender()).isEqualTo(expectedPerson.getGender());
 
     // verify Deleted key "13"
-    {
-      Object obj = region.get("13");
-      assertEquals(obj, null);
 
-      obj = region.get("14");
-      assertEquals(obj, null);
+    Object obj = region.get("13");
+    assertThat(obj).isNull();
 
-      obj = region.get("15");
-      assertEquals(obj, null);
+    obj = region.get("14");
+    assertThat(obj).isNull();
 
-      obj = region.get("16");
-      assertEquals(obj, null);
-    }
+    obj = region.get("15");
+    assertThat(obj).isNull();
 
+    obj = region.get("16");
+    assertThat(obj).isNull();
   }
 
-  public void doUpdatesUsingRestApis(String restEndpoint) {
-    // UPdate keys using REST calls
-    {
-
-      try {
-        CloseableHttpClient httpclient = HttpClients.createDefault();
-        HttpPut put = new HttpPut(restEndpoint + "/People/3,4,5,6,7,8,9,10,11,12");
-        put.addHeader("Content-Type", "application/json");
-        put.addHeader("Accept", "application/json");
-        StringEntity entity = new StringEntity(PERSON_LIST_AS_JSON);
-        put.setEntity(entity);
-        CloseableHttpResponse result = httpclient.execute(put);
-      } catch (Exception e) {
-        throw new RuntimeException("unexpected exception", e);
-      }
-    }
+  private void doUpdatesUsingRestApis(String restEndpoint) throws IOException {
+    // Update keys using REST calls
+
+    CloseableHttpClient httpclient = HttpClients.createDefault();
+    HttpPut put = new HttpPut(restEndpoint + "/People/3,4,5,6,7,8,9,10,11,12");
+    put.addHeader("Content-Type", "application/json");
+    put.addHeader("Accept", "application/json");
+    StringEntity entity = new StringEntity(PERSON_LIST_AS_JSON);
+    put.setEntity(entity);
+    CloseableHttpResponse result = httpclient.execute(put);
+    assertThat(result).isNotNull();
 
     // Delete Single keys
-    {
-      try {
-        CloseableHttpClient httpclient = HttpClients.createDefault();
-        HttpDelete delete = new HttpDelete(restEndpoint + "/People/13");
-        delete.addHeader("Content-Type", "application/json");
-        delete.addHeader("Accept", "application/json");
-        CloseableHttpResponse result = httpclient.execute(delete);
-      } catch (Exception e) {
-        throw new RuntimeException("unexpected exception", e);
-      }
-    }
+
+    httpclient = HttpClients.createDefault();
+    HttpDelete delete = new HttpDelete(restEndpoint + "/People/13");
+    delete.addHeader("Content-Type", "application/json");
+    delete.addHeader("Accept", "application/json");
+    result = httpclient.execute(delete);
+    assertThat(result).isNotNull();
 
     // Delete set of keys
-    {
-      try {
-        CloseableHttpClient httpclient = HttpClients.createDefault();
-        HttpDelete delete = new HttpDelete(restEndpoint + "/People/14,15,16");
-        delete.addHeader("Content-Type", "application/json");
-        delete.addHeader("Accept", "application/json");
-        CloseableHttpResponse result = httpclient.execute(delete);
-      } catch (Exception e) {
-        throw new RuntimeException("unexpected exception", e);
-      }
-    }
+
+    httpclient = HttpClients.createDefault();
+    delete = new HttpDelete(restEndpoint + "/People/14,15,16");
+    delete.addHeader("Content-Type", "application/json");
+    delete.addHeader("Accept", "application/json");
+    result = httpclient.execute(delete);
+    assertThat(result).isNotNull();
 
     // REST put?op=CAS for key 1
-    /*
-     * try { { HttpEntity<Object> entity = new HttpEntity<Object>(PERSON_AS_JSON_CAS, headers);
-     * ResponseEntity<String> result = RestTestUtils.getRestTemplate().exchange( restEndpoint +
-     * "/People/1?op=cas", HttpMethod.PUT, entity, String.class); } } catch
-     * (HttpClientErrorException e) {
-     *
-     * fail("Caught HttpClientErrorException while doing put with op=cas"); }catch
-     * (HttpServerErrorException se) {
-     * fail("Caught HttpServerErrorException while doing put with op=cas"); }
-     */
 
     // REST put?op=REPLACE for key 2
-    {
-      /*
-       * HttpEntity<Object> entity = new HttpEntity<Object>(PERSON_AS_JSON_REPLACE, headers);
-       * ResponseEntity<String> result = RestTestUtils.getRestTemplate().exchange( restEndpoint +
-       * "/People/2?op=replace", HttpMethod.PUT, entity, String.class);
-       */
-
-      try {
-        CloseableHttpClient httpclient = HttpClients.createDefault();
-        HttpPut put = new HttpPut(restEndpoint + "/People/2?op=replace");
-        put.addHeader("Content-Type", "application/json");
-        put.addHeader("Accept", "application/json");
-        StringEntity entity = new StringEntity(PERSON_AS_JSON_REPLACE);
-        put.setEntity(entity);
-        CloseableHttpResponse result = httpclient.execute(put);
-      } catch (Exception e) {
-        throw new RuntimeException("unexpected exception", e);
-      }
-    }
+
+    httpclient = HttpClients.createDefault();
+    put = new HttpPut(restEndpoint + "/People/2?op=replace");
+    put.addHeader("Content-Type", "application/json");
+    put.addHeader("Accept", "application/json");
+    entity = new StringEntity(PERSON_AS_JSON_REPLACE);
+    put.setEntity(entity);
+    result = httpclient.execute(put);
+    assertThat(result).isNotNull();
   }
 
-  public void fetchRestServerEndpoints(String restEndpoint) {
+  private void fetchRestServerEndpoints(String restEndpoint) throws IOException {
     HttpGet get = new HttpGet(restEndpoint + "/servers");
     get.addHeader("Content-Type", "application/json");
     get.addHeader("Accept", "application/json");
     CloseableHttpClient httpclient = HttpClients.createDefault();
-    CloseableHttpResponse response;
-
-    try {
-      response = httpclient.execute(get);
-      HttpEntity entity = response.getEntity();
-      InputStream content = entity.getContent();
-      BufferedReader reader = new BufferedReader(new InputStreamReader(content));
-      String line;
-      StringBuffer str = new StringBuffer();
-      while ((line = reader.readLine()) != null) {
-        str.append(line);
-      }
-
-      // validate the satus code
-      assertEquals(response.getStatusLine().getStatusCode(), 200);
-
-      if (response.getStatusLine().getStatusCode() == 200) {
-        JSONArray jsonArray = new JSONArray(str.toString());
-
-        // verify total number of REST service endpoints in DS
-        assertEquals(jsonArray.length(), 2);
-      }
-
-    } catch (ClientProtocolException e) {
-      e.printStackTrace();
-      fail(" Rest Request should not have thrown ClientProtocolException!");
-    } catch (IOException e) {
-      e.printStackTrace();
-      fail(" Rest Request should not have thrown IOException!");
-    } catch (JSONException e) {
-      e.printStackTrace();
-      fail(" Rest Request should not have thrown  JSONException!");
+
+    CloseableHttpResponse response = httpclient.execute(get);
+    HttpEntity entity = response.getEntity();
+    InputStream content = entity.getContent();
+    BufferedReader reader = new BufferedReader(new InputStreamReader(content));
+    String line;
+    StringBuilder sb = new StringBuilder();
+    while ((line = reader.readLine()) != null) {
+      sb.append(line);
     }
 
+    // validate the status code
+    assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
+
+    JSONArray jsonArray = new JSONArray(sb.toString());
+
+    // verify total number of REST service endpoints in DS
+    assertThat(jsonArray.length()).isEqualTo(2);
   }
 
-  public void doGetsUsingRestApis(String restEndpoint) {
-
-    // HttpHeaders headers = setAcceptAndContentTypeHeaders();
-    String currentOperation = null;
-    JSONObject jObject;
-    JSONArray jArray;
-    try {
-      // 1. Get on key="1" and validate result.
-      {
-        currentOperation = "GET on key 1";
-
-        HttpGet get = new HttpGet(restEndpoint + "/People/1");
-        get.addHeader("Content-Type", "application/json");
-        get.addHeader("Accept", "application/json");
-        CloseableHttpClient httpclient = HttpClients.createDefault();
-        CloseableHttpResponse response = httpclient.execute(get);
-
-        HttpEntity entity = response.getEntity();
-        InputStream content = entity.getContent();
-        BufferedReader reader = new BufferedReader(new InputStreamReader(content));
-        String line;
-        StringBuffer str = new StringBuffer();
-        while ((line = reader.readLine()) != null) {
-          str.append(line);
-        }
-
-        jObject = new JSONObject(str.toString());
-
-        assertEquals(jObject.get("id"), 101);
-        assertEquals(jObject.get("firstName"), "Mithali");
-        assertEquals(jObject.get("middleName"), "Dorai");
-        assertEquals(jObject.get("lastName"), "Raj");
-        assertEquals(jObject.get("gender"), Gender.FEMALE.name());
-      }
-
-      // 2. Get on key="16" and validate result.
-      {
-        currentOperation = "GET on key 16";
-
-        HttpGet get = new HttpGet(restEndpoint + "/People/16");
-        get.addHeader("Content-Type", "application/json");
-        get.addHeader("Accept", "application/json");
-        CloseableHttpClient httpclient = HttpClients.createDefault();
-        CloseableHttpResponse response = httpclient.execute(get);
-
-        HttpEntity entity = response.getEntity();
-        InputStream content = entity.getContent();
-        BufferedReader reader = new BufferedReader(new InputStreamReader(content));
-        String line;
-        StringBuffer str = new StringBuffer();
-        while ((line = reader.readLine()) != null) {
-          str.append(line);
-        }
-
-        jObject = new JSONObject(str.toString());
-
-        assertEquals(jObject.get("id"), 104);
-        assertEquals(jObject.get("firstName"), "Shila");
-        assertEquals(jObject.get("middleName"), "kumari");
-        assertEquals(jObject.get("lastName"), "Dixit");
-        assertEquals(jObject.get("gender"), Gender.FEMALE.name());
-      }
-
-      // 3. Get all (getAll) entries in Region
-      {
-
-        HttpGet get = new HttpGet(restEndpoint + "/People");
-        get.addHeader("Content-Type", "application/json");
-        get.addHeader("Accept", "application/json");
-        CloseableHttpClient httpclient = HttpClients.createDefault();
-        CloseableHttpResponse result = httpclient.execute(get);
-        assertEquals(result.getStatusLine().getStatusCode(), 200);
-        assertNotNull(result.getEntity());
-
-        HttpEntity entity = result.getEntity();
-        InputStream content = entity.getContent();
-        BufferedReader reader = new BufferedReader(new InputStreamReader(content));
-        String line;
-        StringBuffer sb = new StringBuffer();
-        while ((line = reader.readLine()) != null) {
-          sb.append(line);
-        }
-        result.close();
-
-        try {
-          jObject = new JSONObject(sb.toString());
-          jArray = jObject.getJSONArray("People");
-          assertEquals(jArray.length(), 16);
-        } catch (JSONException e) {
-          fail(" Rest Request ::" + currentOperation + " :: should not have thrown JSONException ");
-        }
-      }
-
-      // 4. GetAll?limit=10 (10 entries) and verify results
-      {
-        HttpGet get = new HttpGet(restEndpoint + "/People?limit=10");
-        get.addHeader("Content-Type", "application/json");
-        get.addHeader("Accept", "application/json");
-        CloseableHttpClient httpclient = HttpClients.createDefault();
-        CloseableHttpResponse response = httpclient.execute(get);
-        assertEquals(response.getStatusLine().getStatusCode(), 200);
-        assertNotNull(response.getEntity());
-
-        HttpEntity entity = response.getEntity();
-        InputStream content = entity.getContent();
-        BufferedReader reader = new BufferedReader(new InputStreamReader(content));
-        String line;
-        StringBuffer str = new StringBuffer();
-        while ((line = reader.readLine()) != null) {
-          str.append(line);
-        }
-
-        try {
-          jObject = new JSONObject(str.toString());
-          jArray = jObject.getJSONArray("People");
-          assertEquals(jArray.length(), 10);
-        } catch (JSONException e) {
-          fail(" Rest Request ::" + currentOperation + " :: should not have thrown JSONException ");
-        }
-      }
-
-      // 5. Get keys - List all keys in region
-      {
-
-        HttpGet get = new HttpGet(restEndpoint + "/People/keys");
-        get.addHeader("Content-Type", "application/json");
-        get.addHeader("Accept", "application/json");
-        CloseableHttpClient httpclient = HttpClients.createDefault();
-        CloseableHttpResponse response = httpclient.execute(get);
-        assertEquals(response.getStatusLine().getStatusCode(), 200);
-        assertNotNull(response.getEntity());
-
-        HttpEntity entity = response.getEntity();
-        InputStream content = entity.getContent();
-        BufferedReader reader = new BufferedReader(new InputStreamReader(content));
-        String line;
-        StringBuffer str = new StringBuffer();
-        while ((line = reader.readLine()) != null) {
-          str.append(line);
-        }
-
-        try {
-          jObject = new JSONObject(str.toString());
-          jArray = jObject.getJSONArray("keys");
-          assertEquals(jArray.length(), 16);
-        } catch (JSONException e) {
-          fail(" Rest Request ::" + currentOperation + " :: should not have thrown JSONException ");
-        }
-      }
-
-      // 6. Get data for specific keys
-      {
-
-        HttpGet get = new HttpGet(restEndpoint + "/People/1,3,5,7,9,11");
-        get.addHeader("Content-Type", "application/json");
-        get.addHeader("Accept", "application/json");
-        CloseableHttpClient httpclient = HttpClients.createDefault();
-        CloseableHttpResponse response = httpclient.execute(get);
-        assertEquals(response.getStatusLine().getStatusCode(), 200);
-        assertNotNull(response.getEntity());
-
-        HttpEntity entity = response.getEntity();
-        InputStream content = entity.getContent();
-        BufferedReader reader = new BufferedReader(new InputStreamReader(content));
-        String line;
-        StringBuffer str = new StringBuffer();
-        while ((line = reader.readLine()) != null) {
-          str.append(line);
-        }
-
-        try {
-          jObject = new JSONObject(str.toString());
-          jArray = jObject.getJSONArray("People");
-          assertEquals(jArray.length(), 6);
-
-        } catch (JSONException e) {
-          fail(" Rest Request ::" + currentOperation + " :: should not have thrown JSONException ");
-        }
-      }
-    } catch (Exception e) {
-      throw new RuntimeException("unexpected exception", e);
+  private void doGetsUsingRestApis(String restEndpoint) throws IOException {
+    // 1. Get on key="1" and validate result.
+
+    HttpGet get = new HttpGet(restEndpoint + "/People/1");
+    get.addHeader("Content-Type", "application/json");
+    get.addHeader("Accept", "application/json");
+    CloseableHttpClient httpclient = HttpClients.createDefault();
+    CloseableHttpResponse response = httpclient.execute(get);
+
+    HttpEntity entity = response.getEntity();
+    InputStream content = entity.getContent();
+    BufferedReader reader = new BufferedReader(new InputStreamReader(content));
+    String line;
+    StringBuilder sb = new StringBuilder();
+    while ((line = reader.readLine()) != null) {
+      sb.append(line);
+    }
+
+    JSONObject jObject = new JSONObject(sb.toString());
+
+    assertThat(jObject.get("id")).isEqualTo(101);
+    assertThat(jObject.get("firstName")).isEqualTo("Mithali");
+    assertThat(jObject.get("middleName")).isEqualTo("Dorai");
+    assertThat(jObject.get("lastName")).isEqualTo("Raj");
+    assertThat(jObject.get("gender")).isEqualTo(Gender.FEMALE.name());
+
+    // 2. Get on key="16" and validate result.
+
+    get = new HttpGet(restEndpoint + "/People/16");
+    get.addHeader("Content-Type", "application/json");
+    get.addHeader("Accept", "application/json");
+    httpclient = HttpClients.createDefault();
+    response = httpclient.execute(get);
+
+    entity = response.getEntity();
+    content = entity.getContent();
+    reader = new BufferedReader(new InputStreamReader(content));
+    sb = new StringBuilder();
+    while ((line = reader.readLine()) != null) {
+      sb.append(line);
+    }
+
+    jObject = new JSONObject(sb.toString());
+
+    assertThat(jObject.get("id")).isEqualTo(104);
+    assertThat(jObject.get("firstName")).isEqualTo("Shila");
+    assertThat(jObject.get("middleName")).isEqualTo("kumari");
+    assertThat(jObject.get("lastName")).isEqualTo("Dixit");
+    assertThat(jObject.get("gender")).isEqualTo(Gender.FEMALE.name());
+
+    // 3. Get all (getAll) entries in Region
+
+    get = new HttpGet(restEndpoint + "/People");
+    get.addHeader("Content-Type", "application/json");
+    get.addHeader("Accept", "application/json");
+    httpclient = HttpClients.createDefault();
+    CloseableHttpResponse result = httpclient.execute(get);
+    assertThat(result.getStatusLine().getStatusCode()).isEqualTo(200);
+    assertThat(result.getEntity()).isNotNull();
+
+    entity = result.getEntity();
+    content = entity.getContent();
+    reader = new BufferedReader(new InputStreamReader(content));
+    sb = new StringBuilder();
+    while ((line = reader.readLine()) != null) {
+      sb.append(line);
+    }
+    result.close();
+
+    jObject = new JSONObject(sb.toString());
+    JSONArray jArray = jObject.getJSONArray("People");
+    assertThat(jArray.length()).isEqualTo(16);
+
+    // 4. GetAll?limit=10 (10 entries) and verify results
+
+    get = new HttpGet(restEndpoint + "/People?limit=10");
+    get.addHeader("Content-Type", "application/json");
+    get.addHeader("Accept", "application/json");
+    httpclient = HttpClients.createDefault();
+    response = httpclient.execute(get);
+    assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
+    assertThat(response.getEntity()).isNotNull();
+
+    entity = response.getEntity();
+    content = entity.getContent();
+    reader = new BufferedReader(new InputStreamReader(content));
+    sb = new StringBuilder();
+    while ((line = reader.readLine()) != null) {
+      sb.append(line);
     }
+
+    jObject = new JSONObject(sb.toString());
+    jArray = jObject.getJSONArray("People");
+    assertThat(jArray.length()).isEqualTo(10);
+
+    // 5. Get keys - List all keys in region
+
+    get = new HttpGet(restEndpoint + "/People/keys");
+    get.addHeader("Content-Type", "application/json");
+    get.addHeader("Accept", "application/json");
+    httpclient = HttpClients.createDefault();
+    response = httpclient.execute(get);
+    assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
+    assertThat(response.getEntity()).isNotNull();
+
+    entity = response.getEntity();
+    content = entity.getContent();
+    reader = new BufferedReader(new InputStreamReader(content));
+    sb = new StringBuilder();
+    while ((line = reader.readLine()) != null) {
+      sb.append(line);
+    }
+
+    jObject = new JSONObject(sb.toString());
+    jArray = jObject.getJSONArray("keys");
+    assertThat(jArray.length()).isEqualTo(16);
+
+    // 6. Get data for specific keys
+
+    get = new HttpGet(restEndpoint + "/People/1,3,5,7,9,11");
+    get.addHeader("Content-Type", "application/json");
+    get.addHeader("Accept", "application/json");
+    httpclient = HttpClients.createDefault();
+    response = httpclient.execute(get);
+    assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
+    assertThat(response.getEntity()).isNotNull();
+
+    entity = response.getEntity();
+    content = entity.getContent();
+    reader = new BufferedReader(new InputStreamReader(content));
+    sb = new StringBuilder();
+    while ((line = reader.readLine()) != null) {
+      sb.append(line);
+    }
+
+    jObject = new JSONObject(sb.toString());
+    jArray = jObject.getJSONArray("People");
+    assertThat(jArray.length()).isEqualTo(6);
   }
 
-  public void createRegionInClientCache() {
+  private void createRegionInClientCache() {
     ClientCache cache = GemFireCacheImpl.getInstance();
-    assertNotNull(cache);
+    assertThat(cache).isNotNull();
     ClientRegionFactory<String, Object> crf =
         cache.createClientRegionFactory(ClientRegionShortcut.PROXY);
     Region<String, Object> region = crf.create(PEOPLE_REGION_NAME);
-
   }
 
-  public void createRegion() {
+  private void createRegion() {
     Cache cache = GemFireCacheImpl.getInstance();
-    assertNotNull(cache);
+    assertThat(cache).isNotNull();
 
     RegionFactory<String, Object> rf = cache.createRegionFactory(RegionShortcut.REPLICATE);
     Region<String, Object> region = rf.create(PEOPLE_REGION_NAME);
@@ -751,7 +610,6 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase {
    */
   @Test
   public void testInterOpsWithReplicatedRegion() throws Exception {
-
     final Host host = Host.getHost(0);
     VM locator = host.getVM(0);
     VM manager = host.getVM(1);
@@ -802,12 +660,12 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase {
     doQueryOpsUsingRestApis(restEndpoint);
   }
 
-  private void createClientCache(final String host, final int port) throws Exception {
+  private void createClientCache(final String host, final int port) {
     // Connect using the GemFire locator and create a Caching_Proxy cache
-    ClientCache c =
+    ClientCache clientCache =
         new ClientCacheFactory().setPdxReadSerialized(true).addPoolLocator(host, port).create();
 
-    c.createClientRegionFactory(ClientRegionShortcut.PROXY).create(REGION_NAME);
+    clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(REGION_NAME);
   }
 
   private int startManager(final String[] groups, final String locators, final String[] regions,
@@ -842,6 +700,6 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase {
     server.setLoadProbe(probe);
     server.start();
 
-    return new Integer(server.getPort());
+    return server.getPort();
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/main/java/org/apache/geode/cache/CacheFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/CacheFactory.java b/geode-core/src/main/java/org/apache/geode/cache/CacheFactory.java
index 38fdac6..9b23f6c 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/CacheFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/CacheFactory.java
@@ -14,11 +14,10 @@
  */
 package org.apache.geode.cache;
 
-import java.util.Properties;
-
 import org.apache.geode.distributed.ConfigurationProperties;
 import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.distributed.internal.SecurityConfig;
 import org.apache.geode.internal.GemFireVersion;
 import org.apache.geode.internal.cache.CacheConfig;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
@@ -29,9 +28,12 @@ import org.apache.geode.pdx.PdxInstance;
 import org.apache.geode.pdx.PdxSerializer;
 import org.apache.geode.security.AuthenticationFailedException;
 import org.apache.geode.security.AuthenticationRequiredException;
+import org.apache.geode.security.GemFireSecurityException;
 import org.apache.geode.security.PostProcessor;
 import org.apache.geode.security.SecurityManager;
 
+import java.util.Properties;
+
 /**
  * Factory class used to create the singleton {@link Cache cache} and connect to the GemFire
  * singleton {@link DistributedSystem distributed system}. If the application wants to connect to
@@ -170,7 +172,7 @@ public class CacheFactory {
       CacheConfig cacheConfig) throws CacheExistsException, TimeoutException, CacheWriterException,
       GatewayException, RegionExistsException {
     // Moved code in this method to GemFireCacheImpl.create
-    return GemFireCacheImpl.create(system, existingOk, cacheConfig);
+    return GemFireCacheImpl.create((InternalDistributedSystem) system, existingOk, cacheConfig);
   }
 
   /**
@@ -205,11 +207,41 @@ public class CacheFactory {
       if (this.dsProps.isEmpty()) {
         // any ds will do
         ds = InternalDistributedSystem.getConnectedInstance();
+        validateUsabilityOfSecurityCallbacks(ds);
       }
       if (ds == null) {
-        ds = DistributedSystem.connect(this.dsProps);
+        // use ThreadLocal to avoid exposing new User API in DistributedSystem
+        SecurityConfig.set(this.cacheConfig.getSecurityManager(),
+            this.cacheConfig.getPostProcessor());
+        try {
+          ds = DistributedSystem.connect(this.dsProps);
+        } finally {
+          SecurityConfig.remove();
+        }
       }
-      return create(ds, true, cacheConfig);
+      return create(ds, true, this.cacheConfig);
+    }
+  }
+
+  /**
+   * Throws GemFireSecurityException if existing DistributedSystem connection cannot use specified
+   * SecurityManager or PostProcessor.
+   */
+  private void validateUsabilityOfSecurityCallbacks(DistributedSystem ds)
+      throws GemFireSecurityException {
+    if (ds == null) {
+      return;
+    }
+    // pre-existing DistributedSystem already has an incompatible SecurityService in use
+    if (this.cacheConfig.getSecurityManager() != null) {
+      // invalid configuration
+      throw new GemFireSecurityException(
+          "Existing DistributedSystem connection cannot use specified SecurityManager");
+    }
+    if (this.cacheConfig.getPostProcessor() != null) {
+      // invalid configuration
+      throw new GemFireSecurityException(
+          "Existing DistributedSystem connection cannot use specified PostProcessor");
     }
   }
 
@@ -321,7 +353,7 @@ public class CacheFactory {
   }
 
   /**
-   * sets the securityManager for the cache. If this securityManager is set. It will override the
+   * Sets the securityManager for the cache. If this securityManager is set, it will override the
    * security-manager property you set in your gemfire system properties.
    *
    * This is provided mostly for container to inject an already initialized securityManager. An
@@ -336,7 +368,7 @@ public class CacheFactory {
   }
 
   /**
-   * sets the postProcessor for the cache. If this postProcessor is set. It will override thie
+   * Sets the postProcessor for the cache. If this postProcessor is set, it will override the
    * security-post-processor setting in the gemfire system properties.
    *
    * This is provided mostly for container to inject an already initialized post processor. An

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/main/java/org/apache/geode/cache/client/ClientCacheFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/ClientCacheFactory.java b/geode-core/src/main/java/org/apache/geode/cache/client/ClientCacheFactory.java
index 0d678ca..4839a7c 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/client/ClientCacheFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/client/ClientCacheFactory.java
@@ -27,6 +27,7 @@ import org.apache.geode.cache.TimeoutException;
 import org.apache.geode.cache.client.internal.InternalClientCache;
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.internal.GemFireVersion;
 import org.apache.geode.internal.cache.CacheConfig;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
@@ -237,7 +238,8 @@ public class ClientCacheFactory {
       }
       this.dsProps.setProperty(MCAST_PORT, "0");
       this.dsProps.setProperty(LOCATORS, "");
-      DistributedSystem system = DistributedSystem.connect(this.dsProps);
+      InternalDistributedSystem system =
+          (InternalDistributedSystem) DistributedSystem.connect(this.dsProps);
 
       if (instance != null && !instance.isClosed()) {
         // this is ok; just make sure it is a client cache

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java b/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
index e06949c..c175744 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
@@ -243,7 +243,6 @@ public class LocatorLauncher extends AbstractLauncher<String> {
     this.distributedSystemProperties = builder.getDistributedSystemProperties();
     this.hostnameForClients = builder.getHostnameForClients();
     this.memberName = builder.getMemberName();
-    // TODO:KIRK: set ThreadLocal for LogService with getLogFile or getLogFileName
     this.pid = builder.getPid();
     this.portSpecified = builder.isPortSpecified();
     this.port = builder.getPort();

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java b/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
index 4de1a95..395b262 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
@@ -283,7 +283,6 @@ public class ServerLauncher extends AbstractLauncher<String> {
     this.help = Boolean.TRUE.equals(builder.getHelp());
     this.hostNameForClients = builder.getHostNameForClients();
     this.memberName = builder.getMemberName();
-    // TODO:KIRK: set ThreadLocal for LogService with getLogFile or getLogFileName
     this.pid = builder.getPid();
     this.rebalance = Boolean.TRUE.equals(builder.getRebalance());
     this.redirectOutput = Boolean.TRUE.equals(builder.getRedirectOutput());

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionManager.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionManager.java
index 15f45a8..2988ffd 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionManager.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionManager.java
@@ -1152,8 +1152,8 @@ public class DistributionManager implements DM {
       start = System.currentTimeMillis();
 
       MyListener l = new MyListener(this);
-      membershipManager =
-          MemberFactory.newMembershipManager(l, system.getConfig(), transport, stats);
+      membershipManager = MemberFactory.newMembershipManager(l, system.getConfig(), transport,
+          stats, system.getSecurityService());
 
       sb.append(System.currentTimeMillis() - start);
 

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
----------------------------------------------------------------------
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 7caad3f..22edb6f 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
@@ -40,6 +40,9 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.geode.cache.CacheXmlException;
+import org.apache.geode.internal.security.SecurityService;
+import org.apache.geode.internal.security.SecurityServiceFactory;
+import org.apache.geode.security.PostProcessor;
 import org.apache.logging.log4j.Logger;
 
 import org.apache.geode.CancelCriterion;
@@ -108,6 +111,7 @@ import org.apache.geode.internal.statistics.platform.OsStatisticsFactory;
 import org.apache.geode.internal.tcp.ConnectionTable;
 import org.apache.geode.management.ManagementException;
 import org.apache.geode.security.GemFireSecurityException;
+import org.apache.geode.security.SecurityManager;
 
 /**
  * The concrete implementation of {@link DistributedSystem} that provides internal-only
@@ -291,35 +295,51 @@ public class InternalDistributedSystem extends DistributedSystem
    */
   private final Throwable creationStack;
 
+  private volatile SecurityService securityService;
+
   ///////////////////// Static Methods /////////////////////
 
   /**
    * Creates a new instance of <code>InternalDistributedSystem</code> with the given configuration.
    */
   public static InternalDistributedSystem newInstance(Properties config) {
+    return newInstance(config, SecurityConfig.get());
+  }
+
+  public static InternalDistributedSystem newInstance(Properties config,
+      SecurityConfig securityConfig) {
+    if (securityConfig == null) {
+      return newInstance(config, null, null);
+    } else {
+      return newInstance(config, securityConfig.getSecurityManager(),
+          securityConfig.getPostProcessor());
+    }
+  }
+
+  public static InternalDistributedSystem newInstance(Properties config,
+      SecurityManager securityManager, PostProcessor postProcessor) {
     boolean success = false;
     InternalDataSerializer.checkSerializationVersion();
     try {
       SystemFailure.startThreads();
       InternalDistributedSystem newSystem = new InternalDistributedSystem(config);
-      newSystem.initialize();
+      newSystem.initialize(securityManager, postProcessor);
       reconnectAttemptCounter = 0; // reset reconnect count since we just got a new connection
       notifyConnectListeners(newSystem);
       success = true;
       return newSystem;
     } finally {
       if (!success) {
-        LoggingThreadGroup.cleanUpThreadGroups(); // bug44365 - logwriters accumulate, causing mem
-                                                  // leak
+        // bug44365 - logwriters accumulate, causing mem leak
+        LoggingThreadGroup.cleanUpThreadGroups();
         SystemFailure.stopThreads();
       }
     }
   }
 
-
   /**
    * creates a non-functional instance for testing
-   * 
+   *
    * @param nonDefault - non-default distributed system properties
    */
   public static InternalDistributedSystem newInstanceForTesting(DM dm, Properties nonDefault) {
@@ -488,23 +508,14 @@ public class InternalDistributedSystem extends DistributedSystem
 
     this.creationStack =
         TEST_CREATION_STACK_GENERATOR.get().generateCreationStack(this.originalConfig);
-
-    // if (DistributionConfigImpl.multicastTest) {
-    // this.logger.warning("Use of multicast has been forced");
-    // }
-    // if (DistributionConfigImpl.forceDisableTcp) {
-    // this.logger.warning("Use of UDP has been forced");
-    // }
-    // if
-    // (org.apache.geode.distributed.internal.membership.jgroup.JGroupMembershipManager.multicastTest)
-    // {
-    // this.logger.warning("Use of multicast for all distributed cache operations has been forced");
-    // }
-
   }
 
   //////////////////// Instance Methods ////////////////////
 
+  public SecurityService getSecurityService() {
+    return this.securityService;
+  }
+
   /**
    * Registers a listener to the system
    * 
@@ -562,7 +573,7 @@ public class InternalDistributedSystem extends DistributedSystem
   /**
    * Initializes this connection to a distributed system with the current configuration state.
    */
-  private void initialize() {
+  private void initialize(SecurityManager securityManager, PostProcessor postProcessor) {
     if (this.originalConfig.getLocators().equals("")) {
       if (this.originalConfig.getMcastPort() != 0) {
         throw new GemFireConfigException("The " + LOCATORS + " attribute can not be empty when the "
@@ -574,6 +585,10 @@ public class InternalDistributedSystem extends DistributedSystem
     }
 
     this.config = new RuntimeDistributionConfigImpl(this);
+
+    this.securityService =
+        SecurityServiceFactory.create(this.config, securityManager, postProcessor);
+
     if (!this.isLoner) {
       this.attemptingToReconnect = (reconnectAttemptCounter > 0);
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/main/java/org/apache/geode/distributed/internal/SecurityConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/SecurityConfig.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/SecurityConfig.java
new file mode 100644
index 0000000..deea55f
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/SecurityConfig.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.distributed.internal;
+
+import org.apache.geode.security.PostProcessor;
+import org.apache.geode.security.SecurityManager;
+
+public class SecurityConfig {
+
+  private static final ThreadLocal<SecurityConfig> THREAD_LOCAL = new ThreadLocal<>();
+
+  public static void set(SecurityManager securityManager, PostProcessor postProcessor) {
+    THREAD_LOCAL.set(new SecurityConfig(securityManager, postProcessor));
+  }
+
+  public static SecurityConfig get() {
+    return THREAD_LOCAL.get();
+  }
+
+  public static void remove() {
+    THREAD_LOCAL.remove();
+  }
+
+  private final SecurityManager securityManager;
+  private final PostProcessor postProcessor;
+
+  public SecurityConfig(SecurityManager securityManager, PostProcessor postProcessor) {
+    this.securityManager = securityManager;
+    this.postProcessor = postProcessor;
+  }
+
+  public SecurityManager getSecurityManager() {
+    return this.securityManager;
+  }
+
+  public PostProcessor getPostProcessor() {
+    return this.postProcessor;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/MemberFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/MemberFactory.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/MemberFactory.java
index f324e33..b682d93 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/MemberFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/MemberFactory.java
@@ -20,6 +20,7 @@ import org.apache.geode.distributed.internal.LocatorStats;
 import org.apache.geode.distributed.internal.membership.gms.GMSMemberFactory;
 import org.apache.geode.distributed.internal.membership.gms.NetLocator;
 import org.apache.geode.internal.admin.remote.RemoteTransportConfig;
+import org.apache.geode.internal.security.SecurityService;
 
 import java.io.File;
 import java.net.InetAddress;
@@ -45,7 +46,7 @@ public class MemberFactory {
    * @param payload the payload for this member
    * @return the new NetMember
    */
-  static public NetMember newNetMember(InetAddress i, int p, boolean splitBrainEnabled,
+  public static NetMember newNetMember(InetAddress i, int p, boolean splitBrainEnabled,
       boolean canBeCoordinator, short version, MemberAttributes payload) {
     return services.newNetMember(i, p, splitBrainEnabled, canBeCoordinator, payload, version);
   }
@@ -57,7 +58,7 @@ public class MemberFactory {
    * @param p the membership port being used
    * @return the new NetMember
    */
-  static public NetMember newNetMember(InetAddress i, int p) {
+  public static NetMember newNetMember(InetAddress i, int p) {
     NetMember result = services.newNetMember(i, p);
     return result;
   }
@@ -69,7 +70,7 @@ public class MemberFactory {
    * @param p the membership port being used
    * @return the new member
    */
-  static public NetMember newNetMember(String s, int p) {
+  public static NetMember newNetMember(String s, int p) {
     return services.newNetMember(s, p);
   }
 
@@ -84,16 +85,17 @@ public class MemberFactory {
    * @param stats are used for recording statistical communications information
    * @return a MembershipManager
    */
-  static public MembershipManager newMembershipManager(DistributedMembershipListener listener,
-      DistributionConfig config, RemoteTransportConfig transport, DMStats stats) {
-    return services.newMembershipManager(listener, config, transport, stats);
+  public static MembershipManager newMembershipManager(DistributedMembershipListener listener,
+      DistributionConfig config, RemoteTransportConfig transport, DMStats stats,
+      SecurityService securityService) {
+    return services.newMembershipManager(listener, config, transport, stats, securityService);
   }
 
   /**
    * currently this is a test method but it ought to be used by InternalLocator to create the peer
    * location TcpHandler
    */
-  static public NetLocator newLocatorHandler(InetAddress bindAddress, File stateFile,
+  public static NetLocator newLocatorHandler(InetAddress bindAddress, File stateFile,
       String locatorString, boolean usePreferredCoordinators,
       boolean networkPartitionDetectionEnabled, LocatorStats stats, String securityUDPDHAlgo) {
     return services.newLocatorHandler(bindAddress, stateFile, locatorString,

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/MemberServices.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/MemberServices.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/MemberServices.java
index 6024966..c52ccbc 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/MemberServices.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/MemberServices.java
@@ -19,6 +19,7 @@ import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.LocatorStats;
 import org.apache.geode.distributed.internal.membership.gms.NetLocator;
 import org.apache.geode.internal.admin.remote.RemoteTransportConfig;
+import org.apache.geode.internal.security.SecurityService;
 
 import java.io.File;
 import java.net.InetAddress;
@@ -75,7 +76,8 @@ public interface MemberServices {
    * @return a MembershipManager
    */
   public abstract MembershipManager newMembershipManager(DistributedMembershipListener listener,
-      DistributionConfig config, RemoteTransportConfig transport, DMStats stats);
+      DistributionConfig config, RemoteTransportConfig transport, DMStats stats,
+      SecurityService securityService);
 
 
   /**

http://git-wip-us.apache.org/repos/asf/geode/blob/0211029b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMemberFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMemberFactory.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMemberFactory.java
index bc94ab5..01d9995 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMemberFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMemberFactory.java
@@ -34,6 +34,7 @@ import org.apache.geode.internal.Version;
 import org.apache.geode.internal.admin.remote.RemoteTransportConfig;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.net.SocketCreator;
+import org.apache.geode.internal.security.SecurityService;
 import org.apache.geode.internal.tcp.ConnectionException;
 import org.apache.geode.security.GemFireSecurityException;
 
@@ -55,6 +56,7 @@ public class GMSMemberFactory implements MemberServices {
    * @param attr the MemberAttributes
    * @return the new NetMember
    */
+  @Override
   public NetMember newNetMember(InetAddress i, int p, boolean splitBrainEnabled,
       boolean canBeCoordinator, MemberAttributes attr, short version) {
     GMSMember result =
@@ -70,6 +72,7 @@ public class GMSMemberFactory implements MemberServices {
    * @param p the membership port being used
    * @return the new NetMember
    */
+  @Override
   public NetMember newNetMember(InetAddress i, int p) {
     return new GMSMember(MemberAttributes.DEFAULT, i, p, false, true, Version.CURRENT_ORDINAL, 0,
         0);
@@ -83,6 +86,7 @@ public class GMSMemberFactory implements MemberServices {
    * @param p the membership port being used
    * @return the new member
    */
+  @Override
   public NetMember newNetMember(String s, int p) {
     InetAddress inetAddr = null;
     try {
@@ -93,10 +97,11 @@ public class GMSMemberFactory implements MemberServices {
     return newNetMember(inetAddr, p);
   }
 
+  @Override
   public MembershipManager newMembershipManager(DistributedMembershipListener listener,
-      DistributionConfig config, RemoteTransportConfig transport, DMStats stats)
-      throws DistributionException {
-    Services services = new Services(listener, config, transport, stats);
+      DistributionConfig config, RemoteTransportConfig transport, DMStats stats,
+      SecurityService securityService) throws DistributionException {
+    Services services = new Services(listener, config, transport, stats, securityService);
     try {
       services.init();
       services.start();


Mime
View raw message