geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [30/50] [abbrv] incubator-geode git commit: GEODE-1712: add static factory methods to SecurityService
Date Wed, 10 Aug 2016 19:41:16 GMT
GEODE-1712: add static factory methods to SecurityService


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

Branch: refs/heads/feature/GEODE-420
Commit: 8dea2cf100c7220c673f8bcd6033ae35c67eeb90
Parents: 3ac987f
Author: gmeilen <gracemeilen@gmail.com>
Authored: Thu Jul 28 13:20:23 2016 -0700
Committer: Kirk Lund <klund@apache.org>
Committed: Thu Aug 4 09:44:30 2016 -0700

----------------------------------------------------------------------
 .../membership/gms/auth/GMSAuthenticator.java         |  5 ++---
 .../internal/cache/tier/sockets/HandShake.java        |  4 +---
 .../internal/security/IntegratedSecurityService.java  |  6 ++++++
 .../gemfire/internal/security/SecurityService.java    | 14 ++++++++++++++
 .../internal/security/shiro/CustomAuthRealm.java      |  4 ++--
 .../internal/security/MBeanServerWrapper.java         |  1 -
 ...tegratedSecurityCacheLifecycleDistributedTest.java |  8 ++++++--
 ...tegratedSecurityCacheLifecycleIntegrationTest.java |  8 ++++++--
 8 files changed, 37 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8dea2cf1/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/auth/GMSAuthenticator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/auth/GMSAuthenticator.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/auth/GMSAuthenticator.java
index 516ca74..7fc212c 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/auth/GMSAuthenticator.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/auth/GMSAuthenticator.java
@@ -30,7 +30,6 @@ import com.gemstone.gemfire.distributed.internal.membership.gms.Services;
 import com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.Authenticator;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.InternalLogWriter;
-import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
 import com.gemstone.gemfire.internal.security.IntegratedSecurityService;
 import com.gemstone.gemfire.internal.security.SecurityService;
 import com.gemstone.gemfire.security.AuthInitialize;
@@ -146,7 +145,7 @@ public class GMSAuthenticator implements Authenticator {
       String authMethod = securityProps.getProperty(SECURITY_PEER_AUTHENTICATOR);
     com.gemstone.gemfire.security.Authenticator auth = null;
     try {
-      auth = GeodeSecurityUtil.getObjectOfTypeFromFactoryMethod(authMethod, com.gemstone.gemfire.security.Authenticator.class);
+      auth = SecurityService.getObjectOfTypeFromFactoryMethod(authMethod, com.gemstone.gemfire.security.Authenticator.class);
 
       LogWriter logWriter = this.services.getLogWriter();
       LogWriter securityLogWriter = this.services.getSecurityLogWriter();
@@ -193,7 +192,7 @@ public class GMSAuthenticator implements Authenticator {
 
     try {
       if (authMethod != null && authMethod.length() > 0) {
-        AuthInitialize auth = GeodeSecurityUtil.getObjectOfType(authMethod, AuthInitialize.class);
+        AuthInitialize auth = SecurityService.getObjectOfType(authMethod, AuthInitialize.class);
         assert auth != null;
         try {
           LogWriter logWriter = services.getLogWriter();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8dea2cf1/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/HandShake.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/HandShake.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/HandShake.java
index 8f9c9c7..9e7edd0 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/HandShake.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/HandShake.java
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.gemstone.gemfire.internal.cache.tier.sockets;
 
 import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
@@ -91,7 +90,6 @@ import com.gemstone.gemfire.internal.cache.tier.ConnectionProxy;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.InternalLogWriter;
 import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
 import com.gemstone.gemfire.internal.security.IntegratedSecurityService;
 import com.gemstone.gemfire.internal.security.SecurityService;
 import com.gemstone.gemfire.pdx.internal.PeerTypeRegistration;
@@ -1603,7 +1601,7 @@ public class HandShake implements ClientHandShake
     Properties credentials = null;
     try {
       if (authInitMethod != null && authInitMethod.length() > 0) {
-        AuthInitialize auth = GeodeSecurityUtil.getObjectOfType(authInitMethod, AuthInitialize.class);
+        AuthInitialize auth = SecurityService.getObjectOfType(authInitMethod, AuthInitialize.class);
         auth.init(logWriter, securityLogWriter);
         try {
           credentials = auth.getCredentials(securityProperties, server, isPeer);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8dea2cf1/geode-core/src/main/java/com/gemstone/gemfire/internal/security/IntegratedSecurityService.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/IntegratedSecurityService.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/IntegratedSecurityService.java
index 50cf07c..c4a693c 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/IntegratedSecurityService.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/IntegratedSecurityService.java
@@ -4,6 +4,7 @@ import java.util.Properties;
 import java.util.concurrent.Callable;
 
 import org.apache.geode.security.ResourcePermission;
+import org.apache.geode.security.SecurityManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.shiro.subject.Subject;
 import org.apache.shiro.util.ThreadState;
@@ -155,4 +156,9 @@ public class IntegratedSecurityService implements SecurityService {
   public boolean isIntegratedSecurity() {
     return GeodeSecurityUtil.isIntegratedSecurity();
   }
+
+  @Override
+  public SecurityManager getSecurityManager() {
+    return GeodeSecurityUtil.getSecurityManager();
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8dea2cf1/geode-core/src/main/java/com/gemstone/gemfire/internal/security/SecurityService.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/SecurityService.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/SecurityService.java
index 76e607e..9629ba3 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/SecurityService.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/SecurityService.java
@@ -22,6 +22,7 @@ import java.util.concurrent.Callable;
 import com.gemstone.gemfire.management.internal.security.ResourceOperation;
 
 import org.apache.geode.security.ResourcePermission;
+import org.apache.geode.security.SecurityManager;
 import org.apache.shiro.subject.Subject;
 import org.apache.shiro.util.ThreadState;
 
@@ -54,4 +55,17 @@ public interface SecurityService {
   boolean isClientSecurityRequired();
   boolean isPeerSecurityRequired();
   boolean isIntegratedSecurity();
+  SecurityManager getSecurityManager();
+
+  static <T> T getObjectOfType(String factoryName, Class<T> clazz) {
+    return GeodeSecurityUtil.getObjectOfType(factoryName, clazz);
+  }
+
+  static <T> T getObjectOfTypeFromFactoryMethod(String factoryMethodName, Class<T>
expectedClazz) {
+    return GeodeSecurityUtil.getObjectOfTypeFromFactoryMethod(factoryMethodName, expectedClazz);
+  }
+
+  static <T> T getObjectOfTypeFromClassName(String className, Class<T> expectedClazz)
{
+    return GeodeSecurityUtil.getObjectOfTypeFromClassName(className, expectedClazz);
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8dea2cf1/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/CustomAuthRealm.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/CustomAuthRealm.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/CustomAuthRealm.java
index 75148da..edb0790 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/CustomAuthRealm.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/shiro/CustomAuthRealm.java
@@ -31,7 +31,7 @@ import org.apache.shiro.authz.Permission;
 import org.apache.shiro.realm.AuthorizingRealm;
 import org.apache.shiro.subject.PrincipalCollection;
 
-import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
+import com.gemstone.gemfire.internal.security.SecurityService;
 import com.gemstone.gemfire.management.internal.security.ResourceConstants;
 
 public class CustomAuthRealm extends AuthorizingRealm {
@@ -57,7 +57,7 @@ public class CustomAuthRealm extends AuthorizingRealm {
    * @param securityProperties the security properties to initialize SecurityManager with
    */
   public CustomAuthRealm(String authenticatorFactory, Properties securityProperties) {
-    this.securityManager = GeodeSecurityUtil.getObjectOfTypeFromClassName(authenticatorFactory,
SecurityManager.class);
+    this.securityManager = SecurityService.getObjectOfTypeFromClassName(authenticatorFactory,
SecurityManager.class);
     this.securityManager.init(securityProperties);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8dea2cf1/geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/MBeanServerWrapper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/MBeanServerWrapper.java
b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/MBeanServerWrapper.java
index 7fcf922..857c83c 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/MBeanServerWrapper.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/MBeanServerWrapper.java
@@ -48,7 +48,6 @@ import com.gemstone.gemfire.internal.security.IntegratedSecurityService;
 import com.gemstone.gemfire.internal.security.SecurityService;
 import com.gemstone.gemfire.management.internal.ManagementConstants;
 import com.gemstone.gemfire.security.GemFireSecurityException;
-import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
 import org.apache.geode.security.ResourcePermission;
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8dea2cf1/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityCacheLifecycleDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityCacheLifecycleDistributedTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityCacheLifecycleDistributedTest.java
index 902ebf0..87fc840 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityCacheLifecycleDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityCacheLifecycleDistributedTest.java
@@ -27,7 +27,8 @@ import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.cache.server.CacheServer;
 import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
+import com.gemstone.gemfire.internal.security.IntegratedSecurityService;
+import com.gemstone.gemfire.internal.security.SecurityService;
 import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
 import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.NetworkUtils;
@@ -40,12 +41,15 @@ import com.gemstone.gemfire.test.junit.categories.SecurityTest;
 public class IntegratedSecurityCacheLifecycleDistributedTest extends JUnit4CacheTestCase
{
 
   private VM locator;
+  private SecurityService securityService;
 
   @Override
   public final void postSetUp() throws Exception {
     Host host = Host.getHost(0);
     locator = host.getVM(0);
 
+    securityService = IntegratedSecurityService.getSecurityService();
+
     int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     String locators =  NetworkUtils.getServerHostName(host) + "[" + locatorPort + "]";
 
@@ -93,7 +97,7 @@ public class IntegratedSecurityCacheLifecycleDistributedTest extends JUnit4Cache
   }
 
   private void verifyInitCloseInvoked() {
-    SpySecurityManager ssm = (SpySecurityManager) GeodeSecurityUtil.getSecurityManager();
+    SpySecurityManager ssm = (SpySecurityManager) this.securityService.getSecurityManager();
     assertThat(ssm.initInvoked).isEqualTo(1);
     getCache().close();
     assertThat(ssm.closeInvoked).isEqualTo(1);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8dea2cf1/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityCacheLifecycleIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityCacheLifecycleIntegrationTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityCacheLifecycleIntegrationTest.java
index 228a8d6..8cb894a 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityCacheLifecycleIntegrationTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityCacheLifecycleIntegrationTest.java
@@ -24,7 +24,8 @@ import java.util.Properties;
 
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
+import com.gemstone.gemfire.internal.security.IntegratedSecurityService;
+import com.gemstone.gemfire.internal.security.SecurityService;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
 import com.gemstone.gemfire.test.junit.categories.SecurityTest;
 
@@ -38,9 +39,12 @@ public class IntegratedSecurityCacheLifecycleIntegrationTest {
 
   private Properties securityProps;
   private Cache cache;
+  private SecurityService securityService;
 
   @Before
   public void before() {
+    securityService = IntegratedSecurityService.getSecurityService();
+
     securityProps = new Properties();
     securityProps.setProperty(SECURITY_MANAGER, SpySecurityManager.class.getName());
 
@@ -61,7 +65,7 @@ public class IntegratedSecurityCacheLifecycleIntegrationTest {
 
   @Test
   public void initAndCloseTest () {
-    SpySecurityManager ssm = (SpySecurityManager)GeodeSecurityUtil.getSecurityManager();
+    SpySecurityManager ssm = (SpySecurityManager)securityService.getSecurityManager();
     assertThat(ssm.initInvoked).isEqualTo(1);
     cache.close();
     assertThat(ssm.closeInvoked).isEqualTo(1);


Mime
View raw message