geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [9/9] geode git commit: Use immutable SecurityService
Date Mon, 05 Jun 2017 16:46:32 GMT
Use immutable SecurityService


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

Branch: refs/heads/feature/GEODE-2632-21
Commit: eab9e6e078262a9ef24f49009bdac377bdd8b5ff
Parents: 74c7bbc
Author: Kirk Lund <klund@apache.org>
Authored: Wed May 31 16:13:20 2017 -0700
Committer: Kirk Lund <klund@apache.org>
Committed: Mon Jun 5 09:45:31 2017 -0700

----------------------------------------------------------------------
 .../RestAPIsAndInterOpsDUnitTest.java           | 807 +++++++++----------
 .../org/apache/geode/cache/CacheFactory.java    |  10 +-
 .../geode/cache/client/ClientCacheFactory.java  |   4 +-
 .../internal/DistributionManager.java           |   4 +-
 .../internal/InternalDistributedSystem.java     |  43 +-
 .../distributed/internal/InternalLocator.java   |   2 +
 .../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   |  43 +-
 .../geode/internal/cache/CacheServerImpl.java   |   4 +
 .../geode/internal/cache/GemFireCacheImpl.java  |  38 +-
 .../geode/internal/cache/InternalCache.java     |   3 +
 .../geode/internal/cache/tier/Command.java      |   4 +-
 .../internal/cache/tier/CommandContext.java     |  31 +
 .../cache/tier/sockets/AcceptorImpl.java        |   5 +-
 .../cache/tier/sockets/BaseCommand.java         |  14 +-
 .../cache/tier/sockets/BaseCommandQuery.java    |  54 +-
 .../cache/tier/sockets/CacheClientNotifier.java |  47 +-
 .../cache/tier/sockets/CacheClientProxy.java    |   7 +-
 .../cache/tier/sockets/CommandContextImpl.java  |  64 ++
 .../internal/cache/tier/sockets/HandShake.java  |  35 +-
 .../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       |   5 +-
 .../internal/cache/xmlcache/CacheCreation.java  |   7 +
 .../apache/geode/internal/lang/Initializer.java |   4 +-
 .../security/CustomSecurityService.java         | 206 +++++
 .../security/DisabledSecurityService.java       | 209 +++++
 .../security/EnabledSecurityService.java        | 423 ++++++++++
 .../security/LegacySecurityService.java         | 219 +++++
 .../internal/security/SecurityService.java      |  40 +-
 .../security/SecurityServiceFactory.java        | 188 +++++
 .../internal/security/SecurityServiceType.java  |  28 +
 .../security/shiro/ConfigInitialization.java    |  45 ++
 .../security/shiro/JMXShiroAuthenticator.java   |  18 +-
 .../geode/management/cli/CommandService.java    |   3 +-
 .../management/internal/ManagementAgent.java    |  11 +-
 .../internal/SystemManagementService.java       |   2 +-
 .../CreateAlterDestroyRegionCommands.java       |   4 +-
 .../internal/cli/commands/DataCommands.java     |  60 +-
 .../internal/cli/commands/DeployCommands.java   |  19 +-
 .../internal/cli/commands/GfshCommand.java      |  19 +-
 .../internal/cli/commands/IndexCommands.java    |  44 +-
 .../cli/functions/DataCommandFunction.java      | 119 +--
 .../internal/cli/functions/SelectExecStep.java  | 137 ++++
 .../internal/cli/remote/CommandProcessor.java   |   9 +-
 .../cli/remote/MemberCommandService.java        |  19 +-
 .../functions/RecreateCacheFunction.java        |   4 +-
 .../internal/security/AccessControlMBean.java   |   6 +-
 .../internal/security/MBeanServerWrapper.java   |  20 +-
 .../controllers/AbstractCommandsController.java |   8 +-
 .../support/LoginHandlerInterceptor.java        |  30 +-
 .../apache/geode/security/PostProcessor.java    |   2 +-
 .../AnalyzeSerializablesJUnitTest.java          |  23 +-
 .../membership/MembershipJUnitTest.java         |  80 +-
 .../auth/AbstractGMSAuthenticatorTestCase.java  |  33 +-
 .../GMSAuthenticatorWithAuthenticatorTest.java  |  76 +-
 ...GMSAuthenticatorWithSecurityManagerTest.java |  62 +-
 .../locator/GMSLocatorRecoveryJUnitTest.java    |  70 +-
 .../cache/ha/BlockingHARegionJUnitTest.java     |   9 +-
 .../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 +-
 .../internal/lang/InitializerJUnitTest.java     |   2 +-
 .../internal/security/FakePostProcessor.java    | 103 +++
 .../internal/security/FakeSecurityManager.java  | 103 +++
 .../security/IntegratedSecurityServiceTest.java | 222 -----
 .../security/SecurityServiceFactoryTest.java    | 244 ++++++
 .../internal/security/SecurityServiceTest.java  | 227 ++++++
 .../CacheServerMBeanShiroJUnitTest.java         | 109 ---
 ...eServerMBeanWithShiroIniIntegrationTest.java | 109 +++
 ...atedSecurityServiceCustomRealmJUnitTest.java |  44 -
 ...atedSecurityServiceWithIniFileJUnitTest.java | 152 ----
 ...tyServiceWithCustomRealmIntegrationTest.java |  44 +
 ...urityServiceWithShiroIniIntegrationTest.java | 154 ++++
 .../CacheFactoryWithSecurityObjectTest.java     |  16 +-
 ...edSecurityCacheLifecycleIntegrationTest.java |  74 --
 .../PDXGfshPostProcessorOnRemoteServerTest.java |   4 +-
 .../security/PDXPostProcessorDUnitTest.java     |  11 +-
 ...SecurityManagerCallbacksDistributedTest.java | 132 ---
 ...SecurityManagerLifecycleDistributedTest.java | 143 ++++
 ...SecurityManagerLifecycleIntegrationTest.java |  73 ++
 .../geode/security/SpySecurityManager.java      |  19 +-
 .../test/dunit/rules/ServerStarterRule.java     |   8 +-
 .../cache/tier/sockets/command/CloseCQ.java     |  16 +-
 .../cache/tier/sockets/command/ExecuteCQ.java   |  11 +-
 .../cache/tier/sockets/command/ExecuteCQ61.java |  14 +-
 .../cache/tier/sockets/command/GetCQStats.java  |  13 +-
 .../tier/sockets/command/GetDurableCQs.java     |   9 +-
 .../cache/tier/sockets/command/MonitorCQ.java   |  15 +-
 .../cache/tier/sockets/command/StopCQ.java      |  15 +-
 .../security/CQPDXPostProcessorDUnitTest.java   |   2 +-
 .../security/ClientAuthzObjectModDUnitTest.java |  22 +-
 .../internal/cli/LuceneIndexCommands.java       |   8 +-
 .../cli/LuceneIndexCommandsJUnitTest.java       |  43 +-
 .../apache/geode/tools/pulse/tests/Server.java  |  18 +-
 .../tools/pulse/tests/rules/ServerRule.java     |   4 +-
 .../apache/geode/cache/util/AutoBalancer.java   |   6 +-
 .../security/GeodeAuthenticationProvider.java   |  24 +-
 .../web/security/RestSecurityConfiguration.java |   4 +-
 .../web/security/RestSecurityService.java       |  16 +-
 .../web/security/SecurityServiceProvider.java   |  18 +
 ...andlerInterceptorRequestHeaderJUnitTest.java |   3 +-
 204 files changed, 4760 insertions(+), 2701 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/eab9e6e0/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..a5a71d2 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,19 @@
  */
 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.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import org.apache.geode.cache.AttributesFactory;
 import org.apache.geode.cache.Cache;
@@ -72,6 +54,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 +89,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,10 +103,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\" :" + "{"
+  private static final 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\" :" + "{"
@@ -108,7 +115,7 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase {
       + " \"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,8 +162,9 @@ 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
@@ -166,8 +174,9 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase {
   }
 
   @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,16 +201,13 @@ 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);
     Region<String, Object> region = cache.getRegion(PEOPLE_REGION_NAME);
@@ -263,114 +269,104 @@ 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) {
+  private void doQueryOpsUsingRestApis(String restEndpoint) throws IOException {
     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);
+
+    // 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");
+    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;
+    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++) {
+      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";
+    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);
+
+    assertEquals(200, runNamedQueryResponse.getStatusLine().getStatusCode());
+    assertNotNull(runNamedQueryResponse.getEntity());
   }
 
-  public void verifyUpdatesInClientCache() {
+  private void verifyUpdatesInClientCache() {
     ClientCache cache = GemFireCacheImpl.getInstance();
     assertNotNull(cache);
     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");
+    // TODO: use assertion
+    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 ");
     }
 
     // TODO: uncomment it once following issue encountered in put?op=CAS is fixed or document the
@@ -391,86 +387,68 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase {
      */
 
     // 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");
+    // TODO: use assertion
+    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 ");
     }
 
     // verify Deleted key "13"
-    {
-      Object obj = region.get("13");
-      assertEquals(obj, null);
 
-      obj = region.get("14");
-      assertEquals(obj, null);
+    Object obj = region.get("13");
+    assertEquals(obj, null);
 
-      obj = region.get("15");
-      assertEquals(obj, null);
+    obj = region.get("14");
+    assertEquals(obj, null);
 
-      obj = region.get("16");
-      assertEquals(obj, null);
-    }
+    obj = region.get("15");
+    assertEquals(obj, null);
 
+    obj = region.get("16");
+    assertEquals(obj, null);
   }
 
-  public void doUpdatesUsingRestApis(String restEndpoint) {
+  private void doUpdatesUsingRestApis(String restEndpoint) throws IOException {
     // 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);
-      }
-    }
+
+    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);
 
     // 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);
 
     // 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);
 
     // 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 +
@@ -483,262 +461,208 @@ public class RestAPIsAndInterOpsDUnitTest extends LocatorTestBase {
      */
 
     // 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);
-      }
-    }
+
+    /*
+     * 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);
+     */
+
+    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);
   }
 
-  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!");
+    response = httpclient.execute(get);
+    HttpEntity entity = response.getEntity();
+    InputStream content = entity.getContent();
+    BufferedReader reader = new BufferedReader(new InputStreamReader(content));
+    String line;
+    StringBuilder str = new StringBuilder();
+    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());
 
-  public void doGetsUsingRestApis(String restEndpoint) {
+      // verify total number of REST service endpoints in DS
+      assertEquals(jsonArray.length(), 2);
+    }
+  }
 
+  private void doGetsUsingRestApis(String restEndpoint) throws IOException {
     // 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);
+
+    // 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;
+    StringBuilder str = new StringBuilder();
+    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";
+
+    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));
+    str = new StringBuilder();
+    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
+
+    get = new HttpGet(restEndpoint + "/People");
+    get.addHeader("Content-Type", "application/json");
+    get.addHeader("Accept", "application/json");
+    httpclient = HttpClients.createDefault();
+    CloseableHttpResponse result = httpclient.execute(get);
+    assertEquals(result.getStatusLine().getStatusCode(), 200);
+    assertNotNull(result.getEntity());
+
+    entity = result.getEntity();
+    content = entity.getContent();
+    reader = new BufferedReader(new InputStreamReader(content));
+    StringBuilder sb = new StringBuilder();
+    while ((line = reader.readLine()) != null) {
+      sb.append(line);
+    }
+    result.close();
+
+    jObject = new JSONObject(sb.toString());
+    jArray = jObject.getJSONArray("People");
+    assertEquals(jArray.length(), 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);
+    assertEquals(response.getStatusLine().getStatusCode(), 200);
+    assertNotNull(response.getEntity());
+
+    entity = response.getEntity();
+    content = entity.getContent();
+    reader = new BufferedReader(new InputStreamReader(content));
+    str = new StringBuilder();
+    while ((line = reader.readLine()) != null) {
+      str.append(line);
+    }
+
+    jObject = new JSONObject(str.toString());
+    jArray = jObject.getJSONArray("People");
+    assertEquals(jArray.length(), 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);
+    assertEquals(response.getStatusLine().getStatusCode(), 200);
+    assertNotNull(response.getEntity());
+
+    entity = response.getEntity();
+    content = entity.getContent();
+    reader = new BufferedReader(new InputStreamReader(content));
+    str = new StringBuilder();
+    while ((line = reader.readLine()) != null) {
+      str.append(line);
+    }
+
+    jObject = new JSONObject(str.toString());
+    jArray = jObject.getJSONArray("keys");
+    assertEquals(jArray.length(), 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);
+    assertEquals(response.getStatusLine().getStatusCode(), 200);
+    assertNotNull(response.getEntity());
+
+    entity = response.getEntity();
+    content = entity.getContent();
+    reader = new BufferedReader(new InputStreamReader(content));
+    str = new StringBuilder();
+    while ((line = reader.readLine()) != null) {
+      str.append(line);
     }
+
+    jObject = new JSONObject(str.toString());
+    jArray = jObject.getJSONArray("People");
+    assertEquals(jArray.length(), 6);
   }
 
-  public void createRegionInClientCache() {
+  private void createRegionInClientCache() {
     ClientCache cache = GemFireCacheImpl.getInstance();
     assertNotNull(cache);
     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);
 
@@ -751,7 +675,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,7 +725,7 @@ 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 =
         new ClientCacheFactory().setPdxReadSerialized(true).addPoolLocator(host, port).create();
@@ -842,6 +765,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/eab9e6e0/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..d9faf6b 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,8 +14,6 @@
  */
 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;
@@ -32,6 +30,8 @@ import org.apache.geode.security.AuthenticationRequiredException;
 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 +170,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 +205,13 @@ public class CacheFactory {
       if (this.dsProps.isEmpty()) {
         // any ds will do
         ds = InternalDistributedSystem.getConnectedInstance();
+        // TODO:if already connected AND used setSecurityManager or setPostProcessor then throw
+        // Error
       }
       if (ds == null) {
         ds = DistributedSystem.connect(this.dsProps);
       }
-      return create(ds, true, cacheConfig);
+      return create(ds, true, this.cacheConfig);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/eab9e6e0/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/eab9e6e0/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 029e637..11d87a7 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
@@ -1149,8 +1149,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/eab9e6e0/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..bcabe3d 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,41 @@ 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, null, null);
+  }
+
+  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 +498,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 +563,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 +575,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/eab9e6e0/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
index c299dd0..5431432 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
@@ -694,6 +694,8 @@ public class InternalLocator extends Locator implements ConnectListener {
               LocalizedStrings.InternalDistributedSystem_STARTUP_CONFIGURATIONN_0,
               this.config.toLoggerString()));
 
+      // TODO:KIRK: need SecurityService for both DistributedSystem and startCache below
+
       this.myDs = (InternalDistributedSystem) DistributedSystem.connect(connectEnv);
 
       if (this.peerLocator) {

http://git-wip-us.apache.org/repos/asf/geode/blob/eab9e6e0/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/eab9e6e0/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/eab9e6e0/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();

http://git-wip-us.apache.org/repos/asf/geode/blob/eab9e6e0/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/Services.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/Services.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/Services.java
index 1404b3b..2d6af1a 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/Services.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/Services.java
@@ -26,7 +26,12 @@ import org.apache.geode.distributed.internal.membership.MembershipManager;
 import org.apache.geode.distributed.internal.membership.NetView;
 import org.apache.geode.distributed.internal.membership.gms.auth.GMSAuthenticator;
 import org.apache.geode.distributed.internal.membership.gms.fd.GMSHealthMonitor;
-import org.apache.geode.distributed.internal.membership.gms.interfaces.*;
+import org.apache.geode.distributed.internal.membership.gms.interfaces.Authenticator;
+import org.apache.geode.distributed.internal.membership.gms.interfaces.HealthMonitor;
+import org.apache.geode.distributed.internal.membership.gms.interfaces.JoinLeave;
+import org.apache.geode.distributed.internal.membership.gms.interfaces.Locator;
+import org.apache.geode.distributed.internal.membership.gms.interfaces.Manager;
+import org.apache.geode.distributed.internal.membership.gms.interfaces.Messenger;
 import org.apache.geode.distributed.internal.membership.gms.locator.GMSLocator;
 import org.apache.geode.distributed.internal.membership.gms.membership.GMSJoinLeave;
 import org.apache.geode.distributed.internal.membership.gms.messenger.JGroupsMessenger;
@@ -35,6 +40,8 @@ import org.apache.geode.internal.admin.remote.RemoteTransportConfig;
 import org.apache.geode.internal.logging.InternalLogWriter;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.logging.LoggingThreadGroup;
+import org.apache.geode.internal.security.SecurityService;
+import org.apache.geode.internal.security.SecurityServiceFactory;
 import org.apache.geode.security.AuthenticationFailedException;
 import org.apache.logging.log4j.Logger;
 
@@ -51,26 +58,27 @@ public class Services {
   private static InternalLogWriter staticLogWriter;
   private static InternalLogWriter staticSecurityLogWriter;
 
-  final private Manager manager;
-  final private JoinLeave joinLeave;
-  private Locator locator;
-  final private HealthMonitor healthMon;
-  final private Messenger messenger;
-  final private Authenticator auth;
-  final private ServiceConfig config;
-  final private DMStats stats;
-  final private Stopper cancelCriterion;
+  private final Manager manager;
+  private final JoinLeave joinLeave;
+  private final HealthMonitor healthMon;
+  private final Messenger messenger;
+  private final Authenticator auth;
+  private final ServiceConfig config;
+  private final DMStats stats;
+  private final Stopper cancelCriterion;
+  private final SecurityService securityService;
+
   private volatile boolean stopping;
   private volatile boolean stopped;
   private volatile Exception shutdownCause;
 
+  private Locator locator;
+
   private InternalLogWriter logWriter;
   private InternalLogWriter securityLogWriter;
 
   private final Timer timer = new Timer("Geode Membership Timer", true);
 
-
-
   /**
    * A common logger for membership classes
    */
@@ -96,7 +104,6 @@ public class Services {
     return this.stopped;
   }
 
-
   /**
    * for testing only - create a non-functional Services object with a Stopper
    */
@@ -108,11 +115,12 @@ public class Services {
     this.joinLeave = null;
     this.healthMon = null;
     this.messenger = null;
+    this.securityService = SecurityServiceFactory.create();
     this.auth = null;
   }
 
   public Services(DistributedMembershipListener listener, DistributionConfig config,
-      RemoteTransportConfig transport, DMStats stats) {
+      RemoteTransportConfig transport, DMStats stats, SecurityService securityService) {
     this.cancelCriterion = new Stopper();
     this.stats = stats;
     this.config = new ServiceConfig(transport, config);
@@ -120,15 +128,16 @@ public class Services {
     this.joinLeave = new GMSJoinLeave();
     this.healthMon = new GMSHealthMonitor();
     this.messenger = new JGroupsMessenger();
+    this.securityService = securityService;
     this.auth = new GMSAuthenticator();
   }
 
   protected void init() {
     // InternalDistributedSystem establishes this log writer at boot time
     // TODO fix this so that IDS doesn't know about Services
-    securityLogWriter = staticSecurityLogWriter;
+    this.securityLogWriter = staticSecurityLogWriter;
     staticSecurityLogWriter = null;
-    logWriter = staticLogWriter;
+    this.logWriter = staticLogWriter;
     staticLogWriter = null;
     this.auth.init(this);
     this.messenger.init(this);
@@ -186,29 +195,29 @@ public class Services {
   }
 
   public void emergencyClose() {
-    if (stopping) {
+    if (this.stopping) {
       return;
     }
-    stopping = true;
+    this.stopping = true;
     logger.info("Stopping membership services");
-    timer.cancel();
+    this.timer.cancel();
     try {
-      joinLeave.emergencyClose();
+      this.joinLeave.emergencyClose();
     } finally {
       try {
-        healthMon.emergencyClose();
+        this.healthMon.emergencyClose();
       } finally {
         try {
-          auth.emergencyClose();
+          this.auth.emergencyClose();
         } finally {
           try {
-            messenger.emergencyClose();
+            this.messenger.emergencyClose();
           } finally {
             try {
-              manager.emergencyClose();
+              this.manager.emergencyClose();
             } finally {
-              cancelCriterion.cancel("Membership services are shut down");
-              stopped = true;
+              this.cancelCriterion.cancel("Membership services are shut down");
+              this.stopped = true;
             }
           }
         }
@@ -217,31 +226,31 @@ public class Services {
   }
 
   public void stop() {
-    if (stopping) {
+    if (this.stopping) {
       return;
     }
     logger.info("Stopping membership services");
-    stopping = true;
+    this.stopping = true;
     try {
-      timer.cancel();
+      this.timer.cancel();
     } finally {
       try {
-        joinLeave.stop();
+        this.joinLeave.stop();
       } finally {
         try {
-          healthMon.stop();
+          this.healthMon.stop();
         } finally {
           try {
-            auth.stop();
+            this.auth.stop();
           } finally {
             try {
-              messenger.stop();
+              this.messenger.stop();
             } finally {
               try {
-                manager.stop();
+                this.manager.stop();
               } finally {
-                cancelCriterion.cancel("Membership services are shut down");
-                stopped = true;
+                this.cancelCriterion.cancel("Membership services are shut down");
+                this.stopped = true;
               }
             }
           }
@@ -258,6 +267,10 @@ public class Services {
     staticSecurityLogWriter = securityWriter;
   }
 
+  public SecurityService getSecurityService() {
+    return this.securityService;
+  }
+
   public InternalLogWriter getLogWriter() {
     return this.logWriter;
   }
@@ -267,38 +280,38 @@ public class Services {
   }
 
   public Authenticator getAuthenticator() {
-    return auth;
+    return this.auth;
   }
 
   public void installView(NetView v) {
     try {
-      auth.installView(v);
+      this.auth.installView(v);
     } catch (AuthenticationFailedException e) {
       return;
     }
-    if (locator != null) {
-      locator.installView(v);
+    if (this.locator != null) {
+      this.locator.installView(v);
     }
-    healthMon.installView(v);
-    messenger.installView(v);
-    manager.installView(v);
+    this.healthMon.installView(v);
+    this.messenger.installView(v);
+    this.manager.installView(v);
   }
 
   public void memberSuspected(InternalDistributedMember initiator,
       InternalDistributedMember suspect, String reason) {
     try {
-      joinLeave.memberSuspected(initiator, suspect, reason);
+      this.joinLeave.memberSuspected(initiator, suspect, reason);
     } finally {
       try {
-        healthMon.memberSuspected(initiator, suspect, reason);
+        this.healthMon.memberSuspected(initiator, suspect, reason);
       } finally {
         try {
-          auth.memberSuspected(initiator, suspect, reason);
+          this.auth.memberSuspected(initiator, suspect, reason);
         } finally {
           try {
-            messenger.memberSuspected(initiator, suspect, reason);
+            this.messenger.memberSuspected(initiator, suspect, reason);
           } finally {
-            manager.memberSuspected(initiator, suspect, reason);
+            this.manager.memberSuspected(initiator, suspect, reason);
           }
         }
       }
@@ -306,11 +319,11 @@ public class Services {
   }
 
   public Manager getManager() {
-    return manager;
+    return this.manager;
   }
 
   public Locator getLocator() {
-    return locator;
+    return this.locator;
   }
 
   public void setLocator(Locator locator) {
@@ -318,11 +331,11 @@ public class Services {
   }
 
   public JoinLeave getJoinLeave() {
-    return joinLeave;
+    return this.joinLeave;
   }
 
   public HealthMonitor getHealthMonitor() {
-    return healthMon;
+    return this.healthMon;
   }
 
   public ServiceConfig getConfig() {
@@ -346,11 +359,11 @@ public class Services {
   }
 
   public Exception getShutdownCause() {
-    return shutdownCause;
+    return this.shutdownCause;
   }
 
   public boolean isShutdownDueToForcedDisconnect() {
-    return shutdownCause instanceof ForcedDisconnectException;
+    return this.shutdownCause instanceof ForcedDisconnectException;
   }
 
   public boolean isAutoReconnectEnabled() {
@@ -358,8 +371,8 @@ public class Services {
   }
 
   public byte[] getPublicKey(InternalDistributedMember mbr) {
-    if (locator != null) {
-      return ((GMSLocator) locator).getPublicKey(mbr);
+    if (this.locator != null) {
+      return ((GMSLocator) this.locator).getPublicKey(mbr);
     }
     return null;
   }
@@ -375,7 +388,7 @@ public class Services {
     public String cancelInProgress() {
       if (Services.this.shutdownCause != null)
         return Services.this.shutdownCause.toString();
-      return reasonForStopping;
+      return this.reasonForStopping;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/geode/blob/eab9e6e0/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/auth/GMSAuthenticator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/auth/GMSAuthenticator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/auth/GMSAuthenticator.java
index ab0ca6b..3656a97 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/auth/GMSAuthenticator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/auth/GMSAuthenticator.java
@@ -14,33 +14,41 @@
  */
 package org.apache.geode.distributed.internal.membership.gms.auth;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.apache.geode.internal.i18n.LocalizedStrings.*;
-
-import java.security.Principal;
-import java.util.Properties;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTHENTICATOR;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTH_INIT;
+import static org.apache.geode.internal.i18n.LocalizedStrings.AUTH_PEER_AUTHENTICATION_FAILED;
+import static org.apache.geode.internal.i18n.LocalizedStrings.AUTH_PEER_AUTHENTICATION_FAILED_WITH_EXCEPTION;
+import static org.apache.geode.internal.i18n.LocalizedStrings.AUTH_PEER_AUTHENTICATION_MISSING_CREDENTIALS;
+import static org.apache.geode.internal.i18n.LocalizedStrings.HandShake_FAILED_TO_ACQUIRE_AUTHENTICATOR_OBJECT;
 
 import org.apache.commons.lang.StringUtils;
-
 import org.apache.geode.LogWriter;
 import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
 import org.apache.geode.distributed.internal.membership.NetView;
 import org.apache.geode.distributed.internal.membership.gms.Services;
 import org.apache.geode.distributed.internal.membership.gms.interfaces.Authenticator;
+import org.apache.geode.internal.cache.CacheConfig;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.tier.sockets.HandShake;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.InternalLogWriter;
 import org.apache.geode.internal.security.IntegratedSecurityService;
 import org.apache.geode.internal.security.SecurityService;
+import org.apache.geode.internal.security.SecurityServiceFactory;
 import org.apache.geode.security.AuthenticationFailedException;
 import org.apache.geode.security.GemFireSecurityException;
 
+import java.security.Principal;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicReference;
+
 public class GMSAuthenticator implements Authenticator {
 
   private Services services;
   private Properties securityProps;
-  private SecurityService securityService = IntegratedSecurityService.getSecurityService();
 
   @Override
   public void init(Services s) {
@@ -98,11 +106,12 @@ public class GMSAuthenticator implements Authenticator {
    */
   String authenticate(DistributedMember member, Properties credentials, Properties secProps)
       throws AuthenticationFailedException {
+    SecurityService securityService = this.services.getSecurityService();
+
     // For older systems, locator might be started without cache, so secureService may not be
-    // initialized here. We need to check
-    // if the passed in secProps has peer authenticator or not
+    // initialized here. We need to check if the passed in secProps has peer authenticator or not at
+    // this point
     String authMethod = secProps.getProperty(SECURITY_PEER_AUTHENTICATOR);
-    // at this point,
     if (!securityService.isPeerSecurityRequired() && StringUtils.isBlank(authMethod)) {
       return null;
     }
@@ -116,9 +125,9 @@ public class GMSAuthenticator implements Authenticator {
 
     String failMsg = null;
     try {
-      if (this.securityService.isIntegratedSecurity()) {
-        this.securityService.login(credentials);
-        this.securityService.authorizeClusterManage();
+      if (securityService.isIntegratedSecurity()) {
+        securityService.login(credentials);
+        securityService.authorizeClusterManage();
       } else {
         invokeAuthenticator(secProps, member, credentials);
       }
@@ -145,10 +154,10 @@ public class GMSAuthenticator implements Authenticator {
 
       LogWriter logWriter = this.services.getLogWriter();
       LogWriter securityLogWriter = this.services.getSecurityLogWriter();
-      auth.init(this.securityProps, logWriter, securityLogWriter); // this.securityProps contains
-                                                                   // security-ldap-basedn but
-                                                                   // security-ldap-baseDomainName
-                                                                   // is expected
+
+      // this.securityProps contains security-ldap-basedn but security-ldap-baseDomainName is
+      // expected
+      auth.init(this.securityProps, logWriter, securityLogWriter);
       return auth.authenticate(credentials, member);
 
     } catch (GemFireSecurityException gse) {


Mime
View raw message