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 04:12:39 UTC
[2/2] incubator-geode git commit: GEODE-1673: fail start if
security.json cannot be found
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/6b748eb5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/6b748eb5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/6b748eb5
Branch: refs/heads/feature/GEODE-1673-PR-212
Commit: 6b748eb5f7ac5dab0fb07fc1c59d187d6b019a24
Parents: 603bae8
Author: gmeilen <gr...@gmail.com>
Authored: Mon Jul 18 14:50:53 2016 -0700
Committer: Kirk Lund <kl...@pivotal.io>
Committed: Thu Jul 21 21:12:14 2016 -0700
----------------------------------------------------------------------
.../internal/InternalDistributedSystem.java | 2 +-
.../security/shiro/CustomAuthRealm.java | 17 +-
.../apache/geode/security/SecurityManager.java | 4 +-
.../templates/SampleSecurityManager.java | 260 +++++++++++--------
.../internal/DistributionConfigJUnitTest.java | 6 +-
.../cli/commands/CliCommandTestBase.java | 14 +-
.../security/AccessControlMBeanJUnitTest.java | 13 +-
...CacheServerMBeanAuthenticationJUnitTest.java | 5 +-
.../CacheServerMBeanAuthorizationJUnitTest.java | 13 +-
.../CacheServerMBeanShiroJUnitTest.java | 12 +-
.../security/CliCommandsSecurityTest.java | 10 +-
.../security/DataCommandsSecurityTest.java | 16 +-
.../DiskStoreMXBeanSecurityJUnitTest.java | 13 +-
.../GatewayReceiverMBeanSecurityTest.java | 19 +-
.../GatewaySenderMBeanSecurityTest.java | 20 +-
.../security/GeodePermissionJUnitTest.java | 8 +-
.../GeodeSecurityUtilCustomRealmJUnitTest.java | 19 +-
.../GeodeSecurityUtilWithIniFileJUnitTest.java | 12 +-
.../security/GfshCommandsPostProcessorTest.java | 11 +-
.../security/GfshCommandsSecurityTest.java | 17 +-
.../internal/security/JSONAuthorization.java | 48 ----
.../JsonAuthorizationCacheStartRule.java | 12 +-
.../LockServiceMBeanAuthorizationJUnitTest.java | 19 +-
.../security/MBeanSecurityJUnitTest.java | 49 ++--
.../security/MBeanServerConnectionRule.java | 6 +-
.../ManagerMBeanAuthorizationJUnitTest.java | 16 +-
.../security/MemberMBeanSecurityJUnitTest.java | 13 +-
.../internal/security/MultiUserDUnitTest.java | 6 +-
.../internal/security/ShiroCacheStartRule.java | 10 +-
.../internal/security/TestCommand.java | 5 +-
...ractIntegratedClientAuthDistributedTest.java | 9 +-
...gratedClientGetEntryAuthDistributedTest.java | 1 -
...IntegratedClientSizeAuthDistributedTest.java | 1 -
...edSecurityCacheLifecycleDistributedTest.java | 12 +-
...edSecurityCacheLifecycleIntegrationTest.java | 5 +-
...urityNoShowValue1PostProcessorDUnitTest.java | 2 -
...ntegratedSecurityPostProcessorDUnitTest.java | 2 -
.../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 | 9 +-
42 files changed, 533 insertions(+), 344 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6b748eb5/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/6b748eb5/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/6b748eb5/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/6b748eb5/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..dbe9f6f 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;
@@ -44,19 +46,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": [
* {
@@ -73,11 +80,11 @@ import com.gemstone.gemfire.security.NotAuthorizedException;
* ],
* "regions": ["RegionA", "RegionB"]
* }
- * ]
+ * ],
* "users": [
* {
* "name": "admin",
- * "password": "secret".
+ * "password": "secret",
* "roles": ["admin"]
* },
* {
@@ -87,101 +94,174 @@ 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) {
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 : "*";
@@ -190,54 +270,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/6b748eb5/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..1b95e6d 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.management.internal.security.JSONAuthorization;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
@@ -330,7 +330,7 @@ public class DistributionConfigJUnitTest {
@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 +343,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/6b748eb5/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..3818672 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,10 +43,10 @@ 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.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.
@@ -67,6 +68,9 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
protected transient String gfshDir;
@Rule
+ public transient DistributedRestoreSystemProperties restoreSystemProperties = new DistributedRestoreSystemProperties();
+
+ @Rule
public transient TemporaryFolder temporaryFolder = new TemporaryFolder();
@Override
@@ -139,6 +143,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 +161,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/6b748eb5/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..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
@@ -18,24 +18,26 @@ package com.gemstone.gemfire.management.internal.security;
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, "cacheServer.json");
+ jmxManagerPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
@@ -47,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/6b748eb5/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..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
@@ -28,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, "cacheServer.json");
+ jmxManagerPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json");
@Rule
public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
@@ -44,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/6b748eb5/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..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
@@ -18,24 +18,27 @@ 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 CacheServerMBeanAuthorizationJUnitTest {
+
private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
private CacheServerMXBean bean;
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, "cacheServer.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/6b748eb5/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/6b748eb5/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..015bd61 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,7 +16,7 @@
*/
package com.gemstone.gemfire.management.internal.security;
-import static org.assertj.core.api.AssertionsForClassTypes.fail;
+import static org.assertj.core.api.Assertions.fail;
import static org.junit.Assert.*;
import java.util.List;
@@ -34,11 +34,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;
@@ -47,7 +45,7 @@ public class CliCommandsSecurityTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxManagerPort, "cacheServer.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/6b748eb5/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..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
@@ -18,26 +18,28 @@ 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.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, "cacheServer.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/6b748eb5/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..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
@@ -18,9 +18,6 @@ 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.DiskStoreMXBean;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
@@ -28,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, "cacheServer.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/6b748eb5/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..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
@@ -21,11 +21,6 @@ import static org.mockito.Mockito.*;
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;
@@ -34,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, "cacheServer.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/6b748eb5/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..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
@@ -21,11 +21,6 @@ import static org.mockito.Mockito.*;
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;
@@ -34,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, "cacheServer.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/6b748eb5/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/6b748eb5/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..5255ba3 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
@@ -19,23 +19,26 @@ package com.gemstone.gemfire.management.internal.security;
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
+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.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/6b748eb5/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/6b748eb5/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..efce1c3 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,11 +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.internal.Assert.*;
+import org.apache.geode.security.templates.SamplePostProcessor;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
@@ -27,18 +27,19 @@ 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, "cacheServer.json", SamplePostProcessor.class);
+ jmxPort, "com/gemstone/gemfire/management/internal/security/cacheServer.json", SamplePostProcessor.class);
@Rule
public GfshShellConnectionRule gfshConnection;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6b748eb5/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..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,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.*;
@@ -36,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];
@@ -47,15 +48,10 @@ public class GfshCommandsSecurityTest {
@ClassRule
public static JsonAuthorizationCacheStartRule serverRule = new JsonAuthorizationCacheStartRule(
- jmxPort, httpPort, "cacheServer.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(){
@@ -128,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) {
@@ -183,6 +178,4 @@ public class GfshCommandsSecurityTest {
gfsh.executeCommand("query --query=\"select * from /region1\"");
}
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6b748eb5/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/6b748eb5/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..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,12 +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;
public class JsonAuthorizationCacheStartRule extends ExternalResource {
+
private Cache cache;
private int jmxManagerPort = 0;
private int httpPort = 0;
@@ -38,7 +40,6 @@ public class JsonAuthorizationCacheStartRule extends ExternalResource {
this.postProcessor = postProcessor;
}
-
public JsonAuthorizationCacheStartRule(int jmxManagerPort, String jsonFile) {
this.jmxManagerPort = jmxManagerPort;
this.jsonFile = jsonFile;
@@ -52,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");
@@ -59,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/6b748eb5/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..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
@@ -18,12 +18,6 @@ package com.gemstone.gemfire.management.internal.security;
import static org.assertj.core.api.Assertions.*;
-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;
@@ -32,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, "cacheServer.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/6b748eb5/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..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,16 +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 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;
@@ -34,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, "cacheServer.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
*/
@@ -74,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 {
@@ -88,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{
@@ -102,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/6b748eb5/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/6b748eb5/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..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
@@ -20,12 +20,9 @@ import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
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;
@@ -33,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, "cacheServer.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/6b748eb5/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..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
@@ -18,24 +18,27 @@ 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.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, "cacheServer.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/6b748eb5/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..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,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.*;
@@ -26,6 +25,7 @@ import java.util.Properties;
import java.util.concurrent.TimeUnit;
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;
@@ -51,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, "cacheServer.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.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6b748eb5/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/6b748eb5/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..c8ce6f3 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/6b748eb5/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..8950479 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
@@ -22,6 +22,7 @@ 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;
@@ -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,11 +56,10 @@ public class AbstractIntegratedClientAuthDistributedTest extends JUnit4CacheTest
this.client2 = host.getVM(2);
this.client3 = host.getVM(3);
- JSONAuthorization.setUpWithJsonFile("clientServer.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(SECURITY_MANAGER, SampleSecurityManager.class.getName());
+ if (postProcessor!=null) {
props.setProperty(SECURITY_POST_PROCESSOR, postProcessor.getName());
}
props.setProperty(MCAST_PORT, "0");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6b748eb5/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/6b748eb5/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/6b748eb5/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..7e4547c 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,20 +16,18 @@
*/
package com.gemstone.gemfire.security;
-
import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
import static org.assertj.core.api.Assertions.*;
-import java.security.Principal;
import java.util.Properties;
+import org.apache.geode.security.templates.SampleSecurityManager;
import org.junit.Test;
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;
@@ -41,13 +39,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");
+
int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
String locators = NetworkUtils.getServerHostName(host) + "[" + locatorPort + "]";
@@ -55,6 +54,7 @@ public class IntegratedSecurityCacheLifecycleDistributedTest extends JUnit4Cache
DistributedTestUtils.deleteLocatorStateFile(locatorPort);
final Properties properties = new Properties();
+ properties.setProperty(SampleSecurityManager.SECURITY_JSON, "com/gemstone/gemfire/management/internal/security/clientServer.json");
properties.setProperty(MCAST_PORT, "0");
properties.setProperty(START_LOCATOR, locators);
properties.setProperty(SECURITY_MANAGER, SpySecurityManager.class.getName());
@@ -64,6 +64,7 @@ public class IntegratedSecurityCacheLifecycleDistributedTest extends JUnit4Cache
});
final Properties properties = new Properties();
+ properties.setProperty(SampleSecurityManager.SECURITY_JSON, "com/gemstone/gemfire/management/internal/security/clientServer.json");
properties.setProperty(MCAST_PORT, "0");
properties.setProperty(SECURITY_MANAGER, SpySecurityManager.class.getName());
properties.setProperty(LOCATORS, locators);
@@ -95,8 +96,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);