You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/07/22 05:17:39 UTC
[01/10] incubator-geode git commit: GEODE-1655: CI Failure in
AutoConnectionSourceDUnitTest.testClientMembershipListener [Forced Update!]
Repository: incubator-geode
Updated Branches:
refs/heads/feature/GEODE-1673-PR-212 6b748eb5f -> 87c2383a6 (forced update)
GEODE-1655: CI Failure in AutoConnectionSourceDUnitTest.testClientMembershipListener
Clients may get a memberLeft event instead of a memberCrashed event when
a server is shut down. I've adjusted the test's expectations and added
some logging in the membership listener to note which events it receives.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/7c2e2193
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/7c2e2193
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/7c2e2193
Branch: refs/heads/feature/GEODE-1673-PR-212
Commit: 7c2e21933ecce1602e27e0b74f439fa94ceb8b52
Parents: 603bae8
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Wed Jul 20 15:05:45 2016 -0700
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Wed Jul 20 15:08:21 2016 -0700
----------------------------------------------------------------------
.../internal/AutoConnectionSourceDUnitTest.java | 65 +++++++++-----------
1 file changed, 28 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c2e2193/geode-core/src/test/java/com/gemstone/gemfire/cache/client/internal/AutoConnectionSourceDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/client/internal/AutoConnectionSourceDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/client/internal/AutoConnectionSourceDUnitTest.java
index 87ee0bc..3f8f488 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/client/internal/AutoConnectionSourceDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/client/internal/AutoConnectionSourceDUnitTest.java
@@ -16,36 +16,25 @@
*/
package com.gemstone.gemfire.cache.client.internal;
-import org.junit.experimental.categories.Category;
-import org.junit.Test;
-
import static org.junit.Assert.*;
-import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
-import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
-import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.client.NoAvailableLocatorsException;
-import com.gemstone.gemfire.cache.client.NoAvailableServersException;
-import com.gemstone.gemfire.cache.client.PoolManager;
-import com.gemstone.gemfire.cache.server.CacheServer;
-import com.gemstone.gemfire.distributed.internal.ServerLocation;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.management.membership.ClientMembership;
-import com.gemstone.gemfire.management.membership.ClientMembershipEvent;
-import com.gemstone.gemfire.management.membership.ClientMembershipListenerAdapter;
-import com.gemstone.gemfire.test.dunit.*;
-import org.junit.Assert;
+import java.io.*;
+import java.net.*;
+import java.util.*;
-import java.io.Serializable;
-import java.net.BindException;
-import java.net.InetSocketAddress;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
+import org.junit.Assert;
+import org.junit.*;
+import org.junit.experimental.categories.*;
+
+import com.gemstone.gemfire.cache.*;
+import com.gemstone.gemfire.cache.client.*;
+import com.gemstone.gemfire.cache.server.*;
+import com.gemstone.gemfire.distributed.internal.*;
+import com.gemstone.gemfire.internal.*;
+import com.gemstone.gemfire.internal.cache.*;
+import com.gemstone.gemfire.management.membership.*;
+import com.gemstone.gemfire.test.dunit.*;
+import com.gemstone.gemfire.test.junit.categories.*;
/**
* Tests cases that are particular for the auto connection source
@@ -387,9 +376,8 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase {
resetBridgeListener(bridge1VM);
waitForCrash(clientVM);
clientListener = getBridgeListener(clientVM);
- Assert.assertEquals(1, clientListener.getCrashes());
- Assert.assertEquals(0, clientListener.getDepartures());
Assert.assertEquals(0, clientListener.getJoins());
+ Assert.assertEquals(1, clientListener.getDepartures()+clientListener.getCrashes());
resetBridgeListener(clientVM);
//stop the client and make sure the bridge server notices
@@ -479,9 +467,8 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase {
}
if (expectedEndpointPorts.size() == actualEndpointPorts.size()) {
break;
- } else {
- Wait.pause(100);
}
+ Wait.pause(100);
} while (retryCount-- > 0);
Assert.assertEquals(expectedEndpointPorts, actualEndpointPorts);
}
@@ -499,7 +486,7 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase {
}
protected void resetBridgeListener(VM vm) {
- vm.invoke(new SerializableRunnable("Add membership listener") {
+ vm.invoke(new SerializableRunnable("Reset membership listener") {
public void run() {
MyListener listener = (MyListener) remoteObjects.get(BRIDGE_LISTENER);
listener.reset();
@@ -508,7 +495,7 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase {
}
private MyListener getBridgeListener(VM vm) {
- return (MyListener) vm.invoke(new SerializableCallable("Add membership listener") {
+ return (MyListener) vm.invoke(new SerializableCallable("Get membership listener") {
public Object call() {
return remoteObjects.get(BRIDGE_LISTENER);
}
@@ -516,7 +503,7 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase {
}
private void waitForJoin(VM vm) {
- vm.invoke(new SerializableRunnable() {
+ vm.invoke(new SerializableRunnable("wait for join") {
public void run() {
MyListener listener = (MyListener) remoteObjects.get(BRIDGE_LISTENER);
synchronized (listener) {
@@ -524,7 +511,7 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase {
while (listener.joins == 0) {
try {
long remaining = end - System.currentTimeMillis();
- if (remaining < 0) {
+ if (remaining <= 0) {
break;
}
listener.wait(remaining);
@@ -532,13 +519,14 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase {
fail("interrupted");
}
}
+ GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
}
}
});
}
private void waitForCrash(VM vm) {
- vm.invoke(new SerializableRunnable() {
+ vm.invoke(new SerializableRunnable("wait for crash") {
public void run() {
MyListener listener = (MyListener) remoteObjects.get(BRIDGE_LISTENER);
synchronized (listener) {
@@ -560,7 +548,7 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase {
}
private void waitForDeparture(VM vm) {
- vm.invoke(new SerializableRunnable() {
+ vm.invoke(new SerializableRunnable("wait for departure") {
public void run() {
MyListener listener = (MyListener) remoteObjects.get(BRIDGE_LISTENER);
synchronized (listener) {
@@ -589,6 +577,7 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase {
@Override
public synchronized void memberCrashed(ClientMembershipEvent event) {
crashes++;
+ System.out.println("memberCrashed invoked");
notifyAll();
}
@@ -601,12 +590,14 @@ public class AutoConnectionSourceDUnitTest extends LocatorTestBase {
@Override
public synchronized void memberJoined(ClientMembershipEvent event) {
joins++;
+ System.out.println("memberJoined invoked");
notifyAll();
}
@Override
public synchronized void memberLeft(ClientMembershipEvent event) {
departures++;
+ System.out.println("memberLeft invoked");
notifyAll();
}
[03/10] incubator-geode git commit: GEODE-1647: Add Integrated
Security to Peer Authentication
Posted by kl...@apache.org.
GEODE-1647: Add Integrated Security to Peer Authentication
* This closes #210
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/16b73564
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/16b73564
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/16b73564
Branch: refs/heads/feature/GEODE-1673-PR-212
Commit: 16b73564f638aea652842dd071d01e1e3d5ad204
Parents: 7c2e219
Author: gmeilen <gr...@gmail.com>
Authored: Mon Jul 18 13:13:11 2016 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Wed Jul 20 16:04:31 2016 -0700
----------------------------------------------------------------------
.../membership/gms/auth/GMSAuthenticator.java | 79 +++++-----
.../gms/interfaces/Authenticator.java | 6 +-
.../membership/gms/membership/GMSJoinLeave.java | 2 +-
.../cache/tier/sockets/AcceptorImpl.java | 2 +-
.../internal/cache/tier/sockets/HandShake.java | 6 +-
.../gemfire/internal/i18n/LocalizedStrings.java | 4 +-
.../internal/security/GeodeSecurityUtil.java | 45 +++---
.../templates/SampleSecurityManager.java | 5 +
.../internal/DistributionConfigJUnitTest.java | 2 +-
.../gms/auth/GMSAuthenticatorJUnitTest.java | 37 +++--
.../gms/membership/GMSJoinLeaveJUnitTest.java | 2 +-
.../cli/commands/CliCommandTestBase.java | 2 +-
.../security/AccessControlMBeanJUnitTest.java | 3 +-
...CacheServerMBeanAuthenticationJUnitTest.java | 4 +-
.../CacheServerMBeanAuthorizationJUnitTest.java | 3 +-
.../security/CliCommandsSecurityTest.java | 6 +-
.../security/DataCommandsSecurityTest.java | 3 +-
.../DiskStoreMXBeanSecurityJUnitTest.java | 3 +-
.../GatewayReceiverMBeanSecurityTest.java | 3 +-
.../GatewaySenderMBeanSecurityTest.java | 3 +-
.../GeodeSecurityUtilCustomRealmJUnitTest.java | 4 +-
.../security/GfshCommandsPostProcessorTest.java | 3 +-
.../security/GfshCommandsSecurityTest.java | 3 +-
.../internal/security/JSONAuthorization.java | 48 ------
.../JsonAuthorizationCacheStartRule.java | 1 +
.../LockServiceMBeanAuthorizationJUnitTest.java | 3 +-
.../security/MBeanSecurityJUnitTest.java | 3 +-
.../ManagerMBeanAuthorizationJUnitTest.java | 3 +-
.../security/MemberMBeanSecurityJUnitTest.java | 3 +-
.../internal/security/MultiUserDUnitTest.java | 4 +-
...ractIntegratedClientAuthDistributedTest.java | 4 +-
...edSecurityCacheLifecycleDistributedTest.java | 19 +--
...edSecurityCacheLifecycleIntegrationTest.java | 27 +---
...tegratedSecurityPeerAuthDistributedTest.java | 146 +++++++++++++++++++
.../gemfire/security/JSONAuthorization.java | 54 +++++++
.../gemfire/security/SpySecurityManager.java | 43 ++++++
.../com/gemstone/gemfire/security/peerAuth.json | 36 +++++
.../gemfire/tools/pulse/tests/Server.java | 2 +-
38 files changed, 430 insertions(+), 196 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/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 f16a722..cf99ea2 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
@@ -19,19 +19,15 @@ package com.gemstone.gemfire.distributed.internal.membership.gms.auth;
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
import static com.gemstone.gemfire.internal.i18n.LocalizedStrings.*;
-import java.lang.reflect.Method;
import java.security.Principal;
import java.util.Properties;
-import java.util.Set;
import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.distributed.DistributedMember;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
import com.gemstone.gemfire.distributed.internal.membership.NetView;
import com.gemstone.gemfire.distributed.internal.membership.gms.Services;
import com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.Authenticator;
-import com.gemstone.gemfire.internal.ClassLoadUtil;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
import com.gemstone.gemfire.internal.logging.InternalLogWriter;
import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
@@ -44,15 +40,13 @@ import com.gemstone.gemfire.security.GemFireSecurityException;
public class GMSAuthenticator implements Authenticator {
- private final static String secPrefix = DistributionConfig.GEMFIRE_PREFIX + "sys.security-";
- private final static int gemfireSysPrefixLen = (DistributionConfig.GEMFIRE_PREFIX + "sys.").length();
-
private Services services;
- private Properties securityProps = getSecurityProps();
+ private Properties securityProps;
@Override
public void init(Services s) {
this.services = s;
+ this.securityProps = this.services.getConfig().getDistributionConfig().getSecurityProps();
}
@Override
@@ -105,57 +99,59 @@ public class GMSAuthenticator implements Authenticator {
* this will be removed since return string is used for failure
*/
@Override
- public String authenticate(InternalDistributedMember member, Object credentials) throws AuthenticationFailedException {
+ public String authenticate(InternalDistributedMember member, Properties credentials) throws AuthenticationFailedException {
return authenticate(member, credentials, this.securityProps, this.services.getJoinLeave().getMemberID());
}
/**
* Method is package protected to be used in testing.
*/
- String authenticate(DistributedMember member, Object credentials, Properties secProps, DistributedMember localMember) throws AuthenticationFailedException {
-
- String authMethod = secProps.getProperty(SECURITY_PEER_AUTHENTICATOR);
- if (authMethod == null || authMethod.length() == 0) {
+ String authenticate(DistributedMember member, Properties credentials, Properties secProps, DistributedMember localMember) throws AuthenticationFailedException {
+ if(!GeodeSecurityUtil.isPeerSecurityRequired()){
return null;
}
InternalLogWriter securityLogWriter = this.services.getSecurityLogWriter();
- String failMsg = null;
- if (credentials != null) {
- try {
- invokeAuthenticator(authMethod, member, credentials);
-
- } catch (Exception ex) {
- securityLogWriter.warning(AUTH_PEER_AUTHENTICATION_FAILED_WITH_EXCEPTION, new Object[] {member, authMethod, ex.getLocalizedMessage()}, ex);
- failMsg = AUTH_PEER_AUTHENTICATION_FAILED.toLocalizedString(localMember);
- }
- } else { // No credentials - need to send failure message
- securityLogWriter.warning(AUTH_PEER_AUTHENTICATION_MISSING_CREDENTIALS, new Object[] {member, authMethod});
- failMsg = AUTH_PEER_AUTHENTICATION_MISSING_CREDENTIALS.toLocalizedString(member, authMethod);
+ if(credentials == null){
+ securityLogWriter.warning(AUTH_PEER_AUTHENTICATION_MISSING_CREDENTIALS, member);
+ return AUTH_PEER_AUTHENTICATION_MISSING_CREDENTIALS.toLocalizedString(member);
}
+ String failMsg = null;
+ try {
+ if(GeodeSecurityUtil.isIntegratedSecurity()){
+ String username = credentials.getProperty("security-username");
+ String password = credentials.getProperty("security-password");
+ GeodeSecurityUtil.login(username, password);
+ }
+ else {
+ invokeAuthenticator(secProps, member, credentials);
+ }
+ } catch (Exception ex) {
+ securityLogWriter.warning(AUTH_PEER_AUTHENTICATION_FAILED_WITH_EXCEPTION, new Object[] {
+ member, ex.getLocalizedMessage()
+ }, ex);
+ failMsg = AUTH_PEER_AUTHENTICATION_FAILED.toLocalizedString(localMember);
+ }
return failMsg;
}
+
/**
* Method is package protected to be used in testing.
*/
- Principal invokeAuthenticator(String authMethod, DistributedMember member, Object credentials) throws AuthenticationFailedException {
+ Principal invokeAuthenticator(Properties securityProps, DistributedMember member, Properties credentials) throws AuthenticationFailedException {
+ String authMethod = securityProps.getProperty(SECURITY_PEER_AUTHENTICATOR);
com.gemstone.gemfire.security.Authenticator auth = null;
-
try {
- Method getter = ClassLoadUtil.methodFromName(authMethod);
- auth = (com.gemstone.gemfire.security.Authenticator) getter.invoke(null, (Object[]) null);
- if (auth == null) {
- throw new AuthenticationFailedException(HandShake_AUTHENTICATOR_INSTANCE_COULD_NOT_BE_OBTAINED.toLocalizedString());
- }
+ auth = GeodeSecurityUtil.getObjectOfTypeFromFactoryMethod(authMethod, com.gemstone.gemfire.security.Authenticator .class);
LogWriter logWriter = this.services.getLogWriter();
LogWriter securityLogWriter = this.services.getSecurityLogWriter();
auth.init(this.securityProps, logWriter, securityLogWriter); // this.securityProps contains security-ldap-basedn but security-ldap-baseDomainName is expected
- return auth.authenticate((Properties) credentials, member);
+ return auth.authenticate(credentials, member);
} catch (GemFireSecurityException gse) {
throw gse;
@@ -173,10 +169,10 @@ public class GMSAuthenticator implements Authenticator {
*
* @param member
* the target distributed member
- * @return the credential object
+ * @return the credentials
*/
@Override
- public Object getCredentials(InternalDistributedMember member) {
+ public Properties getCredentials(InternalDistributedMember member) {
try {
return getCredentials(member, securityProps);
@@ -217,16 +213,11 @@ public class GMSAuthenticator implements Authenticator {
return credentials;
}
+ /**
+ * For testing only.
+ */
Properties getSecurityProps() {
- Properties props = new Properties();
- Set keys = System.getProperties().keySet();
- for (Object key: keys) {
- String propKey = (String) key;
- if (propKey.startsWith(secPrefix)) {
- props.setProperty(propKey.substring(gemfireSysPrefixLen), System.getProperty(propKey));
- }
- }
- return props;
+ return this.securityProps;
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/interfaces/Authenticator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/interfaces/Authenticator.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/interfaces/Authenticator.java
index fe96127..9660267 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/interfaces/Authenticator.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/interfaces/Authenticator.java
@@ -16,12 +16,14 @@
*/
package com.gemstone.gemfire.distributed.internal.membership.gms.interfaces;
+import java.util.Properties;
+
import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
import com.gemstone.gemfire.security.AuthenticationFailedException;
public interface Authenticator extends Service {
- String authenticate(InternalDistributedMember m, Object credentials) throws AuthenticationFailedException;
+ String authenticate(InternalDistributedMember m, Properties credentials) throws AuthenticationFailedException;
- Object getCredentials(InternalDistributedMember m);
+ Properties getCredentials(InternalDistributedMember m);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index e5cac2d..4b82fa0 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -476,7 +476,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
Object creds = incomingRequest.getCredentials();
String rejection = null;
try {
- rejection = services.getAuthenticator().authenticate(incomingRequest.getMemberID(), creds);
+ rejection = services.getAuthenticator().authenticate(incomingRequest.getMemberID(), (Properties)creds);
} catch (Exception e) {
rejection = e.getMessage();
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/AcceptorImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/AcceptorImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/AcceptorImpl.java
index 43f90d5..4f952a8 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/AcceptorImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/AcceptorImpl.java
@@ -638,7 +638,7 @@ public class AcceptorImpl extends Acceptor implements Runnable
this.hsPool = tmp_hsPool;
}
- isAuthenticationRequired = GeodeSecurityUtil.isSecurityRequired();
+ isAuthenticationRequired = GeodeSecurityUtil.isClientSecurityRequired();
isIntegratedSecurity = GeodeSecurityUtil.isIntegratedSecurity();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/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 2dcf8e7..e501531 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
@@ -899,7 +899,7 @@ public class HandShake implements ClientHandShake
throws GemFireSecurityException, IOException {
Properties credentials = null;
- boolean requireAuthentication = GeodeSecurityUtil.isSecurityRequired();
+ boolean requireAuthentication = GeodeSecurityUtil.isClientSecurityRequired();
try {
byte secureMode = dis.readByte();
if (secureMode == CREDENTIALS_NONE) {
@@ -1161,7 +1161,7 @@ public class HandShake implements ClientHandShake
// non-blank setting for DH symmetric algo, or this is a server
// that has authenticator defined.
if ((dhSKAlgo != null && dhSKAlgo.length() > 0)
- || GeodeSecurityUtil.isSecurityRequired()) {
+ || GeodeSecurityUtil.isClientSecurityRequired()) {
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DH");
DHParameterSpec dhSpec = new DHParameterSpec(dhP, dhG, dhL);
keyGen.initialize(dhSpec);
@@ -1632,7 +1632,7 @@ public class HandShake implements ClientHandShake
DataOutputStream dos, DistributedSystem system)
throws GemFireSecurityException, IOException {
- boolean requireAuthentication = GeodeSecurityUtil.isSecurityRequired();
+ boolean requireAuthentication = GeodeSecurityUtil.isClientSecurityRequired();
Properties credentials = null;
try {
byte secureMode = dis.readByte();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
index be1ff17..2254a89 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
@@ -3731,9 +3731,9 @@ public class LocalizedStrings {
public static final StringId Network_partition_detected = new StringId(6607, "Exiting due to possible network partition event due to loss of {0} cache processes: {1}");
// GMSAuthenticator
- public static final StringId AUTH_PEER_AUTHENTICATION_FAILED_WITH_EXCEPTION = new StringId(6608, "Authentication failed for [{0}] using Authenticator [{1}]. {2}");
+ public static final StringId AUTH_PEER_AUTHENTICATION_FAILED_WITH_EXCEPTION = new StringId(6608, "Authentication failed for [{0}]. {1}");
public static final StringId AUTH_PEER_AUTHENTICATION_FAILED = new StringId(6609, "Authentication failed. See coordinator [{0}] logs for details.");
- public static final StringId AUTH_PEER_AUTHENTICATION_MISSING_CREDENTIALS = new StringId(6610, "Failed to find credentials from [{0}] using Authenticator [{1}]");
+ public static final StringId AUTH_PEER_AUTHENTICATION_MISSING_CREDENTIALS = new StringId(6610, "Failed to find credentials from [{0}]");
public static final StringId AUTH_FAILED_TO_ACQUIRE_AUTHINITIALIZE_INSTANCE = new StringId(6611, "AuthInitialize instance could not be obtained");
public static final StringId AUTH_FAILED_TO_OBTAIN_CREDENTIALS_IN_0_USING_AUTHINITIALIZE_1_2 = new StringId(6612, "Failed to obtain credentials using AuthInitialize [{1}]. {2}");
public static final StringId DistributedSystem_BACKUP_ALREADY_IN_PROGRESS = new StringId(6613, "A backup is already in progress.");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
index d439b19..ead82e5 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
@@ -65,7 +65,7 @@ public class GeodeSecurityUtil {
* @return the shiro subject, null if security is not enabled
*/
public static Subject getSubject() {
- if (!isIntegratedSecure) {
+ if (!isIntegratedSecurity) {
return null;
}
@@ -102,7 +102,7 @@ public class GeodeSecurityUtil {
* @return null if security is not enabled, otherwise return a shiro subject
*/
public static Subject login(String username, String password) {
- if (!isIntegratedSecure) {
+ if (!isIntegratedSecurity) {
return null;
}
@@ -271,8 +271,9 @@ public class GeodeSecurityUtil {
private static PostProcessor postProcessor;
private static SecurityManager securityManager;
- private static boolean isSecure;
- private static boolean isIntegratedSecure;
+ private static boolean isIntegratedSecurity;
+ private static boolean isClientAuthenticator;
+ private static boolean isPeerAuthenticator;
/**
* initialize Shiro's Security Manager and Security Utilities
@@ -286,6 +287,7 @@ public class GeodeSecurityUtil {
String shiroConfig = securityProps.getProperty(SECURITY_SHIRO_INIT);
String securityConfig = securityProps.getProperty(SECURITY_MANAGER);
String clientAuthenticatorConfig = securityProps.getProperty(SECURITY_CLIENT_AUTHENTICATOR);
+ String peerAuthenticatorConfig = securityProps.getProperty(SECURITY_PEER_AUTHENTICATOR);
if (!StringUtils.isBlank(shiroConfig)) {
IniSecurityManagerFactory factory = new IniSecurityManagerFactory("classpath:" + shiroConfig);
@@ -299,8 +301,7 @@ public class GeodeSecurityUtil {
org.apache.shiro.mgt.SecurityManager securityManager = factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
- isSecure = true;
- isIntegratedSecure = true;
+ isIntegratedSecurity = true;
}
// only set up shiro realm if user has implemented SecurityManager
else if (!StringUtils.isBlank(securityConfig)) {
@@ -309,17 +310,18 @@ public class GeodeSecurityUtil {
Realm realm = new CustomAuthRealm(securityManager);
org.apache.shiro.mgt.SecurityManager shiroManager = new DefaultSecurityManager(realm);
SecurityUtils.setSecurityManager(shiroManager);
- isSecure = true;
- isIntegratedSecure = true;
+ isIntegratedSecurity = true;
}
else if( !StringUtils.isBlank(clientAuthenticatorConfig)) {
- isSecure = true;
- isIntegratedSecure = false;
+ isClientAuthenticator = true;
+ }
+ else if (!StringUtils.isBlank(peerAuthenticatorConfig)) {
+ isPeerAuthenticator = true;
}
else {
- SecurityUtils.setSecurityManager(null);
- isSecure = false;
- isIntegratedSecure = false;
+ isIntegratedSecurity = false;
+ isClientAuthenticator = false;
+ isPeerAuthenticator = false;
}
// this initializes the post processor
@@ -344,8 +346,9 @@ public class GeodeSecurityUtil {
postProcessor = null;
}
ThreadContext.remove();
- isSecure = false;
- isIntegratedSecure = false;
+ isIntegratedSecurity = false;
+ isClientAuthenticator = false;
+ isPeerAuthenticator = false;
}
/**
@@ -353,7 +356,7 @@ public class GeodeSecurityUtil {
* But if your postProcess is pretty involved with preparations and you need to bypass it entirely, call this first.
*/
public static boolean needPostProcess(){
- return (isIntegratedSecure && postProcessor != null);
+ return (isIntegratedSecurity && postProcessor != null);
}
public static Object postProcess(String regionPath, Object key, Object result){
@@ -446,12 +449,16 @@ public class GeodeSecurityUtil {
}
- public static boolean isSecurityRequired(){
- return isSecure;
+ public static boolean isClientSecurityRequired() {
+ return isClientAuthenticator || isIntegratedSecurity;
+ }
+
+ public static boolean isPeerSecurityRequired() {
+ return isPeerAuthenticator || isIntegratedSecurity;
}
public static boolean isIntegratedSecurity(){
- return isIntegratedSecure;
+ return isIntegratedSecurity;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java b/geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java
index f0275e4..dd49f11 100644
--- a/geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java
+++ b/geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java
@@ -21,6 +21,7 @@ import java.io.InputStream;
import java.io.StringWriter;
import java.security.Principal;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -154,6 +155,10 @@ public class SampleSecurityManager implements SecurityManager {
}
private static Map<String, Role> readRoles(JsonNode jsonNode) {
+ if (jsonNode.get("roles") == null) {
+ return Collections.EMPTY_MAP;
+ }
+
Map<String, Role> roleMap = new HashMap<>();
for (JsonNode r : jsonNode.get("roles")) {
Role role = new Role();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
index d2b0d51..c4b3a4d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
@@ -38,7 +38,7 @@ import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.InternalGemFireException;
import com.gemstone.gemfire.UnmodifiableException;
import com.gemstone.gemfire.internal.ConfigSource;
-import com.gemstone.gemfire.management.internal.security.JSONAuthorization;
+import com.gemstone.gemfire.security.JSONAuthorization;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/auth/GMSAuthenticatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/auth/GMSAuthenticatorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/auth/GMSAuthenticatorJUnitTest.java
index d52b261..18152b0 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/auth/GMSAuthenticatorJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/auth/GMSAuthenticatorJUnitTest.java
@@ -32,8 +32,10 @@ import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.distributed.DistributedMember;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.membership.gms.ServiceConfig;
import com.gemstone.gemfire.distributed.internal.membership.gms.Services;
import com.gemstone.gemfire.internal.logging.InternalLogWriter;
+import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
import com.gemstone.gemfire.security.AuthInitialize;
import com.gemstone.gemfire.security.AuthenticationFailedException;
import com.gemstone.gemfire.security.Authenticator;
@@ -46,6 +48,7 @@ public class GMSAuthenticatorJUnitTest {
private String prefix;
private Properties props;
+ protected Properties securityProps;
private Services services;
private GMSAuthenticator authenticator;
private DistributedMember member;
@@ -57,27 +60,26 @@ public class GMSAuthenticatorJUnitTest {
public void setUp() throws Exception {
prefix = getClass().getName() + "$";
props = new Properties();
+ securityProps = new Properties();
authenticator = new GMSAuthenticator();
services = mock(Services.class);
InternalLogWriter securityLog = mock(InternalLogWriter.class);
when(services.getSecurityLogWriter()).thenReturn(mock(InternalLogWriter.class));
- authenticator.init(services);
+ DistributionConfig distributionConfig = mock(DistributionConfig.class);
+ when(distributionConfig.getSecurityProps()).thenReturn(securityProps);
- member = mock(DistributedMember.class);
- }
+ ServiceConfig serviceConfig = mock(ServiceConfig.class);
+ when(serviceConfig.getDistributionConfig()).thenReturn(distributionConfig);
- @Test
- public void testGetSecurityProps() throws Exception {
- props.setProperty(DistributionConfig.GEMFIRE_PREFIX + "sys."+SECURITY_PEER_AUTH_INIT, "dummy1");
- props.setProperty(DistributionConfig.GEMFIRE_PREFIX + "sys."+SECURITY_PEER_AUTHENTICATOR, "dummy2");
- props.setProperty("security-auth-init", "dummy3");
- System.setProperties(props);
- Properties secProps = authenticator.getSecurityProps();
- assertEquals("wrong size", 2, secProps.size());
- assertEquals("wrong value", "dummy1", secProps.getProperty(SECURITY_PEER_AUTH_INIT));
- assertEquals("wrong value", "dummy2", secProps.getProperty(SECURITY_PEER_AUTHENTICATOR));
+ services = mock(Services.class);
+ when(services.getSecurityLogWriter()).thenReturn(securityLog);
+ when(services.getConfig()).thenReturn(serviceConfig);
+
+ authenticator.init(services);
+ GeodeSecurityUtil.initSecurity(securityProps);
+ member = mock(DistributedMember.class);
}
@Test
@@ -141,6 +143,7 @@ public class GMSAuthenticatorJUnitTest {
@Test
public void testAuthenticatorNormal() throws Exception {
props.setProperty(SECURITY_PEER_AUTHENTICATOR, prefix + "TestAuthenticator4.create");
+ GeodeSecurityUtil.initSecurity(props);
TestAuthenticator4 auth = new TestAuthenticator4();
assertFalse(auth.isClosed());
TestAuthenticator4.setAuthenticator(auth);
@@ -159,6 +162,7 @@ public class GMSAuthenticatorJUnitTest {
@Test
public void testAuthenticatorWithEmptyAuth() throws Exception {
props.setProperty(SECURITY_PEER_AUTHENTICATOR, "");
+ GeodeSecurityUtil.initSecurity(props);
String result = authenticator.authenticate(member, props, props, member);
assertNull(result);
}
@@ -166,34 +170,39 @@ public class GMSAuthenticatorJUnitTest {
@Test
public void testAuthenticatorWithNotExistAuth() throws Exception {
props.setProperty(SECURITY_PEER_AUTHENTICATOR, prefix + "NotExistAuth.create");
+ GeodeSecurityUtil.initSecurity(props);
verifyNegativeAuthenticate(props, props, "Authentication failed. See coordinator");
}
@Test
public void testAuthenticatorWithNullAuth() throws Exception {
props.setProperty(SECURITY_PEER_AUTHENTICATOR, prefix + "TestAuthenticator1.create");
+ GeodeSecurityUtil.initSecurity(props);
verifyNegativeAuthenticate(props, props, "Authentication failed. See coordinator");
}
@Test
public void testAuthenticatorWithNullCredential() throws Exception {
props.setProperty(SECURITY_PEER_AUTHENTICATOR, prefix + "TestAuthenticator1.create");
+ GeodeSecurityUtil.initSecurity(props);
verifyNegativeAuthenticate(null, props, "Failed to find credentials from");
}
@Test
public void testAuthenticatorWithAuthInitFailure() throws Exception {
props.setProperty(SECURITY_PEER_AUTHENTICATOR, prefix + "TestAuthenticator2.create");
+ GeodeSecurityUtil.initSecurity(props);
verifyNegativeAuthenticate(props, props, "Authentication failed. See coordinator");
}
@Test
public void testAuthenticatorWithAuthFailure() throws Exception {
props.setProperty(SECURITY_PEER_AUTHENTICATOR, prefix + "TestAuthenticator3.create");
+ GeodeSecurityUtil.initSecurity(props);
verifyNegativeAuthenticate(props, props, "Authentication failed. See coordinator");
}
- void verifyNegativeAuthenticate(Object credential, Properties props, String expectedError) throws Exception {
+ void verifyNegativeAuthenticate(Properties credential, Properties props, String expectedError) throws Exception {
String result = authenticator.authenticate(member, credential, props, member);
assertTrue(result, result.startsWith(expectedError));
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
index 732d7a1..35298ac 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
@@ -67,7 +67,7 @@ public class GMSJoinLeaveJUnitTest {
private InternalDistributedMember gmsJoinLeaveMemberId;
private InternalDistributedMember[] mockMembers;
private InternalDistributedMember mockOldMember;
- private Object credentials = new Object();
+ private Properties credentials = new Properties();
private Messenger messenger;
private GMSJoinLeave gmsJoinLeave;
private Manager manager;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
index 75d88aa..163f9b5 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
@@ -42,7 +42,7 @@ import com.gemstone.gemfire.management.internal.cli.parser.CommandTarget;
import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
import com.gemstone.gemfire.management.internal.cli.shell.Gfsh;
import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
-import com.gemstone.gemfire.management.internal.security.JSONAuthorization;
+import com.gemstone.gemfire.security.JSONAuthorization;
import com.gemstone.gemfire.test.dunit.Host;
import com.gemstone.gemfire.test.dunit.IgnoredException;
import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/AccessControlMBeanJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/AccessControlMBeanJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/AccessControlMBeanJUnitTest.java
index ac5c65a..6c626fc 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/AccessControlMBeanJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/AccessControlMBeanJUnitTest.java
@@ -16,6 +16,7 @@
*/
package com.gemstone.gemfire.management.internal.security;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import static org.assertj.core.api.Assertions.*;
import com.gemstone.gemfire.internal.AvailablePort;
@@ -35,7 +36,7 @@ public class AccessControlMBeanJUnitTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, "cacheServer.json");
+ jmxManagerPort, CACHE_SERVER_JSON);
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
index f38f2fc..6857e18 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
@@ -16,6 +16,8 @@
*/
package com.gemstone.gemfire.management.internal.security;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
+
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
@@ -34,7 +36,7 @@ public class CacheServerMBeanAuthenticationJUnitTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, "cacheServer.json");
+ jmxManagerPort, CACHE_SERVER_JSON);
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
index 3ded1dc..39094fb 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
@@ -16,6 +16,7 @@
*/
package com.gemstone.gemfire.management.internal.security;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import static org.assertj.core.api.Assertions.*;
import com.gemstone.gemfire.internal.AvailablePort;
@@ -35,7 +36,7 @@ public class CacheServerMBeanAuthorizationJUnitTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, "cacheServer.json");
+ jmxManagerPort, CACHE_SERVER_JSON);
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CliCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CliCommandsSecurityTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CliCommandsSecurityTest.java
index abcafaf..af26147 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CliCommandsSecurityTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CliCommandsSecurityTest.java
@@ -16,6 +16,7 @@
*/
package com.gemstone.gemfire.management.internal.security;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import static org.assertj.core.api.AssertionsForClassTypes.fail;
import static org.junit.Assert.*;
@@ -34,9 +35,6 @@ import com.gemstone.gemfire.security.NotAuthorizedException;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
-/**
- */
-
@Category({IntegrationTest.class, SecurityTest.class})
public class CliCommandsSecurityTest {
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
@@ -47,7 +45,7 @@ public class CliCommandsSecurityTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, "cacheServer.json");
+ jmxManagerPort, CACHE_SERVER_JSON);
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DataCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DataCommandsSecurityTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DataCommandsSecurityTest.java
index 01575b1..73da024 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DataCommandsSecurityTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DataCommandsSecurityTest.java
@@ -17,6 +17,7 @@
package com.gemstone.gemfire.management.internal.security;
import static org.assertj.core.api.Assertions.*;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import com.gemstone.gemfire.internal.AvailablePort;
import com.gemstone.gemfire.management.MemberMXBean;
@@ -37,7 +38,7 @@ public class DataCommandsSecurityTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, "cacheServer.json");
+ jmxManagerPort, CACHE_SERVER_JSON);
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
index 05d3e3d..2d8099d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
@@ -17,6 +17,7 @@
package com.gemstone.gemfire.management.internal.security;
import static org.assertj.core.api.Assertions.*;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import com.gemstone.gemfire.internal.AvailablePort;
import com.gemstone.gemfire.management.DiskStoreMXBean;
@@ -36,7 +37,7 @@ public class DiskStoreMXBeanSecurityJUnitTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, "cacheServer.json");
+ jmxManagerPort, CACHE_SERVER_JSON);
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewayReceiverMBeanSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewayReceiverMBeanSecurityTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewayReceiverMBeanSecurityTest.java
index 6c97694..8bc55f0 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewayReceiverMBeanSecurityTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewayReceiverMBeanSecurityTest.java
@@ -18,6 +18,7 @@ package com.gemstone.gemfire.management.internal.security;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import javax.management.ObjectName;
@@ -45,7 +46,7 @@ public class GatewayReceiverMBeanSecurityTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, "cacheServer.json");
+ jmxManagerPort, CACHE_SERVER_JSON);
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewaySenderMBeanSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewaySenderMBeanSecurityTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewaySenderMBeanSecurityTest.java
index 4806464..fe4f624 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewaySenderMBeanSecurityTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewaySenderMBeanSecurityTest.java
@@ -18,6 +18,7 @@ package com.gemstone.gemfire.management.internal.security;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import javax.management.ObjectName;
@@ -45,7 +46,7 @@ public class GatewaySenderMBeanSecurityTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, "cacheServer.json");
+ jmxManagerPort, CACHE_SERVER_JSON);
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodeSecurityUtilCustomRealmJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodeSecurityUtilCustomRealmJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodeSecurityUtilCustomRealmJUnitTest.java
index 5627c9e..dd9961d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodeSecurityUtilCustomRealmJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodeSecurityUtilCustomRealmJUnitTest.java
@@ -18,11 +18,13 @@
package com.gemstone.gemfire.management.internal.security;
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import org.junit.BeforeClass;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
+import com.gemstone.gemfire.security.JSONAuthorization;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
@@ -35,7 +37,7 @@ public class GeodeSecurityUtilCustomRealmJUnitTest extends GeodeSecurityUtilWith
@BeforeClass
public static void beforeClass() throws Exception{
props.put(SECURITY_MANAGER, JSONAuthorization.class.getName());
- JSONAuthorization.setUpWithJsonFile("shiro-ini.json");
+ JSONAuthorization.setUpWithJsonFile(SHIRO_INI_JSON);
GeodeSecurityUtil.initSecurity(props);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsPostProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsPostProcessorTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsPostProcessorTest.java
index 07bd1c1..8b96e8b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsPostProcessorTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsPostProcessorTest.java
@@ -18,6 +18,7 @@
package com.gemstone.gemfire.management.internal.security;
import static com.gemstone.gemfire.internal.Assert.assertTrue;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import org.junit.Before;
import org.junit.ClassRule;
@@ -38,7 +39,7 @@ public class GfshCommandsPostProcessorTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxPort, "cacheServer.json", SamplePostProcessor.class);
+ jmxPort, CACHE_SERVER_JSON, SamplePostProcessor.class);
@Rule
public GfshShellConnectionRule gfshConnection;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsSecurityTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsSecurityTest.java
index 6d42aa8..603088e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsSecurityTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsSecurityTest.java
@@ -18,6 +18,7 @@
package com.gemstone.gemfire.management.internal.security;
import static org.junit.Assert.*;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import java.util.List;
@@ -47,7 +48,7 @@ public class GfshCommandsSecurityTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxPort, httpPort, "cacheServer.json");
+ jmxPort, httpPort, CACHE_SERVER_JSON);
@Rule
public GfshShellConnectionRule gfshConnection;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JSONAuthorization.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JSONAuthorization.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JSONAuthorization.java
deleted file mode 100644
index b97cf85..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JSONAuthorization.java
+++ /dev/null
@@ -1,48 +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 com.gemstone.gemfire.management.internal.security;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-
-import org.apache.geode.security.templates.SampleSecurityManager;
-import com.gemstone.gemfire.util.test.TestUtil;
-
-/**
- * Used by test code. when using this class for security-manager, you will need explicitly call setUpWithJsonFile
- * to initialize the acl (access control list).
- */
-public class JSONAuthorization extends SampleSecurityManager {
-
- /**
- * Override the child class's implemention to look for jsonFile in the same package as this class instead of
- * in the classpath
- * @param jsonFileName
- * @throws IOException
- */
- public static void setUpWithJsonFile(String jsonFileName) throws IOException {
- String filePath = TestUtil.getResourcePath(JSONAuthorization.class, jsonFileName);
- File file = new File(filePath);
- FileReader reader = new FileReader(file);
- char[] buffer = new char[(int) file.length()];
- reader.read(buffer);
- String json = new String(buffer);
- reader.close();
- readSecurityDescriptor(json);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JsonAuthorizationCacheStartRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JsonAuthorizationCacheStartRule.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JsonAuthorizationCacheStartRule.java
index d64e2ee..1d4fb40 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JsonAuthorizationCacheStartRule.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JsonAuthorizationCacheStartRule.java
@@ -24,6 +24,7 @@ import org.junit.rules.ExternalResource;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.security.JSONAuthorization;
public class JsonAuthorizationCacheStartRule extends ExternalResource {
private Cache cache;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/LockServiceMBeanAuthorizationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/LockServiceMBeanAuthorizationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/LockServiceMBeanAuthorizationJUnitTest.java
index f07358b..44e414c 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/LockServiceMBeanAuthorizationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/LockServiceMBeanAuthorizationJUnitTest.java
@@ -17,6 +17,7 @@
package com.gemstone.gemfire.management.internal.security;
import static org.assertj.core.api.Assertions.*;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
@@ -40,7 +41,7 @@ public class LockServiceMBeanAuthorizationJUnitTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, "cacheServer.json");
+ jmxManagerPort, CACHE_SERVER_JSON);
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanSecurityJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanSecurityJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanSecurityJUnitTest.java
index 6f8ee34..1d6c95d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanSecurityJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanSecurityJUnitTest.java
@@ -26,6 +26,7 @@ import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import javax.management.DynamicMBean;
import javax.management.MBeanServer;
@@ -47,7 +48,7 @@ public class MBeanSecurityJUnitTest {
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
@ClassRule
- public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(jmxManagerPort, "cacheServer.json");
+ public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(jmxManagerPort, CACHE_SERVER_JSON);
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
index 425c467..635daa6 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
@@ -18,6 +18,7 @@ package com.gemstone.gemfire.management.internal.security;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import java.lang.management.ManagementFactory;
import javax.management.ObjectName;
@@ -41,7 +42,7 @@ public class ManagerMBeanAuthorizationJUnitTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, "cacheServer.json");
+ jmxManagerPort, CACHE_SERVER_JSON);
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MemberMBeanSecurityJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MemberMBeanSecurityJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MemberMBeanSecurityJUnitTest.java
index e32b6ca..4ee5b13 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MemberMBeanSecurityJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MemberMBeanSecurityJUnitTest.java
@@ -16,6 +16,7 @@
*/
package com.gemstone.gemfire.management.internal.security;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import static org.assertj.core.api.Assertions.*;
import com.gemstone.gemfire.internal.AvailablePort;
@@ -35,7 +36,7 @@ public class MemberMBeanSecurityJUnitTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, "cacheServer.json");
+ jmxManagerPort, CACHE_SERVER_JSON);
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MultiUserDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MultiUserDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MultiUserDUnitTest.java
index 1c55a3c..e86cf61 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MultiUserDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MultiUserDUnitTest.java
@@ -19,12 +19,14 @@ package com.gemstone.gemfire.management.internal.security;
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
import static org.junit.Assert.*;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
+import com.gemstone.gemfire.security.JSONAuthorization;
import com.jayway.awaitility.Awaitility;
import org.json.JSONException;
import org.junit.Test;
@@ -54,7 +56,7 @@ public class MultiUserDUnitTest extends CliCommandTestBase {
properties.put(SECURITY_MANAGER, JSONAuthorization.class.getName());
// set up vm_0 the secure jmx manager
- Object[] results = setUpJMXManagerOnVM(0, properties, "cacheServer.json");
+ Object[] results = setUpJMXManagerOnVM(0, properties, CACHE_SERVER_JSON);
String gfshDir = this.gfshDir;
// set up vm_1 as a gfsh vm, data-reader will login and log out constantly in this vm until the test is done.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
index 10c316a..feee478 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
@@ -17,6 +17,7 @@
package com.gemstone.gemfire.security;
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
@@ -32,7 +33,6 @@ import com.gemstone.gemfire.cache.client.ClientCache;
import com.gemstone.gemfire.cache.client.ClientCacheFactory;
import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
import com.gemstone.gemfire.cache.server.CacheServer;
-import com.gemstone.gemfire.management.internal.security.JSONAuthorization;
import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
import com.gemstone.gemfire.test.dunit.Host;
import com.gemstone.gemfire.test.dunit.Invoke;
@@ -56,7 +56,7 @@ public class AbstractIntegratedClientAuthDistributedTest extends JUnit4CacheTest
this.client2 = host.getVM(2);
this.client3 = host.getVM(3);
- JSONAuthorization.setUpWithJsonFile("clientServer.json");
+ JSONAuthorization.setUpWithJsonFile(CLIENT_SERVER_JSON);
Properties props = new Properties();
props.setProperty(SECURITY_MANAGER, JSONAuthorization.class.getName());
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/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 9f06482..dc63f2f 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
@@ -16,11 +16,10 @@
*/
package com.gemstone.gemfire.security;
-
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
import static org.assertj.core.api.Assertions.*;
-import java.security.Principal;
import java.util.Properties;
import org.junit.Test;
@@ -29,8 +28,6 @@ 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.management.internal.security.JSONAuthorization;
-import com.gemstone.gemfire.security.IntegratedSecurityCacheLifecycleIntegrationTest.SpySecurityManager;
import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
import com.gemstone.gemfire.test.dunit.Host;
import com.gemstone.gemfire.test.dunit.NetworkUtils;
@@ -41,13 +38,14 @@ import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({DistributedTest.class, SecurityTest.class})
public class IntegratedSecurityCacheLifecycleDistributedTest extends JUnit4CacheTestCase {
+
private VM locator;
@Override
public final void postSetUp() throws Exception {
Host host = Host.getHost(0);
locator = host.getVM(0);
- JSONAuthorization.setUpWithJsonFile("clientServer.json");
+ JSONAuthorization.setUpWithJsonFile(CLIENT_SERVER_JSON);
int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
String locators = NetworkUtils.getServerHostName(host) + "[" + locatorPort + "]";
@@ -55,21 +53,19 @@ public class IntegratedSecurityCacheLifecycleDistributedTest extends JUnit4Cache
DistributedTestUtils.deleteLocatorStateFile(locatorPort);
final Properties properties = new Properties();
+// properties.setProperty(LOCATORS, locators);
properties.setProperty(MCAST_PORT, "0");
- properties.setProperty(START_LOCATOR, locators);
properties.setProperty(SECURITY_MANAGER, SpySecurityManager.class.getName());
+ properties.setProperty(START_LOCATOR, locators);
properties.setProperty(USE_CLUSTER_CONFIGURATION, "false");
getSystem(properties);
getCache();
});
final Properties properties = new Properties();
+ properties.setProperty(LOCATORS, locators);
properties.setProperty(MCAST_PORT, "0");
properties.setProperty(SECURITY_MANAGER, SpySecurityManager.class.getName());
- properties.setProperty(LOCATORS, locators);
- properties.setProperty(JMX_MANAGER, "false");
- properties.setProperty(JMX_MANAGER_PORT, "0");
- properties.setProperty(JMX_MANAGER_START, "false");
properties.setProperty(USE_CLUSTER_CONFIGURATION, "false");
getSystem(properties);
@@ -95,8 +91,7 @@ public class IntegratedSecurityCacheLifecycleDistributedTest extends JUnit4Cache
}
private void verifyInitCloseInvoked() {
- SpySecurityManager ssm = (SpySecurityManager) GeodeSecurityUtil
- .getSecurityManager();
+ SpySecurityManager ssm = (SpySecurityManager) GeodeSecurityUtil.getSecurityManager();
assertThat(ssm.initInvoked).isEqualTo(1);
getCache().close();
assertThat(ssm.closeInvoked).isEqualTo(1);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/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 712329d..228a8d6 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
@@ -14,13 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.security;
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
import static org.assertj.core.api.Assertions.*;
+import static org.mockito.Mockito.*;
-import java.security.Principal;
import java.util.Properties;
import com.gemstone.gemfire.cache.Cache;
@@ -29,8 +28,6 @@ import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
-import org.apache.geode.security.GeodePermission;
-import org.apache.geode.security.SecurityManager;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -38,6 +35,7 @@ import org.junit.experimental.categories.Category;
@Category({IntegrationTest.class, SecurityTest.class})
public class IntegratedSecurityCacheLifecycleIntegrationTest {
+
private Properties securityProps;
private Cache cache;
@@ -52,7 +50,6 @@ public class IntegratedSecurityCacheLifecycleIntegrationTest {
props.setProperty(LOCATORS, "");
cache = new CacheFactory(props).create();
-
}
@After
@@ -70,24 +67,4 @@ public class IntegratedSecurityCacheLifecycleIntegrationTest {
assertThat(ssm.closeInvoked).isEqualTo(1);
}
- public static class SpySecurityManager implements SecurityManager {
-
- public int initInvoked = 0;
- public int closeInvoked = 0;
-
- @Override
- public void init(final Properties securityProps) {
- initInvoked++;
- }
-
- @Override
- public Principal authenticate(final Properties props) throws AuthenticationFailedException {
- return null;
- }
-
- @Override
- public void close() {
- closeInvoked++;
- }
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPeerAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPeerAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPeerAuthDistributedTest.java
new file mode 100644
index 0000000..a5e0aa0
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPeerAuthDistributedTest.java
@@ -0,0 +1,146 @@
+/*
+ * 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 com.gemstone.gemfire.security;
+
+import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
+import static com.gemstone.gemfire.security.JSONAuthorization.*;
+import static com.gemstone.gemfire.test.dunit.Invoke.*;
+import static org.assertj.core.api.Assertions.*;
+
+import java.util.Properties;
+
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
+import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category({ DistributedTest.class, SecurityTest.class })
+public class IntegratedSecurityPeerAuthDistributedTest extends JUnit4CacheTestCase{
+
+ private static SpyJSONAuthorization spyJSONAuthorization;
+
+ private VM locator;
+ private VM server1;
+ private VM server2;
+
+ private String locators;
+
+ @Override
+ public final void postSetUp() throws Exception {
+ Host host = Host.getHost(0);
+ locator = host.getVM(0);
+ server1 = host.getVM(1);
+ server2 = host.getVM(2);
+
+ int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+ locators = NetworkUtils.getServerHostName(host) + "[" + locatorPort + "]";
+
+ locator.invoke(() -> {
+ JSONAuthorization.setUpWithJsonFile(PEER_AUTH_JSON);
+ spyJSONAuthorization = new SpyJSONAuthorization();
+
+ DistributedTestUtils.deleteLocatorStateFile(locatorPort);
+
+ final Properties properties = createProperties(locators);
+ properties.setProperty(UserPasswordAuthInit.USER_NAME, "locator1");
+ properties.setProperty(UserPasswordAuthInit.PASSWORD, "1234567");
+ properties.setProperty(START_LOCATOR, locators);
+
+ getSystem(properties);
+ getCache();
+ });
+
+ server1.invoke(()-> {
+ JSONAuthorization.setUpWithJsonFile(PEER_AUTH_JSON);
+ spyJSONAuthorization = new SpyJSONAuthorization();
+
+ final Properties properties = createProperties(locators);
+ properties.setProperty(UserPasswordAuthInit.USER_NAME, "server1");
+ properties.setProperty(UserPasswordAuthInit.PASSWORD, "1234567");
+
+ getSystem(properties);
+ getCache();
+ });
+
+ server2.invoke(()-> {
+ JSONAuthorization.setUpWithJsonFile(PEER_AUTH_JSON);
+ spyJSONAuthorization = new SpyJSONAuthorization();
+
+ final Properties properties = createProperties(locators);
+ properties.setProperty(UserPasswordAuthInit.USER_NAME, "server2");
+ properties.setProperty(UserPasswordAuthInit.PASSWORD, "1234567");
+
+ getSystem(properties);
+ getCache();
+ });
+ }
+
+ @Test
+ public void initAndCloseTest() throws Exception {
+ JSONAuthorization.setUpWithJsonFile(PEER_AUTH_JSON);
+ spyJSONAuthorization = new SpyJSONAuthorization();
+
+ final Properties properties = createProperties(locators);
+ properties.setProperty(UserPasswordAuthInit.USER_NAME, "stranger");
+ properties.setProperty(UserPasswordAuthInit.PASSWORD, "1234567");
+
+ assertThatThrownBy(() -> getSystem(properties)).isExactlyInstanceOf(AuthenticationFailedException.class);
+ }
+
+ @Override
+ public void postTearDownCacheTestCase() throws Exception {
+ closeAllCache();
+ spyJSONAuthorization = null;
+ invokeInEveryVM(() -> { spyJSONAuthorization = null; });
+ }
+
+ private static Properties createProperties(String locators) {
+ Properties allProperties = new Properties();
+ allProperties.setProperty(LOCATORS, locators);
+ allProperties.setProperty(MCAST_PORT, "0");
+ allProperties.setProperty(SECURITY_MANAGER, SpyJSONAuthorization.class.getName());
+ allProperties.setProperty(SECURITY_PEER_AUTH_INIT, UserPasswordAuthInit.class.getName() + ".create");
+ allProperties.setProperty(USE_CLUSTER_CONFIGURATION, "false");
+ return allProperties;
+ }
+
+ public static class SpyJSONAuthorization extends JSONAuthorization {
+
+ static int initInvoked = 0;
+ static int closeInvoked = 0;
+
+ @Override
+ public void init(final Properties securityProps) {
+ initInvoked++;
+ super.init(securityProps);
+ }
+
+ @Override
+ public void close() {
+ closeInvoked++;
+ super.close();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/security/JSONAuthorization.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/JSONAuthorization.java b/geode-core/src/test/java/com/gemstone/gemfire/security/JSONAuthorization.java
new file mode 100644
index 0000000..bf7990a
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/JSONAuthorization.java
@@ -0,0 +1,54 @@
+/*
+ * 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 com.gemstone.gemfire.security;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import org.apache.geode.security.templates.SampleSecurityManager;
+import com.gemstone.gemfire.util.test.TestUtil;
+
+/**
+ * Used by test code. when using this class for security-manager, you will need explicitly call setUpWithJsonFile
+ * to initialize the acl (access control list).
+ */
+public class JSONAuthorization extends SampleSecurityManager {
+
+ public static String AUTH1_JSON = "/com/gemstone/gemfire/management/internal/security/auth1.json";
+ public static String AUTH2_JSON = "/com/gemstone/gemfire/management/internal/security/auth2.json";
+ public static String AUTH3_JSON = "/com/gemstone/gemfire/management/internal/security/auth3.json";
+ public static String CACHE_SERVER_JSON = "/com/gemstone/gemfire/management/internal/security/cacheServer.json";
+ public static String CLIENT_SERVER_JSON = "/com/gemstone/gemfire/management/internal/security/clientServer.json";
+ public static String SHIRO_INI_JSON = "/com/gemstone/gemfire/management/internal/security/shiro-ini.json";
+ public static String PEER_AUTH_JSON = "/com/gemstone/gemfire/security/peerAuth.json";
+
+ /**
+ * Override the child class's implemention to look for jsonFile in the same package as this class instead of
+ * in the classpath
+ */
+ public static void setUpWithJsonFile(String jsonFileName) throws IOException {
+ String filePath = TestUtil.getResourcePath(JSONAuthorization.class, jsonFileName);
+ File file = new File(filePath);
+ FileReader reader = new FileReader(file);
+ char[] buffer = new char[(int) file.length()];
+ reader.read(buffer);
+ String json = new String(buffer);
+ reader.close();
+ readSecurityDescriptor(json);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/java/com/gemstone/gemfire/security/SpySecurityManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/SpySecurityManager.java b/geode-core/src/test/java/com/gemstone/gemfire/security/SpySecurityManager.java
new file mode 100644
index 0000000..6d04a0d
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/SpySecurityManager.java
@@ -0,0 +1,43 @@
+/*
+ * 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 com.gemstone.gemfire.security;
+
+import java.security.Principal;
+import java.util.Properties;
+
+import org.apache.geode.security.SecurityManager;
+
+public class SpySecurityManager implements SecurityManager {
+
+ public int initInvoked = 0;
+ public int closeInvoked = 0;
+
+ @Override
+ public void init(final Properties securityProps) {
+ initInvoked++;
+ }
+
+ @Override
+ public Principal authenticate(final Properties props) throws AuthenticationFailedException {
+ return null;
+ }
+
+ @Override
+ public void close() {
+ closeInvoked++;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-core/src/test/resources/com/gemstone/gemfire/security/peerAuth.json
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/com/gemstone/gemfire/security/peerAuth.json b/geode-core/src/test/resources/com/gemstone/gemfire/security/peerAuth.json
new file mode 100644
index 0000000..9bd8936
--- /dev/null
+++ b/geode-core/src/test/resources/com/gemstone/gemfire/security/peerAuth.json
@@ -0,0 +1,36 @@
+{
+ "users": [
+ {
+ "name": "locator1",
+ "password": "1234567",
+ "roles": [
+ ]
+ },
+ {
+ "name": "server1",
+ "password": "1234567",
+ "roles": [
+ ]
+ },
+ {
+ "name": "server2",
+ "password": "1234567",
+ "roles": [
+ ]
+ }
+ ]
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/16b73564/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Server.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Server.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Server.java
index 7385e7f..8f47145 100644
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Server.java
+++ b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Server.java
@@ -46,7 +46,7 @@ import org.apache.shiro.realm.Realm;
import com.gemstone.gemfire.internal.security.shiro.CustomAuthRealm;
import com.gemstone.gemfire.internal.security.shiro.JMXShiroAuthenticator;
import com.gemstone.gemfire.management.internal.security.AccessControlMBean;
-import com.gemstone.gemfire.management.internal.security.JSONAuthorization;
+import com.gemstone.gemfire.security.JSONAuthorization;
import com.gemstone.gemfire.management.internal.security.MBeanServerWrapper;
import com.gemstone.gemfire.management.internal.security.ResourceConstants;
[09/10] incubator-geode git commit: GEODE-1673: fail start if
security.json cannot be found
Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ShiroCacheStartRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ShiroCacheStartRule.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ShiroCacheStartRule.java
index 49cbbaa..3c11e53 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ShiroCacheStartRule.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ShiroCacheStartRule.java
@@ -16,13 +16,14 @@
*/
package com.gemstone.gemfire.management.internal.security;
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheFactory;
-import org.junit.rules.ExternalResource;
+import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
import java.util.Properties;
-import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
+import org.junit.rules.ExternalResource;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
public class ShiroCacheStartRule extends ExternalResource {
private Cache cache;
@@ -34,7 +35,6 @@ public class ShiroCacheStartRule extends ExternalResource {
this.shiroFile = shiroFile;
}
-
protected void before() throws Throwable {
Properties properties = new Properties();
properties.put(NAME, ShiroCacheStartRule.class.getSimpleName());
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/TestCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/TestCommand.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/TestCommand.java
index 8c8ed40..875aeef 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/TestCommand.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/TestCommand.java
@@ -14,17 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.management.internal.security;
import java.util.ArrayList;
import java.util.List;
import org.apache.geode.security.GeodePermission;
-
import org.apache.shiro.authz.Permission;
public class TestCommand {
+
public static GeodePermission none = null;
public static GeodePermission everyOneAllowed = new GeodePermission();
public static GeodePermission dataRead = new GeodePermission("DATA", "READ");
@@ -206,7 +205,6 @@ public class TestCommand {
createTestCommand("sleep", null);
createTestCommand("sh ls", null);
-
// WAN Commands
createTestCommand("create gateway-sender --id=sender1 --remote-distributed-system-id=2", dataManage);
createTestCommand("start gateway-sender --id=sender1", dataManage);
@@ -223,6 +221,7 @@ public class TestCommand {
//ShellCommand
createTestCommand("disconnect", null);
+
//Misc commands
//createTestCommand("shutdown", clusterManage);
};
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
index feee478..feda4b4 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
@@ -17,12 +17,12 @@
package com.gemstone.gemfire.security;
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;
import java.util.Properties;
+import org.apache.geode.security.templates.SampleSecurityManager;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.Before;
@@ -56,16 +56,15 @@ public class AbstractIntegratedClientAuthDistributedTest extends JUnit4CacheTest
this.client2 = host.getVM(2);
this.client3 = host.getVM(3);
- JSONAuthorization.setUpWithJsonFile(CLIENT_SERVER_JSON);
-
Properties props = new Properties();
- props.setProperty(SECURITY_MANAGER, JSONAuthorization.class.getName());
- if(postProcessor!=null){
+ props.setProperty(SampleSecurityManager.SECURITY_JSON, "com/gemstone/gemfire/management/internal/security/clientServer.json");
+ props.setProperty(LOCATORS, "");
+ props.setProperty(MCAST_PORT, "0");
+ if (postProcessor!=null) {
props.setProperty(SECURITY_POST_PROCESSOR, postProcessor.getName());
}
- props.setProperty(MCAST_PORT, "0");
- props.setProperty(LOCATORS, "");
props.setProperty(SECURITY_LOG_LEVEL, "finest");
+ props.setProperty(SECURITY_MANAGER, SampleSecurityManager.class.getName());
getSystem(props);
@@ -101,9 +100,9 @@ public class AbstractIntegratedClientAuthDistributedTest extends JUnit4CacheTest
Properties props = new Properties();
props.setProperty(UserPasswordAuthInit.USER_NAME, userName);
props.setProperty(UserPasswordAuthInit.PASSWORD, password);
- props.setProperty(SECURITY_CLIENT_AUTH_INIT, UserPasswordAuthInit.class.getName() + ".create");
- props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
+ props.setProperty(MCAST_PORT, "0");
+ props.setProperty(SECURITY_CLIENT_AUTH_INIT, UserPasswordAuthInit.class.getName() + ".create");
props.setProperty(SECURITY_LOG_LEVEL, "finest");
return props;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetEntryAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetEntryAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetEntryAuthDistributedTest.java
index 8472af9..746dbb1 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetEntryAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetEntryAuthDistributedTest.java
@@ -16,7 +16,6 @@
*/
package com.gemstone.gemfire.security;
-
import org.junit.Test;
import org.junit.experimental.categories.Category;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientSizeAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientSizeAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientSizeAuthDistributedTest.java
index b0a1fa2..6aa3d68 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientSizeAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientSizeAuthDistributedTest.java
@@ -16,7 +16,6 @@
*/
package com.gemstone.gemfire.security;
-
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/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 dc63f2f..ed19d19 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
@@ -17,11 +17,11 @@
package com.gemstone.gemfire.security;
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
import static org.assertj.core.api.Assertions.*;
import java.util.Properties;
+import org.apache.geode.security.templates.SampleSecurityManager;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -45,7 +45,7 @@ public class IntegratedSecurityCacheLifecycleDistributedTest extends JUnit4Cache
public final void postSetUp() throws Exception {
Host host = Host.getHost(0);
locator = host.getVM(0);
- JSONAuthorization.setUpWithJsonFile(CLIENT_SERVER_JSON);
+
int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
String locators = NetworkUtils.getServerHostName(host) + "[" + locatorPort + "]";
@@ -53,7 +53,8 @@ public class IntegratedSecurityCacheLifecycleDistributedTest extends JUnit4Cache
DistributedTestUtils.deleteLocatorStateFile(locatorPort);
final Properties properties = new Properties();
-// properties.setProperty(LOCATORS, locators);
+ properties.setProperty(SampleSecurityManager.SECURITY_JSON, "com/gemstone/gemfire/management/internal/security/clientServer.json");
+ properties.setProperty(LOCATORS, locators); // TODO:KIRK: keep?
properties.setProperty(MCAST_PORT, "0");
properties.setProperty(SECURITY_MANAGER, SpySecurityManager.class.getName());
properties.setProperty(START_LOCATOR, locators);
@@ -63,7 +64,8 @@ public class IntegratedSecurityCacheLifecycleDistributedTest extends JUnit4Cache
});
final Properties properties = new Properties();
- properties.setProperty(LOCATORS, locators);
+ properties.setProperty(SampleSecurityManager.SECURITY_JSON, "com/gemstone/gemfire/management/internal/security/clientServer.json");
+ properties.setProperty(LOCATORS, locators); // TODO:KIRK: keep?
properties.setProperty(MCAST_PORT, "0");
properties.setProperty(SECURITY_MANAGER, SpySecurityManager.class.getName());
properties.setProperty(USE_CLUSTER_CONFIGURATION, "false");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/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..5eabe7a 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
@@ -18,7 +18,6 @@ package com.gemstone.gemfire.security;
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
import static org.assertj.core.api.Assertions.*;
-import static org.mockito.Mockito.*;
import java.util.Properties;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityNoShowValue1PostProcessorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityNoShowValue1PostProcessorDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityNoShowValue1PostProcessorDUnitTest.java
index d6ac3aa..ce090f1 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityNoShowValue1PostProcessorDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityNoShowValue1PostProcessorDUnitTest.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.security;
import static org.junit.Assert.*;
@@ -81,7 +80,6 @@ public class IntegratedSecurityNoShowValue1PostProcessorDUnitTest extends Abstra
assertTrue(result.contains("value2"));
assertTrue(result.contains("value3"));
assertTrue(result.contains("value4"));
-
});
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPeerAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPeerAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPeerAuthDistributedTest.java
index a5e0aa0..7a4830d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPeerAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPeerAuthDistributedTest.java
@@ -17,7 +17,6 @@
package com.gemstone.gemfire.security;
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
import static com.gemstone.gemfire.test.dunit.Invoke.*;
import static org.assertj.core.api.Assertions.*;
@@ -33,13 +32,14 @@ import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+import org.apache.geode.security.templates.SampleSecurityManager;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@Category({ DistributedTest.class, SecurityTest.class })
public class IntegratedSecurityPeerAuthDistributedTest extends JUnit4CacheTestCase{
- private static SpyJSONAuthorization spyJSONAuthorization;
+ private static SpySecurityManager spySecurityManager;
private VM locator;
private VM server1;
@@ -58,12 +58,12 @@ public class IntegratedSecurityPeerAuthDistributedTest extends JUnit4CacheTestCa
locators = NetworkUtils.getServerHostName(host) + "[" + locatorPort + "]";
locator.invoke(() -> {
- JSONAuthorization.setUpWithJsonFile(PEER_AUTH_JSON);
- spyJSONAuthorization = new SpyJSONAuthorization();
+ spySecurityManager = new SpySecurityManager();
DistributedTestUtils.deleteLocatorStateFile(locatorPort);
final Properties properties = createProperties(locators);
+ properties.setProperty(SampleSecurityManager.SECURITY_JSON, "com/gemstone/gemfire/security/peerAuth.json");
properties.setProperty(UserPasswordAuthInit.USER_NAME, "locator1");
properties.setProperty(UserPasswordAuthInit.PASSWORD, "1234567");
properties.setProperty(START_LOCATOR, locators);
@@ -73,10 +73,10 @@ public class IntegratedSecurityPeerAuthDistributedTest extends JUnit4CacheTestCa
});
server1.invoke(()-> {
- JSONAuthorization.setUpWithJsonFile(PEER_AUTH_JSON);
- spyJSONAuthorization = new SpyJSONAuthorization();
+ spySecurityManager = new SpySecurityManager();
final Properties properties = createProperties(locators);
+ properties.setProperty(SampleSecurityManager.SECURITY_JSON, "com/gemstone/gemfire/security/peerAuth.json");
properties.setProperty(UserPasswordAuthInit.USER_NAME, "server1");
properties.setProperty(UserPasswordAuthInit.PASSWORD, "1234567");
@@ -85,10 +85,10 @@ public class IntegratedSecurityPeerAuthDistributedTest extends JUnit4CacheTestCa
});
server2.invoke(()-> {
- JSONAuthorization.setUpWithJsonFile(PEER_AUTH_JSON);
- spyJSONAuthorization = new SpyJSONAuthorization();
+ spySecurityManager = new SpySecurityManager();
final Properties properties = createProperties(locators);
+ properties.setProperty(SampleSecurityManager.SECURITY_JSON, "com/gemstone/gemfire/security/peerAuth.json");
properties.setProperty(UserPasswordAuthInit.USER_NAME, "server2");
properties.setProperty(UserPasswordAuthInit.PASSWORD, "1234567");
@@ -99,10 +99,10 @@ public class IntegratedSecurityPeerAuthDistributedTest extends JUnit4CacheTestCa
@Test
public void initAndCloseTest() throws Exception {
- JSONAuthorization.setUpWithJsonFile(PEER_AUTH_JSON);
- spyJSONAuthorization = new SpyJSONAuthorization();
+ spySecurityManager = new SpySecurityManager();
final Properties properties = createProperties(locators);
+ properties.setProperty(SampleSecurityManager.SECURITY_JSON, "com/gemstone/gemfire/security/peerAuth.json");
properties.setProperty(UserPasswordAuthInit.USER_NAME, "stranger");
properties.setProperty(UserPasswordAuthInit.PASSWORD, "1234567");
@@ -112,21 +112,21 @@ public class IntegratedSecurityPeerAuthDistributedTest extends JUnit4CacheTestCa
@Override
public void postTearDownCacheTestCase() throws Exception {
closeAllCache();
- spyJSONAuthorization = null;
- invokeInEveryVM(() -> { spyJSONAuthorization = null; });
+ spySecurityManager = null;
+ invokeInEveryVM(() -> { spySecurityManager = null; });
}
private static Properties createProperties(String locators) {
Properties allProperties = new Properties();
allProperties.setProperty(LOCATORS, locators);
allProperties.setProperty(MCAST_PORT, "0");
- allProperties.setProperty(SECURITY_MANAGER, SpyJSONAuthorization.class.getName());
+ allProperties.setProperty(SECURITY_MANAGER, SpySecurityManager.class.getName());
allProperties.setProperty(SECURITY_PEER_AUTH_INIT, UserPasswordAuthInit.class.getName() + ".create");
allProperties.setProperty(USE_CLUSTER_CONFIGURATION, "false");
return allProperties;
}
- public static class SpyJSONAuthorization extends JSONAuthorization {
+ public static class SpySecurityManager extends SampleSecurityManager {
static int initInvoked = 0;
static int closeInvoked = 0;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPostProcessorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPostProcessorDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPostProcessorDUnitTest.java
index f573073..0568659 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPostProcessorDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPostProcessorDUnitTest.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.security;
import static org.junit.Assert.*;
@@ -85,7 +84,6 @@ public class IntegratedSecurityPostProcessorDUnitTest extends AbstractIntegrated
assertTrue(result.contains("super-user/null/null/value2"));
assertTrue(result.contains("super-user/null/null/value3"));
assertTrue(result.contains("super-user/null/null/value4"));
-
});
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/security/JSONAuthorization.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/JSONAuthorization.java b/geode-core/src/test/java/com/gemstone/gemfire/security/JSONAuthorization.java
deleted file mode 100644
index bf7990a..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/JSONAuthorization.java
+++ /dev/null
@@ -1,54 +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 com.gemstone.gemfire.security;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-
-import org.apache.geode.security.templates.SampleSecurityManager;
-import com.gemstone.gemfire.util.test.TestUtil;
-
-/**
- * Used by test code. when using this class for security-manager, you will need explicitly call setUpWithJsonFile
- * to initialize the acl (access control list).
- */
-public class JSONAuthorization extends SampleSecurityManager {
-
- public static String AUTH1_JSON = "/com/gemstone/gemfire/management/internal/security/auth1.json";
- public static String AUTH2_JSON = "/com/gemstone/gemfire/management/internal/security/auth2.json";
- public static String AUTH3_JSON = "/com/gemstone/gemfire/management/internal/security/auth3.json";
- public static String CACHE_SERVER_JSON = "/com/gemstone/gemfire/management/internal/security/cacheServer.json";
- public static String CLIENT_SERVER_JSON = "/com/gemstone/gemfire/management/internal/security/clientServer.json";
- public static String SHIRO_INI_JSON = "/com/gemstone/gemfire/management/internal/security/shiro-ini.json";
- public static String PEER_AUTH_JSON = "/com/gemstone/gemfire/security/peerAuth.json";
-
- /**
- * Override the child class's implemention to look for jsonFile in the same package as this class instead of
- * in the classpath
- */
- public static void setUpWithJsonFile(String jsonFileName) throws IOException {
- String filePath = TestUtil.getResourcePath(JSONAuthorization.class, jsonFileName);
- File file = new File(filePath);
- FileReader reader = new FileReader(file);
- char[] buffer = new char[(int) file.length()];
- reader.read(buffer);
- String json = new String(buffer);
- reader.close();
- readSecurityDescriptor(json);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/security/NoShowValue1PostProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/NoShowValue1PostProcessor.java b/geode-core/src/test/java/com/gemstone/gemfire/security/NoShowValue1PostProcessor.java
index b6fd2f7..b428144 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/NoShowValue1PostProcessor.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/NoShowValue1PostProcessor.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.security;
import java.security.Principal;
@@ -28,9 +27,10 @@ public class NoShowValue1PostProcessor implements PostProcessor {
final String regionName,
final Object key,
final Object value) {
- if(value.equals("value1"))
+ if (value.equals("value1")) {
return null;
- else
+ } else {
return value;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
index b74b054..598242d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package com.gemstone.gemfire.security;
import static com.gemstone.gemfire.cache30.ClientServerTestCase.*;
@@ -90,6 +89,7 @@ import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
/**
* Contains utility methods for setting up servers/clients for authentication
* and authorization tests.
+ *
* @since GemFire 5.5
*/
public final class SecurityTestUtils {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/org/apache/geode/security/templates/SampleSecurityManagerTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/templates/SampleSecurityManagerTest.java b/geode-core/src/test/java/org/apache/geode/security/templates/SampleSecurityManagerTest.java
new file mode 100644
index 0000000..c810cb0
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/security/templates/SampleSecurityManagerTest.java
@@ -0,0 +1,123 @@
+/*
+ * 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.templates;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import org.apache.geode.security.templates.SampleSecurityManager.Role;
+import org.apache.geode.security.templates.SampleSecurityManager.User;
+
+@Category({ IntegrationTest.class, SecurityTest.class })
+public class SampleSecurityManagerTest {
+
+ private SampleSecurityManager sampleSecurityManager;
+ private String jsonResource;
+ private File jsonFile;
+ private String json;
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Before
+ public void setUp() throws Exception {
+ // resource file
+ this.jsonResource = "org/apache/geode/security/templates/security.json";
+ InputStream inputStream = ClassLoader.getSystemResourceAsStream(this.jsonResource);
+
+ assertThat(inputStream).isNotNull();
+
+ // non-resource file
+ this.jsonFile = new File(temporaryFolder.getRoot(), "security.json");
+ IOUtils.copy(inputStream, new FileOutputStream(this.jsonFile));
+
+ // string
+ this.json = FileUtils.readFileToString(this.jsonFile, "UTF-8");
+ this.sampleSecurityManager = new SampleSecurityManager();
+ }
+
+ @Test
+ public void shouldInitializeFromJsonString() throws Exception {
+ this.sampleSecurityManager.initializeFromJson(this.json);
+ verifySecurityManagerState();
+ }
+
+ @Test
+ public void shouldInitializeFromJsonResource() throws Exception {
+ this.sampleSecurityManager.initializeFromJsonResource(this.jsonResource);
+ verifySecurityManagerState();
+ }
+
+ @Test
+ public void shouldInitializeFromJsonFile() throws Exception {
+ this.sampleSecurityManager.initializeFromJsonFile(this.jsonFile);
+ verifySecurityManagerState();
+ }
+
+ @Test
+ public void initShouldUsePropertyAsJsonString() throws Exception {
+ Properties securityProperties = new Properties();
+ securityProperties.setProperty(SampleSecurityManager.SECURITY_JSON, this.json);
+ this.sampleSecurityManager.init(securityProperties);
+ verifySecurityManagerState();
+ }
+
+ @Test
+ public void initShouldUsePropertyAsJsonFile() throws Exception {
+ Properties securityProperties = new Properties();
+ securityProperties.setProperty(SampleSecurityManager.SECURITY_JSON, this.jsonFile.getAbsolutePath());
+ this.sampleSecurityManager.init(securityProperties);
+ verifySecurityManagerState();
+ }
+
+ @Test
+ public void initShouldUsePropertyAsJsonResource() throws Exception {
+ Properties securityProperties = new Properties();
+ securityProperties.setProperty(SampleSecurityManager.SECURITY_JSON, this.jsonResource);
+ this.sampleSecurityManager.init(securityProperties);
+ verifySecurityManagerState();
+ }
+
+ private void verifySecurityManagerState() {
+ User adminUser = this.sampleSecurityManager.getUser("admin");
+ assertThat(adminUser).isNotNull();
+ assertThat(adminUser.name).isEqualTo("admin");
+ assertThat(adminUser.password).isEqualTo("secret");
+ assertThat(adminUser.roles).hasSize(1);
+
+ User guestUser = this.sampleSecurityManager.getUser("guest");
+ assertThat(guestUser).isNotNull();
+ assertThat(guestUser.name).isEqualTo("guest");
+ assertThat(guestUser.password).isEqualTo("guest");
+ assertThat(guestUser.roles).hasSize(1);
+ // TODO: need to do more verification
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/resources/org/apache/geode/security/templates/security.json
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/security/templates/security.json b/geode-core/src/test/resources/org/apache/geode/security/templates/security.json
new file mode 100644
index 0000000..c1ee9fc
--- /dev/null
+++ b/geode-core/src/test/resources/org/apache/geode/security/templates/security.json
@@ -0,0 +1,30 @@
+{
+ "roles": [
+ {
+ "name": "admin",
+ "operationsAllowed": [
+ "CLUSTER:MANAGE",
+ "DATA:MANAGE"
+ ]
+ },
+ {
+ "name": "readRegionA",
+ "operationsAllowed": [
+ "DATA:READ"
+ ],
+ "regions": ["RegionA", "RegionB"]
+ }
+ ],
+ "users": [
+ {
+ "name": "admin",
+ "password": "secret",
+ "roles": ["admin"]
+ },
+ {
+ "name": "guest",
+ "password": "guest",
+ "roles": ["readRegionA"]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Server.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Server.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Server.java
index 8f47145..d59b562 100644
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Server.java
+++ b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Server.java
@@ -26,6 +26,7 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanRegistrationException;
@@ -38,6 +39,7 @@ import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL;
import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.security.templates.SampleSecurityManager;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.mgt.DefaultSecurityManager;
import org.apache.shiro.mgt.SecurityManager;
@@ -46,11 +48,11 @@ import org.apache.shiro.realm.Realm;
import com.gemstone.gemfire.internal.security.shiro.CustomAuthRealm;
import com.gemstone.gemfire.internal.security.shiro.JMXShiroAuthenticator;
import com.gemstone.gemfire.management.internal.security.AccessControlMBean;
-import com.gemstone.gemfire.security.JSONAuthorization;
import com.gemstone.gemfire.management.internal.security.MBeanServerWrapper;
import com.gemstone.gemfire.management.internal.security.ResourceConstants;
public class Server {
+
private static final String DEFAULT_HOST = "127.0.0.1"; //"localhost"
private static final int DEFAULT_PORT = 9999;
private final JMXServiceURL url;
@@ -68,11 +70,13 @@ public class Server {
if (jsonAuthFile != null) {
System.setProperty("spring.profiles.active", "pulse.authentication.gemfire");
- JSONAuthorization.setUpWithJsonFile(jsonAuthFile);
+
Map<String, Object> env = new HashMap<String, Object>();
// set up Shiro Security Manager
- Realm realm = new CustomAuthRealm(JSONAuthorization.class.getName());
+ Properties securityProperties = new Properties();
+ securityProperties.setProperty(SampleSecurityManager.SECURITY_JSON, jsonAuthFile);
+ Realm realm = new CustomAuthRealm(SampleSecurityManager.class.getName(), securityProperties);
SecurityManager securityManager = new DefaultSecurityManager(realm);
SecurityUtils.setSecurityManager(securityManager);
[02/10] incubator-geode git commit: GEODE-1647: add more unit test
Posted by kl...@apache.org.
GEODE-1647: add more unit test
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/50aedb1f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/50aedb1f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/50aedb1f
Branch: refs/heads/feature/GEODE-1673-PR-212
Commit: 50aedb1fc025f10219f2067967eafddab32d02c5
Parents: 16b7356
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Wed Jul 20 09:42:24 2016 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Wed Jul 20 16:04:31 2016 -0700
----------------------------------------------------------------------
.../security/GeodeSecurityUtilTest.java | 57 ++++++++++++++++++++
1 file changed, 57 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/50aedb1f/geode-core/src/test/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtilTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtilTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtilTest.java
index a26f06a..272b04f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtilTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtilTest.java
@@ -17,9 +17,13 @@
package com.gemstone.gemfire.internal.security;
+import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
import static org.assertj.core.api.Java6Assertions.*;
import static org.junit.Assert.*;
+import java.util.Properties;
+
+import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -28,6 +32,12 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
public class GeodeSecurityUtilTest {
+ Properties properties;
+ @Before
+ public void before(){
+ properties = new Properties();
+ GeodeSecurityUtil.initSecurity(properties);
+ }
@Test
public void testGetObjectFromConstructor(){
@@ -61,6 +71,53 @@ public class GeodeSecurityUtilTest {
.isInstanceOf(GemFireSecurityException.class);
}
+ @Test
+ public void testInitialSecurityFlags() {
+ // initial state of GeodeSecurityUtil
+ assertFalse(GeodeSecurityUtil.isClientSecurityRequired());
+ assertFalse(GeodeSecurityUtil.isIntegratedSecurity());
+ assertFalse(GeodeSecurityUtil.isPeerSecurityRequired());
+ }
+
+ @Test
+ public void testInitWithSecurityManager() {
+ properties.setProperty(SECURITY_MANAGER, "org.apache.geode.security.templates.SampleSecurityManager");
+ GeodeSecurityUtil.initSecurity(properties);
+ assertTrue(GeodeSecurityUtil.isClientSecurityRequired());
+ assertTrue(GeodeSecurityUtil.isIntegratedSecurity());
+ assertTrue(GeodeSecurityUtil.isPeerSecurityRequired());
+ }
+
+ @Test
+ public void testInitWithClientAuthenticator()
+ {
+ properties.setProperty(SECURITY_CLIENT_AUTHENTICATOR, "org.abc.test");
+ GeodeSecurityUtil.initSecurity(properties);
+ assertTrue(GeodeSecurityUtil.isClientSecurityRequired());
+ assertFalse(GeodeSecurityUtil.isIntegratedSecurity());
+ assertFalse(GeodeSecurityUtil.isPeerSecurityRequired());
+ }
+
+ @Test
+ public void testInitWithPeerAuthenticator()
+ {
+ properties.setProperty(SECURITY_PEER_AUTHENTICATOR, "org.abc.test");
+ GeodeSecurityUtil.initSecurity(properties);
+ assertFalse(GeodeSecurityUtil.isClientSecurityRequired());
+ assertFalse(GeodeSecurityUtil.isIntegratedSecurity());
+ assertTrue(GeodeSecurityUtil.isPeerSecurityRequired());
+ }
+
+ @Test
+ public void testInitWithShiroAuthenticator()
+ {
+ properties.setProperty(SECURITY_SHIRO_INIT, "shiro.ini");
+ GeodeSecurityUtil.initSecurity(properties);
+ assertTrue(GeodeSecurityUtil.isClientSecurityRequired());
+ assertTrue(GeodeSecurityUtil.isIntegratedSecurity());
+ assertTrue(GeodeSecurityUtil.isPeerSecurityRequired());
+ }
+
private static class Factories{
public static String getString(){
return new String();
[06/10] incubator-geode git commit: GEODE-1420: fix 100ms delay in
stopping tombstone sweeper
Posted by kl...@apache.org.
GEODE-1420: fix 100ms delay in stopping tombstone sweeper
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/54f305be
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/54f305be
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/54f305be
Branch: refs/heads/feature/GEODE-1673-PR-212
Commit: 54f305be774312bed7125fe6b0abcf19f6f2c11a
Parents: 3e6eb4c
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Wed Jul 20 16:39:00 2016 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Thu Jul 21 10:41:40 2016 -0700
----------------------------------------------------------------------
.../com/gemstone/gemfire/internal/cache/TombstoneService.java | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/54f305be/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TombstoneService.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TombstoneService.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TombstoneService.java
index 192e24d..2241b33 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TombstoneService.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TombstoneService.java
@@ -787,9 +787,9 @@ public class TombstoneService {
this.sweeperThread.start();
}
- synchronized void stop() {
- this.isStopped = true;
- if (this.sweeperThread != null) {
+ void stop() {
+ synchronized (this) {
+ this.isStopped = true;
notifyAll();
}
try {
@@ -797,7 +797,6 @@ public class TombstoneService {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
- getQueue().clear();
}
private void lockQueueHead() {
[10/10] incubator-geode git commit: GEODE-1673: fail start if
security.json cannot be found
Posted by kl...@apache.org.
GEODE-1673: fail start if security.json cannot be found
* collapse JSONAuthorization into SampleSecurityManager
* update SampleSecurityManager to support file, resource and string json
* cleanup security tests
* add SecurityTest category to security tests
This closes #212
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/87c2383a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/87c2383a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/87c2383a
Branch: refs/heads/feature/GEODE-1673-PR-212
Commit: 87c2383a6263c956ac2aeccba9402905da154c5d
Parents: 686db9c
Author: gmeilen <gr...@gmail.com>
Authored: Mon Jul 18 14:50:53 2016 -0700
Committer: Kirk Lund <kl...@pivotal.io>
Committed: Thu Jul 21 22:15:59 2016 -0700
----------------------------------------------------------------------
.../internal/InternalDistributedSystem.java | 2 +-
.../gms/mgr/GMSMembershipManager.java | 1 -
.../internal/security/GeodeSecurityUtil.java | 58 ++---
.../security/shiro/CustomAuthRealm.java | 17 +-
.../apache/geode/security/GeodePermission.java | 61 ++---
.../apache/geode/security/SecurityManager.java | 4 +-
.../security/templates/SamplePostProcessor.java | 6 +-
.../templates/SampleSecurityManager.java | 261 +++++++++++--------
.../internal/DistributionConfigJUnitTest.java | 7 +-
.../cli/commands/CliCommandTestBase.java | 26 +-
.../security/AccessControlMBeanJUnitTest.java | 14 +-
...CacheServerMBeanAuthenticationJUnitTest.java | 7 +-
.../CacheServerMBeanAuthorizationJUnitTest.java | 14 +-
.../CacheServerMBeanShiroJUnitTest.java | 12 +-
.../security/CliCommandsSecurityTest.java | 7 +-
.../security/DataCommandsSecurityTest.java | 17 +-
.../DiskStoreMXBeanSecurityJUnitTest.java | 14 +-
.../GatewayReceiverMBeanSecurityTest.java | 20 +-
.../GatewaySenderMBeanSecurityTest.java | 21 +-
.../security/GeodePermissionJUnitTest.java | 8 +-
.../GeodeSecurityUtilCustomRealmJUnitTest.java | 22 +-
.../GeodeSecurityUtilWithIniFileJUnitTest.java | 12 +-
.../security/GfshCommandsPostProcessorTest.java | 18 +-
.../security/GfshCommandsSecurityTest.java | 18 +-
.../JsonAuthorizationCacheStartRule.java | 13 +-
.../LockServiceMBeanAuthorizationJUnitTest.java | 20 +-
.../security/MBeanSecurityJUnitTest.java | 50 ++--
.../security/MBeanServerConnectionRule.java | 6 +-
.../ManagerMBeanAuthorizationJUnitTest.java | 17 +-
.../security/MemberMBeanSecurityJUnitTest.java | 14 +-
.../internal/security/MultiUserDUnitTest.java | 8 +-
.../internal/security/ShiroCacheStartRule.java | 10 +-
.../internal/security/TestCommand.java | 5 +-
...ractIntegratedClientAuthDistributedTest.java | 17 +-
...gratedClientGetEntryAuthDistributedTest.java | 1 -
...IntegratedClientSizeAuthDistributedTest.java | 1 -
...edSecurityCacheLifecycleDistributedTest.java | 10 +-
...edSecurityCacheLifecycleIntegrationTest.java | 1 -
...urityNoShowValue1PostProcessorDUnitTest.java | 2 -
...tegratedSecurityPeerAuthDistributedTest.java | 28 +-
...ntegratedSecurityPostProcessorDUnitTest.java | 2 -
.../gemfire/security/JSONAuthorization.java | 54 ----
.../security/NoShowValue1PostProcessor.java | 6 +-
.../gemfire/security/SecurityTestUtils.java | 2 +-
.../templates/SampleSecurityManagerTest.java | 123 +++++++++
.../geode/security/templates/security.json | 30 +++
.../gemfire/tools/pulse/tests/Server.java | 10 +-
47 files changed, 608 insertions(+), 469 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java
index 32f1bff..013a72d 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalDistributedSystem.java
@@ -2085,7 +2085,7 @@ public class InternalDistributedSystem
listener.handleEvent(event, resource);
} catch(CancelException e) {
//ignore
- } catch (ManagementException ex) {
+ } catch (GemFireSecurityException|ManagementException ex) {
if (event == ResourceEvent.CACHE_CREATE) {
throw ex;
} else {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/mgr/GMSMembershipManager.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
index e6ca8e1..4e839e7 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
@@ -2034,7 +2034,6 @@ public class GMSMembershipManager implements MembershipManager, Manager
*
* Concurrency: protected by {@link #latestViewLock} ReentrantReadWriteLock
*
- * @guarded.By latestViewLock
* @return true if the given member is a zombie
*/
public boolean isShunned(DistributedMember m) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
index ead82e5..19f3325 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.internal.security;
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
@@ -58,10 +57,17 @@ public class GeodeSecurityUtil {
private static Logger logger = LogService.getLogger();
+ private static PostProcessor postProcessor;
+ private static SecurityManager securityManager;
+ private static boolean isIntegratedSecurity;
+ private static boolean isClientAuthenticator;
+ private static boolean isPeerAuthenticator;
/**
- * It first looks the shiro subject in AccessControlContext since JMX will use multiple threads to process operations from the same client.
- * then it looks into Shiro's thead context.
+ * It first looks the shiro subject in AccessControlContext since JMX will
+ * use multiple threads to process operations from the same client, then it
+ * looks into Shiro's thead context.
+ *
* @return the shiro subject, null if security is not enabled
*/
public static Subject getSubject() {
@@ -97,8 +103,6 @@ public class GeodeSecurityUtil {
}
/**
- * @param username
- * @param password
* @return null if security is not enabled, otherwise return a shiro subject
*/
public static Subject login(String username, String password) {
@@ -153,7 +157,9 @@ public class GeodeSecurityUtil {
}
/**
- * this binds the passed-in subject to the executing thread, normally, you would do this:
+ * this binds the passed-in subject to the executing thread, normally, you
+ * would do this:
+ *
* ThreadState state = null;
* try{
* state = GeodeSecurityUtil.bindSubject(subject);
@@ -269,15 +275,8 @@ public class GeodeSecurityUtil {
}
}
- private static PostProcessor postProcessor;
- private static SecurityManager securityManager;
- private static boolean isIntegratedSecurity;
- private static boolean isClientAuthenticator;
- private static boolean isPeerAuthenticator;
-
/**
* initialize Shiro's Security Manager and Security Utilities
- * @param securityProps
*/
public static void initSecurity(Properties securityProps) {
if (securityProps == null) {
@@ -352,8 +351,10 @@ public class GeodeSecurityUtil {
}
/**
- * postProcess call already has this logic built in, you don't need to call this everytime you call postProcess.
- * But if your postProcess is pretty involved with preparations and you need to bypass it entirely, call this first.
+ * postProcess call already has this logic built in, you don't need to call
+ * this everytime you call postProcess. But if your postProcess is pretty
+ * involved with preparations and you need to bypass it entirely, call this
+ * first.
*/
public static boolean needPostProcess(){
return (isIntegratedSecurity && postProcessor != null);
@@ -372,13 +373,9 @@ public class GeodeSecurityUtil {
return postProcessor.processRegionValue((Principal)subject.getPrincipal(), regionName, key, result);
}
-
/**
- * this method would never return null, it either throws an exception or returns an object
- * @param className
- * @param expectedClazz
- * @param <T>
- * @return
+ * this method would never return null, it either throws an exception or
+ * returns an object
*/
public static <T> T getObjectOfTypeFromClassName(String className, Class<T> expectedClazz) {
Class actualClass = null;
@@ -403,11 +400,8 @@ public class GeodeSecurityUtil {
}
/**
- * this method would never return null, it either throws an exception or returns an object
- * @param factoryMethodName
- * @param expectedClazz
- * @param <T>
- * @return
+ * this method would never return null, it either throws an exception or
+ * returns an object
*/
public static <T> T getObjectOfTypeFromFactoryMethod(String factoryMethodName, Class<T> expectedClazz){
T actualObject = null;
@@ -426,12 +420,11 @@ public class GeodeSecurityUtil {
}
/**
- * this method would never return null, it either throws an exception or returns an object
- * @param classOrMethod
- * @param expectedClazz
- * @param <T>
- * @return an object of type expectedClazz. This method would never return null. It either returns an non-null
- * object or throws exception.
+ * this method would never return null, it either throws an exception or
+ * returns an object
+ *
+ * @return an object of type expectedClazz. This method would never return
+ * null. It either returns an non-null object or throws exception.
*/
public static <T> T getObjectOfType(String classOrMethod, Class<T> expectedClazz) {
T object = null;
@@ -448,7 +441,6 @@ public class GeodeSecurityUtil {
return securityManager;
}
-
public static boolean isClientSecurityRequired() {
return isClientAuthenticator || isIntegratedSecurity;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/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 db07fe0..c890dc9 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
@@ -34,18 +34,31 @@ import org.apache.shiro.subject.PrincipalCollection;
import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
import com.gemstone.gemfire.management.internal.security.ResourceConstants;
-public class CustomAuthRealm extends AuthorizingRealm{
+public class CustomAuthRealm extends AuthorizingRealm {
private static final String REALM_NAME = "CUSTOMAUTHREALM";
private SecurityManager securityManager = null;
+ /**
+ * The caller must invoke {@link org.apache.geode.security.SecurityManager#init(Properties)}
+ * prior to instantiating CustomAuthRealm.
+ *
+ * @param securityManager instance of SecurityManager which has already been initialized
+ */
public CustomAuthRealm(SecurityManager securityManager) {
this.securityManager = securityManager;
}
- public CustomAuthRealm (String authenticatorFactory) {
+ /**
+ * SecurityManager will be constructed and initialized with the provided security properties.
+ *
+ * @param authenticatorFactory name of the SecurityManager implementation to construct
+ * @param securityProperties the security properties to initialize SecurityManager with
+ */
+ public CustomAuthRealm(String authenticatorFactory, Properties securityProperties) {
this.securityManager = GeodeSecurityUtil.getObjectOfTypeFromClassName(authenticatorFactory, SecurityManager.class);
+ this.securityManager.init(securityProperties);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/main/java/org/apache/geode/security/GeodePermission.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/security/GeodePermission.java b/geode-core/src/main/java/org/apache/geode/security/GeodePermission.java
index 0a777a8..21cec6b 100644
--- a/geode-core/src/main/java/org/apache/geode/security/GeodePermission.java
+++ b/geode-core/src/main/java/org/apache/geode/security/GeodePermission.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.geode.security;
import org.apache.shiro.authz.permission.WildcardPermission;
@@ -42,38 +41,6 @@ public class GeodePermission extends WildcardPermission {
READ
}
- /**
- * Returns the resource, could be either DATA or CLUSTER
- * @return
- */
- public Resource getResource() {
- return resource;
- }
-
- /**
- * Returns the operation, could be either MANAGE, WRITE or READ
- * @return
- */
- public Operation getOperation() {
- return operation;
- }
-
- /**
- * returns the regionName, could be "*", meaning all regions
- * @return
- */
- public String getRegionName() {
- return regionName;
- }
-
- /**
- * returns the key, could be "*" meaning all keys.
- * @return
- */
- public String getKey() {
- return key;
- }
-
// these default values are used when creating a lock around an operation
private Resource resource = Resource.NULL;
private Operation operation = Operation.NULL;
@@ -116,6 +83,34 @@ public class GeodePermission extends WildcardPermission {
setParts(this.resource+":"+this.operation+":"+this.regionName+":"+this.key, true);
}
+ /**
+ * Returns the resource, could be either DATA or CLUSTER
+ */
+ public Resource getResource() {
+ return resource;
+ }
+
+ /**
+ * Returns the operation, could be either MANAGE, WRITE or READ
+ */
+ public Operation getOperation() {
+ return operation;
+ }
+
+ /**
+ * returns the regionName, could be "*", meaning all regions
+ */
+ public String getRegionName() {
+ return regionName;
+ }
+
+ /**
+ * returns the key, could be "*" meaning all keys.
+ */
+ public String getKey() {
+ return key;
+ }
+
@Override
public String toString() {
if (ALL_REGIONS.equals(regionName)) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/main/java/org/apache/geode/security/SecurityManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/security/SecurityManager.java b/geode-core/src/main/java/org/apache/geode/security/SecurityManager.java
index 269ed43..51a6879 100644
--- a/geode-core/src/main/java/org/apache/geode/security/SecurityManager.java
+++ b/geode-core/src/main/java/org/apache/geode/security/SecurityManager.java
@@ -43,13 +43,13 @@ public interface SecurityManager {
/**
* Verify the credentials provided in the properties
- * @param props
+ * @param credentials
* it contains the security-username and security-password as keys of the properties
* @return
* the authenticated Principal object
* @throws AuthenticationFailedException
*/
- Principal authenticate(Properties props) throws AuthenticationFailedException;
+ Principal authenticate(Properties credentials) throws AuthenticationFailedException;
/**
* Authorize the GeodePermission for a given Principal
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/main/java/org/apache/geode/security/templates/SamplePostProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/security/templates/SamplePostProcessor.java b/geode-core/src/main/java/org/apache/geode/security/templates/SamplePostProcessor.java
index 8f61db7..14cd46c 100644
--- a/geode-core/src/main/java/org/apache/geode/security/templates/SamplePostProcessor.java
+++ b/geode-core/src/main/java/org/apache/geode/security/templates/SamplePostProcessor.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.geode.security.templates;
import java.security.Principal;
@@ -29,11 +28,11 @@ public class SamplePostProcessor implements PostProcessor{
@Override
public void init(final Properties securityProps) {
-
}
/**
- * this simply modifies the value with all the parameter values
+ * This simply modifies the value with all the parameter values
+ *
* @param principal
* The principal that's accessing the value
* @param regionName
@@ -42,7 +41,6 @@ public class SamplePostProcessor implements PostProcessor{
* the key of the value that's been accessed. This could be null.
* @param value
* the value, this could be null.
- * @return
*/
@Override
public Object processRegionValue(Principal principal,
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java b/geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java
index dd49f11..97ebe4f 100644
--- a/geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java
+++ b/geode-core/src/main/java/org/apache/geode/security/templates/SampleSecurityManager.java
@@ -16,6 +16,8 @@
*/
package org.apache.geode.security.templates;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
@@ -45,19 +47,24 @@ import com.gemstone.gemfire.security.AuthenticationFailedException;
import com.gemstone.gemfire.security.NotAuthorizedException;
/**
- * This class provides a sample implementation for authentication and authorization via the {@link SecurityManager}
+ * This class provides a sample implementation of {@link SecurityManager} for
+ * authentication and authorization initialized from data provided as JSON.
*
- * In order to use it, a Geode member must be started with the following properties:
- * <p/>
- * <code>
- * security-manager = com.gemstone.gemfire.security.examples.SampleSecurityManager
- * </code>
- * <p/>
- * The class is initialized with a JSON file called {@code security.json}. This file must exist on the classpath,
+ * <p>A Geode member must be configured with the following:
+ *
+ * <p>{@code security-manager = com.gemstone.gemfire.security.examples.SampleSecurityManager}
+ *
+ * <p>The class can be initialized with from either a JSON string or a JSON
+ * file
+ *
+ * <p>TODO: example of configuring from in-memory JSON string specified in securityProperties
+ *
+ * <p>TODO: example of configuring from a JSON file specified in securityProperties<br/>
+ * ...called {@code security.json}. This file must exist on the classpath,
* so members should be started with an appropriate {@code --classpath} option.
- * <p/>
- * The format of the file is as follows:
- * <pre>
+ *
+ * <p>The format of the JSON for configuration is as follows:
+ * <pre><code>
* {
* "roles": [
* {
@@ -74,11 +81,11 @@ import com.gemstone.gemfire.security.NotAuthorizedException;
* ],
* "regions": ["RegionA", "RegionB"]
* }
- * ]
+ * ],
* "users": [
* {
* "name": "admin",
- * "password": "secret".
+ * "password": "secret",
* "roles": ["admin"]
* },
* {
@@ -88,105 +95,177 @@ import com.gemstone.gemfire.security.NotAuthorizedException;
* }
* ]
* }
- * </pre>
+ * </code></pre>
*/
public class SampleSecurityManager implements SecurityManager {
- public SampleSecurityManager() {
- try {
- setUpWithJsonFile("security.json");
+ public static final String SECURITY_JSON = "security-json";
+
+ protected static final String DEFAULT_JSON_FILE_NAME = "security.json";
+
+ private Map<String, User> userNameToUser;
+
+ @Override
+ public boolean authorize(final Principal principal, final GeodePermission context) {
+ if (principal == null) return false;
+
+ User user = this.userNameToUser.get(principal.getName());
+ if (user == null) return false; // this user is not authorized to do anything
+
+ // check if the user has this permission defined in the context
+ for (Role role : this.userNameToUser.get(user.name).roles) {
+ for (Permission permitted : role.permissions) {
+ if (permitted.implies(context)) {
+ return true;
+ }
+ }
}
- catch (IOException e) {
- e.printStackTrace();
+
+ return false;
+ }
+
+ @Override
+ public void init(final Properties securityProperties) throws NotAuthorizedException {
+ String jsonPropertyValue = securityProperties.getProperty(SECURITY_JSON);
+ if (jsonPropertyValue == null) {
+ throw new AuthenticationFailedException("SampleSecurityManager: property [" + SECURITY_JSON + "] must be set.");
+ }
+
+ // 1st try to load value as a json resource
+ boolean initialized = initializeFromJsonResource(jsonPropertyValue);
+
+ // 2nd try to load value as a json file
+ if (!initialized) {
+ initialized = initializeFromJsonFile(new File(jsonPropertyValue));
+ }
+
+ // 3rd try to use value as a json string
+ if (!initialized) {
+ initialized = initializeFromJson(jsonPropertyValue);
+ }
+
+ if (!initialized) {
+ throw new AuthenticationFailedException("SampleSecurityManager: unable to read json from \"" + jsonPropertyValue + "\" as specified by [" + SECURITY_JSON + "].");
}
}
- public static class Role {
- List<GeodePermission> permissions = new ArrayList<>();
- String name;
- String serverGroup;
+ @Override
+ public Principal authenticate(final Properties credentials) throws AuthenticationFailedException {
+ String user = credentials.getProperty(ResourceConstants.USER_NAME);
+ String password = credentials.getProperty(ResourceConstants.PASSWORD);
+
+ User userObj = this.userNameToUser.get(user);
+ if (userObj == null) {
+ throw new AuthenticationFailedException("SampleSecurityManager: wrong username/password");
+ }
+
+ if (user != null && !userObj.password.equals(password) && !"".equals(user)) {
+ throw new AuthenticationFailedException("SampleSecurityManager: wrong username/password");
+ }
+
+ return new JMXPrincipal(user);
}
- public static class User {
- String name;
- Set<Role> roles = new HashSet<>();
- String pwd;
+ boolean initializeFromJson(final String json) {//throws IOException {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode jsonNode = mapper.readTree(json);
+ this.userNameToUser = new HashMap<>();
+ Map<String, Role> roleMap = readRoles(jsonNode);
+ readUsers(this.userNameToUser, jsonNode, roleMap);
+ return true;
+ } catch (IOException ex) {
+ return false;
+ }
}
- private static Map<String, User> acl = null;
+ boolean initializeFromJsonFile(final File jsonFile) {//throws IOException {
+ try {
+ InputStream input = new FileInputStream(jsonFile);
+ if (input != null) {
+ initializeFromJson(readJsonFromInputStream(input));
+ return true;
+ }
+ } catch (IOException ex) {
+ }
+ return false;
+ }
+ boolean initializeFromJsonResource(final String jsonResource) {//throws IOException {
+ try {
+ InputStream input = ClassLoader.getSystemResourceAsStream(jsonResource);
+ if (input != null) {
+ initializeFromJson(readJsonFromInputStream(input));
+ return true;
+ }
+ } catch (IOException ex) {
+ }
+ return false;
+ }
- public static void setUpWithJsonFile(String jsonFileName) throws IOException {
- InputStream input = ClassLoader.getSystemResourceAsStream(jsonFileName);
- if (input == null)
- return;
+ User getUser(final String user) {
+ return this.userNameToUser.get(user);
+ }
+ private String readJsonFromInputStream(final InputStream input) throws IOException {
StringWriter writer = new StringWriter();
IOUtils.copy(input, writer, "UTF-8");
- String json = writer.toString();
- readSecurityDescriptor(json);
+ return writer.toString();
}
- protected static void readSecurityDescriptor(String json) throws IOException {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode jsonNode = mapper.readTree(json);
- acl = new HashMap<>();
- Map<String, Role> roleMap = readRoles(jsonNode);
- readUsers(acl, jsonNode, roleMap);
- }
-
- private static void readUsers(Map<String, User> acl, JsonNode node, Map<String, Role> roleMap) {
- for (JsonNode u : node.get("users")) {
+ private void readUsers(final Map<String, User> rolesToUsers, final JsonNode node, final Map<String, Role> roleMap) {
+ for (JsonNode usersNode : node.get("users")) {
User user = new User();
- user.name = u.get("name").asText();
+ user.name = usersNode.get("name").asText();
- if (u.has("password")) {
- user.pwd = u.get("password").asText();
+ if (usersNode.has("password")) {
+ user.password = usersNode.get("password").asText();
} else {
- user.pwd = user.name;
+ user.password = user.name;
}
- for (JsonNode r : u.get("roles")) {
- user.roles.add(roleMap.get(r.asText()));
+ for (JsonNode rolesNode : usersNode.get("roles")) {
+ user.roles.add(roleMap.get(rolesNode.asText()));
}
- acl.put(user.name, user);
+ rolesToUsers.put(user.name, user);
}
}
- private static Map<String, Role> readRoles(JsonNode jsonNode) {
+ private Map<String, Role> readRoles(final JsonNode jsonNode) {
if (jsonNode.get("roles") == null) {
return Collections.EMPTY_MAP;
}
-
Map<String, Role> roleMap = new HashMap<>();
- for (JsonNode r : jsonNode.get("roles")) {
+ for (JsonNode rolesNode : jsonNode.get("roles")) {
Role role = new Role();
- role.name = r.get("name").asText();
+ role.name = rolesNode.get("name").asText();
String regionNames = null;
String keys = null;
- JsonNode regions = r.get("regions");
- if (regions != null) {
- if (regions.isArray()) {
- regionNames = StreamSupport.stream(regions.spliterator(), false)
- .map(JsonNode::asText)
- .collect(Collectors.joining(","));
+ JsonNode regionsNode = rolesNode.get("regions");
+ if (regionsNode != null) {
+ if (regionsNode.isArray()) {
+ regionNames = StreamSupport.stream(regionsNode.spliterator(), false)
+ .map(JsonNode::asText)
+ .collect(Collectors.joining(","));
} else {
- regionNames = regions.asText();
+ regionNames = regionsNode.asText();
}
}
- for (JsonNode op : r.get("operationsAllowed")) {
- String[] parts = op.asText().split(":");
+ for (JsonNode operationsAllowedNode : rolesNode.get("operationsAllowed")) {
+ String[] parts = operationsAllowedNode.asText().split(":");
String resourcePart = (parts.length > 0) ? parts[0] : null;
String operationPart = (parts.length > 1) ? parts[1] : null;
- if(parts.length>2){
+
+ if (parts.length>2){
regionNames = parts[2];
}
- if(parts.length>3){
+ if (parts.length>3){
keys = parts[3];
}
+
String regionPart = (regionNames != null) ? regionNames : "*";
String keyPart = (keys !=null) ? keys : "*";
@@ -195,54 +274,24 @@ public class SampleSecurityManager implements SecurityManager {
roleMap.put(role.name, role);
- if (r.has("serverGroup")) {
- role.serverGroup = r.get("serverGroup").asText();
+ if (rolesNode.has("serverGroup")) {
+ role.serverGroup = rolesNode.get("serverGroup").asText();
}
}
return roleMap;
}
- public static Map<String, User> getAcl() {
- return acl;
- }
- @Override
- public boolean authorize(Principal principal, GeodePermission context) {
- if (principal == null) return false;
-
- User user = acl.get(principal.getName());
- if (user == null) return false; // this user is not authorized to do anything
-
- // check if the user has this permission defined in the context
- for (Role role : acl.get(user.name).roles) {
- for (Permission permitted : role.permissions) {
- if (permitted.implies(context)) {
- return true;
- }
- }
- }
-
- return false;
+ static class Role {
+ List<GeodePermission> permissions = new ArrayList<>();
+ String name;
+ String serverGroup;
}
- @Override
- public void init(Properties props) throws NotAuthorizedException {
+ static class User {
+ String name;
+ Set<Role> roles = new HashSet<>();
+ String password;
}
- @Override
- public Principal authenticate(Properties props) throws AuthenticationFailedException {
- String user = props.getProperty(ResourceConstants.USER_NAME);
- String pwd = props.getProperty(ResourceConstants.PASSWORD);
-
- User userObj = acl.get(user);
- if (userObj == null) {
- throw new AuthenticationFailedException("Wrong username/password");
- }
-
- if (user != null && !userObj.pwd.equals(pwd) && !"".equals(user)) {
- throw new AuthenticationFailedException("Wrong username/password");
- }
-
- return new JMXPrincipal(user);
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
index c4b3a4d..36783ed 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
@@ -31,6 +31,7 @@ import java.util.Map;
import java.util.Properties;
import org.apache.geode.security.templates.SamplePostProcessor;
+import org.apache.geode.security.templates.SampleSecurityManager;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -38,7 +39,6 @@ import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.InternalGemFireException;
import com.gemstone.gemfire.UnmodifiableException;
import com.gemstone.gemfire.internal.ConfigSource;
-import com.gemstone.gemfire.security.JSONAuthorization;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
@@ -326,11 +326,10 @@ public class DistributionConfigJUnitTest {
assertTrue(config.isAttributeModifiable(JMX_MANAGER_HTTP_PORT));
}
-
@Test
public void testSecurityProps(){
Properties props = new Properties();
- props.put(SECURITY_MANAGER, JSONAuthorization.class.getName());
+ props.put(SECURITY_MANAGER, SampleSecurityManager.class.getName());
props.put(SECURITY_POST_PROCESSOR, SamplePostProcessor.class.getName());
props.put(SECURITY_LOG_LEVEL, "config");
// add another non-security property to verify it won't get put in the security properties
@@ -343,7 +342,7 @@ public class DistributionConfigJUnitTest {
@Test
public void testSecurityPropsWithNoSetter(){
Properties props = new Properties();
- props.put(SECURITY_MANAGER, JSONAuthorization.class.getName());
+ props.put(SECURITY_MANAGER, SampleSecurityManager.class.getName());
props.put(SECURITY_POST_PROCESSOR, SamplePostProcessor.class.getName());
props.put(SECURITY_LOG_LEVEL, "config");
// add another non-security property to verify it won't get put in the security properties
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
index 163f9b5..a6627d5 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
@@ -29,6 +29,7 @@ import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.geode.security.templates.SampleSecurityManager;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
@@ -42,31 +43,33 @@ import com.gemstone.gemfire.management.internal.cli.parser.CommandTarget;
import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
import com.gemstone.gemfire.management.internal.cli.shell.Gfsh;
import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
-import com.gemstone.gemfire.security.JSONAuthorization;
import com.gemstone.gemfire.test.dunit.Host;
import com.gemstone.gemfire.test.dunit.IgnoredException;
import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.dunit.rules.DistributedRestoreSystemProperties;
/**
* Base class for all the CLI/gfsh command dunit tests.
*/
public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
- private static final long serialVersionUID = 1L;
+ public static final String USE_HTTP_SYSTEM_PROPERTY = "useHTTP";
+
+ private boolean useHttpOnConnect = Boolean.getBoolean(USE_HTTP_SYSTEM_PROPERTY);
private ManagementService managementService;
private transient HeadlessGfsh shell;
- public static final String USE_HTTP_SYSTEM_PROPERTY = "useHTTP";
- private boolean useHttpOnConnect = Boolean.getBoolean(USE_HTTP_SYSTEM_PROPERTY);
-
protected transient int httpPort;
protected transient int jmxPort;
protected transient String jmxHost;
protected transient String gfshDir;
@Rule
+ public transient DistributedRestoreSystemProperties restoreSystemProperties = new DistributedRestoreSystemProperties();
+
+ @Rule
public transient TemporaryFolder temporaryFolder = new TemporaryFolder();
@Override
@@ -97,7 +100,6 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
* cache). When adding regions, functions, keys, whatever to your cache for tests, you'll need to use
* Host.getHost(0).getVM(0).invoke(new SerializableRunnable() { public void run() { ... } } in order to have this
* setup run in the same VM as the manager.
- * <p>
*
* @param props the Properties used when creating the cache for this default setup.
* @return the default testable GemFire shell.
@@ -117,10 +119,6 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
}
/**
- *
- * @param vm
- * @param props
- * @param jsonFile
* @return an object array, result[0] is jmxHost(String), result[1] is jmxPort, result[2] is httpPort
*/
protected Object[] setUpJMXManagerOnVM(int vm, final Properties props, String jsonFile) {
@@ -139,6 +137,10 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
localProps.setProperty(NAME, "Manager");
}
+ if (jsonFile!=null) {
+ localProps.setProperty(SampleSecurityManager.SECURITY_JSON, jsonFile);
+ }
+
final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
jmxPort = ports[0];
@@ -153,10 +155,6 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
getSystem(localProps);
verifyManagementServiceStarted(getCache());
- if(jsonFile!=null){
- JSONAuthorization.setUpWithJsonFile(jsonFile);
- }
-
IgnoredException.addIgnoredException("org.eclipse.jetty.io.EofException");
IgnoredException.addIgnoredException("java.nio.channels.ClosedChannelException");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/AccessControlMBeanJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/AccessControlMBeanJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/AccessControlMBeanJUnitTest.java
index 6c626fc..6124e31 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/AccessControlMBeanJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/AccessControlMBeanJUnitTest.java
@@ -16,27 +16,28 @@
*/
package com.gemstone.gemfire.management.internal.security;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
import static org.assertj.core.api.Assertions.*;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-@Category(IntegrationTest.class)
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
+@Category({ IntegrationTest.class, SecurityTest.class })
public class AccessControlMBeanJUnitTest {
+
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
private AccessControlMXBean bean;
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, CACHE_SERVER_JSON);
+ jmxManagerPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
@@ -48,7 +49,6 @@ public class AccessControlMBeanJUnitTest {
/**
* Test that any authenticated user can access this method
- * @throws Exception
*/
@Test
@JMXConnectionConfiguration(user = "stranger", password = "1234567")
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
index 6857e18..53fce5f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
@@ -16,8 +16,6 @@
*/
package com.gemstone.gemfire.management.internal.security;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
-
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
@@ -30,13 +28,14 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
@Category(IntegrationTest.class)
public class CacheServerMBeanAuthenticationJUnitTest {
+
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
private CacheServerMXBean bean;
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, CACHE_SERVER_JSON);
+ jmxManagerPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
@@ -46,7 +45,7 @@ public class CacheServerMBeanAuthenticationJUnitTest {
bean = connectionRule.getProxyMBean(CacheServerMXBean.class, "GemFire:service=CacheServer,*");
}
- @Test()
+ @Test
@JMXConnectionConfiguration(user = "data-admin", password = "1234567")
public void testAllAccess() throws Exception {
bean.removeIndex("foo");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
index 39094fb..aba0b58 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
@@ -16,27 +16,29 @@
*/
package com.gemstone.gemfire.management.internal.security;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
import static org.assertj.core.api.Assertions.*;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.management.CacheServerMXBean;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-@Category(IntegrationTest.class)
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.management.CacheServerMXBean;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
+@Category({ IntegrationTest.class, SecurityTest.class })
public class CacheServerMBeanAuthorizationJUnitTest {
+
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
private CacheServerMXBean bean;
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, CACHE_SERVER_JSON);
+ jmxManagerPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanShiroJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanShiroJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanShiroJUnitTest.java
index 85a55a7..d53dc0e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanShiroJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CacheServerMBeanShiroJUnitTest.java
@@ -18,17 +18,20 @@ package com.gemstone.gemfire.management.internal.security;
import static org.assertj.core.api.Assertions.*;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.management.CacheServerMXBean;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-@Category(IntegrationTest.class)
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.management.CacheServerMXBean;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
+@Category({ IntegrationTest.class, SecurityTest.class })
public class CacheServerMBeanShiroJUnitTest {
+
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
private CacheServerMXBean bean;
@@ -57,7 +60,6 @@ public class CacheServerMBeanShiroJUnitTest {
bean.showClientQueueDetails("foo");
}
-
@Test
@JMXConnectionConfiguration(user = "guest", password = "guest")
public void testNoAccess() throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CliCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CliCommandsSecurityTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CliCommandsSecurityTest.java
index af26147..56078e1 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CliCommandsSecurityTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/CliCommandsSecurityTest.java
@@ -16,8 +16,6 @@
*/
package com.gemstone.gemfire.management.internal.security;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
-import static org.assertj.core.api.AssertionsForClassTypes.fail;
import static org.junit.Assert.*;
import java.util.List;
@@ -35,8 +33,9 @@ import com.gemstone.gemfire.security.NotAuthorizedException;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
-@Category({IntegrationTest.class, SecurityTest.class})
+@Category({ IntegrationTest.class, SecurityTest.class })
public class CliCommandsSecurityTest {
+
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
private MemberMXBean bean;
@@ -45,7 +44,7 @@ public class CliCommandsSecurityTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, CACHE_SERVER_JSON);
+ jmxManagerPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DataCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DataCommandsSecurityTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DataCommandsSecurityTest.java
index 73da024..eea9f06 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DataCommandsSecurityTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DataCommandsSecurityTest.java
@@ -17,28 +17,29 @@
package com.gemstone.gemfire.management.internal.security;
import static org.assertj.core.api.Assertions.*;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.management.MemberMXBean;
-import com.gemstone.gemfire.security.GemFireSecurityException;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import com.gemstone.gemfire.test.junit.categories.SecurityTest;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-@Category({IntegrationTest.class, SecurityTest.class})
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.management.MemberMXBean;
+import com.gemstone.gemfire.security.GemFireSecurityException;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
+@Category({ IntegrationTest.class, SecurityTest.class })
public class DataCommandsSecurityTest {
+
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
private MemberMXBean bean;
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, CACHE_SERVER_JSON);
+ jmxManagerPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
index 2d8099d..185c984 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
@@ -17,11 +17,7 @@
package com.gemstone.gemfire.management.internal.security;
import static org.assertj.core.api.Assertions.*;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.management.DiskStoreMXBean;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
@@ -29,15 +25,21 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-@Category(IntegrationTest.class)
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.management.DiskStoreMXBean;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
+@Category({ IntegrationTest.class, SecurityTest.class })
public class DiskStoreMXBeanSecurityJUnitTest {
+
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
private DiskStoreMXBean bean;
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, CACHE_SERVER_JSON);
+ jmxManagerPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewayReceiverMBeanSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewayReceiverMBeanSecurityTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewayReceiverMBeanSecurityTest.java
index 8bc55f0..b339094 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewayReceiverMBeanSecurityTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewayReceiverMBeanSecurityTest.java
@@ -18,15 +18,9 @@ package com.gemstone.gemfire.management.internal.security;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
import javax.management.ObjectName;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.management.GatewayReceiverMXBean;
-import com.gemstone.gemfire.management.ManagementService;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -35,18 +29,26 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-@Category(IntegrationTest.class)
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.management.GatewayReceiverMXBean;
+import com.gemstone.gemfire.management.ManagementService;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
+@Category({ IntegrationTest.class, SecurityTest.class })
public class GatewayReceiverMBeanSecurityTest {
+
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
- private GatewayReceiverMXBean bean;
private static GatewayReceiverMXBean mock = mock(GatewayReceiverMXBean.class);
private static ObjectName mockBeanName = null;
private static ManagementService service = null;
+ private GatewayReceiverMXBean bean;
+
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, CACHE_SERVER_JSON);
+ jmxManagerPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewaySenderMBeanSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewaySenderMBeanSecurityTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewaySenderMBeanSecurityTest.java
index fe4f624..e65adfb 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewaySenderMBeanSecurityTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GatewaySenderMBeanSecurityTest.java
@@ -18,15 +18,9 @@ package com.gemstone.gemfire.management.internal.security;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
import javax.management.ObjectName;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.management.GatewaySenderMXBean;
-import com.gemstone.gemfire.management.ManagementService;
-import com.gemstone.gemfire.management.internal.beans.GatewaySenderMBean;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -35,18 +29,27 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-@Category(IntegrationTest.class)
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.management.GatewaySenderMXBean;
+import com.gemstone.gemfire.management.ManagementService;
+import com.gemstone.gemfire.management.internal.beans.GatewaySenderMBean;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
+@Category({ IntegrationTest.class, SecurityTest.class })
public class GatewaySenderMBeanSecurityTest {
+
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
- private GatewaySenderMXBean bean;
private static GatewaySenderMBean mock = mock(GatewaySenderMBean.class);
private static ObjectName mockBeanName = null;
private static ManagementService service = null;
+ private GatewaySenderMXBean bean;
+
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, CACHE_SERVER_JSON);
+ jmxManagerPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodePermissionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodePermissionJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodePermissionJUnitTest.java
index a955dae..104ea5e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodePermissionJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodePermissionJUnitTest.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.management.internal.security;
import static org.junit.Assert.*;
@@ -22,13 +21,14 @@ import static org.junit.Assert.*;
import org.apache.geode.security.GeodePermission;
import org.apache.geode.security.GeodePermission.Operation;
import org.apache.geode.security.GeodePermission.Resource;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
import org.apache.shiro.authz.permission.WildcardPermission;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-@Category(UnitTest.class)
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category({ UnitTest.class, SecurityTest.class })
public class GeodePermissionJUnitTest {
private GeodePermission context;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodeSecurityUtilCustomRealmJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodeSecurityUtilCustomRealmJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodeSecurityUtilCustomRealmJUnitTest.java
index dd9961d..78168bf 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodeSecurityUtilCustomRealmJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodeSecurityUtilCustomRealmJUnitTest.java
@@ -14,30 +14,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.management.internal.security;
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
+import org.apache.geode.security.templates.SampleSecurityManager;
import org.junit.BeforeClass;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
-import com.gemstone.gemfire.security.JSONAuthorization;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
/**
- * this test and ShiroUtilWithIniFileJunitTest uses the same test body, but initialize the SecurityUtils differently.
- * If you change shiro-ini.json, remmber to change the shiro.ini to match the changes as well.
+ * Integration tests for {@link GeodeSecurityUtil} using shiro-ini.json.
+ *
+ * @see GeodeSecurityUtilWithIniFileJUnitTest
*/
-
-@Category(UnitTest.class)
+@Category({ IntegrationTest.class, SecurityTest.class })
public class GeodeSecurityUtilCustomRealmJUnitTest extends GeodeSecurityUtilWithIniFileJUnitTest {
+
@BeforeClass
- public static void beforeClass() throws Exception{
- props.put(SECURITY_MANAGER, JSONAuthorization.class.getName());
- JSONAuthorization.setUpWithJsonFile(SHIRO_INI_JSON);
+ public static void beforeClass() throws Exception {
+ props.put(SampleSecurityManager.SECURITY_JSON, "com/gemstone/gemfire/management/internal/security/shiro-ini.json");
+ props.put(SECURITY_MANAGER, SampleSecurityManager.class.getName());
GeodeSecurityUtil.initSecurity(props);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodeSecurityUtilWithIniFileJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodeSecurityUtilWithIniFileJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodeSecurityUtilWithIniFileJUnitTest.java
index 6496076..ec0d393 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodeSecurityUtilWithIniFileJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GeodeSecurityUtilWithIniFileJUnitTest.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.management.internal.security;
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
@@ -22,23 +21,24 @@ import static org.assertj.core.api.Assertions.*;
import java.util.Properties;
+import org.apache.geode.security.GeodePermission;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
import com.gemstone.gemfire.security.GemFireSecurityException;
-import org.apache.geode.security.GeodePermission;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
- * this test and ShiroUtilCustomRealmJUunitTest uses the same test body, but initialize the SecurityUtils differently.
- * If you change shiro.ini, remmber to change the shiro-ini.json to match the changes as well.
+ * Integration tests for {@link GeodeSecurityUtil} using shiro.ini
*/
-@Category({UnitTest.class, SecurityTest.class})
+@Category({ IntegrationTest.class, SecurityTest.class })
public class GeodeSecurityUtilWithIniFileJUnitTest {
+
protected static Properties props = new Properties();
+
@BeforeClass
public static void beforeClass() throws Exception{
props.setProperty(SECURITY_SHIRO_INIT, "shiro.ini");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsPostProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsPostProcessorTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsPostProcessorTest.java
index 8b96e8b..44db600 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsPostProcessorTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsPostProcessorTest.java
@@ -14,12 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.management.internal.security;
-import static com.gemstone.gemfire.internal.Assert.assertTrue;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
+import static com.gemstone.gemfire.internal.Assert.*;
+import org.apache.geode.security.templates.SamplePostProcessor;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
@@ -28,25 +27,22 @@ import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.internal.AvailablePortHelper;
import com.gemstone.gemfire.management.internal.cli.HeadlessGfsh;
-import org.apache.geode.security.templates.SamplePostProcessor;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
-@Category(IntegrationTest.class)
+@Category({ IntegrationTest.class, SecurityTest.class })
public class GfshCommandsPostProcessorTest {
+
protected static int jmxPort = AvailablePortHelper.getRandomAvailableTCPPort();
private HeadlessGfsh gfsh = null;
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxPort, CACHE_SERVER_JSON, SamplePostProcessor.class);
+ jmxPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json", SamplePostProcessor.class);
@Rule
- public GfshShellConnectionRule gfshConnection;
-
- public GfshCommandsPostProcessorTest(){
- gfshConnection = new GfshShellConnectionRule(jmxPort);
- }
+ public GfshShellConnectionRule gfshConnection = new GfshShellConnectionRule(jmxPort);
@Before
public void before(){
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsSecurityTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsSecurityTest.java
index 603088e..8d6c54d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsSecurityTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/GfshCommandsSecurityTest.java
@@ -14,11 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.management.internal.security;
import static org.junit.Assert.*;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
import java.util.List;
@@ -37,9 +35,11 @@ import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
import com.gemstone.gemfire.management.internal.cli.result.ErrorResultData;
import com.gemstone.gemfire.management.internal.cli.result.ResultBuilder;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
-@Category(IntegrationTest.class)
+@Category({ IntegrationTest.class, SecurityTest.class })
public class GfshCommandsSecurityTest {
+
protected static int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
protected static int jmxPort = ports[0];
protected static int httpPort = ports[1];
@@ -48,15 +48,10 @@ public class GfshCommandsSecurityTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxPort, httpPort, CACHE_SERVER_JSON);
+ jmxPort, httpPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
@Rule
- public GfshShellConnectionRule gfshConnection;
-
- public GfshCommandsSecurityTest(){
- gfshConnection = new GfshShellConnectionRule(jmxPort, httpPort, false);
- }
-
+ public GfshShellConnectionRule gfshConnection = new GfshShellConnectionRule(jmxPort, httpPort, false);
@Before
public void before(){
@@ -129,7 +124,6 @@ public class GfshCommandsSecurityTest {
runCommandsWithAndWithout("DATA:MANAGE:RegionA");
}
-
private void runCommandsWithAndWithout(String permission) throws Exception{
List<TestCommand> allPermitted = TestCommand.getPermittedCommands(new WildcardPermission(permission, true));
for(TestCommand permitted:allPermitted) {
@@ -184,6 +178,4 @@ public class GfshCommandsSecurityTest {
gfsh.executeCommand("query --query=\"select * from /region1\"");
}
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JsonAuthorizationCacheStartRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JsonAuthorizationCacheStartRule.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JsonAuthorizationCacheStartRule.java
index 1d4fb40..81cf92f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JsonAuthorizationCacheStartRule.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/JsonAuthorizationCacheStartRule.java
@@ -20,13 +20,14 @@ import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
import java.util.Properties;
+import org.apache.geode.security.templates.SampleSecurityManager;
import org.junit.rules.ExternalResource;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.security.JSONAuthorization;
public class JsonAuthorizationCacheStartRule extends ExternalResource {
+
private Cache cache;
private int jmxManagerPort = 0;
private int httpPort = 0;
@@ -39,7 +40,6 @@ public class JsonAuthorizationCacheStartRule extends ExternalResource {
this.postProcessor = postProcessor;
}
-
public JsonAuthorizationCacheStartRule(int jmxManagerPort, String jsonFile) {
this.jmxManagerPort = jmxManagerPort;
this.jsonFile = jsonFile;
@@ -53,6 +53,7 @@ public class JsonAuthorizationCacheStartRule extends ExternalResource {
protected void before() throws Throwable {
Properties properties = new Properties();
+ properties.put(SampleSecurityManager.SECURITY_JSON, jsonFile);
properties.put(NAME, JsonAuthorizationCacheStartRule.class.getSimpleName());
properties.put(LOCATORS, "");
properties.put(MCAST_PORT, "0");
@@ -60,20 +61,18 @@ public class JsonAuthorizationCacheStartRule extends ExternalResource {
properties.put(JMX_MANAGER_START, "true");
properties.put(JMX_MANAGER_PORT, String.valueOf(jmxManagerPort));
properties.put(HTTP_SERVICE_PORT, String.valueOf(httpPort));
- properties.put(SECURITY_MANAGER, JSONAuthorization.class.getName());
+ properties.put(SECURITY_MANAGER, SampleSecurityManager.class.getName());
- if(postProcessor!=null){
+ if (postProcessor!=null) {
properties.put(SECURITY_POST_PROCESSOR, postProcessor.getName());
}
- JSONAuthorization.setUpWithJsonFile(jsonFile);
-
cache = new CacheFactory(properties).create();
cache.addCacheServer().start();
cache.createRegionFactory().create("region1");
}
- public Cache getCache(){
+ public Cache getCache() {
return cache;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/LockServiceMBeanAuthorizationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/LockServiceMBeanAuthorizationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/LockServiceMBeanAuthorizationJUnitTest.java
index 44e414c..8258f81 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/LockServiceMBeanAuthorizationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/LockServiceMBeanAuthorizationJUnitTest.java
@@ -17,14 +17,7 @@
package com.gemstone.gemfire.management.internal.security;
import static org.assertj.core.api.Assertions.*;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-import com.gemstone.gemfire.distributed.internal.locks.DLockService;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.management.LockServiceMXBean;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -33,15 +26,24 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-@Category(IntegrationTest.class)
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+import com.gemstone.gemfire.distributed.internal.locks.DLockService;
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.management.LockServiceMXBean;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
+@Category({ IntegrationTest.class, SecurityTest.class })
public class LockServiceMBeanAuthorizationJUnitTest {
+
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
private LockServiceMXBean lockServiceMBean;
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, CACHE_SERVER_JSON);
+ jmxManagerPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanSecurityJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanSecurityJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanSecurityJUnitTest.java
index 1d6c95d..1d77375 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanSecurityJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanSecurityJUnitTest.java
@@ -16,17 +16,11 @@
*/
package com.gemstone.gemfire.management.internal.security;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.management.ManagementException;
-import com.gemstone.gemfire.management.ManagementService;
-import com.gemstone.gemfire.management.MemberMXBean;
-import com.gemstone.gemfire.management.internal.MBeanJMXAdapter;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
+import static org.assertj.core.api.Assertions.*;
+import static org.mockito.Mockito.*;
+
+import java.io.IOException;
+import java.util.Set;
import javax.management.DynamicMBean;
import javax.management.MBeanServer;
@@ -35,25 +29,31 @@ import javax.management.MalformedObjectNameException;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.ReflectionException;
-import java.io.IOException;
-import java.util.Set;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Mockito.mock;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.management.ManagementException;
+import com.gemstone.gemfire.management.ManagementService;
+import com.gemstone.gemfire.management.MemberMXBean;
+import com.gemstone.gemfire.management.internal.MBeanJMXAdapter;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
-@Category(IntegrationTest.class)
+@Category({ IntegrationTest.class, SecurityTest.class })
public class MBeanSecurityJUnitTest {
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
@ClassRule
- public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(jmxManagerPort, CACHE_SERVER_JSON);
+ public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(jmxManagerPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
-
/**
* No user can call createBean or unregisterBean of GemFire Domain
*/
@@ -75,9 +75,9 @@ public class MBeanSecurityJUnitTest {
).isInstanceOf(ReflectionException.class);
}
- /*
- * looks like everyone can query for beans, but the AccessControlMXBean is filtered from the result
- */
+ /**
+ * looks like everyone can query for beans, but the AccessControlMXBean is filtered from the result
+ */
@Test
@JMXConnectionConfiguration(user = "stranger", password = "1234567")
public void testQueryBean() throws MalformedObjectNameException, IOException {
@@ -89,8 +89,8 @@ public class MBeanSecurityJUnitTest {
assertThat(objects.size()).isEqualTo(1);
}
- /*
- * These calls does not go through the MBeanServerWrapper authentication, therefore is not throwing the SecurityExceptions
+ /**
+ * These calls does not go through the MBeanServerWrapper authentication, therefore is not throwing the SecurityExceptions
*/
@Test
public void testLocalCalls() throws Exception{
@@ -103,8 +103,6 @@ public class MBeanSecurityJUnitTest {
assertThatThrownBy(
() -> adapter.registerMBean(mock(DynamicMBean.class), new ObjectName("MockDomain", "name", "mock"), false)
).isInstanceOf(ManagementException.class);
-
-
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanServerConnectionRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanServerConnectionRule.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanServerConnectionRule.java
index 51cc6b8..2ca4b19 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanServerConnectionRule.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanServerConnectionRule.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+
import javax.management.JMX;
import javax.management.MBeanServerConnection;
import javax.management.MalformedObjectNameException;
@@ -33,13 +34,13 @@ import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
-import com.gemstone.gemfire.test.junit.rules.DescribedExternalResource;
import org.junit.runner.Description;
+import com.gemstone.gemfire.test.junit.rules.DescribedExternalResource;
+
/**
* Class which eases the creation of MBeans for security testing. When combined with {@link JMXConnectionConfiguration}
* it allows for the creation of per-test connections with different user/password combinations.
- *
*/
public class MBeanServerConnectionRule extends DescribedExternalResource {
@@ -96,7 +97,6 @@ public class MBeanServerConnectionRule extends DescribedExternalResource {
return getProxyMBean(null, beanQueryName);
}
-
public MBeanServerConnection getMBeanServerConnection() throws IOException {
return con;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
index 635daa6..4df20e7 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
@@ -18,15 +18,11 @@ package com.gemstone.gemfire.management.internal.security;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
import java.lang.management.ManagementFactory;
+
import javax.management.ObjectName;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.management.ManagerMXBean;
-import com.gemstone.gemfire.management.internal.beans.ManagerMBean;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
@@ -34,15 +30,22 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-@Category(IntegrationTest.class)
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.management.ManagerMXBean;
+import com.gemstone.gemfire.management.internal.beans.ManagerMBean;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
+@Category({ IntegrationTest.class, SecurityTest.class })
public class ManagerMBeanAuthorizationJUnitTest {
+
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
private ManagerMXBean managerMXBean;
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, CACHE_SERVER_JSON);
+ jmxManagerPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MemberMBeanSecurityJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MemberMBeanSecurityJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MemberMBeanSecurityJUnitTest.java
index 4ee5b13..6c8a638 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MemberMBeanSecurityJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MemberMBeanSecurityJUnitTest.java
@@ -16,27 +16,29 @@
*/
package com.gemstone.gemfire.management.internal.security;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
import static org.assertj.core.api.Assertions.*;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.management.MemberMXBean;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-@Category(IntegrationTest.class)
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.management.MemberMXBean;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
+@Category({ IntegrationTest.class, SecurityTest.class })
public class MemberMBeanSecurityJUnitTest {
+
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
private MemberMXBean bean;
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, CACHE_SERVER_JSON);
+ jmxManagerPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/87c2383a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MultiUserDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MultiUserDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MultiUserDUnitTest.java
index e86cf61..3324e7a 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MultiUserDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/MultiUserDUnitTest.java
@@ -14,20 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.management.internal.security;
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
import static org.junit.Assert.*;
-import static com.gemstone.gemfire.security.JSONAuthorization.*;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
-import com.gemstone.gemfire.security.JSONAuthorization;
import com.jayway.awaitility.Awaitility;
+import org.apache.geode.security.templates.SampleSecurityManager;
import org.json.JSONException;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -53,10 +51,10 @@ public class MultiUserDUnitTest extends CliCommandTestBase {
public void testMultiUser() throws IOException, JSONException, InterruptedException {
Properties properties = new Properties();
properties.put(NAME, MultiUserDUnitTest.class.getSimpleName());
- properties.put(SECURITY_MANAGER, JSONAuthorization.class.getName());
+ properties.put(SECURITY_MANAGER, SampleSecurityManager.class.getName());
// set up vm_0 the secure jmx manager
- Object[] results = setUpJMXManagerOnVM(0, properties, CACHE_SERVER_JSON);
+ Object[] results = setUpJMXManagerOnVM(0, properties, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
String gfshDir = this.gfshDir;
// set up vm_1 as a gfsh vm, data-reader will login and log out constantly in this vm until the test is done.
[07/10] incubator-geode git commit: GEODE-1677: Events are now added
to tmpQueuedEvents while shadow pr is created
Posted by kl...@apache.org.
GEODE-1677: Events are now added to tmpQueuedEvents while shadow pr is created
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/9103a3db
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/9103a3db
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/9103a3db
Branch: refs/heads/feature/GEODE-1673-PR-212
Commit: 9103a3db8642b9b9b4e00aa2d9a8ae3a0ddbc906
Parents: 54f305b
Author: Barry Oglesby <bo...@pivotal.io>
Authored: Wed Jul 13 17:33:05 2016 -0700
Committer: Barry Oglesby <bo...@pivotal.io>
Committed: Thu Jul 21 13:47:54 2016 -0700
----------------------------------------------------------------------
...rentParallelGatewaySenderEventProcessor.java | 2 +-
.../ConcurrentParallelGatewaySenderQueue.java | 23 ++++++++++++++++----
2 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9103a3db/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderEventProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderEventProcessor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderEventProcessor.java
index 04015f7..8b6a700 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderEventProcessor.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderEventProcessor.java
@@ -107,7 +107,7 @@ public class ConcurrentParallelGatewaySenderEventProcessor extends AbstractGatew
createProcessors(sender.getDispatcherThreads(), targetRs);
// this.queue = parallelQueue;
- this.queue = new ConcurrentParallelGatewaySenderQueue(this.processors);
+ this.queue = new ConcurrentParallelGatewaySenderQueue(sender, this.processors);
setDaemon(true);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9103a3db/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderQueue.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderQueue.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderQueue.java
index f995ba4..ccdf42a 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderQueue.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/parallel/ConcurrentParallelGatewaySenderQueue.java
@@ -27,6 +27,7 @@ import com.gemstone.gemfire.internal.cache.DistributedRegion;
import com.gemstone.gemfire.internal.cache.ForceReattemptException;
import com.gemstone.gemfire.internal.cache.PartitionedRegion;
import com.gemstone.gemfire.internal.cache.RegionQueue;
+import com.gemstone.gemfire.internal.cache.wan.AbstractGatewaySender;
import com.gemstone.gemfire.internal.cache.wan.GatewaySenderEventImpl;
import com.gemstone.gemfire.internal.cache.wan.parallel.ParallelGatewaySenderEventProcessor;
import com.gemstone.gemfire.internal.cache.wan.parallel.ParallelGatewaySenderQueue;
@@ -53,10 +54,13 @@ import com.gemstone.gemfire.internal.size.SingleObjectSizer;
*/
public class ConcurrentParallelGatewaySenderQueue implements RegionQueue {
+ private final AbstractGatewaySender sender;
+
private final ParallelGatewaySenderEventProcessor processors[];
- public ConcurrentParallelGatewaySenderQueue(
+ public ConcurrentParallelGatewaySenderQueue(AbstractGatewaySender sender,
ParallelGatewaySenderEventProcessor pro[]) {
+ this.sender = sender;
this.processors = pro;
}
@@ -168,9 +172,20 @@ public class ConcurrentParallelGatewaySenderQueue implements RegionQueue {
}
public void addShadowPartitionedRegionForUserPR(PartitionedRegion pr) {
- for(int i =0; i< processors.length; i++){
- processors[i].addShadowPartitionedRegionForUserPR(pr);
- }
+ // Reset enqueuedAllTempQueueEvents if the sender is running
+ // This is done so that any events received while the shadow PR is added are queued in the tmpQueuedEvents
+ // instead of blocking the distribute call which could cause a deadlock. See GEM-801.
+ if (this.sender.isRunning()) {
+ this.sender.setEnqueuedAllTempQueueEvents(false);
+ }
+ this.sender.getLifeCycleLock().writeLock().lock();
+ try {
+ for (int i = 0; i < processors.length; i++) {
+ processors[i].addShadowPartitionedRegionForUserPR(pr);
+ }
+ } finally {
+ this.sender.getLifeCycleLock().writeLock().unlock();
+ }
}
private ParallelGatewaySenderEventProcessor getPGSProcessor(int bucketId) {
[04/10] incubator-geode git commit: GEODE-1680: Change "list regions"
to DATA:READ permissions
Posted by kl...@apache.org.
GEODE-1680: Change "list regions" to DATA:READ permissions
Edited the annotations for listRegions in RegionCommands and updated unit tests.
* this closes #214
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/4a9c6ea0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/4a9c6ea0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/4a9c6ea0
Branch: refs/heads/feature/GEODE-1673-PR-212
Commit: 4a9c6ea0b4f096aabe54e3f30ceeb24aa622937b
Parents: 50aedb1
Author: Kevin J. Duling <kd...@pivotal.io>
Authored: Wed Jul 20 11:50:22 2016 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Thu Jul 21 08:42:35 2016 -0700
----------------------------------------------------------------------
.../internal/cli/commands/RegionCommands.java | 16 ++++++++--------
.../management/internal/security/TestCommand.java | 2 +-
2 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4a9c6ea0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/RegionCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/RegionCommands.java b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/RegionCommands.java
index e2e9e12..9114fc8 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/RegionCommands.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/RegionCommands.java
@@ -24,6 +24,13 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
+import org.apache.geode.security.GeodePermission.Operation;
+import org.apache.geode.security.GeodePermission.Resource;
+import org.springframework.shell.core.CommandMarker;
+import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.Region;
@@ -50,13 +57,6 @@ import com.gemstone.gemfire.management.internal.cli.result.TabularResultData;
import com.gemstone.gemfire.management.internal.cli.shell.Gfsh;
import com.gemstone.gemfire.management.internal.cli.util.RegionAttributesNames;
import com.gemstone.gemfire.management.internal.security.ResourceOperation;
-import org.apache.geode.security.GeodePermission.Operation;
-import org.apache.geode.security.GeodePermission.Resource;
-
-import org.springframework.shell.core.CommandMarker;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
/***
* Class containing implementation of commands based on region:
@@ -77,7 +77,7 @@ public class RegionCommands implements CommandMarker {
@CliCommand(value = { CliStrings.LIST_REGION }, help = CliStrings.LIST_REGION__HELP)
@CliMetaData(shellOnly = false, relatedTopic = CliStrings.TOPIC_GEODE_REGION)
- @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
+ @ResourceOperation(resource = Resource.DATA, operation = Operation.READ)
public Result listRegion(
@CliOption(key = { CliStrings.LIST_REGION__GROUP },
optionContext = ConverterHint.MEMBERGROUP,
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4a9c6ea0/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/TestCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/TestCommand.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/TestCommand.java
index d3d14d5..8c8ed40 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/TestCommand.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/TestCommand.java
@@ -191,7 +191,7 @@ public class TestCommand {
//RegionCommands
createTestCommand("describe region --name=value", clusterRead);
- createTestCommand("list regions", clusterRead);
+ createTestCommand("list regions", dataRead);
// StatusCommands
createTestCommand("status cluster-config-service", clusterRead);
[05/10] incubator-geode git commit: GEODE-1685 Upgrade to JGroups
3.6.10.Final
Posted by kl...@apache.org.
GEODE-1685 Upgrade to JGroups 3.6.10.Final
Passed precheckin with no failures
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/3e6eb4c7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/3e6eb4c7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/3e6eb4c7
Branch: refs/heads/feature/GEODE-1673-PR-212
Commit: 3e6eb4c7bd683fd2913ee4669e53a422afbe679a
Parents: 4a9c6ea
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Thu Jul 21 09:19:31 2016 -0700
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Thu Jul 21 09:21:21 2016 -0700
----------------------------------------------------------------------
gradle/dependency-versions.properties | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3e6eb4c7/gradle/dependency-versions.properties
----------------------------------------------------------------------
diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index 196a4f8..31c181f 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -63,7 +63,7 @@ javax.servlet-api.version = 3.1.0
javax.transaction-api.version = 1.2
jedis.version = 2.7.2
jetty.version = 9.3.6.v20151106
-jgroups.version = 3.6.8.Final
+jgroups.version = 3.6.10.Final
jline.version = 2.12
jmock.version = 2.8.2
jna.version = 4.0.0
[08/10] incubator-geode git commit: GEODE-1669: Made changes to
add/remove list of interested keys using addAll() and removeAll()
Posted by kl...@apache.org.
GEODE-1669: Made changes to add/remove list of interested keys using addAll() and removeAll()
The client interests are managed in "FilterProfile" class on server side. These are maintained
using the concurrent data structures CopyOnWriteHashSet and CopyOnWriteHashMap...
When set of keys are registered from client, the keys are added to CopyOnWriteHashSet one by
one (FilterProfile.registerClientInterestList()); Where a new HashSet is created each time when
an entry is added, which could impact performance based on the number of keys registered.
Testing:
precheckin
Added new unit test.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/686db9c0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/686db9c0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/686db9c0
Branch: refs/heads/feature/GEODE-1673-PR-212
Commit: 686db9c07eda35a435f9cf7ba8745f1c79f14000
Parents: 9103a3d
Author: agingade <ag...@pivotal.io>
Authored: Thu Jul 21 15:50:36 2016 -0700
Committer: agingade <ag...@pivotal.io>
Committed: Thu Jul 21 15:50:56 2016 -0700
----------------------------------------------------------------------
.../gemfire/internal/cache/FilterProfile.java | 46 ++++++-----
.../tier/sockets/FilterProfileJUnitTest.java | 82 ++++++++++++++++++++
2 files changed, 104 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/686db9c0/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/FilterProfile.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/FilterProfile.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/FilterProfile.java
index 08a6484..73df7be 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/FilterProfile.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/FilterProfile.java
@@ -515,20 +515,19 @@ public class FilterProfile implements DataSerializableFixedID {
public Set registerClientInterestList(Object inputClientID,
List keys, boolean updatesAsInvalidates) {
Long clientID = getClientIDForMaps(inputClientID);
- Set keysRegistered = new HashSet();
+ Set keysRegistered = new HashSet(keys);
synchronized (interestListLock) {
- Map<Object, Set> koi = updatesAsInvalidates?
- getKeysOfInterestInv() : getKeysOfInterest();
- Set interestList = koi.get(clientID);
+ Map<Object, Set> koi = updatesAsInvalidates?getKeysOfInterestInv():getKeysOfInterest();
+ CopyOnWriteHashSet interestList = (CopyOnWriteHashSet)koi.get(clientID);
if (interestList == null) {
interestList = new CopyOnWriteHashSet();
koi.put(clientID, interestList);
+ } else {
+ // Get the list of keys that will be registered new, not already registered.
+ keysRegistered.removeAll(interestList.getSnapshot());
}
- for (Object key: keys) {
- if (interestList.add(key)) {
- keysRegistered.add(key);
- }
- }
+ interestList.addAll(keys);
+
if (this.region != null && this.isLocalProfile) {
sendProfileOperation(clientID, operationType.REGISTER_KEYS, keys, updatesAsInvalidates);
}
@@ -549,36 +548,35 @@ public class FilterProfile implements DataSerializableFixedID {
public Set unregisterClientInterestList(Object inputClientID,
List keys) {
Long clientID = getClientIDForMaps(inputClientID);
- Set keysUnregistered = new HashSet();
+ Set keysUnregistered = new HashSet(keys);
+ Set keysNotUnregistered = new HashSet(keys);
synchronized (interestListLock) {
- Set interestList = getKeysOfInterest().get(clientID);
+ CopyOnWriteHashSet interestList = (CopyOnWriteHashSet)getKeysOfInterest().get(clientID);
if (interestList != null) {
- for (Iterator i = keys.iterator(); i.hasNext();) {
- Object keyOfInterest = i.next();
- if (interestList.remove(keyOfInterest)) {
- keysUnregistered.add(keyOfInterest);
- }
- }
+ // Get the list of keys that are not registered but in unregister set.
+ keysNotUnregistered.removeAll(interestList.getSnapshot());
+ interestList.removeAll(keys);
+
if (interestList.isEmpty()) {
getKeysOfInterest().remove(clientID);
}
}
- interestList = getKeysOfInterestInv().get(clientID);
+ interestList = (CopyOnWriteHashSet)getKeysOfInterestInv().get(clientID);
if (interestList != null) {
- for (Iterator i = keys.iterator(); i.hasNext();) {
- Object keyOfInterest = i.next();
- if (interestList.remove(keyOfInterest)) {
- keysUnregistered.add(keyOfInterest);
- }
- }
+ keysNotUnregistered.removeAll(interestList.getSnapshot());
+ interestList.removeAll(keys);
+
if (interestList.isEmpty()) {
getKeysOfInterestInv().remove(clientID);
}
}
+
if (this.region != null && this.isLocalProfile) {
sendProfileOperation(clientID, operationType.UNREGISTER_KEYS, keys, false);
}
} // synchronized
+ // Get the keys that are not unregistered.
+ keysUnregistered.removeAll(keysNotUnregistered);
return keysUnregistered;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/686db9c0/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/FilterProfileJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/FilterProfileJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/FilterProfileJUnitTest.java
index 5d53dd2..29709a7 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/FilterProfileJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/FilterProfileJUnitTest.java
@@ -19,7 +19,10 @@ package com.gemstone.gemfire.internal.cache.tier.sockets;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
+import java.util.Arrays;
import java.util.Collections;
+import java.util.List;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
@@ -403,4 +406,83 @@ public class FilterProfileJUnitTest {
assertFalse(fprofile.hasFilterInterestFor(clientId, inv));
}
+ @Test
+ public void testRegisterUnregisterClientInterestListAndVerifyKeysRegistered() {
+ registerUnregisterClientInterestListAndVerifyKeysRegistered(false);
+ }
+
+ @Test
+ public void testRegisterUnregisterClientInterestListInvAndVerifyKeysRegistered() {
+ registerUnregisterClientInterestListAndVerifyKeysRegistered(true);
+ }
+
+
+ private void registerUnregisterClientInterestListAndVerifyKeysRegistered(boolean updatesAsInvalidates){
+ String clientId = "client";
+ List<String> keys = Arrays.asList("K1", "K2");
+
+ Set registeredKeys = fprofile.registerClientInterestList(clientId, keys, updatesAsInvalidates);
+ int numKeys = updatesAsInvalidates? fprofile.getKeysOfInterestInv(clientId).size():fprofile.getKeysOfInterest(clientId).size();
+ assertEquals(2, numKeys);
+ assertTrue("Expected key not found in registered list.", registeredKeys.containsAll(keys));
+
+ // Re-register same keys. The return should be empty.
+ registeredKeys = fprofile.registerClientInterestList(clientId, keys, updatesAsInvalidates);
+ numKeys = updatesAsInvalidates? fprofile.getKeysOfInterestInv(clientId).size():fprofile.getKeysOfInterest(clientId).size();
+ assertEquals(2, numKeys);
+ assertEquals(0, registeredKeys.size());
+
+ // Register one old key and new. It should return only the new key.
+ keys = Arrays.asList("K2", "K3");
+ registeredKeys = fprofile.registerClientInterestList(clientId, keys, updatesAsInvalidates);
+ numKeys = updatesAsInvalidates? fprofile.getKeysOfInterestInv(clientId).size():fprofile.getKeysOfInterest(clientId).size();
+ assertEquals(3, numKeys);
+ assertEquals(1, registeredKeys.size());
+ assertTrue("Expected key not found in registered list.", registeredKeys.contains("K3"));
+
+ // Keys Registered are K1, K2, K3
+ keys = Arrays.asList("K1", "K2");
+ registeredKeys = fprofile.unregisterClientInterestList(clientId, keys);
+ numKeys = updatesAsInvalidates? fprofile.getKeysOfInterestInv(clientId).size():fprofile.getKeysOfInterest(clientId).size();
+ assertEquals(1, numKeys);
+ assertTrue("Expected keys not found in unregistered list.", keys.containsAll(registeredKeys));
+
+ // Unregister previously unregistered key and a new key.
+ keys = Arrays.asList("K2", "K3");
+ registeredKeys = fprofile.unregisterClientInterestList(clientId, keys);
+ // Once all the interest for client is removed, the client id is removed from the interest list map.
+ Set keySet = updatesAsInvalidates? fprofile.getKeysOfInterestInv(clientId):fprofile.getKeysOfInterest(clientId);
+ assertNull(keySet);
+ assertEquals(1, registeredKeys.size());
+ assertTrue("Expected key not found in unregistered list.", registeredKeys.contains("K3"));
+
+ // Unregister again, this should return empty set.
+ registeredKeys = fprofile.unregisterClientInterestList(clientId, keys);
+ assertTrue(registeredKeys.isEmpty());
+ }
+
+ @Test
+ public void testRegisterUnregisterClientInterestListsAndVerifyKeysRegistered() {
+ String clientId = "client";
+ List<String> keys = Arrays.asList("K1", "K2");
+
+ Set registeredKeys = fprofile.registerClientInterestList(clientId, keys, false);
+ // Register interest with invalidates.
+ keys = Arrays.asList("K3", "K4");
+ registeredKeys = fprofile.registerClientInterestList(clientId, keys, true);
+
+ // Unregister keys from both list.
+ keys = Arrays.asList("K2", "K3", "K5"); // K5 is not registered.
+ registeredKeys = fprofile.unregisterClientInterestList(clientId, keys);
+ assertEquals(2, registeredKeys.size());
+ assertFalse("Expected key not found in registered list.", registeredKeys.contains("K5"));
+
+ Set keySet = fprofile.getKeysOfInterest(clientId);
+ assertEquals(1, keySet.size());
+ assertTrue("Expected key not found in registered list.", keySet.contains("K1"));
+
+ keySet = fprofile.getKeysOfInterestInv(clientId);
+ assertEquals(1, keySet.size());
+ assertTrue("Expected key not found in registered list.", keySet.contains("K4"));
+ }
}