geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [01/11] geode git commit: GEODE-2632: use immutable SecurityService impls to improve performance
Date Fri, 09 Jun 2017 17:24:55 GMT
Repository: geode
Updated Branches:
  refs/heads/release/1.2.0 2a248a3e4 -> 5eca6f039


http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-core/src/test/java/org/apache/geode/security/SecurityManagerLifecycleIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/SecurityManagerLifecycleIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/security/SecurityManagerLifecycleIntegrationTest.java
new file mode 100644
index 0000000..f00b03a
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/security/SecurityManagerLifecycleIntegrationTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.security;
+
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.security.SecurityService;
+import org.apache.geode.test.junit.categories.FlakyTest;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.Properties;
+
+@Category({IntegrationTest.class, SecurityTest.class})
+public class SecurityManagerLifecycleIntegrationTest {
+
+  private Properties securityProps;
+  private InternalCache cache;
+  private SecurityService securityService;
+
+  @Before
+  public void before() {
+    this.securityProps = new Properties();
+    this.securityProps.setProperty(SECURITY_MANAGER, SpySecurityManager.class.getName());
+
+    Properties props = new Properties();
+    props.putAll(this.securityProps);
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(LOCATORS, "");
+
+    this.cache = (InternalCache) new CacheFactory(props).create();
+
+    this.securityService = this.cache.getSecurityService();
+  }
+
+  @After
+  public void after() {
+    if (this.cache != null && !this.cache.isClosed()) {
+      this.cache.close();
+    }
+  }
+
+  @Category(FlakyTest.class) // GEODE-1661
+  @Test
+  public void initAndCloseTest() {
+    SpySecurityManager ssm = (SpySecurityManager) this.securityService.getSecurityManager();
+    assertThat(ssm.getInitInvocationCount()).isEqualTo(1);
+    this.cache.close();
+    assertThat(ssm.getCloseInvocationCount()).isEqualTo(1);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-core/src/test/java/org/apache/geode/security/SimpleSecurityManagerTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/SimpleSecurityManagerTest.java b/geode-core/src/test/java/org/apache/geode/security/SimpleSecurityManagerTest.java
index 2d6fbca..1c73b57 100644
--- a/geode-core/src/test/java/org/apache/geode/security/SimpleSecurityManagerTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/SimpleSecurityManagerTest.java
@@ -12,7 +12,6 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package org.apache.geode.security;
 
 import static org.apache.geode.internal.Assert.assertTrue;

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-core/src/test/java/org/apache/geode/security/SimpleTestSecurityManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/SimpleTestSecurityManager.java b/geode-core/src/test/java/org/apache/geode/security/SimpleTestSecurityManager.java
index c754376..ac2d15d 100644
--- a/geode-core/src/test/java/org/apache/geode/security/SimpleTestSecurityManager.java
+++ b/geode-core/src/test/java/org/apache/geode/security/SimpleTestSecurityManager.java
@@ -23,20 +23,23 @@ import java.util.Properties;
  *
  * It is meant for demo purpose, not for production.
  *
- * Authentiation: All users whose password matches the username are authenticated. e.g.
+ * Authentication: All users whose password matches the username are authenticated. e.g.
  * username/password = test/test, user/user, admin/admin
  *
  * Authorization: users whose username is a substring (case insensitive) of the permission required
  * are authorized. e.g. username = data: is authorized for all data operations: data; data:manage
  * data:read data:write username = dataWrite: is authorized for data writes on all regions:
  * data:write data:write:regionA username = cluster: authorized for all cluster operations username
- * = cluserRead: authorzed for all cluster read operations
+ * = clusterRead: authorized for all cluster read operations
  *
  * a user could be a comma separated list of roles as well.
  */
 public class SimpleTestSecurityManager implements SecurityManager {
+
   @Override
-  public void init(final Properties securityProps) {}
+  public void init(final Properties securityProps) {
+    // nothing
+  }
 
   @Override
   public Object authenticate(final Properties credentials) throws AuthenticationFailedException {
@@ -60,5 +63,7 @@ public class SimpleTestSecurityManager implements SecurityManager {
   }
 
   @Override
-  public void close() {}
+  public void close() {
+    // nothing
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-core/src/test/java/org/apache/geode/security/SpySecurityManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/SpySecurityManager.java b/geode-core/src/test/java/org/apache/geode/security/SpySecurityManager.java
index 1109489..4523dae 100644
--- a/geode-core/src/test/java/org/apache/geode/security/SpySecurityManager.java
+++ b/geode-core/src/test/java/org/apache/geode/security/SpySecurityManager.java
@@ -15,17 +15,16 @@
 package org.apache.geode.security;
 
 import java.util.Properties;
-
-import org.apache.geode.security.SecurityManager;
+import java.util.concurrent.atomic.AtomicInteger;
 
 public class SpySecurityManager extends SimpleTestSecurityManager {
 
-  public int initInvoked = 0;
-  public int closeInvoked = 0;
+  private final AtomicInteger initInvoked = new AtomicInteger(0);
+  private final AtomicInteger closeInvoked = new AtomicInteger(0);
 
   @Override
   public void init(final Properties securityProps) {
-    initInvoked++;
+    this.initInvoked.incrementAndGet();
   }
 
   @Override
@@ -35,6 +34,14 @@ public class SpySecurityManager extends SimpleTestSecurityManager {
 
   @Override
   public void close() {
-    closeInvoked++;
+    this.closeInvoked.incrementAndGet();
+  }
+
+  public int getInitInvocationCount() {
+    return this.initInvoked.get();
+  }
+
+  public int getCloseInvocationCount() {
+    return this.closeInvoked.get();
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java b/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java
index 72b8190..effbf25 100755
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java
@@ -14,6 +14,9 @@
  */
 package org.apache.geode.test.dunit;
 
+import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_AUTO_RECONNECT;
+import static org.junit.Assert.assertEquals;
+
 import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.distributed.internal.membership.gms.MembershipManagerHelper;
@@ -25,10 +28,6 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
 
-import static org.junit.Assert.assertEquals;
-
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
 /**
  * <code>DistributedTestUtils</code> provides static utility methods that affect the runtime
  * environment or artifacts generated by a DistributedTest.
@@ -155,8 +154,7 @@ public class DistributedTestUtils {
   }
 
   public static void unregisterDataSerializerInThisVM() {
-    // TODO:KIRK: delete DataSerializerPropogationDUnitTest.successfullyLoadedTestDataSerializer =
-    // false;
+    // TODO: delete DataSerializerPropogationDUnitTest.successfullyLoadedTestDataSerializer = false;
     // unregister all the Dataserializers
     InternalDataSerializer.reinitialize();
     // ensure that all are unregistered

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
index 40cfe99..fa3e8c0 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
@@ -19,7 +19,6 @@ import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_
 import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_REST_API;
 
-import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.server.CacheServer;
@@ -27,6 +26,7 @@ import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 
 import java.io.File;
 import java.io.IOException;
@@ -51,7 +51,7 @@ import java.util.Properties;
  * use {@link LocatorServerStartupRule}.
  */
 public class ServerStarterRule extends MemberStarterRule<ServerStarterRule> implements Server {
-  private transient Cache cache;
+  private transient InternalCache cache;
   private transient CacheServer server;
   private int embeddedLocatorPort = -1;
   private boolean pdxPersistent = false;
@@ -74,7 +74,7 @@ public class ServerStarterRule extends MemberStarterRule<ServerStarterRule> impl
     super(workingDir);
   }
 
-  public Cache getCache() {
+  public InternalCache getCache() {
     return cache;
   }
 
@@ -161,7 +161,7 @@ public class ServerStarterRule extends MemberStarterRule<ServerStarterRule> impl
     CacheFactory cf = new CacheFactory(this.properties);
     cf.setPdxReadSerialized(pdxPersistent);
     cf.setPdxPersistent(pdxPersistent);
-    cache = cf.create();
+    cache = (InternalCache) cf.create();
     DistributionConfig config =
         ((InternalDistributedSystem) cache.getDistributedSystem()).getConfig();
     server = cache.addCacheServer();

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-core/src/test/java/org/apache/geode/test/fake/Fakes.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/fake/Fakes.java b/geode-core/src/test/java/org/apache/geode/test/fake/Fakes.java
index 6a1e26f..af38a1c 100644
--- a/geode-core/src/test/java/org/apache/geode/test/fake/Fakes.java
+++ b/geode-core/src/test/java/org/apache/geode/test/fake/Fakes.java
@@ -34,6 +34,7 @@ import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
 import org.apache.geode.internal.cache.CachePerfStats;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.security.SecurityService;
 
 /**
  * Factory methods for fake objects for use in test.
@@ -79,6 +80,7 @@ public class Fakes {
     when(cache.getDistributionManager()).thenReturn(distributionManager);
     when(cache.getCancelCriterion()).thenReturn(systemCancelCriterion);
     when(cache.getCachePerfStats()).thenReturn(mock(CachePerfStats.class));
+    when(cache.getSecurityService()).thenReturn(mock(SecurityService.class));
 
     when(system.getDistributedMember()).thenReturn(member);
     when(system.getConfig()).thenReturn(config);
@@ -86,6 +88,7 @@ public class Fakes {
     when(system.getCancelCriterion()).thenReturn(systemCancelCriterion);
     when(system.getClock()).thenReturn(clock);
     when(system.getLogWriter()).thenReturn(logger);
+    when(system.getSecurityService()).thenReturn(mock(SecurityService.class));
     when(system.createAtomicStatistics(any(), any(), anyLong())).thenReturn(stats);
     when(system.createAtomicStatistics(any(), any())).thenReturn(stats);
 

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
index 9a85c7e..b596c68 100755
--- a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
+++ b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
@@ -450,6 +450,7 @@ org/apache/geode/internal/process/PidUnavailableException,true,-1660269538268828
 org/apache/geode/internal/process/signal/Signal,false,description:java/lang/String,name:java/lang/String,number:int,type:org/apache/geode/internal/process/signal/SignalType
 org/apache/geode/internal/process/signal/SignalEvent,false,signal:org/apache/geode/internal/process/signal/Signal
 org/apache/geode/internal/process/signal/SignalType,false,description:java/lang/String
+org/apache/geode/internal/security/SecurityServiceType,false
 org/apache/geode/internal/sequencelog/GraphType,false
 org/apache/geode/internal/sequencelog/model/GraphID,false,graphName:java/lang/String,type:org/apache/geode/internal/sequencelog/GraphType
 org/apache/geode/internal/size/ReflectionObjectSizer,false

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-core/src/test/resources/org/apache/geode/internal/security/SecurityServiceFactoryShiroIntegrationTest.ini
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/internal/security/SecurityServiceFactoryShiroIntegrationTest.ini b/geode-core/src/test/resources/org/apache/geode/internal/security/SecurityServiceFactoryShiroIntegrationTest.ini
new file mode 100644
index 0000000..8f7ffa7
--- /dev/null
+++ b/geode-core/src/test/resources/org/apache/geode/internal/security/SecurityServiceFactoryShiroIntegrationTest.ini
@@ -0,0 +1,30 @@
+# 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.
+
+# the users and roles in this file needs to be kept in sync with shiro.ini
+# since they are used by the same test to test ShiroUtil
+# -----------------------------------------------------------------------------
+# Users and their (optional) assigned roles
+# username = password, role1, role2, ..., roleN
+# -----------------------------------------------------------------------------
+[users]
+root = secret, admin
+
+# -----------------------------------------------------------------------------
+# Roles with assigned permissions
+# roleName = perm1, perm2, ..., permN
+# -----------------------------------------------------------------------------
+[roles]
+admin = *

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-core/src/test/resources/org/apache/geode/internal/security/shiro/ConfigInitializerIntegrationTest.ini
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/internal/security/shiro/ConfigInitializerIntegrationTest.ini b/geode-core/src/test/resources/org/apache/geode/internal/security/shiro/ConfigInitializerIntegrationTest.ini
new file mode 100644
index 0000000..8f7ffa7
--- /dev/null
+++ b/geode-core/src/test/resources/org/apache/geode/internal/security/shiro/ConfigInitializerIntegrationTest.ini
@@ -0,0 +1,30 @@
+# 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.
+
+# the users and roles in this file needs to be kept in sync with shiro.ini
+# since they are used by the same test to test ShiroUtil
+# -----------------------------------------------------------------------------
+# Users and their (optional) assigned roles
+# username = password, role1, role2, ..., roleN
+# -----------------------------------------------------------------------------
+[users]
+root = secret, admin
+
+# -----------------------------------------------------------------------------
+# Roles with assigned permissions
+# roleName = perm1, perm2, ..., permN
+# -----------------------------------------------------------------------------
+[roles]
+admin = *

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/CloseCQ.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/CloseCQ.java b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/CloseCQ.java
index 18929eb..6748f7d 100644
--- a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/CloseCQ.java
+++ b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/CloseCQ.java
@@ -14,10 +14,6 @@
  */
 package org.apache.geode.internal.cache.tier.sockets.command;
 
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
 import org.apache.geode.cache.query.CqException;
 import org.apache.geode.cache.query.internal.cq.CqService;
 import org.apache.geode.cache.query.internal.cq.InternalCqQuery;
@@ -31,27 +27,31 @@ import org.apache.geode.internal.cache.tier.sockets.Message;
 import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.security.AuthorizeRequest;
+import org.apache.geode.internal.security.SecurityService;
 
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
 
 public class CloseCQ extends BaseCQCommand {
 
-  private final static CloseCQ singleton = new CloseCQ();
+  private static final CloseCQ singleton = new CloseCQ();
 
   public static Command getCommand() {
     return singleton;
   }
 
-  private CloseCQ() {}
+  private CloseCQ() {
+    // nothing
+  }
 
   @Override
-  public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start)
-      throws IOException {
+  public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
+      final SecurityService securityService, long start) throws IOException {
     CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
     ClientProxyMembershipID id = serverConnection.getProxyID();
     CacheServerStats stats = serverConnection.getCacheServerStats();
 
-    // Based on MessageType.QUERY
-    // Added by Rao 2/1/2007
     serverConnection.setAsTrue(REQUIRES_RESPONSE);
     serverConnection.setAsTrue(REQUIRES_CHUNKED_RESPONSE);
 
@@ -73,7 +73,7 @@ public class CloseCQ extends BaseCQCommand {
       return;
     }
 
-    this.securityService.authorizeDataManage();
+    securityService.authorizeDataManage();
 
     // Process CQ close request
     try {
@@ -89,19 +89,16 @@ public class CloseCQ extends BaseCQCommand {
 
       AuthorizeRequest authzRequest = serverConnection.getAuthzRequest();
       if (authzRequest != null) {
-        String queryStr = null;
-        Set cqRegionNames = null;
 
         if (cqQuery != null) {
-          queryStr = cqQuery.getQueryString();
-          cqRegionNames = new HashSet();
-          cqRegionNames.add(((InternalCqQuery) cqQuery).getRegionName());
+          String queryStr = cqQuery.getQueryString();
+          Set cqRegionNames = new HashSet();
+          cqRegionNames.add(cqQuery.getRegionName());
           authzRequest.closeCQAuthorize(cqName, queryStr, cqRegionNames);
         }
 
       }
-      // String cqNameWithClientId = new String(cqName + "__" +
-      // getMembershipID());
+
       cqService.closeCq(cqName, id);
       if (cqQuery != null)
         serverConnection.removeCq(cqName, cqQuery.isDurable());
@@ -123,11 +120,9 @@ public class CloseCQ extends BaseCQCommand {
         clientMessage.getTransactionId(), null, serverConnection);
     serverConnection.setAsTrue(RESPONDED);
 
-    {
-      long oldStart = start;
-      start = DistributionStats.getStatTime();
-      stats.incProcessCloseCqTime(start - oldStart);
-    }
+    long oldStart = start;
+    start = DistributionStats.getStatTime();
+    stats.incProcessCloseCqTime(start - oldStart);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ.java b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ.java
index 86d53f5..04e32f8 100644
--- a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ.java
+++ b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ.java
@@ -14,11 +14,6 @@
  */
 package org.apache.geode.internal.cache.tier.sockets.command;
 
-import java.io.IOException;
-import java.util.Set;
-
-import org.apache.logging.log4j.Logger;
-
 import org.apache.geode.cache.operations.ExecuteCQOperationContext;
 import org.apache.geode.cache.query.CqException;
 import org.apache.geode.cache.query.Query;
@@ -39,21 +34,28 @@ import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.security.AuthorizeRequest;
+import org.apache.geode.internal.security.SecurityService;
+import org.apache.logging.log4j.Logger;
+
+import java.io.IOException;
+import java.util.Set;
 
 public class ExecuteCQ extends BaseCQCommand {
   protected static final Logger logger = LogService.getLogger();
 
-  private final static ExecuteCQ singleton = new ExecuteCQ();
+  private static final ExecuteCQ singleton = new ExecuteCQ();
 
   public static Command getCommand() {
     return singleton;
   }
 
-  private ExecuteCQ() {}
+  private ExecuteCQ() {
+    // nothing
+  }
 
   @Override
-  public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start)
-      throws IOException, InterruptedException {
+  public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
+      final SecurityService securityService, long start) throws IOException, InterruptedException {
     AcceptorImpl acceptor = serverConnection.getAcceptor();
     CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
     ClientProxyMembershipID id = serverConnection.getProxyID();
@@ -69,7 +71,7 @@ public class ExecuteCQ extends BaseCQCommand {
 
     Part isDurablePart = clientMessage.getPart(3);
     byte[] isDurableByte = isDurablePart.getSerializedForm();
-    boolean isDurable = (isDurableByte == null || isDurableByte[0] == 0) ? false : true;
+    boolean isDurable = !(isDurableByte == null || isDurableByte[0] == 0);
     if (logger.isDebugEnabled()) {
       logger.debug("{}: Received {} request from {} CqName: {} queryString: {}",
           serverConnection.getName(), MessageType.getString(clientMessage.getMessageType()),
@@ -116,15 +118,14 @@ public class ExecuteCQ extends BaseCQCommand {
       return;
     }
 
-    long oldstart = start;
     boolean sendResults = false;
-    boolean successQuery = false;
 
     if (clientMessage.getMessageType() == MessageType.EXECUTECQ_WITH_IR_MSG_TYPE) {
       sendResults = true;
     }
 
     // Execute the query and send the result-set to client.
+    boolean successQuery = false;
     try {
       if (query == null) {
         query = qService.newQuery(cqQueryString);
@@ -132,11 +133,11 @@ public class ExecuteCQ extends BaseCQCommand {
       }
       ((DefaultQuery) query).setIsCqQuery(true);
       successQuery = processQuery(clientMessage, query, cqQueryString, cqRegionNames, start,
-          cqQuery, executeCQContext, serverConnection, sendResults);
+          cqQuery, executeCQContext, serverConnection, sendResults, securityService);
 
       // Update the CQ statistics.
-      cqQuery.getVsdStats().setCqInitialResultsTime((DistributionStats.getStatTime()) - oldstart);
-      stats.incProcessExecuteCqWithIRTime((DistributionStats.getStatTime()) - oldstart);
+      cqQuery.getVsdStats().setCqInitialResultsTime(DistributionStats.getStatTime() - start);
+      stats.incProcessExecuteCqWithIRTime(DistributionStats.getStatTime() - start);
       // logger.fine("Time spent in execute with initial results :" +
       // DistributionStats.getStatTime() + ", " + oldstart);
     } finally { // To handle any exception.
@@ -144,7 +145,7 @@ public class ExecuteCQ extends BaseCQCommand {
       if (!successQuery) {
         try {
           cqServiceForExec.closeCq(cqName, id);
-        } catch (Exception ex) {
+        } catch (Exception ignore) {
           // Ignore.
         }
       }
@@ -157,7 +158,7 @@ public class ExecuteCQ extends BaseCQCommand {
           clientMessage.getTransactionId(), null, serverConnection);
 
       long start2 = DistributionStats.getStatTime();
-      stats.incProcessCreateCqTime(start2 - oldstart);
+      stats.incProcessCreateCqTime(start2 - start);
     }
     serverConnection.setAsTrue(RESPONDED);
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ61.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ61.java b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ61.java
index fcc45de..77a608c 100755
--- a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ61.java
+++ b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ61.java
@@ -14,11 +14,6 @@
  */
 package org.apache.geode.internal.cache.tier.sockets.command;
 
-import java.io.IOException;
-import java.util.Set;
-
-import org.apache.logging.log4j.Logger;
-
 import org.apache.geode.cache.operations.ExecuteCQOperationContext;
 import org.apache.geode.cache.query.CqException;
 import org.apache.geode.cache.query.Query;
@@ -44,6 +39,11 @@ import org.apache.geode.internal.cache.vmotion.VMotionObserverHolder;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.security.AuthorizeRequest;
+import org.apache.geode.internal.security.SecurityService;
+import org.apache.logging.log4j.Logger;
+
+import java.io.IOException;
+import java.util.Set;
 
 /**
  * @since GemFire 6.1
@@ -51,17 +51,19 @@ import org.apache.geode.internal.security.AuthorizeRequest;
 public class ExecuteCQ61 extends BaseCQCommand {
   protected static final Logger logger = LogService.getLogger();
 
-  private final static ExecuteCQ61 singleton = new ExecuteCQ61();
+  private static final ExecuteCQ61 singleton = new ExecuteCQ61();
 
   public static Command getCommand() {
     return singleton;
   }
 
-  private ExecuteCQ61() {}
+  private ExecuteCQ61() {
+    // nothing
+  }
 
   @Override
-  public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start)
-      throws IOException, InterruptedException {
+  public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
+      final SecurityService securityService, long start) throws IOException, InterruptedException {
     AcceptorImpl acceptor = serverConnection.getAcceptor();
     CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
     ClientProxyMembershipID id = serverConnection.getProxyID();
@@ -77,7 +79,7 @@ public class ExecuteCQ61 extends BaseCQCommand {
 
     Part isDurablePart = clientMessage.getPart(3);
     byte[] isDurableByte = isDurablePart.getSerializedForm();
-    boolean isDurable = (isDurableByte == null || isDurableByte[0] == 0) ? false : true;
+    boolean isDurable = !(isDurableByte == null || isDurableByte[0] == 0);
     // region data policy
     Part regionDataPolicyPart = clientMessage.getPart(clientMessage.getNumberOfParts() - 1);
     byte[] regionDataPolicyPartBytes = regionDataPolicyPart.getSerializedForm();
@@ -155,9 +157,7 @@ public class ExecuteCQ61 extends BaseCQCommand {
       return;
     }
 
-    long oldstart = start;
     boolean sendResults = false;
-    boolean successQuery = false;
 
     if (clientMessage.getMessageType() == MessageType.EXECUTECQ_WITH_IR_MSG_TYPE) {
       sendResults = true;
@@ -165,8 +165,9 @@ public class ExecuteCQ61 extends BaseCQCommand {
 
     // Execute the query only if it is execute with initial results or
     // if it is a non PR query with execute query and maintain keys flags set
-    if (sendResults || (CqServiceImpl.EXECUTE_QUERY_DURING_INIT && CqServiceProvider.MAINTAIN_KEYS
-        && !cqQuery.isPR())) {
+    boolean successQuery = false;
+    if (sendResults || CqServiceImpl.EXECUTE_QUERY_DURING_INIT && CqServiceProvider.MAINTAIN_KEYS
+        && !cqQuery.isPR()) {
       // Execute the query and send the result-set to client.
       try {
         if (query == null) {
@@ -175,12 +176,12 @@ public class ExecuteCQ61 extends BaseCQCommand {
         }
         ((DefaultQuery) query).setIsCqQuery(true);
         successQuery = processQuery(clientMessage, query, cqQueryString, cqRegionNames, start,
-            cqQuery, executeCQContext, serverConnection, sendResults);
+            cqQuery, executeCQContext, serverConnection, sendResults, securityService);
 
 
         // Update the CQ statistics.
-        cqQuery.getVsdStats().setCqInitialResultsTime((DistributionStats.getStatTime()) - oldstart);
-        stats.incProcessExecuteCqWithIRTime((DistributionStats.getStatTime()) - oldstart);
+        cqQuery.getVsdStats().setCqInitialResultsTime(DistributionStats.getStatTime() - start);
+        stats.incProcessExecuteCqWithIRTime(DistributionStats.getStatTime() - start);
         // logger.fine("Time spent in execute with initial results :" +
         // DistributionStats.getStatTime() + ", " + oldstart);
       } finally { // To handle any exception.
@@ -188,7 +189,7 @@ public class ExecuteCQ61 extends BaseCQCommand {
         if (!successQuery) {
           try {
             cqServiceForExec.closeCq(cqName, id);
-          } catch (Exception ex) {
+          } catch (Exception ignored) {
             // Ignore.
           }
         }
@@ -207,10 +208,9 @@ public class ExecuteCQ61 extends BaseCQCommand {
           clientMessage.getTransactionId(), null, serverConnection);
 
       long start2 = DistributionStats.getStatTime();
-      stats.incProcessCreateCqTime(start2 - oldstart);
+      stats.incProcessCreateCqTime(start2 - start);
     }
     serverConnection.setAsTrue(RESPONDED);
-
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetCQStats.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetCQStats.java b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetCQStats.java
index 0fab303..a37263f 100644
--- a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetCQStats.java
+++ b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetCQStats.java
@@ -14,8 +14,6 @@
  */
 package org.apache.geode.internal.cache.tier.sockets.command;
 
-import java.io.IOException;
-
 import org.apache.geode.cache.query.internal.cq.CqService;
 import org.apache.geode.distributed.internal.DistributionStats;
 import org.apache.geode.internal.cache.tier.CachedRegionHelper;
@@ -24,20 +22,25 @@ import org.apache.geode.internal.cache.tier.MessageType;
 import org.apache.geode.internal.cache.tier.sockets.CacheServerStats;
 import org.apache.geode.internal.cache.tier.sockets.Message;
 import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
+import org.apache.geode.internal.security.SecurityService;
+
+import java.io.IOException;
 
 public class GetCQStats extends BaseCQCommand {
 
-  private final static GetCQStats singleton = new GetCQStats();
+  private static final GetCQStats singleton = new GetCQStats();
 
   public static Command getCommand() {
     return singleton;
   }
 
-  private GetCQStats() {}
+  private GetCQStats() {
+    // nothing
+  }
 
   @Override
-  public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start)
-      throws IOException {
+  public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
+      final SecurityService securityService, long start) throws IOException {
     CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
 
     CacheServerStats stats = serverConnection.getCacheServerStats();
@@ -67,7 +70,7 @@ public class GetCQStats extends BaseCQCommand {
       return;
     }
 
-    this.securityService.authorizeClusterRead();
+    securityService.authorizeClusterRead();
     // Process the cq request
     try {
       // make sure the cqservice has been created
@@ -85,11 +88,9 @@ public class GetCQStats extends BaseCQCommand {
         clientMessage.getTransactionId(), null, serverConnection);
     serverConnection.setAsTrue(RESPONDED);
 
-    {
-      long oldStart = start;
-      start = DistributionStats.getStatTime();
-      stats.incProcessGetCqStatsTime(start - oldStart);
-    }
+    long oldStart = start;
+    start = DistributionStats.getStatTime();
+    stats.incProcessGetCqStatsTime(start - oldStart);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetDurableCQs.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetDurableCQs.java b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetDurableCQs.java
index c14bd72..1ba5fed 100755
--- a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetDurableCQs.java
+++ b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetDurableCQs.java
@@ -32,20 +32,23 @@ import org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID;
 import org.apache.geode.internal.cache.tier.sockets.Message;
 import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
 import org.apache.geode.internal.security.AuthorizeRequest;
+import org.apache.geode.internal.security.SecurityService;
 
 public class GetDurableCQs extends BaseCQCommand {
 
-  private final static GetDurableCQs singleton = new GetDurableCQs();
+  private static final GetDurableCQs singleton = new GetDurableCQs();
 
   public static Command getCommand() {
     return singleton;
   }
 
-  private GetDurableCQs() {}
+  private GetDurableCQs() {
+    // nothing
+  }
 
   @Override
-  public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start)
-      throws IOException, InterruptedException {
+  public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
+      final SecurityService securityService, long start) throws IOException, InterruptedException {
     AcceptorImpl acceptor = serverConnection.getAcceptor();
     CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
     ClientProxyMembershipID id = serverConnection.getProxyID();
@@ -60,13 +63,11 @@ public class GetDurableCQs extends BaseCQCommand {
           serverConnection.getSocketString());
     }
 
-    DefaultQueryService qService = null;
-    CqService cqServiceForExec = null;
-
     try {
-      qService = (DefaultQueryService) crHelper.getCache().getLocalQueryService();
+      DefaultQueryService qService =
+          (DefaultQueryService) crHelper.getCache().getLocalQueryService();
 
-      this.securityService.authorizeClusterRead();
+      securityService.authorizeClusterRead();
 
       // Authorization check
       AuthorizeRequest authzRequest = serverConnection.getAuthzRequest();
@@ -74,7 +75,7 @@ public class GetDurableCQs extends BaseCQCommand {
         authzRequest.getDurableCQsAuthorize();
       }
 
-      cqServiceForExec = qService.getCqService();
+      CqService cqServiceForExec = qService.getCqService();
       List<String> durableCqs = cqServiceForExec.getAllDurableClientCqs(id);
 
       ChunkedMessage chunkedResponseMsg = serverConnection.getChunkedResponseMessage();
@@ -84,7 +85,7 @@ public class GetDurableCQs extends BaseCQCommand {
 
       List durableCqList = new ArrayList(MAXIMUM_CHUNK_SIZE);
       final boolean isTraceEnabled = logger.isTraceEnabled();
-      for (Iterator it = durableCqs.iterator(); it.hasNext();) {
+      for (Iterator<String> it = durableCqs.iterator(); it.hasNext();) {
         Object durableCqName = it.next();
         durableCqList.add(durableCqName);
         if (isTraceEnabled) {
@@ -103,10 +104,8 @@ public class GetDurableCQs extends BaseCQCommand {
     } catch (CqException cqe) {
       sendCqResponse(MessageType.CQ_EXCEPTION_TYPE, "", clientMessage.getTransactionId(), cqe,
           serverConnection);
-      return;
     } catch (Exception e) {
       writeChunkedException(clientMessage, e, serverConnection);
-      return;
     }
   }
 
@@ -120,12 +119,11 @@ public class GetDurableCQs extends BaseCQCommand {
 
     if (logger.isDebugEnabled()) {
       logger.debug("{}: Sending {} durableCQs response chunk{}", servConn.getName(),
-          (lastChunk ? " last " : " "),
-          (logger.isTraceEnabled() ? " keys=" + list + " chunk=<" + chunkedResponseMsg + ">" : ""));
+          lastChunk ? " last " : " ",
+          logger.isTraceEnabled() ? " keys=" + list + " chunk=<" + chunkedResponseMsg + ">" : "");
     }
 
     chunkedResponseMsg.sendChunk(servConn);
   }
 
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/MonitorCQ.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/MonitorCQ.java b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/MonitorCQ.java
index 5f0118b..f5e31df 100644
--- a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/MonitorCQ.java
+++ b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/MonitorCQ.java
@@ -14,8 +14,6 @@
  */
 package org.apache.geode.internal.cache.tier.sockets.command;
 
-import java.io.IOException;
-
 import org.apache.geode.cache.query.CqException;
 import org.apache.geode.cache.query.internal.cq.CqService;
 import org.apache.geode.internal.cache.tier.CachedRegionHelper;
@@ -24,20 +22,25 @@ import org.apache.geode.internal.cache.tier.MessageType;
 import org.apache.geode.internal.cache.tier.sockets.Message;
 import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
 import org.apache.geode.internal.i18n.LocalizedStrings;
+import org.apache.geode.internal.security.SecurityService;
+
+import java.io.IOException;
 
 public class MonitorCQ extends BaseCQCommand {
 
-  private final static MonitorCQ singleton = new MonitorCQ();
+  private static final MonitorCQ singleton = new MonitorCQ();
 
   public static Command getCommand() {
     return singleton;
   }
 
-  private MonitorCQ() {}
+  private MonitorCQ() {
+    // nothing
+  }
 
   @Override
-  public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start)
-      throws IOException {
+  public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
+      final SecurityService securityService, long start) throws IOException {
     CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
     serverConnection.setAsTrue(REQUIRES_RESPONSE);
     serverConnection.setAsTrue(REQUIRES_CHUNKED_RESPONSE);
@@ -71,10 +74,10 @@ public class MonitorCQ extends BaseCQCommand {
     if (logger.isDebugEnabled()) {
       logger.debug("{}: Received MonitorCq request from {} op: {}{}", serverConnection.getName(),
           serverConnection.getSocketString(), op,
-          (regionName != null) ? " RegionName: " + regionName : "");
+          regionName != null ? " RegionName: " + regionName : "");
     }
 
-    this.securityService.authorizeClusterRead();
+    securityService.authorizeClusterRead();
 
     try {
       CqService cqService = crHelper.getCache().getCqService();
@@ -90,13 +93,11 @@ public class MonitorCQ extends BaseCQCommand {
     } catch (CqException cqe) {
       sendCqResponse(MessageType.CQ_EXCEPTION_TYPE, "", clientMessage.getTransactionId(), cqe,
           serverConnection);
-      return;
     } catch (Exception e) {
       String err = LocalizedStrings.MonitorCQ_EXCEPTION_WHILE_HANDLING_THE_MONITOR_REQUEST_OP_IS_0
-          .toLocalizedString(Integer.valueOf(op));
+          .toLocalizedString(op);
       sendCqResponse(MessageType.CQ_EXCEPTION_TYPE, err, clientMessage.getTransactionId(), e,
           serverConnection);
-      return;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/StopCQ.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/StopCQ.java b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/StopCQ.java
index 99fbef1..a3d51ed 100644
--- a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/StopCQ.java
+++ b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/StopCQ.java
@@ -14,12 +14,7 @@
  */
 package org.apache.geode.internal.cache.tier.sockets.command;
 
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
 import org.apache.geode.cache.query.CqException;
-import org.apache.geode.cache.query.internal.cq.CqQueryImpl;
 import org.apache.geode.cache.query.internal.cq.CqService;
 import org.apache.geode.cache.query.internal.cq.InternalCqQuery;
 import org.apache.geode.distributed.internal.DistributionStats;
@@ -32,26 +27,31 @@ import org.apache.geode.internal.cache.tier.sockets.Message;
 import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.security.AuthorizeRequest;
+import org.apache.geode.internal.security.SecurityService;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
 
 public class StopCQ extends BaseCQCommand {
 
-  private final static StopCQ singleton = new StopCQ();
+  private static final StopCQ singleton = new StopCQ();
 
   public static Command getCommand() {
     return singleton;
   }
 
-  private StopCQ() {}
+  private StopCQ() {
+    // nothing
+  }
 
   @Override
-  public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start)
-      throws IOException {
+  public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
+      final SecurityService securityService, long start) throws IOException {
     CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
     ClientProxyMembershipID id = serverConnection.getProxyID();
     CacheServerStats stats = serverConnection.getCacheServerStats();
 
-    // Based on MessageType.QUERY
-    // Added by Rao 2/1/2007
     serverConnection.setAsTrue(REQUIRES_RESPONSE);
     serverConnection.setAsTrue(REQUIRES_CHUNKED_RESPONSE);
 
@@ -86,7 +86,7 @@ public class StopCQ extends BaseCQCommand {
       }
       InternalCqQuery cqQuery = cqService.getCq(serverCqName);
 
-      this.securityService.authorizeDataManage();
+      securityService.authorizeDataManage();
 
       AuthorizeRequest authzRequest = serverConnection.getAuthzRequest();
       if (authzRequest != null) {
@@ -96,7 +96,7 @@ public class StopCQ extends BaseCQCommand {
         if (cqQuery != null) {
           queryStr = cqQuery.getQueryString();
           cqRegionNames = new HashSet();
-          cqRegionNames.add(((CqQueryImpl) cqQuery).getRegionName());
+          cqRegionNames.add(cqQuery.getRegionName());
         }
         authzRequest.stopCQAuthorize(cqName, queryStr, cqRegionNames);
       }
@@ -122,12 +122,9 @@ public class StopCQ extends BaseCQCommand {
 
     serverConnection.setAsTrue(RESPONDED);
 
-    {
-      long oldStart = start;
-      start = DistributionStats.getStatTime();
-      stats.incProcessStopCqTime(start - oldStart);
-    }
-
+    long oldStart = start;
+    start = DistributionStats.getStatTime();
+    stats.incProcessStopCqTime(start - oldStart);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-cq/src/test/java/org/apache/geode/security/CQPDXPostProcessorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/org/apache/geode/security/CQPDXPostProcessorDUnitTest.java b/geode-cq/src/test/java/org/apache/geode/security/CQPDXPostProcessorDUnitTest.java
index 2489b95..c38bd3b 100644
--- a/geode-cq/src/test/java/org/apache/geode/security/CQPDXPostProcessorDUnitTest.java
+++ b/geode-cq/src/test/java/org/apache/geode/security/CQPDXPostProcessorDUnitTest.java
@@ -128,7 +128,7 @@ public class CQPDXPostProcessorDUnitTest extends JUnit4DistributedTestCase {
     // wait for events to fire
     Awaitility.await().atMost(1, TimeUnit.SECONDS);
     PDXPostProcessor pp =
-        (PDXPostProcessor) SecurityService.getSecurityService().getPostProcessor();
+        (PDXPostProcessor) server.getCache().getSecurityService().getPostProcessor();
     assertEquals(pp.getCount(), 2);
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-cq/src/test/java/org/apache/geode/security/ClientAuthzObjectModDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/org/apache/geode/security/ClientAuthzObjectModDUnitTest.java b/geode-cq/src/test/java/org/apache/geode/security/ClientAuthzObjectModDUnitTest.java
index dd50467..a8ab8f9 100755
--- a/geode-cq/src/test/java/org/apache/geode/security/ClientAuthzObjectModDUnitTest.java
+++ b/geode-cq/src/test/java/org/apache/geode/security/ClientAuthzObjectModDUnitTest.java
@@ -14,6 +14,9 @@
  */
 package org.apache.geode.security;
 
+import static org.apache.geode.security.SecurityTestUtils.closeCache;
+import static org.apache.geode.security.SecurityTestUtils.getLocatorPort;
+
 import org.apache.geode.DataSerializable;
 import org.apache.geode.Instantiator;
 import org.apache.geode.cache.operations.OperationContext.OperationCode;
@@ -37,9 +40,6 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Random;
 
-import static org.apache.geode.security.SecurityTestUtils.closeCache;
-import static org.apache.geode.security.SecurityTestUtils.getLocatorPort;
-
 /**
  * Tests for authorization callback that modify objects and callbacks from client to server.
  * 
@@ -57,8 +57,10 @@ import static org.apache.geode.security.SecurityTestUtils.getLocatorPort;
 @Category({DistributedTest.class, SecurityTest.class})
 public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
 
-  private static final String preAccessor = FilterPreAuthorization.class.getName() + ".create";
-  private static final String postAccessor = FilterPostAuthorization.class.getName() + ".create";
+  private static final String PRE_ACCESSOR_CREATE =
+      FilterPreAuthorization.class.getName() + ".create";
+  private static final String POST_ACCESSOR_CREATE =
+      FilterPostAuthorization.class.getName() + ".create";
 
   @Override
   protected final void postSetUpClientAuthorizationTestBase() throws Exception {
@@ -88,13 +90,14 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
 
     System.out.println("testPutsGetsObjectModWithFailover: Using authinit: " + authInit);
     System.out.println("testPutsGetsObjectModWithFailover: Using authenticator: " + authenticator);
-    System.out
-        .println("testPutsGetsObjectModWithFailover: Using pre-operation accessor: " + preAccessor);
     System.out.println(
-        "testPutsGetsObjectModWithFailover: Using post-operation accessor: " + postAccessor);
+        "testPutsGetsObjectModWithFailover: Using pre-operation accessor: " + PRE_ACCESSOR_CREATE);
+    System.out.println("testPutsGetsObjectModWithFailover: Using post-operation accessor: "
+        + POST_ACCESSOR_CREATE);
 
     // Start servers with all required properties
-    Properties serverProps = buildProperties(authenticator, extraProps, preAccessor, postAccessor);
+    Properties serverProps =
+        buildProperties(authenticator, extraProps, PRE_ACCESSOR_CREATE, POST_ACCESSOR_CREATE);
 
     // Get ports for the servers
     int[] portsList = AvailablePortHelper.getRandomAvailableTCPPorts(2);
@@ -249,7 +252,6 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
         OperationWithAction.OPBLOCK_END};
   }
 
-
   private Properties buildProperties(final String authenticator, final Properties extraProps,
       final String preAccessor, final String postAccessor) {
     Properties authProps = new Properties();

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
index da0dfa2..5252bd1 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
@@ -29,8 +29,6 @@ import org.apache.geode.cache.lucene.internal.cli.functions.LuceneSearchIndexFun
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.execute.AbstractExecution;
-import org.apache.geode.internal.security.IntegratedSecurityService;
-import org.apache.geode.internal.security.SecurityService;
 import org.apache.geode.management.cli.CliMetaData;
 import org.apache.geode.management.cli.ConverterHint;
 import org.apache.geode.management.cli.Result;
@@ -80,8 +78,6 @@ public class LuceneIndexCommands implements GfshCommand {
       new LuceneDestroyIndexFunction();
   private List<LuceneSearchResults> searchResults = null;
 
-  private SecurityService securityService = IntegratedSecurityService.getSecurityService();
-
   @CliCommand(value = LuceneCliStrings.LUCENE_LIST_INDEX,
       help = LuceneCliStrings.LUCENE_LIST_INDEX__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
@@ -182,7 +178,7 @@ public class LuceneIndexCommands implements GfshCommand {
     Result result;
     XmlEntity xmlEntity = null;
 
-    this.securityService.authorizeRegionManage(regionPath);
+    getCache().getSecurityService().authorizeRegionManage(regionPath);
     try {
       final InternalCache cache = getCache();
       // trim fields for any leading trailing spaces.
@@ -328,7 +324,7 @@ public class LuceneIndexCommands implements GfshCommand {
           CliStrings.format(LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__INDEX_CANNOT_BE_EMPTY));
     }
 
-    this.securityService.authorizeRegionManage(regionPath);
+    getCache().getSecurityService().authorizeRegionManage(regionPath);
 
     Result result;
     try {

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
index 8deac25..1adab5a 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
@@ -37,6 +37,7 @@ import org.apache.geode.cache.lucene.internal.cli.functions.LuceneListIndexFunct
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.execute.AbstractExecution;
+import org.apache.geode.internal.security.SecurityService;
 import org.apache.geode.internal.util.CollectionUtils;
 import org.apache.geode.management.cli.Result.Status;
 import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
@@ -50,6 +51,7 @@ import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -85,9 +87,16 @@ import junitparams.Parameters;
 @RunWith(JUnitParamsRunner.class)
 public class LuceneIndexCommandsJUnitTest {
 
+  private InternalCache mockCache;
+
+  @Before
+  public void before() throws Exception {
+    this.mockCache = mock(InternalCache.class, "InternalCache");
+    when(this.mockCache.getSecurityService()).thenReturn(mock(SecurityService.class));
+  }
+
   @Test
-  public void testListIndexWithoutStats() {
-    final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
+  public void testListIndexWithoutStats() throws Exception {
     final String serverName = "mockServer";
     final AbstractExecution mockFunctionExecutor =
         mock(AbstractExecution.class, "Function Executor");
@@ -113,7 +122,7 @@ public class LuceneIndexCommandsJUnitTest {
         .thenReturn(mockResultCollector);
     when(mockResultCollector.getResult()).thenReturn(results);
 
-    final LuceneIndexCommands commands = createIndexCommands(mockCache, mockFunctionExecutor);
+    final LuceneIndexCommands commands = createIndexCommands(this.mockCache, mockFunctionExecutor);
 
     CommandResult result = (CommandResult) commands.listIndex(false);
     TabularResultData data = (TabularResultData) result.getResultData();
@@ -133,8 +142,7 @@ public class LuceneIndexCommandsJUnitTest {
   }
 
   @Test
-  public void testListIndexWithStats() {
-    final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
+  public void testListIndexWithStats() throws Exception {
     final String serverName = "mockServer";
     final AbstractExecution mockFunctionExecutor =
         mock(AbstractExecution.class, "Function Executor");
@@ -162,7 +170,7 @@ public class LuceneIndexCommandsJUnitTest {
         .thenReturn(mockResultCollector);
     when(mockResultCollector.getResult()).thenReturn(results);
 
-    final LuceneIndexCommands commands = createIndexCommands(mockCache, mockFunctionExecutor);
+    final LuceneIndexCommands commands = createIndexCommands(this.mockCache, mockFunctionExecutor);
 
     CommandResult result = (CommandResult) commands.listIndex(true);
     TabularResultData data = (TabularResultData) result.getResultData();
@@ -185,9 +193,8 @@ public class LuceneIndexCommandsJUnitTest {
 
   @Test
   public void testCreateIndex() throws Exception {
-    final InternalCache mockCache = mock(InternalCache.class);
     final ResultCollector mockResultCollector = mock(ResultCollector.class);
-    final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
+    final LuceneIndexCommands commands = spy(createIndexCommands(this.mockCache, null));
 
     final List<CliFunctionResult> cliFunctionResults = new ArrayList<>();
     cliFunctionResults.add(new CliFunctionResult("member1", true, "Index Created"));
@@ -215,10 +222,9 @@ public class LuceneIndexCommandsJUnitTest {
 
   @Test
   public void testDescribeIndex() throws Exception {
-    final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
     final String serverName = "mockServer";
     final ResultCollector mockResultCollector = mock(ResultCollector.class, "ResultCollector");
-    final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
+    final LuceneIndexCommands commands = spy(createIndexCommands(this.mockCache, null));
 
     String[] searchableFields = {"field1", "field2", "field3"};
     Map<String, Analyzer> fieldAnalyzers = new HashMap<>();
@@ -252,9 +258,8 @@ public class LuceneIndexCommandsJUnitTest {
 
   @Test
   public void testSearchIndex() throws Exception {
-    final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
     final ResultCollector mockResultCollector = mock(ResultCollector.class, "ResultCollector");
-    final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
+    final LuceneIndexCommands commands = spy(createIndexCommands(this.mockCache, null));
 
     final List<Set<LuceneSearchResults>> queryResultsList = new ArrayList<>();
     HashSet<LuceneSearchResults> queryResults = new HashSet<>();
@@ -277,10 +282,9 @@ public class LuceneIndexCommandsJUnitTest {
 
   @Ignore
   public void testSearchIndexWithPaging() throws Exception {
-    final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
     final Gfsh mockGfsh = mock(Gfsh.class);
     final ResultCollector mockResultCollector = mock(ResultCollector.class, "ResultCollector");
-    final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
+    final LuceneIndexCommands commands = spy(createIndexCommands(this.mockCache, null));
     ArgumentCaptor<String> resultCaptor = ArgumentCaptor.forClass(String.class);
 
     LuceneSearchResults result1 = createQueryResults("A", "Result1", Float.valueOf("1.7"));
@@ -345,9 +349,8 @@ public class LuceneIndexCommandsJUnitTest {
 
   @Test
   public void testSearchIndexWithKeysOnly() throws Exception {
-    final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
     final ResultCollector mockResultCollector = mock(ResultCollector.class, "ResultCollector");
-    final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
+    final LuceneIndexCommands commands = spy(createIndexCommands(this.mockCache, null));
 
     final List<Set<LuceneSearchResults>> queryResultsList = new ArrayList<>();
     HashSet<LuceneSearchResults> queryResults = new HashSet<>();
@@ -368,9 +371,8 @@ public class LuceneIndexCommandsJUnitTest {
 
   @Test
   public void testSearchIndexWhenSearchResultsHaveSameScore() throws Exception {
-    final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
     final ResultCollector mockResultCollector = mock(ResultCollector.class, "ResultCollector");
-    final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
+    final LuceneIndexCommands commands = spy(createIndexCommands(this.mockCache, null));
 
     final List<Set<LuceneSearchResults>> queryResultsList = new ArrayList<>();
     HashSet<LuceneSearchResults> queryResults = new HashSet<>();
@@ -545,9 +547,8 @@ public class LuceneIndexCommandsJUnitTest {
   }
 
   private LuceneIndexCommands createTestLuceneIndexCommandsForDestroyIndex() {
-    final InternalCache mockCache = mock(InternalCache.class);
     final ResultCollector mockResultCollector = mock(ResultCollector.class);
-    final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
+    final LuceneIndexCommands commands = spy(createIndexCommands(this.mockCache, null));
 
     final List<CliFunctionResult> cliFunctionResults = new ArrayList<>();
     cliFunctionResults.add(new CliFunctionResult("member", true, "Index Destroyed"));
@@ -656,7 +657,7 @@ public class LuceneIndexCommandsJUnitTest {
     @Override
     public Execution getMembersFunctionExecutor(final Set<DistributedMember> members) {
       Assert.assertNotNull(members);
-      return functionExecutor;
+      return this.functionExecutor;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
index 087aff4..63f907c 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
@@ -1,5 +1,4 @@
 /*
- *
  * 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
@@ -12,20 +11,33 @@
  * 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.tools.pulse.tests;
 
+import org.apache.geode.internal.security.SecurityService;
+import org.apache.geode.internal.security.SecurityServiceFactory;
+import org.apache.geode.internal.security.shiro.CustomAuthRealm;
+import org.apache.geode.internal.security.shiro.JMXShiroAuthenticator;
+import org.apache.geode.management.internal.security.AccessControlMBean;
+import org.apache.geode.management.internal.security.MBeanServerWrapper;
+import org.apache.geode.management.internal.security.ResourceConstants;
+import org.apache.geode.security.TestSecurityManager;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.mgt.DefaultSecurityManager;
+import org.apache.shiro.mgt.SecurityManager;
+import org.apache.shiro.realm.Realm;
+
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
 import java.net.Inet4Address;
 import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.rmi.registry.LocateRegistry;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
-
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.MBeanRegistrationException;
 import javax.management.MBeanServer;
@@ -36,19 +48,6 @@ import javax.management.remote.JMXConnectorServer;
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
 
-import org.apache.geode.tools.pulse.internal.data.PulseConstants;
-import org.apache.geode.security.TestSecurityManager;
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.mgt.DefaultSecurityManager;
-import org.apache.shiro.mgt.SecurityManager;
-import org.apache.shiro.realm.Realm;
-
-import org.apache.geode.internal.security.shiro.CustomAuthRealm;
-import org.apache.geode.internal.security.shiro.JMXShiroAuthenticator;
-import org.apache.geode.management.internal.security.AccessControlMBean;
-import org.apache.geode.management.internal.security.MBeanServerWrapper;
-import org.apache.geode.management.internal.security.ResourceConstants;
-
 public class Server {
 
   private static final String DEFAULT_HOST = "127.0.0.1"; // "localhost"
@@ -79,16 +78,20 @@ public class Server {
       SecurityUtils.setSecurityManager(securityManager);
 
       // register the AccessControll bean
-      AccessControlMBean acc = new AccessControlMBean();
+      AccessControlMBean acc = new AccessControlMBean(SecurityServiceFactory.create());
       ObjectName accessControlMBeanON = new ObjectName(ResourceConstants.OBJECT_NAME_ACCESSCONTROL);
       MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
       platformMBeanServer.registerMBean(acc, accessControlMBeanON);
 
+      SecurityService securityService =
+          SecurityServiceFactory.create(securityProperties, new TestSecurityManager(), null);
+      securityService.initSecurity(securityProperties);
+
       // wire in the authenticator and authorizaton
-      JMXShiroAuthenticator interceptor = new JMXShiroAuthenticator();
+      JMXShiroAuthenticator interceptor = new JMXShiroAuthenticator(securityService);
       env.put(JMXConnectorServer.AUTHENTICATOR, interceptor);
       cs = JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
-      cs.setMBeanServerForwarder(new MBeanServerWrapper());
+      cs.setMBeanServerForwarder(new MBeanServerWrapper(securityService));
 
       // set up the AccessControlMXBean
 
@@ -98,7 +101,7 @@ public class Server {
     }
 
     try {
-      java.rmi.registry.LocateRegistry.createRegistry(jmxPort);
+      LocateRegistry.createRegistry(jmxPort);
       System.out.println("RMI registry ready.");
     } catch (Exception e) {
       System.out.println("Exception starting RMI registry:");

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java
index 3183f87..767588d 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java
@@ -11,12 +11,10 @@
  * 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.tools.pulse.tests.rules;
 
-
+import org.apache.geode.internal.security.DisabledSecurityService;
 import org.apache.geode.tools.pulse.internal.data.PulseConstants;
 import org.awaitility.Awaitility;
 import org.apache.geode.internal.AvailablePort;

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-rebalancer/src/main/java/org/apache/geode/cache/util/AutoBalancer.java
----------------------------------------------------------------------
diff --git a/geode-rebalancer/src/main/java/org/apache/geode/cache/util/AutoBalancer.java b/geode-rebalancer/src/main/java/org/apache/geode/cache/util/AutoBalancer.java
index 0f1a995..3eced02 100644
--- a/geode-rebalancer/src/main/java/org/apache/geode/cache/util/AutoBalancer.java
+++ b/geode-rebalancer/src/main/java/org/apache/geode/cache/util/AutoBalancer.java
@@ -53,9 +53,9 @@ import org.apache.geode.internal.logging.LogService;
  * re-balancing request. Auto-Balancing is expected to prevent failures and data loss.
  * 
  * <P>
- * This implementation is based on {@code Initializer} implementation. By default auto-balancing is
- * disabled. A user needs to configure {@link AutoBalancer} during cache initialization
- * {@link GemFireCache#getInitializer()}
+ * This implementation is based on {@code ConfigInitialization} implementation. By default
+ * auto-balancing is disabled. A user needs to configure {@link AutoBalancer} during cache
+ * initialization {@link GemFireCache#getInitializer()}
  * 
  * <P>
  * In a cluster only one member owns auto-balancing responsibility. This is achieved by grabbing a

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/GeodeAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/GeodeAuthenticationProvider.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/GeodeAuthenticationProvider.java
index 06c0fb1..2f307c9 100644
--- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/GeodeAuthenticationProvider.java
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/GeodeAuthenticationProvider.java
@@ -16,7 +16,10 @@
 
 package org.apache.geode.rest.internal.web.security;
 
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.security.SecurityService;
+import org.apache.geode.internal.security.SecurityServiceFactory;
 import org.apache.geode.management.internal.security.ResourceConstants;
 import org.apache.geode.security.GemFireSecurityException;
 import org.springframework.security.authentication.AuthenticationProvider;
@@ -32,7 +35,26 @@ import java.util.Properties;
 
 @Component
 public class GeodeAuthenticationProvider implements AuthenticationProvider {
-  private SecurityService securityService = SecurityService.getSecurityService();
+
+  private final SecurityService securityService;
+
+  public GeodeAuthenticationProvider() {
+    // TODO: can we pass SecurityService in?
+    this.securityService = findSecurityService();
+  }
+
+  private static SecurityService findSecurityService() {
+    InternalCache cache = GemFireCacheImpl.getInstance();
+    if (cache != null) {
+      return cache.getSecurityService();
+    } else {
+      return SecurityServiceFactory.create();
+    }
+  }
+
+  public SecurityService getSecurityService() {
+    return this.securityService;
+  }
 
   @Override
   public Authentication authenticate(Authentication authentication) throws AuthenticationException {

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityConfiguration.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityConfiguration.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityConfiguration.java
index f0491b7..ba6970a 100644
--- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityConfiguration.java
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityConfiguration.java
@@ -11,12 +11,9 @@
  * 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.rest.internal.web.security;
 
-import org.apache.geode.internal.security.IntegratedSecurityService;
-import org.apache.geode.internal.security.SecurityService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
@@ -35,8 +32,6 @@ import org.springframework.security.config.http.SessionCreationPolicy;
 @ComponentScan("org.apache.geode.rest.internal.web")
 public class RestSecurityConfiguration extends WebSecurityConfigurerAdapter {
 
-  private SecurityService securityService = IntegratedSecurityService.getSecurityService();
-
   @Autowired
   private GeodeAuthenticationProvider authProvider;
 
@@ -58,7 +53,7 @@ public class RestSecurityConfiguration extends WebSecurityConfigurerAdapter {
             "/webjars/springfox-swagger-ui/**", "/swagger-resources/**")
         .permitAll().anyRequest().authenticated().and().csrf().disable();
 
-    if (securityService.isIntegratedSecurity()) {
+    if (this.authProvider.getSecurityService().isIntegratedSecurity()) {
       http.httpBasic();
     } else {
       http.authorizeRequests().anyRequest().permitAll();

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityService.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityService.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityService.java
index 80ff719..6d66947 100644
--- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityService.java
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityService.java
@@ -12,16 +12,28 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package org.apache.geode.rest.internal.web.security;
 
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.security.SecurityService;
+import org.apache.geode.internal.security.SecurityServiceFactory;
 import org.apache.geode.security.GemFireSecurityException;
 import org.springframework.stereotype.Component;
 
 @Component("securityService")
 public class RestSecurityService {
-  private SecurityService securityService = SecurityService.getSecurityService();
+
+  private final SecurityService securityService;
+
+  public RestSecurityService() {
+    InternalCache cache = GemFireCacheImpl.getInstance();
+    if (cache != null) {
+      this.securityService = cache.getSecurityService();
+    } else {
+      this.securityService = SecurityServiceFactory.create();
+    }
+  }
 
   public boolean authorize(String resource, String operation) {
     return authorize(resource, operation, null, null);

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/DataCommandsOverHttpDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/DataCommandsOverHttpDistributedTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/DataCommandsOverHttpDistributedTest.java
deleted file mode 100644
index 98a9434..0000000
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/DataCommandsOverHttpDistributedTest.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * 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.management.internal.cli.commands;
-
-import static org.apache.geode.test.dunit.LogWriterUtils.*;
-import static org.apache.geode.test.dunit.Wait.*;
-import static org.junit.Assert.*;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.management.DistributedRegionMXBean;
-import org.apache.geode.management.ManagementService;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.SerializableRunnable;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.WaitCriterion;
-import org.apache.geode.test.junit.categories.DistributedTest;
-
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.ProvideSystemProperty;
-import org.junit.experimental.categories.Category;
-
-@Category(DistributedTest.class)
-@SuppressWarnings("deprecated")
-public class DataCommandsOverHttpDistributedTest extends CliCommandTestBase {
-
-  private static final String REBALANCE_REGION_NAME =
-      DataCommandsOverHttpDistributedTest.class.getSimpleName() + "Region";
-
-  @ClassRule
-  public static ProvideSystemProperty provideSystemProperty =
-      new ProvideSystemProperty(CliCommandTestBase.USE_HTTP_SYSTEM_PROPERTY, "true");
-
-  @Test
-  public void testSimulateForEntireDSWithTimeout() {
-    setupTestRebalanceForEntireDS();
-    // check if DistributedRegionMXBean is available so that command will not fail
-    final VM manager = Host.getHost(0).getVM(0);
-    manager.invoke(checkRegionMBeans);
-
-    getLogWriter().info("testSimulateForEntireDS verified MBean and executing command");
-
-    String command = "rebalance --simulate=true --time-out=-1";
-
-    CommandResult cmdResult = executeCommand(command);
-
-    getLogWriter().info("testSimulateForEntireDS just after executing " + cmdResult);
-
-    if (cmdResult != null) {
-      String stringResult = commandResultToString(cmdResult);
-      getLogWriter().info("testSimulateForEntireDS stringResult : " + stringResult);
-      assertEquals(Result.Status.OK, cmdResult.getStatus());
-    } else {
-      fail("testRebalanceForIncludeRegionFunction failed as did not get CommandResult");
-    }
-  }
-
-  SerializableRunnable checkRegionMBeans = new SerializableRunnable() {
-    @Override
-    public void run() {
-      final WaitCriterion waitForMaangerMBean = new WaitCriterion() {
-        @Override
-        public boolean done() {
-          final ManagementService service = ManagementService.getManagementService(getCache());
-          final DistributedRegionMXBean bean =
-              service.getDistributedRegionMXBean(Region.SEPARATOR + REBALANCE_REGION_NAME);
-          if (bean == null) {
-            getLogWriter().info("Still probing for checkRegionMBeans ManagerMBean");
-            return false;
-          } else {
-            // verify that bean is proper before executing tests
-            if (bean.getMembers() != null && bean.getMembers().length > 1
-                && bean.getMemberCount() > 0
-                && service.getDistributedSystemMXBean().listRegions().length >= 2) {
-              return true;
-            } else {
-              return false;
-            }
-          }
-        }
-
-        @Override
-        public String description() {
-          return "Probing for testRebalanceCommandForSimulateWithNoMember ManagerMBean";
-        }
-      };
-      waitForCriterion(waitForMaangerMBean, 2 * 60 * 1000, 2000, true);
-      DistributedRegionMXBean bean = ManagementService.getManagementService(getCache())
-          .getDistributedRegionMXBean("/" + REBALANCE_REGION_NAME);
-      assertNotNull(bean);
-    }
-  };
-
-  void setupTestRebalanceForEntireDS() {
-    final VM vm1 = Host.getHost(0).getVM(1);
-    final VM vm2 = Host.getHost(0).getVM(2);
-    setUpJmxManagerOnVm0ThenConnect(null);
-
-    vm1.invoke(new SerializableRunnable() {
-      public void run() {
-
-        // no need to close cache as it will be closed as part of teardown2
-        Cache cache = getCache();
-
-        RegionFactory<Integer, Integer> dataRegionFactory =
-            cache.createRegionFactory(RegionShortcut.PARTITION);
-        Region region = dataRegionFactory.create(REBALANCE_REGION_NAME);
-        for (int i = 0; i < 10; i++) {
-          region.put("key" + (i + 200), "value" + (i + 200));
-        }
-        region = dataRegionFactory.create(REBALANCE_REGION_NAME + "Another1");
-        for (int i = 0; i < 100; i++) {
-          region.put("key" + (i + 200), "value" + (i + 200));
-        }
-      }
-    });
-
-    vm2.invoke(new SerializableRunnable() {
-      public void run() {
-
-        // no need to close cache as it will be closed as part of teardown2
-        Cache cache = getCache();
-
-        RegionFactory<Integer, Integer> dataRegionFactory =
-            cache.createRegionFactory(RegionShortcut.PARTITION);
-        Region region = dataRegionFactory.create(REBALANCE_REGION_NAME);
-        for (int i = 0; i < 100; i++) {
-          region.put("key" + (i + 400), "value" + (i + 400));
-        }
-        region = dataRegionFactory.create(REBALANCE_REGION_NAME + "Another2");
-        for (int i = 0; i < 10; i++) {
-          region.put("key" + (i + 200), "value" + (i + 200));
-        }
-      }
-    });
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandOverHttpDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandOverHttpDistributedTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandOverHttpDistributedTest.java
new file mode 100644
index 0000000..6101744
--- /dev/null
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandOverHttpDistributedTest.java
@@ -0,0 +1,29 @@
+/*
+ * 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.management.internal.cli.commands;
+
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.ClassRule;
+import org.junit.contrib.java.lang.system.ProvideSystemProperty;
+import org.junit.experimental.categories.Category;
+
+@Category(DistributedTest.class)
+@SuppressWarnings("deprecated")
+public class RebalanceCommandOverHttpDistributedTest extends RebalanceCommandDistributedTest {
+
+  @ClassRule
+  public static ProvideSystemProperty provideSystemProperty =
+      new ProvideSystemProperty(CliCommandTestBase.USE_HTTP_SYSTEM_PROPERTY, "true");
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/5eca6f03/geode-web/src/test/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptorRequestHeaderJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptorRequestHeaderJUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptorRequestHeaderJUnitTest.java
index 00156cd..a58bcba 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptorRequestHeaderJUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptorRequestHeaderJUnitTest.java
@@ -41,8 +41,7 @@ public class LoginHandlerInterceptorRequestHeaderJUnitTest {
   public void before() {
     LoginHandlerInterceptor.getEnvironment().clear();
     securityService = Mockito.mock(SecurityService.class);
-    interceptor = new LoginHandlerInterceptor();
-    interceptor.setSecurityService(securityService);
+    interceptor = new LoginHandlerInterceptor(securityService);
   }
 
   @After


Mime
View raw message