You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by tu...@apache.org on 2015/11/05 11:44:58 UTC

[3/6] incubator-geode git commit: Adding remaining tests for integrated security

Adding remaining tests for integrated security


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

Branch: refs/heads/feature/GEODE-17
Commit: 4a99d0280cd9e5b7c086e9d3ad9122060b5f1bf5
Parents: 876b00a
Author: tushark <tu...@apache.org>
Authored: Thu Nov 5 16:03:59 2015 +0530
Committer: tushark <tu...@apache.org>
Committed: Thu Nov 5 16:03:59 2015 +0530

----------------------------------------------------------------------
 gemfire-core/build.gradle                       |  13 +
 .../internal/security/AuthManagerJUnitTest.java | 192 ++++++
 .../internal/security/CLISecurityDUnitTest.java | 594 +++++++++++++++++
 .../security/CLISecurityUnAuthDUnitTest.java    |  31 +
 .../security/CommandAnnotationJUnitTest.java    |  86 +++
 .../internal/security/CommandBuilders.java      | 648 +++++++++++++++++++
 .../internal/security/CommandTestBase.java      |  12 +-
 .../internal/security/CustomAccessControl.java  |  85 +++
 .../internal/security/CustomAuthenticator.java  |  58 ++
 .../security/MBeanAnnotationJUnitTest.java      |  83 +++
 .../security/RESTAdminAPISecurityDUnitTest.java |  26 +
 .../security/RESTAdminAPIUnAuthDUnitTest.java   |  30 +
 12 files changed, 1853 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4a99d028/gemfire-core/build.gradle
----------------------------------------------------------------------
diff --git a/gemfire-core/build.gradle b/gemfire-core/build.gradle
index 1c17474..11cf861 100755
--- a/gemfire-core/build.gradle
+++ b/gemfire-core/build.gradle
@@ -224,3 +224,16 @@ configurations {
 dependencies {
   classesOutput sourceSets.main.output
 }
+
+test {  
+  def assemblyPath = project(':gemfire-assembly').buildDir
+  def distributionBaseName = "apache-geode"
+  environment 'GEMFIRE', "$assemblyPath/install/${distributionBaseName}"
+}
+
+distributedTest {  
+  def assemblyPath = project(':gemfire-assembly').buildDir
+  def distributionBaseName = "apache-geode"
+  environment 'GEMFIRE', "$assemblyPath/install/${distributionBaseName}"
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4a99d028/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/AuthManagerJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/AuthManagerJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/AuthManagerJUnitTest.java
new file mode 100644
index 0000000..7a84c3d
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/AuthManagerJUnitTest.java
@@ -0,0 +1,192 @@
+package com.gemstone.gemfire.management.internal.security;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheCallback;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.distributed.DistributedSystem;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+import com.gemstone.gemfire.management.ManagementService;
+import com.gemstone.gemfire.management.internal.AuthManager;
+import com.gemstone.gemfire.management.internal.AuthManager.CommandAuthZRequest;
+import com.gemstone.gemfire.management.internal.SystemManagementService;
+import com.gemstone.gemfire.management.internal.security.CLIOperationContext;
+import com.gemstone.gemfire.management.internal.security.ResourceConstants;
+import com.gemstone.gemfire.security.AccessControl;
+import com.gemstone.gemfire.security.AuthenticationFailedException;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+import junit.framework.TestCase;
+
+@Category(UnitTest.class)
+public class AuthManagerJUnitTest extends TestCase {
+
+  InternalDistributedSystem system;
+  
+  private Cache createCache(Properties props) {
+    
+    this.system = (InternalDistributedSystem) DistributedSystem.connect(props);
+    Cache cache =  new CacheFactory().create();
+    return cache;
+  }
+  
+  public void tearDown() throws Exception {
+    super.tearDown();
+    this.system.disconnect();
+    this.system = null;
+  }
+
+  public void testInvalidAuthenticator() {
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.JMX_MANAGER_NAME, "true");
+    props.setProperty(DistributionConfig.JMX_MANAGER_START_NAME, "true");
+    props.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, "com.gemstone.gemfire.management.security.CustomAuthenticatorINVALID.create");
+    Cache cache = createCache(props);
+
+    SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
+
+    AuthManager auth = service.getAuthManager();
+    Properties creds = new Properties();
+    try {
+      auth.verifyCredentials(creds);
+      fail("should not have reached here");
+    } catch (AuthenticationFailedException ae) {
+
+    }
+  }
+  
+  public void testAuthMapSize() {
+    Properties props = new Properties();
+      props.setProperty(DistributionConfig.JMX_MANAGER_NAME, "true");
+    props.setProperty(DistributionConfig.JMX_MANAGER_START_NAME, "true");
+    props.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, CustomAuthenticator.class.getName()+".create");
+    Cache cache = createCache(props);
+
+    SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
+
+    AuthManager auth = service.getAuthManager();
+    Properties creds = new Properties();
+    creds.put(CommandBuilders.SEC_USER_NAME, "AUTHC_1");
+    try {
+      auth.verifyCredentials(creds);
+      assertEquals(1, auth.getAuthMap().size());
+      
+      auth.verifyCredentials(creds);
+      
+      assertEquals(1, auth.getAuthMap().size());
+      
+      creds.put(CommandBuilders.SEC_USER_NAME, "AUTHC_2");
+      auth.verifyCredentials(creds);
+      assertEquals(2, auth.getAuthMap().size());
+    } catch (AuthenticationFailedException ae) {
+      ae.printStackTrace();
+      fail("should not have reached here "+ ae);
+    }catch (Exception ae) {
+      ae.printStackTrace();
+      fail("should not have reached here "+ ae);
+    }
+  }
+  
+  public void testExpiry() {
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.JMX_MANAGER_NAME, "true");
+    props.setProperty(DistributionConfig.JMX_MANAGER_START_NAME, "true");
+    props.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, CustomAuthenticator.class.getName()+".create");
+    System.setProperty(AuthManager.EXPIRY_TIME_FOR_REST_ADMIN_AUTH, "1");
+    Cache cache = createCache(props);
+
+    SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
+
+    AuthManager auth = service.getAuthManager();
+    Properties creds = new Properties();
+    creds.put(CommandBuilders.SEC_USER_NAME, "AUTHC_1");
+    try {
+      auth.verifyCredentials(creds);
+      assertEquals(1, auth.getAuthMap().size());
+      CommandAuthZRequest authReq1 = auth.getAuthMap().get(creds);
+      Thread.sleep(2 * 60 * 1000);
+      auth.verifyCredentials(creds);
+      CommandAuthZRequest authReq2 = auth.getAuthMap().get(creds);
+      assertTrue(!authReq1.equals(authReq2));
+     
+    } catch (AuthenticationFailedException ae) {
+      fail("should not have reached here "+ ae);
+    }catch (Exception ae) {
+      fail("should not have reached here "+ ae);
+    }
+  }
+  
+  public void testAuthorize() {
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.JMX_MANAGER_NAME, "true");
+    props.setProperty(DistributionConfig.JMX_MANAGER_START_NAME, "true");
+    props.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, CustomAuthenticator.class.getName()+".create");
+    props.setProperty(DistributionConfig.SECURITY_CLIENT_ACCESSOR_NAME,
+        CustomAccessControl.class.getName()+".create");
+    Cache cache = createCache(props);
+
+    SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
+
+    AuthManager auth = service.getAuthManager();
+    Properties creds = new Properties();
+    creds.put(CommandBuilders.SEC_USER_NAME, "AUTHC_26");
+    try {
+      auth.verifyCredentials(creds);
+      auth.authorize(creds, new CLIOperationContext("gc"));
+      assertEquals(1, auth.getAuthMap().size());
+    } catch (AuthenticationFailedException ae) {
+      fail("should not have reached here "+ ae);
+    }catch (Exception ae) {
+      fail("should not have reached here "+ ae);
+    }
+  }
+  
+  public void testCacheClose() {
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.JMX_MANAGER_NAME, "true");
+    props.setProperty(DistributionConfig.JMX_MANAGER_START_NAME, "true");
+    props.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, CustomAuthenticator.class.getName()+".create");
+    props.setProperty(DistributionConfig.SECURITY_CLIENT_ACCESSOR_NAME,
+        CustomAccessControl.class.getName()+".create");
+    Cache cache = createCache(props);
+
+    SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
+
+    AuthManager auth = service.getAuthManager();
+    Properties creds = new Properties();
+    creds.put(CommandBuilders.SEC_USER_NAME, "AUTHC_26");
+    try {
+      auth.verifyCredentials(creds);
+      auth.authorize(creds, new CLIOperationContext("gc"));
+      assertEquals(1, auth.getAuthMap().size());
+      Map<Properties, CommandAuthZRequest> authMap = auth.getAuthMap();
+      Map<Properties, CommandAuthZRequest> tempAuthMap = new HashMap<Properties, CommandAuthZRequest>(authMap);
+      Iterator<CommandAuthZRequest> it = tempAuthMap.values().iterator();
+    
+        CommandAuthZRequest authz = it.next();
+        CacheCallback control = authz.getAuthzCallback();
+        CustomAccessControl cControl = CustomAccessControl.class.cast(control);
+        assertFalse(cControl.isClose());
+        
+        cache.close();
+        
+        assertTrue(cControl.isClose());
+      
+    } catch (AuthenticationFailedException ae) {
+      ae.printStackTrace();
+      fail("should not have reached here "+ ae);
+    }catch (Exception ae) {
+      ae.printStackTrace();
+      fail("should not have reached here "+ ae);
+    }
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4a99d028/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CLISecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CLISecurityDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CLISecurityDUnitTest.java
new file mode 100644
index 0000000..167b3dd
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CLISecurityDUnitTest.java
@@ -0,0 +1,594 @@
+package com.gemstone.gemfire.management.internal.security;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+
+public class CLISecurityDUnitTest extends CommandTestBase {
+
+  private static final long serialVersionUID = 1L;
+
+  public static final String ACCESS_DENIED = "Access Denied";
+
+  protected File tempSecFile;
+
+  protected String tempFilePath;
+
+  public CLISecurityDUnitTest(String name) {
+    super(name);
+
+  }
+
+  protected void writeToLog(String text, String resultAsString) {
+    getLogWriter().info(testName + "\n");
+    getLogWriter().info(resultAsString);
+  }
+
+  public void setUp() throws Exception {
+    super.setUp();
+    createTempFile();
+  }
+
+  @Override
+  public void tearDown2() throws Exception {
+    deleteTempFile();
+    super.tearDown2();
+  }
+
+  private void createTempFile() {
+
+    try {
+      File current = new java.io.File(".");
+      tempSecFile = File.createTempFile("gemfire", "sec", current);
+      tempSecFile.deleteOnExit();
+      tempFilePath = tempSecFile.getCanonicalPath();
+    } catch (IOException e) {
+      fail("could not create temp file " + e);
+    }
+  }
+
+  private void deleteTempFile() {
+
+    try {
+      tempSecFile.delete();
+    } catch (Exception e) {
+      fail("could not delete temp file " + e);
+    }
+  }
+
+  protected void writeToFile(Properties props) {
+
+    try {
+
+      FileWriter fw = new FileWriter(tempSecFile, true);
+      Enumeration en = props.keys();
+      while (en.hasMoreElements()) {
+        String key = (String) en.nextElement();
+        String val = props.getProperty(key);
+        String line = key + "=" + val;
+        fw.append(line);
+        fw.append("\n");
+      }
+      fw.flush();
+
+    } catch (IOException x) {
+      fail("could not write to temp file " + x);
+    }
+
+  }
+
+  public class Assertor {
+
+    private String errString;
+
+    public Assertor() {
+      this.errString = null;
+    }
+
+    public Assertor(String errString) {
+      this.errString = errString;
+    }
+
+    public void assertTest() {
+      boolean hasErr = getDefaultShell().hasError();
+      // getLogWriter().info(testName + "hasErr = " +hasErr);
+      if (hasErr) {
+        String error = getDefaultShell().getError();
+        if (errString != null) {
+          assertTrue(error.contains(errString));
+        } else {
+          fail("Command should have passed but failed with error = " + error);
+        }
+
+      } else {
+        if (errString != null) {
+          fail("Command should have failed with error " + errString + " but it passed");
+        }
+      }
+
+    }
+  }
+
+  protected void createDefaultSetup(Properties props, String propertyFile) {
+    this.securityFile = propertyFile;
+    createDefaultSetup(props);
+  }
+
+  private void securityCheckForCommand(String command, String propertyFile, Assertor assertor) {
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME,
+        "com.gemstone.gemfire.management.internal.security.CustomAuthenticator.create");
+    props.setProperty(DistributionConfig.SECURITY_CLIENT_ACCESSOR_NAME,
+        "com.gemstone.gemfire.management.internal.security.CustomAccessControl.create");
+    createDefaultSetup(props, propertyFile);
+    try {
+      executeCommandWithoutClear(command);
+      assertor.assertTest();
+    } catch (Exception e) {
+      fail("Test failed with exception " + e);
+    } finally {
+      getDefaultShell().clearEvents();
+      destroyDefaultSetup();
+    }
+
+  }
+
+  protected Properties getSecuredProperties(int authCode) {
+    Properties props = new Properties();
+    props.put(CommandBuilders.SEC_USER_NAME, "AUTHC_" + authCode);
+    props.put(CommandBuilders.SEC_USER_PWD, "AUTHC_" + authCode);
+    return props;
+  }
+
+  protected Assertor getAssertor() {
+    return new Assertor();
+  }
+
+  /**
+   * The below test is to test the framework for proper error.
+   */
+
+  /*
+   * public void _testCreateIndexParentOP() { String commandString =
+   * CommandBuilders.CREATE_INDEX();
+   * writeToFile(CommandBuilders.getSecuredAdminProperties
+   * (CommandBuilders.OP_CREATE_INDEX)); securityCheckForCommand(commandString,
+   * tempFilePath, getAssertor()); }
+   */
+
+  public void test_ALTER_RUNTIME() {
+    String commandString = CommandBuilders.ALTER_RUNTIME();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_ALTER_RUNTIME));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  
+  public void test_CHANGE_LOGLEVEL() {
+    String commandString = CommandBuilders.CHANGE_LOGLEVEL();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_CHANGE_ALERT_LEVEL));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  //This test is disabled becoz only access level required for this command is LIST_DS
+  //which is the lowest access level
+  //ant test marked with _test is not really required here
+  public void _test_DESCRIBE_CONFIG() {
+    String commandString = CommandBuilders.DESCRIBE_CONFIG();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_EXPORT_CONFIG() {
+    String commandString = CommandBuilders.EXPORT_CONFIG();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_EXPORT_CONFIG));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_EXPORT_SHARED_CONFIG() {
+    String commandString = CommandBuilders.EXPORT_SHARED_CONFIG();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_EXPORT_CONFIG));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_IMPORT_SHARED_CONFIG() throws IOException {
+
+    String commandString = CommandBuilders.IMPORT_SHARED_CONFIG();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_IMPORT_CONFIG));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_STATUS_SHARED_CONFIG() {
+    String commandString = CommandBuilders.STATUS_SHARED_CONFIG();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_EXPORT_DATA() {
+    String commandString = CommandBuilders.EXPORT_DATA();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_EXPORT_DATA));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+  
+  public void test_GET() {
+    String commandString = CommandBuilders.GET();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_GET));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_IMPORT_DATA() {
+    String commandString = CommandBuilders.IMPORT_DATA();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_IMPORT_DATA));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+  
+  public void test_PUT() {
+    String commandString = CommandBuilders.PUT();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_PUT));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+  
+  public void test_QUERY(){
+    String commandString = CommandBuilders.QUERY();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_QUERY));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_REMOVE(){
+    String commandString = CommandBuilders.REMOVE();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_REMOVE));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+  
+  public void test_LOCATE_ENTRY() {
+    String commandString = CommandBuilders.LOCATE_ENTRY();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LOCATE_ENTRY));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_DEPLOY() throws IOException {
+    String commandString = CommandBuilders.DEPLOY();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_DEPLOY));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_LIST_DEPLOYED() {
+    String commandString = CommandBuilders.LIST_DEPLOYED();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_UNDEPLOY() {
+    String commandString = CommandBuilders.UNDEPLOY();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_UNDEPLOY));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void ISSUE_NO_OP_CODE_test_ALTER_DISK_STORE() {
+    String commandString = CommandBuilders.ALTER_DISK_STORE();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_UNDEPLOY));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_BACKUP_DISK_STORE() {
+    String commandString = CommandBuilders.BACKUP_DISK_STORE();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_BACKUP_DISKSTORE));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_COMPACT_DISKSTORE() {
+    String commandString = CommandBuilders.COMPACT_DISK_STORE();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_COMPACT_DISKSTORE));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_CREATE_DISK_STORE() {
+    String commandString = CommandBuilders.CREATE_DISK_STORE();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_CREATE_DISKSTORE));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_DESCRIBE_DISK_STORE() {
+    String commandString = CommandBuilders.DESCRIBE_DISK_STORE();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_DESTROY_DISK_STORE() {
+    String commandString = CommandBuilders.DESTROY_DISK_STORE();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_DESTROY_DISKSTORE));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_LIST_DISK_STORE() {
+    String commandString = CommandBuilders.LIST_DISK_STORE();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_REVOKE_MISSING_DISK_STORE() {
+    String commandString = CommandBuilders.REVOKE_MISSING_DISK_STORE();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_REVOKE_MISSING_DISKSTORE));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void ISSUE_test_SHOW_MISSING_DISK_STORE() {
+    String commandString = CommandBuilders.SHOW_MISSING_DISK_STORE();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_SHOW_MISSING_DISKSTORES));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_LIST_DURABLE_CQS() {
+    String commandString = CommandBuilders.LIST_DURABLE_CQS();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_CLOSE_DURABLE_CQS() {
+    String commandString = CommandBuilders.CLOSE_DURABLE_CQS();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_CLOSE_DURABLE_CQ));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+  
+  public void ISSUE_test_COUNT_DURABLE_CQ_EVENTS() {
+    String commandString = CommandBuilders.COUNT_DURABLE_CQ_EVENTS();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_SHOW_SUBSCRIPTION_QUEUE_SIZE));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+  
+  public void test_CLOSE_DURABLE_CLIENTS() {
+    String commandString = CommandBuilders.CLOSE_DURABLE_CLIENTS();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_CLOSE_DURABLE_CLIENT));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_DESTROY_FUNCTION() {
+    String commandString = CommandBuilders.DESTROY_FUNCTION();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_DESTROY_FUNCTION));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_EXECUTE_FUNCTION() {
+    String commandString = CommandBuilders.EXECUTE_FUNCTION();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_EXECUTE_FUNCTION));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_LIST_FUNCTION() {
+    String commandString = CommandBuilders.LIST_FUNCTION();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_CREATE_ASYNC_EVENT_QUEUE() {
+    String commandString = CommandBuilders.CREATE_ASYNC_EVENT_QUEUE();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_CREATE_AEQ));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_CREATE_GATEWAYRECEIVER() {
+    String commandString = CommandBuilders.CREATE_GATEWAYRECEIVER();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_CREATE_GW_RECEIVER));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_CREATE_GATEWAYSENDER() {
+    String commandString = CommandBuilders.CREATE_GATEWAYSENDER();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_CREATE_GW_SENDER));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_LIST_ASYNC_EVENT_QUEUES() {
+    String commandString = CommandBuilders.LIST_ASYNC_EVENT_QUEUES();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_LIST_GATEWAY() {
+    String commandString = CommandBuilders.LIST_GATEWAY();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_LOAD_BALANCE_GW_SENDER() {
+    String commandString = CommandBuilders.LOAD_BALANCE_GW_SENDER();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LOAD_BALANCE_GW_SENDER));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_PAUSE_GATEWAYSENDER() {
+    String commandString = CommandBuilders.PAUSE_GATEWAYSENDER();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_PAUSE_GW_SENDER));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_RESUME_GATEWAYSENDER() {
+    String commandString = CommandBuilders.RESUME_GATEWAYSENDER();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_RESUME_GW_SENDER));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_START_GATEWAYRECEIVER() {
+    String commandString = CommandBuilders.START_GATEWAYRECEIVER();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_START_GW_RECEIVER));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_START_GATEWAYSENDER() {
+    String commandString = CommandBuilders.START_GATEWAYSENDER();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_START_GW_SENDER));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_STATUS_GATEWAYSENDER() {
+    String commandString = CommandBuilders.STATUS_GATEWAYSENDER();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_STATUS_GATEWAYRECEIVER() {
+    String commandString = CommandBuilders.STATUS_GATEWAYRECEIVER();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_STOP_GATEWAYRECEIVER() {
+    String commandString = CommandBuilders.STOP_GATEWAYRECEIVER();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_STOP_GW_RECEIVER));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_STOP_GATEWAYSENDER() {
+    String commandString = CommandBuilders.STOP_GATEWAYSENDER();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_STOP_GW_SENDER));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_DESCRIBE_CLIENT() {
+    String commandString = CommandBuilders.DESCRIBE_CLIENT();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_DESCRIBE_MEMBER() {
+    String commandString = CommandBuilders.DESCRIBE_MEMBER();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_EXPORT_LOGS() {
+    String commandString = CommandBuilders.EXPORT_LOGS();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_EXPORT_LOGS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_EXPORT_STACKTRACE() {
+    String commandString = CommandBuilders.EXPORT_STACKTRACE();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_EXPORT_STACKTRACE));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_GC() {
+    String commandString = CommandBuilders.GC();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_GC));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_LIST_CLIENTS() {
+    String commandString = CommandBuilders.LIST_CLIENTS();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_LIST_MEMBER() {
+    String commandString = CommandBuilders.LIST_MEMBER();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_NETSTAT() {
+    String commandString = CommandBuilders.NETSTAT();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_NETSTAT));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_SHOW_DEADLOCK() {
+    String commandString = CommandBuilders.SHOW_DEADLOCK();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_SHOW_DEADLOCKS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_SHOW_LOG() {
+    String commandString = CommandBuilders.SHOW_LOG();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_SHOW_LOG));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_SHOW_METRICS() {
+    String commandString = CommandBuilders.SHOW_METRICS();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_SHOW_METRICS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_CLEAR_DEFINED_INDEXES() {
+    String commandString = CommandBuilders.CLEAR_DEFINED_INDEXES();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_CREATE_INDEX));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_CREATE_DEFINED_INDEXES() {
+    String commandString = CommandBuilders.CREATE_DEFINED_INDEXES();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_CREATE_INDEX));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_CREATE_INDEX() {
+    String commandString = CommandBuilders.CREATE_INDEX();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_CREATE_INDEX));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_DEFINE_INDEX() {
+    String commandString = CommandBuilders.DEFINE_INDEX();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_CREATE_INDEX));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_DESTROY_INDEX() {
+    String commandString = CommandBuilders.DESTROY_INDEX();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_DESTROY_INDEX));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_LIST_INDEX() {
+    String commandString = CommandBuilders.LIST_INDEX();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_CONFIGURE_PDX() {
+    String commandString = CommandBuilders.CONFIGURE_PDX();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_CONFIGURE_PDX));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_ALTER_REGION() {
+    String commandString = CommandBuilders.ALTER_REGION();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_ALTER_REGION));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_CREATE_REGION() {
+    String commandString = CommandBuilders.CREATE_REGION();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_CREATE_REGION));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_DESCRIBE_REGION() {
+    String commandString = CommandBuilders.DESCRIBE_REGION();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_DESTROY_REGION() {
+    String commandString = CommandBuilders.DESTROY_REGION();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_DESTROY_REGION));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void _test_LIST_REGION() {
+    String commandString = CommandBuilders.LIST_REGION();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_LIST_DS));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+  public void test_REBALANCE() {
+    String commandString = CommandBuilders.REBALANCE();
+    writeToFile(getSecuredProperties(CommandBuilders.OP_REBALANCE));
+    securityCheckForCommand(commandString, tempFilePath, getAssertor());
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4a99d028/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CLISecurityUnAuthDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CLISecurityUnAuthDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CLISecurityUnAuthDUnitTest.java
new file mode 100644
index 0000000..4ca2a95
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CLISecurityUnAuthDUnitTest.java
@@ -0,0 +1,31 @@
+package com.gemstone.gemfire.management.internal.security;
+
+import java.util.Properties;
+
+import com.gemstone.gemfire.management.internal.security.CLISecurityDUnitTest.Assertor;
+
+public class CLISecurityUnAuthDUnitTest extends CLISecurityDUnitTest{
+
+  public CLISecurityUnAuthDUnitTest(String name) {
+    super(name);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 1L;
+  
+  protected Properties getSecuredProperties(int authCode) {
+    Properties props = new Properties();
+    props.put(CommandBuilders.SEC_USER_NAME, "UNAUTHC_" + authCode);
+    props.put(CommandBuilders.SEC_USER_PWD, "UNAUTHC_" + authCode);
+    return props;
+  }
+  
+  protected Assertor getAssertor(){
+    return new Assertor(ACCESS_DENIED);
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4a99d028/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CommandAnnotationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CommandAnnotationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CommandAnnotationJUnitTest.java
new file mode 100644
index 0000000..d2d5e66
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CommandAnnotationJUnitTest.java
@@ -0,0 +1,86 @@
+package com.gemstone.gemfire.management.internal.security;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.GemFireConfigException;
+import com.gemstone.gemfire.management.internal.cli.util.ClasspathScanLoadHelper;
+import com.gemstone.gemfire.management.internal.security.ResourceOperation;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+import junit.framework.TestCase;
+
+/**
+ * This test will ensure that all the MBean operations are properly annotated or not.
+ * @author rishim
+ *
+ */
+@Category(UnitTest.class)
+public class CommandAnnotationJUnitTest extends TestCase {
+	
+	public CommandAnnotationJUnitTest(String name) {
+		super(name);
+	}
+
+	public void setUp() throws Exception {
+
+	}
+	
+	public void testCommandAnnotation() {
+		List<String> notFoundList = new ArrayList<String>();
+		try {
+			Class[] klassList = ClasspathScanLoadHelper
+					.getClasses("com.gemstone.gemfire.management.internal.cli.commands");
+			for (Class klass : klassList) {
+				if (klass.getName().endsWith("Commands")) {
+					Method[] methods = klass.getMethods();
+					for (Method method : methods) {
+						String name = method.getName();
+						
+						boolean found = false;
+						boolean isCommandMethod = false;
+						
+						Annotation ans[] = method.getDeclaredAnnotations();
+						for (Annotation an : ans) {
+							if (an instanceof org.springframework.shell.core.annotation.CliCommand) {
+								isCommandMethod = true;
+								break;
+								
+							}
+						}
+						if(isCommandMethod){
+							for (Annotation an : ans) {
+								if (an instanceof ResourceOperation) {
+									found = true;
+									break;
+								}
+							}
+							if (!found) {
+								notFoundList.add(klass + ":" + name);
+							}
+						}
+
+					}
+				}
+			}
+		} catch (ClassNotFoundException e) {
+			throw new GemFireConfigException(
+					"Error while testing annotation for commands - ", e);
+		} catch (IOException e) {
+			throw new GemFireConfigException(
+					"Error while testing annotation for commands - ", e);
+		}
+		
+		for (String s : notFoundList) {
+			System.out.println(s);
+		}
+
+		assertTrue(notFoundList.size() == 0);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4a99d028/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CommandBuilders.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CommandBuilders.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CommandBuilders.java
new file mode 100644
index 0000000..73966c4
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CommandBuilders.java
@@ -0,0 +1,648 @@
+package com.gemstone.gemfire.management.internal.security;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
+import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
+
+public class CommandBuilders {
+
+  protected static String SEC_USER_NAME = "security-user-name";
+  protected static String SEC_USER_PWD = "security-user-pwd";
+
+  protected static final int OP_ALTER_REGION = 1;
+  protected static final int OP_ALTER_RUNTIME = 2;
+  protected static final int OP_BACKUP_DISKSTORE = 3;
+  protected static final int OP_CHANGE_ALERT_LEVEL = 4;
+  protected static final int OP_CLOSE_DURABLE_CLIENT = 5;
+  protected static final int OP_CLOSE_DURABLE_CQ = 6;
+  protected static final int OP_COMPACT_DISKSTORE = 7;
+  protected static final int OP_CONFIGURE_PDX = 8;
+  protected static final int OP_CREATE_AEQ = 9;
+  protected static final int OP_CREATE_DISKSTORE = 10;
+  protected static final int OP_CREATE_GW_RECEIVER = 11;
+  protected static final int OP_CREATE_GW_SENDER = 12;
+  protected static final int OP_CREATE_INDEX = 13;
+  protected static final int OP_CREATE_REGION = 14;
+  protected static final int OP_DEPLOY = 15;
+  protected static final int OP_DESTROY_DISKSTORE = 16;
+  protected static final int OP_DESTROY_FUNCTION = 17;
+  protected static final int OP_DESTROY_INDEX = 18;
+  protected static final int OP_DESTROY_REGION = 19;
+  protected static final int OP_EXECUTE_FUNCTION = 20;
+  protected static final int OP_EXPORT_CONFIG = 21;
+  protected static final int OP_EXPORT_DATA = 22;
+  protected static final int OP_EXPORT_LOGS = 23;
+  protected static final int OP_EXPORT_OFFLINE_DISKSTORE = 24;
+  protected static final int OP_EXPORT_STACKTRACE = 25;
+  protected static final int OP_GC = 26;
+  protected static final int OP_GET = 27;
+  protected static final int OP_IMPORT_CONFIG = 28;
+  protected static final int OP_IMPORT_DATA = 29;
+  protected static final int OP_LIST_DS = 30;
+  protected static final int OP_LOAD_BALANCE_GW_SENDER = 31;
+  protected static final int OP_LOCATE_ENTRY = 32;
+  protected static final int OP_NETSTAT = 33;
+  protected static final int OP_PAUSE_GW_SENDER = 34;
+  protected static final int OP_PUT = 35;
+  protected static final int OP_QUERY = 36;
+  protected static final int OP_REBALANCE = 37;
+  protected static final int OP_REMOVE = 38;
+  protected static final int OP_RENAME_PDX = 39;
+  protected static final int OP_RESUME_GW_SENDER = 40;
+  protected static final int OP_REVOKE_MISSING_DISKSTORE = 41;
+  protected static final int OP_SHOW_DEADLOCKS = 42;
+  protected static final int OP_SHOW_LOG = 43;
+  protected static final int OP_SHOW_METRICS = 44;
+  protected static final int OP_SHOW_MISSING_DISKSTORES = 45;
+  protected static final int OP_SHOW_SUBSCRIPTION_QUEUE_SIZE = 46;
+  protected static final int OP_SHUTDOWN = 47;
+  protected static final int OP_STOP_GW_RECEIVER = 48;
+  protected static final int OP_STOP_GW_SENDER = 49;
+  protected static final int OP_UNDEPLOY = 50;
+  protected static final int OP_BACKUP_MEMBERS = 51;
+  protected static final int OP_ROLL_DISKSTORE = 52;
+  protected static final int OP_FORCE_COMPACTION = 53;
+  protected static final int OP_FORCE_ROLL = 54;
+  protected static final int OP_FLUSH_DISKSTORE = 55;
+  protected static final int OP_START_GW_RECEIVER = 56;
+  protected static final int OP_START_GW_SENDER = 57;
+  protected static final int OP_BECOME_LOCK_GRANTOR = 58;
+  protected static final int OP_START_MANAGER = 59;
+  protected static final int OP_STOP_MANAGER = 60;
+  protected static final int OP_CREATE_MANAGER = 61;
+  protected static final int OP_STOP_CONTINUOUS_QUERY = 62;
+  protected static final int OP_SET_DISK_USAGE = 63;
+
+  protected static final int OP_PULSE_DASHBOARD = 92;
+  protected static final int OP_PULSE_DATABROWSER = 93;
+  protected static final int OP_PULSE_WEBGFSH = 94;
+  protected static final int OP_PULSE_ADMIN_V1 = 95;
+
+  protected static final int OP_DATA_READ = 96;
+  protected static final int OP_DATA_WRITE = 97;
+  protected static final int OP_MONITOR = 98;
+  protected static final int OP_ADMIN = 99;
+  
+  private static String JTEST = System.getProperty("JTESTS");
+
+  protected static Properties getInSecuredProperties(int authCode) {
+    Properties props = new Properties();
+    props.put(SEC_USER_NAME, "AUTHI_" + authCode);
+    props.put(SEC_USER_PWD, "AUTHI_" + authCode);
+    return props;
+  }
+
+  protected static Properties getSecuredAdminProperties(int authCode) {
+    Properties props = new Properties();
+    props.put(SEC_USER_NAME, "ADMIN_" + authCode);
+    props.put(SEC_USER_PWD, "ADMIN_" + authCode);
+    return props;
+  }
+
+  protected static Properties getUnAuthorizedProperties(int authCode) {
+    Properties props = new Properties();
+    props.put(SEC_USER_NAME, "UNAUTHC_" + authCode);
+    props.put(SEC_USER_PWD, "UNAUTHC_" + authCode);
+    return props;
+  }
+
+  public static String CREATE_INDEX() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    String regionName = "r1";
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, "test");
+    csb.addOption(CliStrings.CREATE_INDEX__GROUP, "test");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "\"/" + regionName + " p\"");
+    String commandString = csb.toString();
+    return commandString;
+  }
+
+  public static String ALTER_REGION() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    String regionName = "r1";
+    csb = new CommandStringBuilder(CliStrings.ALTER_REGION);
+    csb.addOption(CliStrings.ALTER_REGION__REGION, regionName);
+    csb.addOption(CliStrings.ALTER_REGION__GROUP, "g1");
+    csb.addOption(CliStrings.ALTER_REGION__ENTRYEXPIRATIONTIMETOLIVE, "45635");
+    csb.addOption(CliStrings.ALTER_REGION__ENTRYEXPIRATIONTTLACTION, "DESTROY");
+    String commandString = csb.toString();
+    return commandString;
+  }
+
+  public static String ALTER_RUNTIME() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
+    csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__MEMBER, "m1");
+    csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__LEVEL, "info");
+    csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, "50");
+    csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT, "32");
+    csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT, "49");
+    csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE, "2000");
+    csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, "stat.gfs");
+    csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLING__ENABLED, "true");
+    csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
+    String commandString = csb.getCommandString();
+    return commandString;
+  }
+
+  public static String CLOSE_DURABLE_CLIENTS() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CLOSE_DURABLE_CLIENTS);
+    csb.addOption(CliStrings.CLOSE_DURABLE_CLIENTS__CLIENT__ID, "c1");
+    String commandString = csb.toString();
+    return commandString;
+  }
+  
+  public static String COUNT_DURABLE_CQ_EVENTS() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.COUNT_DURABLE_CQ_EVENTS);
+    csb.addOption(CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE__CLIENT__ID, "c1");
+    String commandString = csb.toString();
+    return commandString;
+  }
+  
+  public static String CLOSE_DURABLE_CQS() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CLOSE_DURABLE_CQS);
+    csb.addOption(CliStrings.CLOSE_DURABLE_CQS__DURABLE__CLIENT__ID, "c1");
+    csb.addOption(CliStrings.CLOSE_DURABLE_CQS__NAME, "cq1");
+    String commandString = csb.toString();
+    return commandString;
+  }
+
+  public static String CONFIGURE_PDX() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CONFIGURE_PDX);
+    csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__AUTO__SERIALIZER__CLASSES, "com.class");
+    csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS, "true");
+    csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__PORTABLE__AUTO__SERIALIZER__CLASSES, "com.class");
+    csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__READ__SERIALIZED, "true");
+    String commandString = csb.toString();
+    return commandString;
+  }
+
+  public static String CREATE_ASYNC_EVENT_QUEUE() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_ASYNC_EVENT_QUEUE);
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__ID, "q1");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__GROUP, "Group1");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__BATCH_SIZE, "514");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__PERSISTENT, "true");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISK_STORE, "d1");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__MAXIMUM_QUEUE_MEMORY, "213");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__BATCHTIMEINTERVAL, "946");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__PARALLEL, "true");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__ENABLEBATCHCONFLATION, "true");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISPATCHERTHREADS, "2");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__ORDERPOLICY, "PARTITION");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__GATEWAYEVENTFILTER, "com.qcdunit.QueueCommandsDUnitTestHelper");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__SUBSTITUTION_FILTER,
+        "com.qcdunit.QueueCommandsDUnitTestHelper");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISKSYNCHRONOUS, "false");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER, "com.qcdunit.QueueCommandsDUnitTestHelper");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER_PARAM_AND_VALUE, "param1");
+    csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER_PARAM_AND_VALUE, "param2#value2");
+    String commandString = csb.toString();
+    return commandString;
+  }
+
+  public static String CREATE_DISK_STORE() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_DISK_STORE);
+    csb.addOption(CliStrings.CREATE_DISK_STORE__NAME, "d1");
+    csb.addOption(CliStrings.CREATE_DISK_STORE__GROUP, "g1");
+    csb.addOption(CliStrings.CREATE_DISK_STORE__DIRECTORY_AND_SIZE, "/temp/temp");
+    String commandString = csb.toString();
+    return commandString;
+  }
+
+  public static String ALTER_DISK_STORE() {
+
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_DISK_STORE);
+    csb.addOption(CliStrings.ALTER_DISK_STORE__DISKSTORENAME, "d1");
+    csb.addOption(CliStrings.ALTER_DISK_STORE__REGIONNAME, "r1");
+    csb.addOption(CliStrings.ALTER_DISK_STORE__DISKDIRS, "/temp/temp");
+    csb.addOption(CliStrings.ALTER_DISK_STORE__CONCURRENCY__LEVEL, "5");
+    csb.addOption(CliStrings.ALTER_DISK_STORE__INITIAL__CAPACITY, "6");
+    csb.addOption(CliStrings.ALTER_DISK_STORE__LRU__EVICTION__ACTION, "local-destroy");
+    csb.addOption(CliStrings.ALTER_DISK_STORE__COMPRESSOR, "com.gemstone.gemfire.compression.SnappyCompressor");
+    csb.addOption(CliStrings.ALTER_DISK_STORE__STATISTICS__ENABLED, "true");
+
+    return csb.getCommandString();
+  }
+
+  public static String BACKUP_DISK_STORE() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.BACKUP_DISK_STORE);
+    csb.addOption(CliStrings.BACKUP_DISK_STORE__DISKDIRS, "/temp/temp");
+    String commandString = csb.toString();
+    return commandString;
+  }
+
+  public static String COMPACT_DISK_STORE() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.COMPACT_DISK_STORE);
+    csb.addOption(CliStrings.COMPACT_DISK_STORE__NAME, "d1");
+    csb.addOption(CliStrings.COMPACT_DISK_STORE__GROUP, "g1");
+    String commandString = csb.toString();
+    return commandString;
+  }
+
+  public static String DESCRIBE_DISK_STORE() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESCRIBE_DISK_STORE);
+    csb.addOption(CliStrings.DESCRIBE_DISK_STORE__MEMBER, "m1");
+    csb.addOption(CliStrings.DESCRIBE_DISK_STORE__NAME, "d1");
+    String commandString = csb.toString();
+    return commandString;
+  }
+
+  public static String DESTROY_DISK_STORE() {
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.DESTROY_DISK_STORE);
+    commandStringBuilder.addOption(CliStrings.DESTROY_DISK_STORE__NAME, "d1");
+    commandStringBuilder.addOption(CliStrings.DESTROY_DISK_STORE__GROUP, "g1");
+    return commandStringBuilder.toString();
+  }
+
+  public static String LIST_DISK_STORE() {
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.LIST_DISK_STORE);
+    return commandStringBuilder.toString();
+  }
+
+  public static String REVOKE_MISSING_DISK_STORE() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.REVOKE_MISSING_DISK_STORE);
+    csb.addOption(CliStrings.REVOKE_MISSING_DISK_STORE__ID, "d1");
+    return csb.toString();
+  }
+
+  public static String SHOW_MISSING_DISK_STORE() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.SHOW_MISSING_DISK_STORE);
+    return csb.toString();
+  }
+
+  public static String CREATE_GATEWAYRECEIVER() {
+    String command = CliStrings.CREATE_GATEWAYRECEIVER + " --" + CliStrings.CREATE_GATEWAYRECEIVER__BINDADDRESS
+        + "=localhost" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT + "=11000" + " --"
+        + CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT + "=10000" + " --"
+        + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
+        + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000";
+
+    return command;
+  }
+
+  public static String CREATE_GATEWAYSENDER() {
+    String command = CliStrings.CREATE_GATEWAYSENDER + " --" + CliStrings.CREATE_GATEWAYSENDER__ID + "=ln" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID + "=2" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__PARALLEL + "=false" + " --" + CliStrings.CREATE_GATEWAYSENDER__MANUALSTART
+        + "=true" + " --" + CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT + "=" + 1000 + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL + "=5000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE + "=true" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS + "=false" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY + "=1000" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD + "=100" + " --"
+        + CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS + "=2";
+    return command;
+  }
+
+  public static String CREATE_REGION() {
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION, "R1");
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "REPLICATE");
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__STATISTICSENABLED, "true");
+    commandStringBuilder.addOption(CliStrings.CREATE_REGION__GROUP, "G1");
+    return commandStringBuilder.toString();
+  }
+
+  public static String DEPLOY() throws IOException {
+    String testJarPath =  createTempFile("testjar",".jar");
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DEPLOY);
+    csb.addOption(CliStrings.DEPLOY__JAR, testJarPath);
+    return csb.toString();
+  }
+
+  public static String LIST_DEPLOYED() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_DEPLOYED);
+    return csb.toString();
+  }
+
+  public static String DESTROY_FUNCTION() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_FUNCTION);
+    csb.addOption(CliStrings.DESTROY_FUNCTION__ID, "fn1");
+    csb.addOption(CliStrings.DESTROY_FUNCTION__ONGROUPS, "g1");
+    return csb.toString();
+  }
+
+  public static String DESTROY_INDEX() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
+    csb.addOption(CliStrings.DESTROY_INDEX__NAME, "idx1");
+    csb.addOption(CliStrings.DESTROY_INDEX__REGION, "/StocksParReg");
+    return csb.toString();
+  }
+
+  public static String DESTROY_REGION() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_REGION);
+    csb.addOption(CliStrings.DESTROY_REGION__REGION, "compressedRegion");
+    return csb.toString();
+  }
+
+  public static String EXECUTE_FUNCTION() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.EXECUTE_FUNCTION);
+    csb.addOption(CliStrings.EXECUTE_FUNCTION__ID, "fn1");
+    csb.addOption(CliStrings.EXECUTE_FUNCTION__ONGROUPS, "g1");
+    return csb.toString();
+  }
+
+  public static String EXPORT_CONFIG() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.EXPORT_CONFIG);
+    csb.addOption(CliStrings.EXPORT_CONFIG__MEMBER, "m1");
+    return csb.toString();
+  }
+
+  public static String EXPORT_DATA() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.EXPORT_DATA);
+    csb.addOption(CliStrings.EXPORT_DATA__REGION, "R1");
+    csb.addOption(CliStrings.EXPORT_DATA__MEMBER, "Manager");
+    csb.addOption(CliStrings.EXPORT_DATA__FILE, "/temp/temp");
+    return csb.toString();
+  }
+
+  public static String EXPORT_LOGS() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.EXPORT_LOGS);
+    csb.addOption(CliStrings.EXPORT_LOGS__DIR, "/temp/temp");
+    csb.addOption(CliStrings.EXPORT_LOGS__MEMBER, "m1");
+    return csb.toString();
+  }
+
+  public static String EXPORT_STACKTRACE() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.EXPORT_STACKTRACE);
+    csb.addOption(CliStrings.EXPORT_STACKTRACE__FILE, "/temp/temp");
+    return csb.toString();
+  }
+
+  public static String GC() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.GC);
+    csb.addOption(CliStrings.GC__MEMBER, "m1");
+    return csb.toString();
+  }
+
+  public static String IMPORT_CONFIG() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.IMPORT_SHARED_CONFIG);
+    csb.addOption(CliStrings.IMPORT_SHARED_CONFIG__ZIP, "test.zip");
+    return csb.toString();
+  }
+
+  public static String IMPORT_DATA() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.IMPORT_DATA);
+    csb.addOption(CliStrings.IMPORT_DATA__REGION, "R1");
+    csb.addOption(CliStrings.IMPORT_DATA__FILE, "/temp/temp");
+    csb.addOption(CliStrings.IMPORT_DATA__MEMBER, "Manager");
+    return csb.toString();
+  }
+
+  public static String LOAD_BALANCE_GW_SENDER() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LOAD_BALANCE_GATEWAYSENDER);
+    csb.addOption(CliStrings.LOAD_BALANCE_GATEWAYSENDER__ID, "1");
+    return csb.toString();
+  }
+
+  public static String LOCATE_ENTRY() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LOCATE_ENTRY);
+    csb.addOption(CliStrings.LOCATE_ENTRY__KEY, "1");
+    csb.addOption(CliStrings.LOCATE_ENTRY__REGIONNAME, "R1");
+    return csb.toString();
+  }
+
+  public static String NETSTAT() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.NETSTAT);
+    csb.addOption(CliStrings.NETSTAT__MEMBER, "m1");
+    csb.addOption(CliStrings.NETSTAT__FILE, "/temp/f1");
+    return csb.toString();
+  }
+
+  public static String PAUSE_GATEWAYSENDER() {
+    String command = CliStrings.PAUSE_GATEWAYSENDER + " --" + CliStrings.PAUSE_GATEWAYSENDER__ID + "=ln --"
+        + CliStrings.PAUSE_GATEWAYSENDER__MEMBER + "=" + "m1" + " --" + CliStrings.PAUSE_GATEWAYSENDER__GROUP
+        + "=SenderGroup1";
+
+    return command;
+  }
+
+  public static String REBALANCE() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.REBALANCE);
+    csb.addOption(CliStrings.REBALANCE__INCLUDEREGION, "r1");
+    return csb.toString();
+  }
+
+  public static String PDX_RENAME() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.PDX_RENAME);
+    csb.addOption(CliStrings.PDX_RENAME_OLD, "com.old");
+    csb.addOption(CliStrings.PDX_RENAME_NEW, "com.new");
+    csb.addOption(CliStrings.PDX_DISKSTORE, "d1");
+    csb.addOption(CliStrings.PDX_DISKDIR, "/temp");
+    return csb.toString();
+  }
+
+  public static String RESUME_GATEWAYSENDER() {
+    String command = CliStrings.RESUME_GATEWAYSENDER + " --" + CliStrings.RESUME_GATEWAYSENDER__ID + "=ln";
+    return command;
+  }
+
+  public static String SHOW_DEADLOCK() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.SHOW_DEADLOCK);
+    csb.addOption(CliStrings.SHOW_DEADLOCK__DEPENDENCIES__FILE, "f1");
+    return csb.toString();
+  }
+
+  public static String SHOW_LOG() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.SHOW_LOG);
+    csb.addOption(CliStrings.SHOW_LOG_MEMBER, "m1");
+    return csb.toString();
+  }
+
+  public static String SHOW_METRICS() {
+    String command = CliStrings.SHOW_METRICS + " --" + CliStrings.SHOW_METRICS__MEMBER + "=" + "m1" + " --"
+        + CliStrings.SHOW_METRICS__CACHESERVER__PORT + "=" + 2099 + " --" + CliStrings.SHOW_METRICS__FILE + "=" + "F1";
+    return command;
+  }
+
+  public static String STOP_GATEWAYRECEIVER() {
+    String command = CliStrings.STOP_GATEWAYRECEIVER + " --" + CliStrings.STOP_GATEWAYRECEIVER__MEMBER + "=" + "m1"
+        + " --" + CliStrings.STOP_GATEWAYRECEIVER__GROUP + "=RG1";
+    return command;
+  }
+
+  public static String STOP_GATEWAYSENDER() {
+    String command = CliStrings.STOP_GATEWAYSENDER + " --" + CliStrings.STOP_GATEWAYSENDER__ID + "=ln --"
+        + CliStrings.STOP_GATEWAYSENDER__MEMBER + "=" + "m1" + " --" + CliStrings.STOP_GATEWAYSENDER__GROUP
+        + "=SenderGroup1";
+    return command;
+  }
+
+  public static String UNDEPLOY() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.UNDEPLOY);
+    csb.addOption(CliStrings.UNDEPLOY__JAR, "test.jar");
+    return csb.toString();
+  }
+
+  public static String CHANGE_LOGLEVEL() {
+    String command = CliStrings.CHANGE_LOGLEVEL + " --" + CliStrings.CHANGE_LOGLEVEL__LOGLEVEL + "=finer" + " --"
+        + CliStrings.CHANGE_LOGLEVEL__GROUPS + "=" + "grp1" + "," + "grp2";
+    return command;
+  }
+
+  public static String DEFINE_INDEX() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DEFINE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, "indexName");
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
+    return csb.toString();
+  }
+
+  public static String CLEAR_DEFINED_INDEXES() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CLEAR_DEFINED_INDEXES);
+    return csb.toString();
+  }
+
+  public static String DESCRIBE_CONFIG() {
+    String command = CliStrings.DESCRIBE_CONFIG + " --member=m1";
+    return command;
+  }
+
+  public static String EXPORT_SHARED_CONFIG() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.EXPORT_SHARED_CONFIG);
+    csb.addOption(CliStrings.EXPORT_SHARED_CONFIG__FILE, "test.zip");
+    return csb.toString();
+  }
+
+  public static String IMPORT_SHARED_CONFIG() throws IOException {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.IMPORT_SHARED_CONFIG);
+    
+    String zipPath = createTempFile("testzip",".zip");
+    csb.addOption(CliStrings.IMPORT_SHARED_CONFIG__ZIP, zipPath);
+    return csb.toString();
+  }
+  
+  private static String createTempFile(String fileName, String suffix) throws IOException {
+    String tempFilePath;
+
+    File current = new java.io.File(".");
+    File tempFile = File.createTempFile(fileName, suffix, current);
+    tempFile.deleteOnExit();
+    tempFilePath = tempFile.getCanonicalPath();
+
+    return tempFilePath;
+  }
+
+  public static String STATUS_SHARED_CONFIG() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.STATUS_SHARED_CONFIG);
+    return csb.toString();
+  }
+
+  public static String LIST_DURABLE_CQS() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_DURABLE_CQS);
+    csb.addOption(CliStrings.LIST_DURABLE_CQS__DURABLECLIENTID, "c1");
+    return csb.toString();
+  }
+
+  public static String LIST_FUNCTION() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_FUNCTION);
+    return csb.toString();
+  }
+
+  public static String LIST_ASYNC_EVENT_QUEUES() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_ASYNC_EVENT_QUEUES);
+    return csb.toString();
+  }
+
+  public static String LIST_GATEWAY() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_GATEWAY);
+    return csb.toString();
+  }
+
+  public static String START_GATEWAYRECEIVER() {
+    String command = CliStrings.START_GATEWAYRECEIVER + " --" + CliStrings.START_GATEWAYRECEIVER__MEMBER + "=" + "m1"
+        + " --" + CliStrings.START_GATEWAYRECEIVER__GROUP + "=RG1";
+    return command;
+  }
+
+  public static String START_GATEWAYSENDER() {
+    String command = CliStrings.START_GATEWAYSENDER + " --" + CliStrings.START_GATEWAYSENDER__ID + "=ln";
+    return command;
+  }
+
+  public static String STATUS_GATEWAYRECEIVER() {
+    String command = CliStrings.STATUS_GATEWAYRECEIVER + " --" + CliStrings.STATUS_GATEWAYRECEIVER__GROUP + "=RG1";
+    return command;
+  }
+
+  public static String STATUS_GATEWAYSENDER() {
+    String command = CliStrings.STATUS_GATEWAYSENDER + " --" + CliStrings.STATUS_GATEWAYSENDER__ID + "=ln_Serial --"
+        + CliStrings.STATUS_GATEWAYSENDER__GROUP + "=Serial_Sender";
+    return command;
+  }
+
+  public static String DESCRIBE_CLIENT() {
+    String command = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\"" + 1 + "\"";
+    return command;
+  }
+
+  public static String DESCRIBE_MEMBER() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESCRIBE_MEMBER);
+    csb.addOption(CliStrings.DESCRIBE_MEMBER__IDENTIFIER, "m1");
+    return csb.toString();
+  }
+
+  public static String LIST_CLIENTS() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_CLIENTS);
+    return csb.toString();
+  }
+
+  public static String LIST_MEMBER() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_MEMBER);
+    return csb.toString();
+  }
+
+  public static String CREATE_DEFINED_INDEXES() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_DEFINED_INDEXES);
+    return csb.toString();
+  }
+
+  public static String LIST_INDEX() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
+    return csb.toString();
+  }
+
+  public static String DESCRIBE_REGION() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESCRIBE_REGION);
+    csb.addOption(CliStrings.DESCRIBE_REGION__NAME, "r1");
+    return csb.toString();
+  }
+
+  public static String LIST_REGION() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_REGION);
+    csb.addOption(CliStrings.LIST_REGION__MEMBER, "m1");
+    return csb.toString();
+  }
+  
+  public static String GET() {
+    CommandStringBuilder command = new CommandStringBuilder(CliStrings.GET);
+    command.addOption(CliStrings.GET__REGIONNAME, "r1");
+    command.addOption(CliStrings.GET__KEY, "jondoe");
+    command.addOption(CliStrings.GET__LOAD, "true");
+    return command.toString();
+  }
+
+  public static String PUT() {
+    String command = CliStrings.PUT + " --" + CliStrings.PUT__KEY + "=k1" + " --" + CliStrings.PUT__VALUE + "=k1"
+        + " --" + CliStrings.PUT__REGIONNAME + "=R1";
+    return command;
+  }
+  
+  public static String QUERY() {
+    String command = CliStrings.QUERY + " --" + CliStrings.QUERY__QUERY + "='select a from /r1'";
+    return command;
+  }
+  
+  public static String REMOVE() {
+    CommandStringBuilder command = new CommandStringBuilder(CliStrings.REMOVE);
+    command.addOption(CliStrings.REMOVE__KEY, "jondoe");
+    command.addOption(CliStrings.REMOVE__REGION, "r1");
+    return command.toString();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4a99d028/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CommandTestBase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CommandTestBase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CommandTestBase.java
index 9fb9d94..a7e8139 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CommandTestBase.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CommandTestBase.java
@@ -13,7 +13,6 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import util.TestException;
-//import util.TestHelper;
 
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache30.CacheTestCase;
@@ -144,12 +143,14 @@ public class CommandTestBase extends CacheTestCase {
   @SuppressWarnings("serial")
   protected final void destroyDefaultSetup() {
     if (this.shell != null) {
-      // Note: HeadlessGfsh doesn't use Launcher & code that does System.exit()
-      // for gfsh is in Launcher. This is just to ensure cleanup.
-      executeCommand(shell, "exit");
+      
       if(shell.isConnectedAndReady()){
         executeCommand(shell, "disconnect");
       }
+      
+      // Note: HeadlessGfsh doesn't use Launcher & code that does System.exit()
+      // for gfsh is in Launcher. This is just to ensure cleanup.
+      executeCommand(shell, "exit");
 
       this.shell.terminate();
       this.shell = null;
@@ -379,8 +380,9 @@ public class CommandTestBase extends CacheTestCase {
     try {
       
       boolean status = shell.executeCommand(command);
+      info("Waiting for result");
       result = shell.getResult();
-      
+      info("Got the Result");
       info("CommandExecutionSuccess=" + status );
       info("Status=" + shell.getCommandExecutionStatus());
       info("ShellOutputString=<" + shell.outputString + ">");

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4a99d028/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CustomAccessControl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CustomAccessControl.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CustomAccessControl.java
new file mode 100644
index 0000000..6967c17
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CustomAccessControl.java
@@ -0,0 +1,85 @@
+package com.gemstone.gemfire.management.internal.security;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.operations.OperationContext;
+import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
+import com.gemstone.gemfire.distributed.DistributedMember;
+import com.gemstone.gemfire.management.internal.security.ResourceOperationContext.ResourceOperationCode;
+import com.gemstone.gemfire.security.AccessControl;
+import com.gemstone.gemfire.security.NotAuthorizedException;
+
+public class CustomAccessControl implements AccessControl{
+  
+  private Principal principal;
+  
+  private boolean close = false;
+  
+  private List<OperationCode> baseOpCodes = new ArrayList<OperationCode>();
+
+  public static AccessControl create() {
+    return new CustomAccessControl();
+  }
+  
+  @Override
+  public void init(Principal principal, DistributedMember remoteMember, Cache cache) throws NotAuthorizedException {
+    this.principal = principal;
+    baseOpCodes.add(OperationCode.GET);
+    baseOpCodes.add(OperationCode.QUERY);
+    baseOpCodes.add(OperationCode.PUT);
+    baseOpCodes.add(OperationCode.REMOVEALL);
+    baseOpCodes.add(OperationCode.DESTROY);
+    baseOpCodes.add(OperationCode.CLOSE_CQ);
+    baseOpCodes.add(OperationCode.REGION_CREATE);
+    baseOpCodes.add(OperationCode.REGION_DESTROY);
+    baseOpCodes.add(OperationCode.EXECUTE_FUNCTION);
+    
+  }
+
+  @Override
+  public boolean authorizeOperation(String regionName, OperationContext context) {
+    System.out.println("OperationContext = "+ context);
+    //This access control only validates OperationCode.RESOURCE
+    if (context.getOperationCode().equals(OperationCode.RESOURCE) || baseOpCodes.contains(context.getOperationCode())) {
+      
+      String principalUser = principal.getName();
+      
+      ResourceOperationContext rContext = (ResourceOperationContext) context;
+      ResourceOperationCode rCode = rContext.getResourceOperationCode();
+      
+      System.out.println("ResourceOperationContext = "+ rContext + " , rCode ordinal = "
+          +rCode + ", principalUser = "+principalUser);      
+      
+      if(rCode.equals(ResourceOperationCode.LIST_DS))
+        return true;
+      
+      if (principalUser.equals("ADMIN_" + rCode)) {
+        if (!ResourceOperationCode.ADMIN.allowedOp(rCode)) {
+          return false;
+        }
+      }    
+      if (principalUser.equals("AUTHC_"+rCode.toOrdinal())) {
+        return true;
+      } else {
+        return false;
+      }
+
+    
+
+    }
+    return false;
+  }
+
+  @Override
+  public void close() {
+   this.close = true;
+  }
+
+  public boolean isClose(){
+    return this.close;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4a99d028/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CustomAuthenticator.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CustomAuthenticator.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CustomAuthenticator.java
new file mode 100644
index 0000000..3b8e9bb
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/CustomAuthenticator.java
@@ -0,0 +1,58 @@
+package com.gemstone.gemfire.management.internal.security;
+
+import java.security.Principal;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.management.remote.JMXPrincipal;
+
+import com.gemstone.gemfire.LogWriter;
+import com.gemstone.gemfire.distributed.DistributedMember;
+import com.gemstone.gemfire.security.AuthenticationFailedException;
+import com.gemstone.gemfire.security.Authenticator;
+
+
+public class CustomAuthenticator implements  Authenticator {
+  
+
+
+  public static Authenticator create() {
+    return new CustomAuthenticator();
+  }
+
+  
+  public static final String AUTHENTICATED_USER = "AUTHC_";
+  public static final String NON_AUTHORIZED_USER = "UNAUTHC_";
+  public static final String ADMIN_USER = "ADMIN_";
+  
+  
+  
+  Set<String> users = new HashSet<String>();
+  
+  private boolean closed = false;
+
+  @Override
+  public void close() {
+    this.closed = true;    
+  }
+
+  @Override
+  public void init(Properties securityProps, LogWriter systemLogger, LogWriter securityLogger)
+      throws AuthenticationFailedException {
+  }
+
+  @Override
+  public Principal authenticate(Properties props, DistributedMember member) throws AuthenticationFailedException {
+    String user = props.getProperty(CommandBuilders.SEC_USER_NAME);
+    String pwd = props.getProperty(CommandBuilders.SEC_USER_PWD);
+    if (user.startsWith(AUTHENTICATED_USER) || user.startsWith(NON_AUTHORIZED_USER) || user.startsWith(ADMIN_USER)) {
+      return new JMXPrincipal(user);
+
+    }
+    throw new AuthenticationFailedException("Not authenticated");
+
+  }
+
+  
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4a99d028/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanAnnotationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanAnnotationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanAnnotationJUnitTest.java
new file mode 100644
index 0000000..15b13e9
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/MBeanAnnotationJUnitTest.java
@@ -0,0 +1,83 @@
+package com.gemstone.gemfire.management.internal.security;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.GemFireConfigException;
+import com.gemstone.gemfire.management.internal.cli.util.ClasspathScanLoadHelper;
+import com.gemstone.gemfire.management.internal.security.JMXOperationContext;
+import com.gemstone.gemfire.management.internal.security.ResourceOperation;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+import junit.framework.TestCase;
+
+/**
+ * This test will ensure that all the MBean operations are properly annotated or not.
+ * @author rishim
+ *
+ */
+@Category(UnitTest.class)
+public class MBeanAnnotationJUnitTest extends TestCase {
+
+	public MBeanAnnotationJUnitTest(String name) {
+		super(name);
+	}
+	
+	public static List<String> excludedClasses = new ArrayList<String>();
+
+	public void setUp() throws Exception {
+     excludedClasses.add("com.gemstone.gemfire.management.CustomMXBean");
+	}
+
+	public void testMBeanAnnotation() {
+		List<String> notFoundList = new ArrayList<String>();
+		try {
+			Class[] klassList = ClasspathScanLoadHelper
+					.getClasses("com.gemstone.gemfire.management");
+			for (Class klass : klassList) {
+				if (klass.getName().endsWith("MXBean")) {
+				  if(excludedClasses.contains(klass.getName())){
+				    continue;
+				  }
+					Method[] methods = klass.getMethods();
+					for (Method method : methods) {
+						String name = method.getName();
+						if(JMXOperationContext.isGetterSetter(name)){
+							continue;
+						}
+						
+						boolean found = false;
+						Annotation ans[] = method.getDeclaredAnnotations();
+						for (Annotation an : ans) {
+							if (an instanceof ResourceOperation) {
+								found = true;
+								break;
+							}
+						}
+						if (!found) {
+							notFoundList.add(klass + ":" + name);
+						}
+					}
+				}
+			}
+		} catch (ClassNotFoundException e) {
+			throw new GemFireConfigException(
+					"Error while testing annotation for jmx - ", e);
+		} catch (IOException e) {
+			throw new GemFireConfigException(
+					"Error while testing annotation for jmx - ", e);
+		}
+		
+		for (String s : notFoundList) {
+			System.out.println(s);
+		}
+
+		assertTrue(notFoundList.size() == 0);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4a99d028/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/RESTAdminAPISecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/RESTAdminAPISecurityDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/RESTAdminAPISecurityDUnitTest.java
new file mode 100644
index 0000000..5481ff7
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/RESTAdminAPISecurityDUnitTest.java
@@ -0,0 +1,26 @@
+package com.gemstone.gemfire.management.internal.security;
+
+import dunit.Host;
+import dunit.SerializableCallable;
+
+public class RESTAdminAPISecurityDUnitTest extends CLISecurityDUnitTest {
+
+  private static final long serialVersionUID = 1L;
+
+  public RESTAdminAPISecurityDUnitTest(String name) {
+    super(name);
+  }
+
+  public void setUp() throws Exception {
+    super.setUp();
+    this.setUseHttpOnConnect(true);
+  }
+
+
+  @Override
+  public void tearDown2() throws Exception {
+    super.tearDown2();
+    this.setUseHttpOnConnect(false);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4a99d028/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/RESTAdminAPIUnAuthDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/RESTAdminAPIUnAuthDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/RESTAdminAPIUnAuthDUnitTest.java
new file mode 100644
index 0000000..94f9958
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/security/RESTAdminAPIUnAuthDUnitTest.java
@@ -0,0 +1,30 @@
+package com.gemstone.gemfire.management.internal.security;
+
+import java.util.Properties;
+
+import com.gemstone.gemfire.management.internal.security.CLISecurityDUnitTest.Assertor;
+
+public class RESTAdminAPIUnAuthDUnitTest extends RESTAdminAPISecurityDUnitTest{
+  
+  public RESTAdminAPIUnAuthDUnitTest(String name) {
+    super(name);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 1L;
+
+  protected Properties getSecuredProperties(int authCode) {
+    Properties props = new Properties();
+    props.put(CommandBuilders.SEC_USER_NAME, "UNAUTHC_" + authCode);
+    props.put(CommandBuilders.SEC_USER_PWD, "UNAUTHC_" + authCode);
+    return props;
+  }
+  
+  protected Assertor getAssertor(){
+    return new Assertor(ACCESS_DENIED);
+  }
+
+}