You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2016/02/25 21:27:17 UTC

[29/50] [abbrv] incubator-geode git commit: Merge branch 'develop' into feature/GEODE-17

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5c01d5f4/geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/ResourceConstants.java
----------------------------------------------------------------------
diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/ResourceConstants.java
index 0000000,3a8bbbf..14d4639
mode 000000,100644..100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/ResourceConstants.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/ResourceConstants.java
@@@ -1,0 -1,115 +1,161 @@@
+ /*
+  * 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;
+ 
++/**
++ * 
++ * @author tushark
++ *
++ * @since 9.0
++ */
+ public class ResourceConstants {
 -	
 -	//public static final String LIST_DS = "LIST_DS";
 -	public static final String READ_DS = "READ_DS";
 -	public static final String SET_DS = "SET_DS";
 -	public static final String CHANGE_ALERT_LEVEL_DS = "CHANGE_ALERT_LEVEL_DS";
 -	public static final String BACKUP_DS = "BACKUP_DS";
 -	public static final String REMOVE_DISKSTORE_DS = "REMOVE_DISKSTORE_DS";
 -	public static final String SHUTDOWN_DS = "SHUTDOWN_DS";
 -	public static final String QUERYDATA_DS = "QUERYDATA_DS";
 -	public static final String ADMIN_DS = "ADMIN_DS";
 -	
 -	/*
 -	public static final String REBALANCE = "REBALANCE";
 -	public static final String PUT = "PUT";
 -	public static final String EXPORT_DATA = "EXPORT_DATA";
 -	public static final String IMPORT_DATA = "IMPORT_DATA";
 -	public static final String LOCATE_ENTRY = "LOCATE_ENTRY";*/
 -	
 -	public static final String PULSE_DASHBOARD = "PULSE_DASHBOARD";
 -  public static final String PULSE_DATABROWSER = "PULSE_DATABROWSER";
 -  public static final String PULSE_ADMIN_V1 = "PULSE_ADMIN_V1";
 -  public static final String PULSE_WEBGFSH = "PULSE_WEBGFSH";  
 -	
 -	public static final String DEFAULT_LABEL="";
 -	
 -	public static final String RESORUCE_SEC_DESCRIPTOR = "resource.secDescriptor";
 -	public static final String RESORUCE_AUTH_ACCESSOR = "resource-auth-accessor";
 -	public static final String RESORUCE_AUTHENTICATOR = "resource-authenticator";
 -  public static final String RESORUCE_DEFAULT_SEC_DESCRIPTOR = "resourceSecDesc.json";
+   
 -  //All ResourceOperation Codes
++  public static final String DEFAULT_LABEL="";
++  
++  public static final String RESORUCE_SEC_DESCRIPTOR = "resource.secDescriptor";
++  public static final String RESORUCE_AUTH_ACCESSOR = "resource-auth-accessor";
++  public static final String RESORUCE_AUTHENTICATOR = "resource-authenticator";
++  public static final String RESORUCE_DEFAULT_SEC_DESCRIPTOR = "resourceSecDesc.json";
++  public static final String CREATE_MBEAN = "createMBean";
++  public static final String UNREGISTER_MBEAN = "unregisterMBean";
++  public static final String SET_PREFIX = "set";
++  public static final String SET_ATTRIBUTE = "setAttribute";
++  public static final String SET_ATTRIBUTES= "setAttributes";
++  public static final String GET_ATTRIBUTES= "getAttributes";
++  public static final String GET_ATTRIBUTE = "getAttribute";
++  public static final String GET_PREFIX = "get";
++  public static final String GET_IS_PREFIX = "is";
++  public static final String REGISTER_MBEAN = "registerMBean";
++  public static final String PROCESS_COMMAND ="processCommand";
++  public static final String ACCESS_DENIED_MESSAGE = "Access Denied";
++  public static final String WRONGE_CREDENTIALS_MESSAGE = "Wrong Credentials";
+   
+   public static final String ALTER_REGION = "ALTER_REGION";
+   public static final String ALTER_RUNTIME = "ALTER_RUNTIME";
+   public static final String BACKUP_DISKSTORE = "BACKUP_DISKSTORE";
+   public static final String CHANGE_ALERT_LEVEL = "CHANGE_ALERT_LEVEL";
+   public static final String CLOSE_DURABLE_CLIENT = "CLOSE_DURABLE_CLIENT";
+   public static final String CLOSE_DURABLE_CQ = "CLOSE_DURABLE_CQ";
+   public static final String COMPACT_DISKSTORE = "COMPACT_DISKSTORE";
+   public static final String CONFIGURE_PDX = "CONFIGURE_PDX";
+   public static final String CREATE_AEQ = "CREATE_AEQ";
+   public static final String CREATE_DISKSTORE = "CREATE_DISKSTORE";
+   public static final String CREATE_GW_RECEIVER = "CREATE_GW_RECEIVER";
+   public static final String CREATE_GW_SENDER = "CREATE_GW_SENDER";
+   public static final String CREATE_INDEX = "CREATE_INDEX";
+   public static final String CREATE_REGION = "CREATE_REGION";
+   public static final String DEPLOY = "DEPLOY";
+   public static final String DESTROY_DISKSTORE = "DESTROY_DISKSTORE";
+   public static final String DESTROY_FUNCTION = "DESTROY_FUNCTION";
+   public static final String DESTROY_INDEX = "DESTROY_INDEX";
++
+   public static final String DESTROY_REGION = "DESTROY_REGION";
+   public static final String EXECUTE_FUNCTION = "EXECUTE_FUNCTION";
+   public static final String EXPORT_CONFIG = "EXPORT_CONFIG";
+   public static final String EXPORT_DATA = "EXPORT_DATA";
+   public static final String EXPORT_LOGS = "EXPORT_LOGS";
+   public static final String EXPORT_OFFLINE_DISKSTORE = "EXPORT_OFFLINE_DISKSTORE";
+   public static final String EXPORT_STACKTRACE = "EXPORT_STACKTRACE";
+   public static final String GC = "GC";
+   public static final String GET = "GET";
+   public static final String IMPORT_CONFIG = "IMPORT_CONFIG";
+   public static final String IMPORT_DATA = "IMPORT_DATA";
+   public static final String LIST_DS = "LIST_DS";
+   public static final String LOAD_BALANCE_GW_SENDER = "LOAD_BALANCE_GW_SENDER";
+   public static final String LOCATE_ENTRY = "LOCATE_ENTRY";
+   public static final String NETSTAT = "NETSTAT";
+   public static final String PAUSE_GW_SENDER = "PAUSE_GW_SENDER";
+   public static final String PUT = "PUT";
+   public static final String QUERY = "QUERY";
+   public static final String REBALANCE = "REBALANCE";
+   public static final String REMOVE = "REMOVE";
+   public static final String RENAME_PDX = "RENAME_PDX";
+   public static final String RESUME_GW_SENDER = "RESUME_GW_SENDER";
+   public static final String REVOKE_MISSING_DISKSTORE = "REVOKE_MISSING_DISKSTORE";
+   public static final String SHOW_DEADLOCKS = "SHOW_DEADLOCKS";
+   public static final String SHOW_LOG = "SHOW_LOG";
+   public static final String SHOW_METRICS = "SHOW_METRICS";
+   public static final String SHOW_MISSING_DISKSTORES = "SHOW_MISSING_DISKSTORES";
+   public static final String SHOW_SUBSCRIPTION_QUEUE_SIZE = "SHOW_SUBSCRIPTION_QUEUE_SIZE";
+   public static final String SHUTDOWN = "SHUTDOWN";
+   public static final String STOP_GW_RECEIVER = "STOP_GW_RECEIVER";
+   public static final String STOP_GW_SENDER = "STOP_GW_SENDER";
+   public static final String UNDEPLOY = "UNDEPLOY";
+   public static final String BACKUP_MEMBERS = "BACKUP_MEMBERS";
+   public static final String ROLL_DISKSTORE = "ROLL_DISKSTORE";
+   public static final String FORCE_COMPACTION = "FORCE_COMPACTION";
++  public static final String FORCE_ROLL = "FORCE_ROLL";
+   public static final String FLUSH_DISKSTORE = "FLUSH_DISKSTORE";
+   public static final String START_GW_RECEIVER = "START_GW_RECEIVER";
+   public static final String START_GW_SENDER = "START_GW_SENDER";
+   public static final String BECOME_LOCK_GRANTOR = "BECOME_LOCK_GRANTOR";
+   public static final String START_MANAGER = "START_MANAGER";
+   public static final String STOP_MANAGER = "STOP_MANAGER";
+   public static final String CREATE_MANAGER = "CREATE_MANAGER";
++  public static final String STOP_CONTINUOUS_QUERY = "STOP_CONTINUOUS_QUERY";
++  public static final String SET_DISK_USAGE = "SET_DISK_USAGE";
++  
+ 
++  public static final String CREATE_HDFS_STORE = "CREATE_HDFS_STORE";
++  public static final String ALTER_HDFS_STORE = "ALTER_HDFS_STORE";
++  public static final String DESTROY_HDFS_STORE = "DESTROY_HDFS_STORE";
++  
++  public static final String PULSE_DASHBOARD = "PULSE_DASHBOARD";
++  public static final String PULSE_DATABROWSER = "PULSE_DATABROWSER";
++  public static final String PULSE_ADMIN_V1 = "PULSE_ADMIN_V1";
++  public static final String PULSE_WEBGFSH = "PULSE_WEBGFSH";
++
++  public static final String DATA_READ = "DATA_READ";
++  public static final String DATA_WRITE = "DATA_WRITE";
++  public static final String MONITOR = "MONITOR";
++  public static final String ADMIN = "ADMIN";
++  
++  public static final String OBJECT_NAME_ACCESSCONTROL = "GemFire:service=AccessControl,type=Distributed";
++  public static final String USER_NAME = "security-username";
++  public static final String PASSWORD = "security-password";
++
++  public static final String MBEAN_TYPE_DISTRIBUTED = "Distributed";
++  public static final String MBEAN_TYPE_MEMBER = "Member";
++  
++  public static final String MBEAN_SERVICE_MANAGER = "Manager";
++  public static final String MBEAN_SERVICE_CACHESERVER="CacheServer";
++  public static final String MBEAN_SERVICE_REGION = "Region";
++  public static final String MBEAN_SERVICE_LOCKSERVICE = "LockService";
++  public static final String MBEAN_SERVICE_DISKSTORE = "DiskStore";
++  public static final String MBEAN_SERVICE_GATEWAY_RECEIVER = "GatewayReceiver";
++  public static final String MBEAN_SERVICE_GATEWAY_SENDER = "GatewaySender";
++  public static final String MBEAN_SERVICE_ASYNCEVENTQUEUE = "AsyncEventQueue";
++  public static final String MBEAN_SERVICE_LOCATOR = "Locator";
++  public static final String MBEAN_SERVICE_SYSTEM = "System";
++  
++  public static final String MBEAN_KEY_SERVICE ="service";
++  public static final String MBEAN_KEY_TYPE ="type";
++  
++  public static final String GETTER_IS= "is";
++  public static final String GETTER_GET = "get";
++  public static final String GETTER_FETCH = "fetch";
++  public static final String GETTER_SHOW = "show";
++  public static final String GETTER_HAS = "has";
++  public static final String GETTER_VIEW = "view";
++  public static final String GETTER_LIST = "list";
++  public static final String GETTER_DESCRIBE = "describe";
++  public static final String GETTER_STATUS = "status";
++  
++  public static final String MANAGEMENT_PACKAGE = "com.gemstone.gemfire.management";
+   
+ 
+ }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5c01d5f4/geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/ResourceOperation.java
----------------------------------------------------------------------
diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/ResourceOperation.java
index 0000000,ceebd6f..4f92417
mode 000000,100644..100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/ResourceOperation.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/ResourceOperation.java
@@@ -1,0 -1,34 +1,40 @@@
+ /*
+  * 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.lang.annotation.ElementType;
+ import java.lang.annotation.Inherited;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+ 
++/**
++ * Annotation describing Security Level required to perform any resource operation
++ * @author tushark
++ *
++ * @since 9.0
++ */
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @Inherited
+ public @interface ResourceOperation {
+   
+   Resource resource();
+   String label() default ResourceConstants.DEFAULT_LABEL;
+   String operation() default ResourceConstants.LIST_DS;
+ 
+ }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5c01d5f4/geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/ResourceOperationContext.java
----------------------------------------------------------------------
diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/ResourceOperationContext.java
index 0000000,50b22a3..dfbf926
mode 000000,100644..100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/ResourceOperationContext.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/security/ResourceOperationContext.java
@@@ -1,0 -1,203 +1,436 @@@
+ /*
+  * 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.util.ArrayList;
++import java.util.Collections;
+ import java.util.HashMap;
++import java.util.List;
+ import java.util.Map;
+ 
+ import com.gemstone.gemfire.cache.operations.OperationContext;
+ 
++/**
++ * This is base class for OperationContext for resource (JMX and CLI) operations
++ * 
++ * @author tushark
++ * 
++ * @since 9.0
++ */
+ public abstract class ResourceOperationContext extends OperationContext {
 -	
 -	 public static class ResourceOperationCode {
 -		 
 -		private static final byte OP_LIST_DS = 1;	
 -	    private static final byte OP_READ_DS = 2;
 -	    private static final byte OP_SET_DS = 3;
 -	    private static final byte OP_ADMIN_DS = 4;
 -	    private static final byte OP_CHANGE_ALERT_LEVEL_DS = 5;
 -	    private static final byte OP_BACKUP_DS = 6;
 -	    private static final byte OP_REMOVE_DISKSTORE_DS = 7;
 -	    private static final byte OP_SHUTDOWN_DS = 8;
 -	    private static final byte OP_QUERYDATA_DS = 9;
 -	    private static final byte OP_REBALANCE_DS = 10;
 -	    
 -	    private static final byte OP_EXPORT_DATA_REGION = 11;
 -	    private static final byte OP_IMPORT_DATA_REGION = 12 ;
 -	    private static final byte OP_PUT_REGION = 13;
 -	    private static final byte OP_LOCATE_ENTRY_REGION = 14;
 -	    
 -	    private static final byte OP_PULSE_DASHBOARD = 15;
 -	    private static final byte OP_PULSE_DATABROWSER = 16;
 -	    private static final byte OP_PULSE_WEBGFSH = 17;
 -	    private static final byte OP_PULSE_ADMIN_V1 = 18;
 -	    
 -	    
 -	    private static final ResourceOperationCode[] VALUES = new ResourceOperationCode[20];
 -	    private static final Map OperationNameMap = new HashMap();
 -	    
 -	    public static final ResourceOperationCode LIST_DS = new ResourceOperationCode(ResourceConstants.LIST_DS, OP_LIST_DS);
 -	    public static final ResourceOperationCode READ_DS = new ResourceOperationCode(ResourceConstants.READ_DS, OP_READ_DS);
 -	    public static final ResourceOperationCode SET_DS = new ResourceOperationCode(ResourceConstants.SET_DS, OP_SET_DS);
 -
 -	    public static final ResourceOperationCode CHANGE_ALERT_LEVEL_DS = new ResourceOperationCode(ResourceConstants.CHANGE_ALERT_LEVEL_DS, OP_CHANGE_ALERT_LEVEL_DS);
 -	    public static final ResourceOperationCode BACKUP_DS = new ResourceOperationCode(ResourceConstants.BACKUP_DS, OP_BACKUP_DS);
 -	    public static final ResourceOperationCode REMOVE_DISKSTORE_DS = new ResourceOperationCode(ResourceConstants.REMOVE_DISKSTORE_DS, OP_REMOVE_DISKSTORE_DS);
 -	    public static final ResourceOperationCode SHUTDOWN_DS = new ResourceOperationCode(ResourceConstants.SHUTDOWN_DS, OP_SHUTDOWN_DS);
 -	    public static final ResourceOperationCode QUERYDATA_DS = new ResourceOperationCode(ResourceConstants.QUERYDATA_DS, OP_QUERYDATA_DS);
 -	    public static final ResourceOperationCode REBALANCE_DS = new ResourceOperationCode(ResourceConstants.REBALANCE, OP_REBALANCE_DS);
 -	    
 -	    public static final ResourceOperationCode EXPORT_DATA_REGION = new ResourceOperationCode(ResourceConstants.EXPORT_DATA, OP_EXPORT_DATA_REGION);
 -	    public static final ResourceOperationCode IMPORT_DATA_REGION = new ResourceOperationCode(ResourceConstants.IMPORT_DATA, OP_IMPORT_DATA_REGION);
 -	    public static final ResourceOperationCode PUT_REGION = new ResourceOperationCode(ResourceConstants.PUT, OP_PUT_REGION);
 -	    public static final ResourceOperationCode LOCATE_ENTRY_REGION = new ResourceOperationCode(ResourceConstants.LOCATE_ENTRY, OP_LOCATE_ENTRY_REGION);	    
 -	    
 -	    public static final ResourceOperationCode PULSE_DASHBOARD = new ResourceOperationCode(ResourceConstants.PULSE_DASHBOARD, OP_PULSE_DASHBOARD);
 -	    public static final ResourceOperationCode PULSE_DATABROWSER = new ResourceOperationCode(ResourceConstants.PULSE_DATABROWSER, OP_PULSE_DATABROWSER);
 -	    public static final ResourceOperationCode PULSE_WEBGFSH = new ResourceOperationCode(ResourceConstants.PULSE_WEBGFSH, OP_PULSE_WEBGFSH);
 -	    public static final ResourceOperationCode PULSE_ADMIN_V1 = new ResourceOperationCode(ResourceConstants.PULSE_ADMIN_V1, OP_PULSE_ADMIN_V1);
 -	    
 -	    public static final ResourceOperationCode ADMIN_DS = new ResourceOperationCode(ResourceConstants.ADMIN_DS, OP_ADMIN_DS,
 -	    		new ResourceOperationCode[]{
 -	          CHANGE_ALERT_LEVEL_DS, 
 -	          BACKUP_DS, 
 -	          REMOVE_DISKSTORE_DS, 
 -	          SHUTDOWN_DS, 
 -	          QUERYDATA_DS, 
 -	    			REBALANCE_DS, 
 -	    			PULSE_DASHBOARD, 
 -	    			PULSE_DATABROWSER, 
 -	    			PULSE_WEBGFSH, 
 -	    			PULSE_ADMIN_V1
 -	    		});
 -		
 -	    
 -	    private final String name;
 -	    private final byte opCode;
 -	    private final ResourceOperationCode[] children;
 -	    
 -	    private ResourceOperationCode(String name, byte opCode) {
 -	      this.name = name;
 -	      this.opCode = opCode;
 -	      VALUES[opCode] = this;
 -	      OperationNameMap.put(name, this);
 -	      this.children = null;
 -	    }
 -	    
 -	    private ResourceOperationCode(String name, byte opCode, ResourceOperationCode[] children) {
 -		      this.name = name;
 -		      this.opCode = opCode;
 -		      VALUES[opCode] = this;
 -		      OperationNameMap.put(name, this);
 -		      this.children = children;
 -		}
 -	    
 -	    
 -	    
 -	    public ResourceOperationCode[] getChildren() {
 -        return children;
++  
++  private boolean isPostOperation=false;
++  private Object opResult = null;
++  
++  public static class ResourceOperationCode {
++    
++    private static final int OP_ALTER_REGION = 1;
++    private static final int OP_ALTER_RUNTIME = 2;
++    private static final int OP_BACKUP_DISKSTORE = 3;
++    private static final int OP_CHANGE_ALERT_LEVEL = 4;
++    private static final int OP_CLOSE_DURABLE_CLIENT = 5;
++    private static final int OP_CLOSE_DURABLE_CQ = 6;
++    private static final int OP_COMPACT_DISKSTORE = 7;
++    private static final int OP_CONFIGURE_PDX = 8;
++    private static final int OP_CREATE_AEQ = 9;
++    private static final int OP_CREATE_DISKSTORE = 10;
++    private static final int OP_CREATE_GW_RECEIVER = 11;
++    private static final int OP_CREATE_GW_SENDER = 12;
++    private static final int OP_CREATE_INDEX = 13;
++    private static final int OP_CREATE_REGION = 14;
++    private static final int OP_DEPLOY = 15;
++    private static final int OP_DESTROY_DISKSTORE = 16;
++    private static final int OP_DESTROY_FUNCTION = 17;
++    private static final int OP_DESTROY_INDEX = 18;
++    private static final int OP_DESTROY_REGION = 19;
++    private static final int OP_EXECUTE_FUNCTION = 20;
++    private static final int OP_EXPORT_CONFIG = 21;
++    private static final int OP_EXPORT_DATA = 22;
++    private static final int OP_EXPORT_LOGS = 23;
++    private static final int OP_EXPORT_OFFLINE_DISKSTORE = 24;
++    private static final int OP_EXPORT_STACKTRACE = 25;
++    private static final int OP_GC = 26;
++    private static final int OP_GET = 27;
++    private static final int OP_IMPORT_CONFIG = 28;
++    private static final int OP_IMPORT_DATA = 29;
++    private static final int OP_LIST_DS = 30;
++    private static final int OP_LOAD_BALANCE_GW_SENDER = 31;
++    private static final int OP_LOCATE_ENTRY = 32;
++    private static final int OP_NETSTAT = 33;
++    private static final int OP_PAUSE_GW_SENDER = 34;
++    private static final int OP_PUT = 35;
++    private static final int OP_QUERY = 36;
++    private static final int OP_REBALANCE = 37;
++    private static final int OP_REMOVE = 38;
++    private static final int OP_RENAME_PDX = 39;
++    private static final int OP_RESUME_GW_SENDER = 40;
++    private static final int OP_REVOKE_MISSING_DISKSTORE = 41;
++    private static final int OP_SHOW_DEADLOCKS = 42;
++    private static final int OP_SHOW_LOG = 43;
++    private static final int OP_SHOW_METRICS = 44;
++    private static final int OP_SHOW_MISSING_DISKSTORES = 45;
++    private static final int OP_SHOW_SUBSCRIPTION_QUEUE_SIZE = 46;
++    private static final int OP_SHUTDOWN = 47;
++    private static final int OP_STOP_GW_RECEIVER = 48;
++    private static final int OP_STOP_GW_SENDER = 49;
++    private static final int OP_UNDEPLOY = 50;
++    private static final int OP_BACKUP_MEMBERS = 51;
++    private static final int OP_ROLL_DISKSTORE = 52;
++    private static final int OP_FORCE_COMPACTION = 53;
++    private static final int OP_FORCE_ROLL = 54;
++    private static final int OP_FLUSH_DISKSTORE = 55;
++    private static final int OP_START_GW_RECEIVER = 56;
++    private static final int OP_START_GW_SENDER = 57;
++    private static final int OP_BECOME_LOCK_GRANTOR = 58;
++    private static final int OP_START_MANAGER = 59;
++    private static final int OP_STOP_MANAGER = 60;
++    private static final int OP_CREATE_MANAGER = 61;
++    private static final int OP_STOP_CONTINUOUS_QUERY = 62;
++    private static final int OP_SET_DISK_USAGE = 63;
++    private static final int OP_CREATE_HDFS_STORE = 64;
++    private static final int OP_ALTER_HDFS_STORE = 65;
++    private static final int OP_DESTROY_HDFS_STORE = 66;
++
++    private static final int OP_PULSE_DASHBOARD = 92;
++    private static final int OP_PULSE_DATABROWSER = 93;
++    private static final int OP_PULSE_WEBGFSH = 94;
++    private static final int OP_PULSE_ADMIN_V1 = 95;
++    
++    private static final int OP_DATA_READ = 96;
++    private static final int OP_DATA_WRITE = 97;
++    private static final int OP_MONITOR = 98;
++    private static final int OP_ADMIN = 99;
++
++    private static final ResourceOperationCode[] VALUES = new ResourceOperationCode[100];
++    private static final Map<String, ResourceOperationCode> OperationNameMap = new HashMap<String, ResourceOperationCode>();
++      
++    
++    public static final ResourceOperationCode ALTER_REGION  = new ResourceOperationCode(ResourceConstants.ALTER_REGION, OP_ALTER_REGION);
++    public static final ResourceOperationCode ALTER_RUNTIME = new ResourceOperationCode(ResourceConstants.ALTER_RUNTIME, OP_ALTER_RUNTIME);
++    public static final ResourceOperationCode BACKUP_DISKSTORE = new ResourceOperationCode(ResourceConstants.BACKUP_DISKSTORE, OP_BACKUP_DISKSTORE);
++    public static final ResourceOperationCode CHANGE_ALERT_LEVEL = new ResourceOperationCode(ResourceConstants.CHANGE_ALERT_LEVEL, OP_CHANGE_ALERT_LEVEL);
++    public static final ResourceOperationCode CLOSE_DURABLE_CLIENT = new ResourceOperationCode(ResourceConstants.CLOSE_DURABLE_CLIENT, OP_CLOSE_DURABLE_CLIENT);
++    public static final ResourceOperationCode CLOSE_DURABLE_CQ = new ResourceOperationCode(ResourceConstants.CLOSE_DURABLE_CQ, OP_CLOSE_DURABLE_CQ);
++    public static final ResourceOperationCode COMPACT_DISKSTORE = new ResourceOperationCode(ResourceConstants.COMPACT_DISKSTORE, OP_COMPACT_DISKSTORE);
++    public static final ResourceOperationCode CONFIGURE_PDX = new ResourceOperationCode(ResourceConstants.CONFIGURE_PDX, OP_CONFIGURE_PDX);
++    public static final ResourceOperationCode CREATE_AEQ = new ResourceOperationCode(ResourceConstants.CREATE_AEQ, OP_CREATE_AEQ);
++    public static final ResourceOperationCode CREATE_DISKSTORE = new ResourceOperationCode(ResourceConstants.CREATE_DISKSTORE, OP_CREATE_DISKSTORE);
++    public static final ResourceOperationCode CREATE_GW_RECEIVER = new ResourceOperationCode(ResourceConstants.CREATE_GW_RECEIVER, OP_CREATE_GW_RECEIVER);
++    public static final ResourceOperationCode CREATE_GW_SENDER = new ResourceOperationCode(ResourceConstants.CREATE_GW_SENDER, OP_CREATE_GW_SENDER);
++    public static final ResourceOperationCode CREATE_INDEX = new ResourceOperationCode(ResourceConstants.CREATE_INDEX, OP_CREATE_INDEX);
++    public static final ResourceOperationCode CREATE_REGION = new ResourceOperationCode(ResourceConstants.CREATE_REGION, OP_CREATE_REGION);
++    public static final ResourceOperationCode DEPLOY = new ResourceOperationCode(ResourceConstants.DEPLOY, OP_DEPLOY);
++    public static final ResourceOperationCode DESTROY_DISKSTORE = new ResourceOperationCode(ResourceConstants.DESTROY_DISKSTORE, OP_DESTROY_DISKSTORE);
++    public static final ResourceOperationCode DESTROY_FUNCTION = new ResourceOperationCode(ResourceConstants.DESTROY_FUNCTION, OP_DESTROY_FUNCTION);
++    public static final ResourceOperationCode DESTROY_INDEX = new ResourceOperationCode(ResourceConstants.DESTROY_INDEX, OP_DESTROY_INDEX);
++    public static final ResourceOperationCode DESTROY_REGION = new ResourceOperationCode(ResourceConstants.DESTROY_REGION, OP_DESTROY_REGION);
++    public static final ResourceOperationCode EXECUTE_FUNCTION = new ResourceOperationCode(ResourceConstants.EXECUTE_FUNCTION, OP_EXECUTE_FUNCTION);
++    public static final ResourceOperationCode EXPORT_CONFIG = new ResourceOperationCode(ResourceConstants.EXPORT_CONFIG, OP_EXPORT_CONFIG);
++    public static final ResourceOperationCode EXPORT_DATA = new ResourceOperationCode(ResourceConstants.EXPORT_DATA, OP_EXPORT_DATA);
++    public static final ResourceOperationCode EXPORT_LOGS = new ResourceOperationCode(ResourceConstants.EXPORT_LOGS, OP_EXPORT_LOGS);
++    public static final ResourceOperationCode EXPORT_OFFLINE_DISKSTORE = new ResourceOperationCode(ResourceConstants.EXPORT_OFFLINE_DISKSTORE, OP_EXPORT_OFFLINE_DISKSTORE);
++    public static final ResourceOperationCode EXPORT_STACKTRACE = new ResourceOperationCode(ResourceConstants.EXPORT_STACKTRACE, OP_EXPORT_STACKTRACE);
++    public static final ResourceOperationCode GC = new ResourceOperationCode(ResourceConstants.GC, OP_GC);
++    public static final ResourceOperationCode GET = new ResourceOperationCode(ResourceConstants.GET, OP_GET);
++    public static final ResourceOperationCode IMPORT_CONFIG = new ResourceOperationCode(ResourceConstants.IMPORT_CONFIG, OP_IMPORT_CONFIG);
++    public static final ResourceOperationCode IMPORT_DATA = new ResourceOperationCode(ResourceConstants.IMPORT_DATA, OP_IMPORT_DATA);
++    public static final ResourceOperationCode LIST_DS = new ResourceOperationCode(ResourceConstants.LIST_DS, OP_LIST_DS);
++    public static final ResourceOperationCode LOAD_BALANCE_GW_SENDER = new ResourceOperationCode(ResourceConstants.LOAD_BALANCE_GW_SENDER, OP_LOAD_BALANCE_GW_SENDER);
++    public static final ResourceOperationCode LOCATE_ENTRY = new ResourceOperationCode(ResourceConstants.LOCATE_ENTRY, OP_LOCATE_ENTRY);
++    public static final ResourceOperationCode NETSTAT = new ResourceOperationCode(ResourceConstants.NETSTAT, OP_NETSTAT);
++    public static final ResourceOperationCode PAUSE_GW_SENDER = new ResourceOperationCode(ResourceConstants.PAUSE_GW_SENDER, OP_PAUSE_GW_SENDER);
++    public static final ResourceOperationCode PUT = new ResourceOperationCode(ResourceConstants.PUT, OP_PUT);
++    public static final ResourceOperationCode QUERY = new ResourceOperationCode(ResourceConstants.QUERY, OP_QUERY);
++    public static final ResourceOperationCode REBALANCE = new ResourceOperationCode(ResourceConstants.REBALANCE, OP_REBALANCE);
++    public static final ResourceOperationCode REMOVE = new ResourceOperationCode(ResourceConstants.REMOVE, OP_REMOVE);
++    public static final ResourceOperationCode RENAME_PDX = new ResourceOperationCode(ResourceConstants.RENAME_PDX, OP_RENAME_PDX);
++    public static final ResourceOperationCode RESUME_GW_SENDER = new ResourceOperationCode(ResourceConstants.RESUME_GW_SENDER, OP_RESUME_GW_SENDER);
++    public static final ResourceOperationCode REVOKE_MISSING_DISKSTORE = new ResourceOperationCode(ResourceConstants.REVOKE_MISSING_DISKSTORE, OP_REVOKE_MISSING_DISKSTORE);
++    public static final ResourceOperationCode SHOW_DEADLOCKS = new ResourceOperationCode(ResourceConstants.SHOW_DEADLOCKS, OP_SHOW_DEADLOCKS);
++    public static final ResourceOperationCode SHOW_LOG = new ResourceOperationCode(ResourceConstants.SHOW_LOG, OP_SHOW_LOG);
++    public static final ResourceOperationCode SHOW_METRICS = new ResourceOperationCode(ResourceConstants.SHOW_METRICS, OP_SHOW_METRICS);
++    public static final ResourceOperationCode SHOW_MISSING_DISKSTORES = new ResourceOperationCode(ResourceConstants.SHOW_MISSING_DISKSTORES, OP_SHOW_MISSING_DISKSTORES);
++    public static final ResourceOperationCode SHOW_SUBSCRIPTION_QUEUE_SIZE = new ResourceOperationCode(ResourceConstants.SHOW_SUBSCRIPTION_QUEUE_SIZE, OP_SHOW_SUBSCRIPTION_QUEUE_SIZE);
++    public static final ResourceOperationCode SHUTDOWN = new ResourceOperationCode(ResourceConstants.SHUTDOWN, OP_SHUTDOWN);
++    public static final ResourceOperationCode STOP_GW_RECEIVER = new ResourceOperationCode(ResourceConstants.STOP_GW_RECEIVER, OP_STOP_GW_RECEIVER);
++    public static final ResourceOperationCode STOP_GW_SENDER = new ResourceOperationCode(ResourceConstants.STOP_GW_SENDER, OP_STOP_GW_SENDER);
++    public static final ResourceOperationCode UNDEPLOY = new ResourceOperationCode(ResourceConstants.UNDEPLOY, OP_UNDEPLOY);
++    public static final ResourceOperationCode BACKUP_MEMBERS = new ResourceOperationCode(ResourceConstants.BACKUP_MEMBERS, OP_BACKUP_MEMBERS);
++    public static final ResourceOperationCode ROLL_DISKSTORE = new ResourceOperationCode(ResourceConstants.ROLL_DISKSTORE, OP_ROLL_DISKSTORE);
++    public static final ResourceOperationCode FORCE_COMPACTION = new ResourceOperationCode(ResourceConstants.FORCE_COMPACTION, OP_FORCE_COMPACTION);
++    public static final ResourceOperationCode FORCE_ROLL = new ResourceOperationCode(ResourceConstants.FORCE_ROLL, OP_FORCE_ROLL);
++    public static final ResourceOperationCode FLUSH_DISKSTORE = new ResourceOperationCode(ResourceConstants.FLUSH_DISKSTORE, OP_FLUSH_DISKSTORE);
++    public static final ResourceOperationCode START_GW_RECEIVER = new ResourceOperationCode(ResourceConstants.START_GW_RECEIVER, OP_START_GW_RECEIVER);
++    public static final ResourceOperationCode START_GW_SENDER = new ResourceOperationCode(ResourceConstants.START_GW_SENDER, OP_START_GW_SENDER);
++    public static final ResourceOperationCode BECOME_LOCK_GRANTOR = new ResourceOperationCode(ResourceConstants.BECOME_LOCK_GRANTOR, OP_BECOME_LOCK_GRANTOR);
++    public static final ResourceOperationCode START_MANAGER = new ResourceOperationCode(ResourceConstants.START_MANAGER, OP_START_MANAGER);
++    public static final ResourceOperationCode STOP_MANAGER = new ResourceOperationCode(ResourceConstants.STOP_MANAGER, OP_STOP_MANAGER);
++    public static final ResourceOperationCode CREATE_MANAGER = new ResourceOperationCode(ResourceConstants.CREATE_MANAGER, OP_CREATE_MANAGER);
++    public static final ResourceOperationCode STOP_CONTINUOUS_QUERY = new ResourceOperationCode(ResourceConstants.STOP_CONTINUOUS_QUERY, OP_STOP_CONTINUOUS_QUERY);
++    public static final ResourceOperationCode SET_DISK_USAGE = new ResourceOperationCode(ResourceConstants.SET_DISK_USAGE, OP_SET_DISK_USAGE);
++    public static final ResourceOperationCode CREATE_HDFS_STORE = new ResourceOperationCode(ResourceConstants.CREATE_HDFS_STORE, OP_CREATE_HDFS_STORE);
++    public static final ResourceOperationCode ALTER_HDFS_STORE = new ResourceOperationCode(ResourceConstants.ALTER_HDFS_STORE, OP_ALTER_HDFS_STORE);
++    public static final ResourceOperationCode DESTROY_HDFS_STORE = new ResourceOperationCode(ResourceConstants.DESTROY_HDFS_STORE, OP_DESTROY_HDFS_STORE);
++    
++
++    public static final ResourceOperationCode PULSE_DASHBOARD = new ResourceOperationCode(
++        ResourceConstants.PULSE_DASHBOARD, OP_PULSE_DASHBOARD);
++    public static final ResourceOperationCode PULSE_DATABROWSER = new ResourceOperationCode(
++        ResourceConstants.PULSE_DATABROWSER, OP_PULSE_DATABROWSER);
++    public static final ResourceOperationCode PULSE_WEBGFSH = new ResourceOperationCode(
++        ResourceConstants.PULSE_WEBGFSH, OP_PULSE_WEBGFSH);
++    public static final ResourceOperationCode PULSE_ADMIN_V1 = new ResourceOperationCode(
++        ResourceConstants.PULSE_ADMIN_V1, OP_PULSE_ADMIN_V1);
++      
++    public static final ResourceOperationCode DATA_READ = new ResourceOperationCode(ResourceConstants.DATA_READ, 
++        OP_DATA_READ,
++        new ResourceOperationCode[]{ 
++          LIST_DS, 
++          PULSE_DASHBOARD
++    });
++    
++    public static final ResourceOperationCode DATA_WRITE = new ResourceOperationCode(ResourceConstants.DATA_WRITE,
++        OP_DATA_WRITE,
++        new ResourceOperationCode[]{ 
++          DATA_READ, 
++          QUERY, 
++          BECOME_LOCK_GRANTOR, 
++          PUT, 
++          REMOVE, 
++          EXECUTE_FUNCTION, 
++          PULSE_DATABROWSER
++    });
++    
++    public static final ResourceOperationCode MONITOR = new ResourceOperationCode(ResourceConstants.MONITOR,
++        OP_MONITOR,
++        new ResourceOperationCode[] {
++          DATA_READ, 
++          EXPORT_CONFIG,
++          EXPORT_DATA,
++          EXPORT_LOGS,
++          EXPORT_OFFLINE_DISKSTORE,
++          EXPORT_STACKTRACE,
++          SHOW_DEADLOCKS,
++          SHOW_LOG,
++          SHOW_METRICS,
++          SHOW_MISSING_DISKSTORES,
++          SHOW_SUBSCRIPTION_QUEUE_SIZE       
++    });
++    
++    public static final ResourceOperationCode ADMIN = new ResourceOperationCode(ResourceConstants.ADMIN,
++        OP_ADMIN,
++        new ResourceOperationCode[] {
++          DATA_WRITE,
++          MONITOR,
++          ALTER_REGION,
++          ALTER_RUNTIME,
++          BACKUP_DISKSTORE,
++          CHANGE_ALERT_LEVEL,
++          CLOSE_DURABLE_CLIENT,
++          CLOSE_DURABLE_CQ,
++          COMPACT_DISKSTORE,
++          CONFIGURE_PDX,
++          CREATE_AEQ,
++          CREATE_DISKSTORE,
++          CREATE_GW_RECEIVER,
++          CREATE_GW_SENDER,
++          CREATE_INDEX,
++          CREATE_REGION,
++          DEPLOY,
++          DESTROY_DISKSTORE,
++          DESTROY_FUNCTION,
++          DESTROY_INDEX,
++          DESTROY_REGION,
++          GC,
++          GET,
++          IMPORT_CONFIG,
++          IMPORT_DATA,
++          LIST_DS,
++          LOAD_BALANCE_GW_SENDER,
++          LOCATE_ENTRY,
++          NETSTAT,
++          PAUSE_GW_SENDER,
++          REBALANCE,
++          RENAME_PDX,
++          RESUME_GW_SENDER,
++          REVOKE_MISSING_DISKSTORE,
++          SHUTDOWN,
++          STOP_GW_RECEIVER,
++          STOP_GW_SENDER,
++          UNDEPLOY,
++          BACKUP_MEMBERS,
++          ROLL_DISKSTORE,
++          FORCE_COMPACTION,
++          FORCE_ROLL,
++          FLUSH_DISKSTORE,
++          START_GW_RECEIVER,
++          START_GW_SENDER,
++          START_MANAGER,
++          STOP_MANAGER,
++          CREATE_MANAGER,
++          STOP_CONTINUOUS_QUERY,
++          SET_DISK_USAGE,
++          PULSE_WEBGFSH,
++          PULSE_ADMIN_V1
++    });
++    
++      
++    private final String name;
++    private final int opCode;
++    private final List<ResourceOperationCode> children;    
++
++    private ResourceOperationCode(String name, int opCode) {
++      this.name = name;
++      this.opCode = opCode;
++      VALUES[opCode] = this;
++      OperationNameMap.put(name, this);
++      this.children = null;
++    }
++
++    private ResourceOperationCode(String name, int opCode, ResourceOperationCode[] children) {
++      this.name = name;
++      this.opCode = opCode;
++      VALUES[opCode] = this;
++      OperationNameMap.put(name, this);      
++      this.children = new ArrayList<ResourceOperationCode>();
++      for(ResourceOperationCode code : children) {
++        this.children.add(code);
++      }
++    }
++      
++    public List<ResourceOperationCode> getChildren() {
++      return Collections.unmodifiableList(children);
++    }
++    
++    public void addChild(ResourceOperationCode code) {
++      this.children.add(code);
++    }
++
++    /**
++     * Returns the <code>OperationCode</code> represented by specified int.
++     */
++    public static ResourceOperationCode fromOrdinal(int opCode) {
++      return VALUES[opCode];
++    }
++
++    /**
++     * Returns the <code>OperationCode</code> represented by specified string.
++     */
++    public static ResourceOperationCode parse(String operationName) {
++      return OperationNameMap.get(operationName);
++    }
++
++    /**
++     * Returns the int representing this operation code.
++     * 
++     * @return a int representing this operation.
++     */
++    public int toOrdinal() {
++      return this.opCode;
++    }
++
++    /**
++     * Returns a string representation for this operation.
++     * 
++     * @return the name of this operation.
++     */
++    @Override
++    final public String toString() {
++      return this.name;
++    }
++
++    /**
++     * Indicates whether other object is same as this one.
++     * 
++     * @return true if other object is same as this one.
++     */
++    @Override
++    final public boolean equals(final Object obj) {
++      if (obj == this) {
++        return true;
+       }
++      if (!(obj instanceof ResourceOperationCode)) {
++        return false;
++      }
++      final ResourceOperationCode other = (ResourceOperationCode) obj;
++      return (other.opCode == this.opCode);
++    }
++
++    /**
++     * Indicates whether other <code>OperationCode</code> is same as this one.
++     * 
++     * @return true if other <code>OperationCode</code> is same as this one.
++     */
++    final public boolean equals(final ResourceOperationCode opCode) {
++      return (opCode != null && opCode.opCode == this.opCode);
++    }
++
++    /**
++     * Returns a hash code value for this <code>OperationCode</code> which is
++     * the same as the int representing its operation type.
++     * 
++     * @return the hashCode of this operation.
++     */
++    @Override
++    final public int hashCode() {
++      return this.opCode;
++    }
++    
++    /**
++     * Returns true if passed operation is same or any one of its
++     * children
++     * 
++     * @param op
++     * @return true if  <code>OperationCode</code> matches 
++     */
++    public boolean allowedOp(ResourceOperationCode op) {
++      if(this.equals(op))
++        return true;
++      else {
++        if(children!=null) {
++          for(ResourceOperationCode child : children) {
++            if(child.allowedOp(op))
++              return true;
++          }
++        }
++      }
++      return false;
++    }
++  }
++
++  public abstract ResourceOperationCode getResourceOperationCode();
++   
++  @Override
++  public boolean isClientUpdate() {
++    return false;
++  }
++  
++  @Override
++  public boolean isPostOperation() {
++    return isPostOperation;
++  }
++
++  public void setPostOperationResult(Object result) {
++    this.isPostOperation = true;
++    this.opResult = result;
++  }
++  
++  public Object getOperationResult() {
++    return this.opResult;
++  }
+ 
 -      /**
 -	     * Returns the <code>OperationCode</code> represented by specified byte.
 -	     */
 -	    public static ResourceOperationCode fromOrdinal(byte opCode) {
 -	      return VALUES[opCode];
 -	    }
 -
 -	    /**
 -	     * Returns the <code>OperationCode</code> represented by specified string.
 -	     */
 -	    public static ResourceOperationCode parse(String operationName) {
 -	      return (ResourceOperationCode)OperationNameMap.get(operationName);
 -	    }
 -
 -	    /**
 -	     * Returns the byte representing this operation code.
 -	     * 
 -	     * @return a byte representing this operation.
 -	     */
 -	    public byte toOrdinal() {
 -	      return this.opCode;
 -	    }
 -
 -	    /**
 -	     * Returns a string representation for this operation.
 -	     * 
 -	     * @return the name of this operation.
 -	     */
 -	    @Override
 -	    final public String toString() {
 -	      return this.name;
 -	    }
 -
 -	    /**
 -	     * Indicates whether other object is same as this one.
 -	     * 
 -	     * @return true if other object is same as this one.
 -	     */
 -	    @Override
 -	    final public boolean equals(final Object obj) {
 -	      if (obj == this) {
 -	        return true;
 -	      }
 -	      if (!(obj instanceof ResourceOperationCode)) {
 -	        return false;
 -	      }
 -	      final ResourceOperationCode other = (ResourceOperationCode)obj;
 -	      return (other.opCode == this.opCode);
 -	    }
 -
 -	    /**
 -	     * Indicates whether other <code>OperationCode</code> is same as this one.
 -	     * 
 -	     * @return true if other <code>OperationCode</code> is same as this one.
 -	     */
 -	    final public boolean equals(final ResourceOperationCode opCode) {
 -	      return (opCode != null && opCode.opCode == this.opCode);
 -	    }
 -
 -	    /**
 -	     * Returns a hash code value for this <code>OperationCode</code> which is
 -	     * the same as the byte representing its operation type.
 -	     * 
 -	     * @return the hashCode of this operation.
 -	     */
 -	    @Override
 -	    final public int hashCode() {
 -	      return this.opCode;
 -	    }
 -
 -	    
 -	 }
 -	
 -
 -	 public abstract ResourceOperationCode getResourceOperationCode();
 -	 
 -	 /*
 -	@Override
 -	public OperationCode getOperationCode() {
 -		// TODO Auto-generated method stub
 -		return null;
 -	}*/
 -
 -	@Override
 -	public boolean isPostOperation() {
 -		return false;
 -	}
 -
 -}
++}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5c01d5f4/geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/controllers/AbstractCommandsController.java
----------------------------------------------------------------------
diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/controllers/AbstractCommandsController.java
index 0000000,41a890a..47c6b17
mode 000000,100644..100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/controllers/AbstractCommandsController.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/controllers/AbstractCommandsController.java
@@@ -1,0 -1,618 +1,711 @@@
+ /*
+  * 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.web.controllers;
+ 
++import static com.gemstone.gemfire.management.internal.security.ResourceConstants.ACCESS_DENIED_MESSAGE;
++
+ import java.io.PrintWriter;
+ import java.io.StringWriter;
+ import java.lang.management.ManagementFactory;
+ import java.net.URI;
++import java.security.Principal;
+ import java.util.Collection;
+ import java.util.HashMap;
+ import java.util.Iterator;
+ import java.util.Map;
++import java.util.Properties;
+ import java.util.Set;
++
+ import javax.management.JMX;
+ import javax.management.MBeanServer;
+ import javax.management.MalformedObjectNameException;
+ import javax.management.ObjectName;
+ import javax.management.Query;
+ import javax.management.QueryExp;
++import javax.management.remote.JMXPrincipal;
++import javax.security.auth.Subject;
+ 
++import com.gemstone.gemfire.GemFireConfigException;
++import com.gemstone.gemfire.cache.CacheFactory;
++import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+ import com.gemstone.gemfire.internal.lang.StringUtils;
+ import com.gemstone.gemfire.internal.logging.LogService;
+ import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
+ import com.gemstone.gemfire.internal.util.ArrayUtils;
+ import com.gemstone.gemfire.management.DistributedSystemMXBean;
++import com.gemstone.gemfire.management.ManagementService;
+ import com.gemstone.gemfire.management.MemberMXBean;
+ import com.gemstone.gemfire.management.internal.MBeanJMXAdapter;
+ import com.gemstone.gemfire.management.internal.ManagementConstants;
++import com.gemstone.gemfire.management.internal.SystemManagementService;
+ 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.CLIOperationContext;
++import com.gemstone.gemfire.management.internal.security.MBeanServerWrapper;
++import com.gemstone.gemfire.management.internal.security.ResourceConstants;
++import com.gemstone.gemfire.management.internal.security.ResourceOperationContext;
+ import com.gemstone.gemfire.management.internal.web.controllers.support.EnvironmentVariablesHandlerInterceptor;
+ import com.gemstone.gemfire.management.internal.web.controllers.support.MemberMXBeanAdapter;
+ import com.gemstone.gemfire.management.internal.web.util.UriUtils;
++import com.gemstone.gemfire.security.AccessControl;
++import com.gemstone.gemfire.security.Authenticator;
+ 
+ import org.apache.logging.log4j.Logger;
+ import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
+ import org.springframework.http.HttpStatus;
+ import org.springframework.http.ResponseEntity;
+ import org.springframework.web.bind.WebDataBinder;
+ import org.springframework.web.bind.annotation.ExceptionHandler;
+ import org.springframework.web.bind.annotation.InitBinder;
+ import org.springframework.web.bind.annotation.ResponseBody;
++import org.springframework.web.bind.annotation.ResponseStatus;
+ import org.springframework.web.context.request.WebRequest;
+ import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
+ import org.springframework.web.util.UriComponentsBuilder;
+ 
+ /**
+  * The AbstractCommandsController class is the abstract base class encapsulating common functionality across all
+  * Management Controller classes that expose REST API web service endpoints (URLs/URIs) for GemFire shell (Gfsh)
+  * commands.
+  * 
+  * @author John Blum
+  * @see com.gemstone.gemfire.management.MemberMXBean
+  * @see com.gemstone.gemfire.management.internal.cli.shell.Gfsh
+  * @see org.springframework.stereotype.Controller
+  * @see org.springframework.web.bind.annotation.ExceptionHandler
+  * @see org.springframework.web.bind.annotation.InitBinder
+  * @since 8.0
+  */
+ @SuppressWarnings("unused")
+ public abstract class AbstractCommandsController {
+ 
+   private static final Logger logger = LogService.getLogger();
+   
+   protected static final String DEFAULT_ENCODING = UriUtils.DEFAULT_ENCODING;
+   protected static final String REST_API_VERSION = "/v1";
+ 
+   private MemberMXBean managingMemberMXBeanProxy;
++  
++
++  
++  private Class accessControlKlass;
++  
++  private GemFireCacheImpl cache;
++  
++  // Convert a predefined exception to an HTTP Status code
++  @ResponseStatus(value=HttpStatus.UNAUTHORIZED, reason="Not authenticated")  // 401
++  @ExceptionHandler(com.gemstone.gemfire.security.AuthenticationFailedException.class)
++  public void authenticate() {
++    
++  }
++  
++  // Convert a predefined exception to an HTTP Status code
++  @ResponseStatus(value=HttpStatus.FORBIDDEN, reason="Access Denied")  // 403
++  @ExceptionHandler(java.lang.SecurityException.class)
++  public void authorize() {
++   
++  }
++  
+ 
+   /**
+    * Asserts the argument is valid, as determined by the caller passing the result of an evaluated expression to this
+    * assertion.
+    * 
+    * @param validArg a boolean value indicating the evaluation of the expression validating the argument.
+    * @param message a String value used as the message when constructing an IllegalArgumentException.
+    * @param args Object arguments used to populate placeholder's in the message.
+    * @throws IllegalArgumentException if the argument is not valid.
+    * @see java.lang.String#format(String, Object...)
+    */
+   protected static void assertArgument(final boolean validArg, final String message, final Object... args) {
+     if (!validArg) {
+       throw new IllegalArgumentException(String.format(message, args));
+     }
+   }
+ 
+   /**
+    * Asserts the Object reference is not null!
+    * 
+    * @param obj the reference to the Object.
+    * @param message the String value used as the message when constructing and throwing a NullPointerException.
+    * @param args Object arguments used to populate placeholder's in the message.
+    * @throws NullPointerException if the Object reference is null.
+    * @see java.lang.String#format(String, Object...)
+    */
+   protected static void assertNotNull(final Object obj, final String message, final Object... args) {
+     if (obj == null) {
+       throw new NullPointerException(String.format(message, args));
+     }
+   }
+ 
+   /**
+    * Asserts whether state, based on the evaluation of a conditional expression, passed to this assertion is valid.
+    * 
+    * @param validState a boolean value indicating the evaluation of the expression from which the conditional state
+    * is based.  For example, a caller might use an expression of the form (initableObj.isInitialized()).
+    * @param message a String values used as the message when constructing an IllegalStateException.
+    * @param args Object arguments used to populate placeholder's in the message.
+    * @throws IllegalStateException if the conditional state is not valid.
+    * @see java.lang.String#format(String, Object...)
+    */
+   protected static void assertState(final boolean validState, final String message, final Object... args) {
+     if (!validState) {
+       throw new IllegalStateException(String.format(message, args));
+     }
+   }
+ 
+   /**
+    * Decodes the encoded String value using the default encoding UTF-8.  It is assumed the String value was encoded
+    * with the URLEncoder using the UTF-8 encoding.  This method handles UnsupportedEncodingException by just returning
+    * the encodedValue.
+    * 
+    * @param encodedValue the encoded String value to decode.
+    * @return the decoded value of the String or encodedValue if the UTF-8 encoding is unsupported.
+    * @see com.gemstone.gemfire.management.internal.web.util.UriUtils#decode(String)
+    */
+   protected static String decode(final String encodedValue) {
+     return UriUtils.decode(encodedValue);
+   }
+ 
+   /**
+    * Decodes the encoded String value using the specified encoding (such as UTF-8).  It is assumed the String value
+    * was encoded with the URLEncoder using the specified encoding.  This method handles UnsupportedEncodingException
+    * by just returning the encodedValue.
+    * 
+    * @param encodedValue a String value encoded in the encoding.
+    * @param encoding a String value specifying the encoding.
+    * @return the decoded value of the String or encodedValue if the specified encoding is unsupported.
+    * @see com.gemstone.gemfire.management.internal.web.util.UriUtils#decode(String, String)
+    */
+   protected static String decode(final String encodedValue, final String encoding) {
+     return UriUtils.decode(encodedValue, encoding);
+   }
+ 
+   /**
+    * Gets the specified value if not null or empty, otherwise returns the default value.
+    * 
+    * @param value the String value being evaluated for having value (not null and not empty).
+    * @param defaultValue the default String value returned if 'value' has no value.
+    * @return 'value' if not null or empty, otherwise returns the default value.
+    * @see #hasValue(String)
+    */
+   protected static String defaultIfNoValue(final String value, final String defaultValue) {
+     return (hasValue(value) ? value : defaultValue);
+   }
+ 
+   /**
+    * Encodes the String value using the default encoding UTF-8.
+    * 
+    * @param value the String value to encode.
+    * @return an encoded value of the String using the default encoding UTF-8 or value if the UTF-8 encoding
+    * is unsupported.
+    * @see com.gemstone.gemfire.management.internal.web.util.UriUtils#encode(String)
+    */
+   protected static String encode(final String value) {
+     return UriUtils.encode(value);
+   }
+ 
+   /**
+    * Encodes the String value using the specified encoding (such as UTF-8).
+    * 
+    * @param value the String value to encode.
+    * @param encoding a String value indicating the encoding.
+    * @return an encoded value of the String using the specified encoding or value if the specified encoding
+    * is unsupported.
+    * @see com.gemstone.gemfire.management.internal.web.util.UriUtils#encode(String, String)
+    */
+   protected static String encode(final String value, final String encoding) {
+     return UriUtils.encode(value, encoding);
+   }
+ 
+   /**
+    * Determines whether the specified Object has value, which is determined by a non-null Object reference.
+    * 
+    * @param value the Object value being evaluated for value.
+    * @return a boolean value indicating whether the specified Object has value.
+    * @see java.lang.Object
+    */
+   protected static boolean hasValue(final Object value) {
+     return (value instanceof String[] ? hasValue((String[]) value)
+       : (value instanceof String ? hasValue((String) value) : value != null));
+   }
+ 
+   /**
+    * Determines whether the specified String has value, determined by whether the String is non-null, not empty
+    * and not blank.
+    * 
+    * @param value the String being evaluated for value.
+    * @return a boolean indicating whether the specified String has value or not.
+    * @see java.lang.String
+    */
+   protected static boolean hasValue(final String value) {
+     return !StringUtils.isBlank(value);
+   }
+ 
+   /**
+    * Determines whether the specified String array has any value, which is determined by a non-null String array
+    * reference along with containing at least 1 non-null, not empty and not blank element.
+    * 
+    * @param array an String array being evaluated for value.
+    * @return a boolean indicating whether the specified String array has any value.
+    * @see #hasValue(String)
+    * @see java.lang.String
+    */
+   protected static boolean hasValue(final String[] array) {
+     if (array != null && array.length > 0) {
+       for (final String element : array) {
+         if (hasValue(element)) {
+           return true;
+         }
+       }
+     }
+ 
+     return false;
+   }
+ 
+   /**
+    * Writes the stack trace of the Throwable to a String.
+    * 
+    * @param t a Throwable object who's stack trace will be written to a String.
+    * @return a String containing the stack trace of the Throwable.
+    * @see java.io.StringWriter
+    * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
+    */
+   protected static String printStackTrace(final Throwable t) {
+     final StringWriter stackTraceWriter = new StringWriter();
+     t.printStackTrace(new PrintWriter(stackTraceWriter));
+     return stackTraceWriter.toString();
+   }
+ 
+   /**
+    * Converts the URI relative path to an absolute path based on the Servlet context information.
+    * 
+    * @param path the URI relative path to append to the Servlet context path.
+    * @param scheme the scheme to use for the URI
+    * @return a URI constructed with all component path information.
+    * @see java.net.URI
+    * @see org.springframework.web.servlet.support.ServletUriComponentsBuilder
+    */
+   protected /*static*/ URI toUri(final String path, final String scheme) {
+     return ServletUriComponentsBuilder.fromCurrentContextPath()
+         .path(REST_API_VERSION).path(path).scheme(scheme).build().toUri();
+   }
+ 
+   /**
+    * Handles any Exception thrown by a REST API web service endpoint, HTTP request handler method during the invocation
+    * and processing of a command.
+    * 
+    * @param cause the Exception causing the error.
+    * @return a ResponseEntity with an appropriate HTTP status code (500 - Internal Server Error) and HTTP response body
+    * containing the stack trace of the Exception.
+    * @see java.lang.Exception
+    * @see org.springframework.http.ResponseEntity
+    * @see org.springframework.web.bind.annotation.ExceptionHandler
+    * @see org.springframework.web.bind.annotation.ResponseBody
+    */
+   @ExceptionHandler(Exception.class)
+   @ResponseBody
+   public ResponseEntity<String> handleException(final Exception cause) {
+     final String stackTrace = printStackTrace(cause);
+     logger.fatal(stackTrace);
+     return new ResponseEntity<String>(stackTrace, HttpStatus.INTERNAL_SERVER_ERROR);
+   }
+ 
+   /**
+    * Initializes data bindings for various HTTP request handler method parameter Java class types.
+    * 
+    * @param dataBinder the DataBinder implementation used for Web transactions.
+    * @see org.springframework.web.bind.WebDataBinder
+    * @see org.springframework.web.bind.annotation.InitBinder
+    */
+   @InitBinder
+   public void initBinder(final WebDataBinder dataBinder) {
+     dataBinder.registerCustomEditor(String[].class, new StringArrayPropertyEditor(
+       StringArrayPropertyEditor.DEFAULT_SEPARATOR, false));
+   }
+ 
+   /**
+    * Logs the client's HTTP (web) request including details of the HTTP headers and request parameters along with the
+    * web request context and description.
+    * 
+    * @param request the object encapsulating the details of the client's HTTP (web) request.
+    * @see org.springframework.web.context.request.WebRequest
+    */
+   protected void logRequest(final WebRequest request) {
+     if (request != null) {
+       final Map<String, String> headers = new HashMap<java.lang.String, java.lang.String>();
+ 
+       for (Iterator<String> it = request.getHeaderNames(); it.hasNext(); ) {
+         final String headerName = it.next();
+         headers.put(headerName, ArrayUtils.toString((Object[]) request.getHeaderValues(headerName)));
+       }
+ 
+       final Map<String, String> parameters = new HashMap<String, String>(request.getParameterMap().size());
+ 
+       for (Iterator<String> it = request.getParameterNames(); it.hasNext(); ) {
+         final String parameterName = it.next();
+         parameters.put(parameterName, ArrayUtils.toString((Object[]) request.getParameterValues(parameterName)));
+       }
+ 
+       logger.info("HTTP-request: description ({}), context ({}), headers ({}), parameters ({})",
+         request.getDescription(false), request.getContextPath(), headers, parameters);
+     }
+   }
+   
+   /**
+    * Gets a reference to the platform MBeanServer running in this JVM process.  The MBeanServer instance constitutes
+    * a connection to the MBeanServer.
+    * 
+    * @return a reference to the platform MBeanServer for this JVM process.
+    * @see java.lang.management.ManagementFactory#getPlatformMBeanServer()
+    * @see javax.management.MBeanServer
+    */
+   protected MBeanServer getMBeanServer() {
+     return ManagementFactory.getPlatformMBeanServer();
+   }
+ 
+   /**
+    * Gets the MemberMXBean from the JVM Platform MBeanServer for the specified member, identified by name or ID
+    * in the GemFire cluster.
+    * 
+    * @param memberNameId a String indicating the name or ID of the GemFire member.
+    * @return a proxy to the GemFire member's MemberMXBean.
+    * @throws IllegalStateException if no MemberMXBean could be found for GemFire member with ID or name.
+    * @throws RuntimeException wrapping the MalformedObjectNameException if the ObjectName pattern is malformed.
+    * @see #getMBeanServer()
+    * @see #isMemberMXBeanFound(java.util.Collection)
+    * @see javax.management.ObjectName
+    * @see javax.management.QueryExp
+    * @see javax.management.MBeanServer#queryNames(javax.management.ObjectName, javax.management.QueryExp)
+    * @see javax.management.JMX#newMXBeanProxy(javax.management.MBeanServerConnection, javax.management.ObjectName, Class)
+    * @see com.gemstone.gemfire.management.MemberMXBean
+    */
+   protected MemberMXBean getMemberMXBean(final String memberNameId) {
+     try {
+       final MBeanServer connection = getMBeanServer();
+ 
+       final String objectNamePattern = ManagementConstants.OBJECTNAME__PREFIX.concat("type=Member,*");
+ 
+       // NOTE throws a MalformedObjectNameException, but this should not happen since we constructed the ObjectName above
+       final ObjectName objectName = ObjectName.getInstance(objectNamePattern);
+ 
+       final QueryExp query = Query.or(
+         Query.eq(Query.attr("Name"), Query.value(memberNameId)),
+         Query.eq(Query.attr("Id"), Query.value(memberNameId))
+       );
+ 
+       final Set<ObjectName> objectNames = connection.queryNames(objectName, query);
+ 
+       assertState(isMemberMXBeanFound(objectNames),
+         "No MemberMXBean with ObjectName (%1$s) based on Query (%2$s) was found in the Platform MBeanServer for member (%3$s)!",
+           objectName, query, memberNameId);
+ 
+       return JMX.newMXBeanProxy(connection, objectNames.iterator().next(), MemberMXBean.class);
+     }
+     catch (MalformedObjectNameException e) {
+       throw new RuntimeException(e);
+     }
+   }
+ 
+   /**
+    * Determines whether the desired MemberMXBean, identified by name or ID, was found in the platform MBeanServer
+    * of this JVM process.
+    * 
+    * @param objectNames a Collection of ObjectNames possibly referring to the desired MemberMXBean.
+    * @return a boolean value indicating whether the desired MemberMXBean was found.
+    * @see javax.management.ObjectName
+    */
+   private boolean isMemberMXBeanFound(final Collection<ObjectName> objectNames) {
+     return !(objectNames == null || objectNames.isEmpty());
+   }
+ 
+   /**
+    * Lookup operation for the MemberMXBean representing the Manager in the GemFire cluster.  This method gets
+    * an instance fo the Platform MBeanServer for this JVM process and uses it to lookup the MemberMXBean for the
+    * GemFire Manager based on the ObjectName declared in the DistributedSystemMXBean.getManagerObjectName() operation.
+    * 
+    * @return a proxy instance to the MemberMXBean of the GemFire Manager.
+    * @see #getMBeanServer()
+    * @see #createMemberMXBeanForManagerUsingAdapter(javax.management.MBeanServer, javax.management.ObjectName)
+    * @see #createMemberMXBeanForManagerUsingProxy(javax.management.MBeanServer, javax.management.ObjectName)
+    * @see com.gemstone.gemfire.management.DistributedSystemMXBean
+    * @see com.gemstone.gemfire.management.MemberMXBean
+    */
+   protected synchronized MemberMXBean getManagingMemberMXBean() {
+     if (managingMemberMXBeanProxy == null) {
+       final MBeanServer platformMBeanServer = getMBeanServer();
+ 
+       final DistributedSystemMXBean distributedSystemMXBean = JMX.newMXBeanProxy(platformMBeanServer,
+         MBeanJMXAdapter.getDistributedSystemName(), DistributedSystemMXBean.class);
+ 
 -      //managingMemberMXBeanProxy = createMemberMXBeanForManagerUsingAdapter(platformMBeanServer,
 -      //  distributedSystemMXBean.getMemberObjectName());
++      /*managingMemberMXBeanProxy = createMemberMXBeanForManagerUsingAdapter(platformMBeanServer,
++      distributedSystemMXBean.getMemberObjectName());*/
+ 
+       managingMemberMXBeanProxy = createMemberMXBeanForManagerUsingProxy(platformMBeanServer,
+         distributedSystemMXBean.getMemberObjectName());
+     }
+ 
+     return managingMemberMXBeanProxy;
+   }
++  
++  protected synchronized ObjectName getMemberObjectName() {
++    final MBeanServer platformMBeanServer = getMBeanServer();
++
++    final DistributedSystemMXBean distributedSystemMXBean = JMX.newMXBeanProxy(platformMBeanServer,
++        MBeanJMXAdapter.getDistributedSystemName(), DistributedSystemMXBean.class);
++
++    return distributedSystemMXBean.getMemberObjectName();
++  }
+ 
+   /**
+    * Creates an Adapter using the Platform MBeanServer and ObjectName to invoke operations on the GemFire Manager's
+    * MemberMXBean.
+    * 
+    * @param server a reference to this JVM's Platform MBeanServer.
+    * @param managingMemberObjectName the ObjectName of the GemFire Manager's MemberMXBean registered in
+    * the Platform MBeanServer.
+    * @return an Adapter for invoking operations on the GemFire Manager's MemberMXBean.
+    * @see com.gemstone.gemfire.management.internal.web.controllers.AbstractCommandsController.MemberMXBeanProxy
+    * @see #createMemberMXBeanForManagerUsingProxy(javax.management.MBeanServer, javax.management.ObjectName)
+    */
+   private MemberMXBean createMemberMXBeanForManagerUsingAdapter(final MBeanServer server, final ObjectName managingMemberObjectName) {
+     return new MemberMXBeanProxy(server, managingMemberObjectName);
+   }
+ 
+   /**
+    * Creates a Proxy using the Platform MBeanServer and ObjectName in order to access attributes and invoke operations
+    * on the GemFire Manager's MemberMXBean.
+    * 
+    * @param server a reference to this JVM's Platform MBeanServer.
+    * @param managingMemberObjectName the ObjectName of the GemFire Manager's MemberMXBean registered in
+    * the Platform MBeanServer.
+    * @return a Proxy for accessing attributes and invoking operations on the GemFire Manager's MemberMXBean.
+    * @see #createMemberMXBeanForManagerUsingAdapter(javax.management.MBeanServer, javax.management.ObjectName)
+    * @see javax.management.JMX#newMXBeanProxy(javax.management.MBeanServerConnection, javax.management.ObjectName, Class)
+    */
+   private MemberMXBean createMemberMXBeanForManagerUsingProxy(final MBeanServer server, final ObjectName managingMemberObjectName) {
+     return JMX.newMXBeanProxy(server, managingMemberObjectName, MemberMXBean.class);
+   }
+ 
+   /**
+    * Gets the environment setup during this HTTP/command request for the current command process execution.
+    * 
+    * @return a mapping of environment variables to values.
+    * @see com.gemstone.gemfire.management.internal.web.controllers.support.EnvironmentVariablesHandlerInterceptor#getEnvironment()
+    */
+   protected Map<String, String> getEnvironment() {
+     final Map<String, String> environment = new HashMap<String, String>();
 -
+     environment.putAll(EnvironmentVariablesHandlerInterceptor.getEnvironment());
+     environment.put(Gfsh.ENV_APP_NAME, Gfsh.GFSH_APP_NAME);
+ 
+     return environment;
+   }
+ 
+   /**
+    * Adds the named option to the command String to be processed if the named option has value or the named option is
+    * present in the HTTP request.
+    * 
+    * @param request the WebRequest object encapsulating the details (headers, request parameters and message body)
+    * of the user HTTP request.
+    * @param command the Gfsh command String to append options and process.
+    * @param optionName the name of the command option.
+    * @param optionValue the value for the named command option.
+    * @see #hasValue(Object)
+    * @see #hasValue(String[])
+    * @see com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder
+    * @see org.springframework.web.context.request.WebRequest
+    */
+   protected void addCommandOption(final WebRequest request,
+                                   final CommandStringBuilder command,
+                                   final String optionName,
+                                   final Object optionValue)
+   {
+     assertNotNull(command, "The command to append options to cannot be null!");
+     assertNotNull(optionName, "The name of the option to add to the command cannot be null!");
+ 
+     if (hasValue(optionValue)) {
+       final String optionValueString = (optionValue instanceof String[] ?
+         StringUtils.concat((String[]) optionValue, StringUtils.COMMA_DELIMITER) : String.valueOf(optionValue));
+       command.addOption(optionName, optionValueString);
+     }
+     else if (request != null && request.getParameterMap().containsKey(optionName)) {
+       command.addOption(optionName);
+     }
+     else {
+       // do nothing!
+     }
+   }
+ 
+   /**
+    * Executes the specified command as entered by the user using the GemFire Shell (Gfsh).  Note, Gfsh performs
+    * validation of the command during parsing before sending the command to the Manager for processing.
+    * 
+    * @param command a String value containing a valid command String as would be entered by the user in Gfsh.
+    * @return a result of the command execution as a String, typically marshalled in JSON to be serialized back to Gfsh.
+    * @see com.gemstone.gemfire.management.internal.cli.shell.Gfsh
+    * @see com.gemstone.gemfire.management.internal.web.controllers.support.EnvironmentVariablesHandlerInterceptor#getEnvironment()
+    * @see #getEnvironment()
+    * @see #processCommand(String, java.util.Map, byte[][])
+    */
+   protected String processCommand(final String command) {
+     return processCommand(command, getEnvironment(), null);
+   }
++  
++  protected String processCommandWithCredentials(final String command, Properties credentials) {
++    if (credentials != null) {
++      EnvironmentVariablesHandlerInterceptor.CREDENTIALS.set(credentials);
++    }
++    return processCommand(command, getEnvironment(), null);
++  }
+ 
+   /**
+    * Executes the specified command as entered by the user using the GemFire Shell (Gfsh).  Note, Gfsh performs
+    * validation of the command during parsing before sending the command to the Manager for processing.
+    * 
+    * @param command a String value containing a valid command String as would be entered by the user in Gfsh.
+    * @param fileData is a two-dimensional byte array containing the pathnames and contents of file data streamed to
+    * the Manager, usually for the 'deploy' Gfsh command.
+    * @return a result of the command execution as a String, typically marshalled in JSON to be serialized back to Gfsh.
+    * @see com.gemstone.gemfire.management.internal.cli.shell.Gfsh
+    * @see com.gemstone.gemfire.management.internal.web.controllers.support.EnvironmentVariablesHandlerInterceptor#getEnvironment()
+    * @see #getEnvironment()
+    * @see #processCommand(String, java.util.Map, byte[][])
+    */
+   protected String processCommand(final String command, final byte[][] fileData) {
+     return processCommand(command, getEnvironment(), fileData);
+   }
++  
++  protected String processCommandWithCredentials(final String command, final byte[][] fileData, Properties credentials) {
++    if (credentials != null) {
++      EnvironmentVariablesHandlerInterceptor.CREDENTIALS.set(credentials);
++    }
++    return processCommand(command, getEnvironment(), fileData);
++  }
+ 
+   /**
+    * Executes the specified command as entered by the user using the GemFire Shell (Gfsh).  Note, Gfsh performs
+    * validation of the command during parsing before sending the command to the Manager for processing.
+    * 
+    * @param command a String value containing a valid command String as would be entered by the user in Gfsh.
+    * @param environment a Map containing any environment configuration settings to be used by the Manager during
+    * command execution.  For example, when executing commands originating from Gfsh, the key/value pair (APP_NAME=gfsh)
+    * is a specified mapping in the "environment.  Note, it is common for the REST API to act as a bridge, or an adapter
+    * between Gfsh and the Manager, and thus need to specify this key/value pair mapping.
+    * @return a result of the command execution as a String, typically marshalled in JSON to be serialized back to Gfsh.
+    * @see com.gemstone.gemfire.management.internal.cli.shell.Gfsh
+    * @see com.gemstone.gemfire.management.internal.web.controllers.support.EnvironmentVariablesHandlerInterceptor#getEnvironment()
+    * @see #processCommand(String, java.util.Map, byte[][])
+    */
+   protected String processCommand(final String command, final Map<String, String> environment) {
+     return processCommand(command, environment, null);
+   }
+ 
+   /**
+    * Executes the specified command as entered by the user using the GemFire Shell (Gfsh).  Note, Gfsh performs
+    * validation of the command during parsing before sending the command to the Manager for processing.
+    * 
+    * @param command a String value containing a valid command String as would be entered by the user in Gfsh.
+    * @param environment a Map containing any environment configuration settings to be used by the Manager during
+    * command execution.  For example, when executing commands originating from Gfsh, the key/value pair (APP_NAME=gfsh)
+    * is a specified mapping in the "environment.  Note, it is common for the REST API to act as a bridge, or an adapter
+    * between Gfsh and the Manager, and thus need to specify this key/value pair mapping.
+    * @param fileData is a two-dimensional byte array containing the pathnames and contents of file data streamed to
+    * the Manager, usually for the 'deploy' Gfsh command.
+    * @return a result of the command execution as a String, typically marshalled in JSON to be serialized back to Gfsh.
+    * @see com.gemstone.gemfire.management.MemberMXBean#processCommand(String, java.util.Map, Byte[][])
+    */
+   protected String processCommand(final String command, final Map<String, String> environment, final byte[][] fileData) {
 -    logger.info(LogMarker.CONFIG, "Processing Command ({}) with Environment ({}) having File Data ({})...",
 -        command, environment, (fileData != null));
++    logger.info(LogMarker.CONFIG, "Processing Command ({}) with Environment ({}) having File Data ({})...", command,
++        environment, (fileData != null));
++
++    ResourceOperationContext ctx = authorize(command);
++
++    String result =  getManagingMemberMXBean().processCommand(command, environment, ArrayUtils.toByteArray(fileData));
++    
++    ctx = postAuthorize(command, ctx, result);
++    
++    return result;
++  }
++
++  protected ResourceOperationContext authorize(final String command) {
++
+     
 -    return getManagingMemberMXBean().processCommand(command, environment, ArrayUtils.toByteArray(fileData));
++    SystemManagementService service = (SystemManagementService) ManagementService
++        .getExistingManagementService(CacheFactory.getAnyInstance());
++    Properties credentials = EnvironmentVariablesHandlerInterceptor.CREDENTIALS.get();
++    CLIOperationContext context = new CLIOperationContext(command);
++    service.getAuthManager().authorize(credentials, context);
++    return context;
++  }
++  
++  protected ResourceOperationContext postAuthorize(final String command, ResourceOperationContext context, Object result) {
++
++    context.setPostOperationResult(result);
++    SystemManagementService service = (SystemManagementService) ManagementService
++        .getExistingManagementService(CacheFactory.getAnyInstance());
++    Properties credentials = EnvironmentVariablesHandlerInterceptor.CREDENTIALS.get();
++
++    service.getAuthManager().postAuthorize(credentials, context);
++    return context;
+   }
++  
++  
++
+ 
+   /**
+    * The MemberMXBeanProxy class is a proxy for the MemberMXBean interface transforming an operation on the member
+    * MBean into a invocation on the MBeanServer, invoke method.
+    * 
+    * @see com.gemstone.gemfire.management.internal.web.controllers.support.MemberMXBeanAdapter
+    */
+   private static class MemberMXBeanProxy extends MemberMXBeanAdapter {
+ 
+     private final MBeanServer server;
+ 
+     private final ObjectName objectName;
+ 
+     public MemberMXBeanProxy(final MBeanServer server, final ObjectName objectName) {
+       assertNotNull(server, "The connection or reference to the Platform MBeanServer cannot be null!");
+       assertNotNull(objectName, "The JMX ObjectName for the GemFire Manager MemberMXBean cannot be null!");
+       this.server = server;
+       this.objectName = objectName;
+     }
+ 
+     protected MBeanServer getMBeanServer() {
+       return server;
+     }
+ 
+     protected ObjectName getObjectName() {
+       return objectName;
+     }
+ 
+     @Override
+     public String processCommand(final String commandString, final Map<String, String> env) {
+       try {
+         return String.valueOf(getMBeanServer().invoke(getObjectName(), "processCommand",
+           new Object[] { commandString, env }, new String[] { String.class.getName(), Map.class.getName() }));
+       }
+       catch (Exception e) {
+         throw new RuntimeException(String.format(
+           "An error occurred while executing processCommand with command String (%1$s) on the MemberMXBean (%2$s) of the GemFire Manager using environment (%3$s)!",
+             commandString, getObjectName(), env), e);
+       }
+     }
+   }
+ 
+ }