geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aba...@apache.org
Subject [04/50] [abbrv] incubator-geode git commit: GEODE-1571: fix permission needed for remove data command
Date Mon, 22 Aug 2016 16:39:32 GMT
GEODE-1571: fix permission needed for remove data command


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

Branch: refs/heads/master
Commit: 1318a4aebda46b4aad8aadb1e00804db33017bc9
Parents: 4a0de72
Author: Jinmei Liao <jiliao@pivotal.io>
Authored: Wed Jul 13 14:56:42 2016 -0700
Committer: Jinmei Liao <jiliao@pivotal.io>
Committed: Thu Jul 14 08:35:52 2016 -0700

----------------------------------------------------------------------
 .../management/internal/cli/commands/DataCommands.java  | 12 +++++++++---
 .../management/internal/security/TestCommand.java       |  2 +-
 2 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1318a4ae/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/DataCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/DataCommands.java
b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/DataCommands.java
index b6ee8b5..89dce97 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/DataCommands.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/DataCommands.java
@@ -30,6 +30,8 @@ import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
+import org.apache.geode.security.GeodePermission.Operation;
+import org.apache.geode.security.GeodePermission.Resource;
 import org.springframework.shell.core.CommandMarker;
 import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
 import org.springframework.shell.core.annotation.CliCommand;
@@ -77,8 +79,6 @@ import com.gemstone.gemfire.management.internal.cli.result.ResultBuilder;
 import com.gemstone.gemfire.management.internal.cli.result.TabularResultData;
 import com.gemstone.gemfire.management.internal.cli.shell.Gfsh;
 import com.gemstone.gemfire.management.internal.security.ResourceOperation;
-import org.apache.geode.security.GeodePermission.Operation;
-import org.apache.geode.security.GeodePermission.Resource;
 
 /**
  * 
@@ -1130,7 +1130,6 @@ public class DataCommands implements CommandMarker {
       CliStrings.TOPIC_GEODE_DATA, CliStrings.TOPIC_GEODE_REGION
   })
   @CliCommand(value = { CliStrings.REMOVE }, help = CliStrings.REMOVE__HELP)
-  @ResourceOperation(resource=Resource.DATA, operation = Operation.MANAGE)
   public Result remove(
       @CliOption(key = { CliStrings.REMOVE__KEY }, help = CliStrings.REMOVE__KEY__HELP) String
key,
       @CliOption(key = { CliStrings.REMOVE__REGION }, mandatory = true, help = CliStrings.REMOVE__REGION__HELP,
optionContext = ConverterHint.REGIONPATH) String regionPath,
@@ -1151,6 +1150,13 @@ public class DataCommands implements CommandMarker {
               CliStrings.REMOVE__MSG__KEY_EMPTY, false));
     }
 
+    if(removeAllKeys){
+      GeodeSecurityUtil.authorizeRegionWrite(regionPath);
+    }
+    else {
+      GeodeSecurityUtil.authorizeRegionWrite(regionPath, key);
+    }
+
     @SuppressWarnings("rawtypes")
     Region region = cache.getRegion(regionPath);
     DataCommandFunction removefn = new DataCommandFunction();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1318a4ae/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/TestCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/TestCommand.java
b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/TestCommand.java
index d6bae35..d3d14d5 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/TestCommand.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/TestCommand.java
@@ -102,7 +102,7 @@ public class TestCommand {
     createTestCommand("import data --region=RegionA --file=import.txt --member=importMember",
regionAWrite);
     createTestCommand("put --key=key1 --value=value1 --region=RegionA", regionAWrite);
     createTestCommand("get --key=key1 --region=RegionA", regionARead);
-    createTestCommand("remove --region=RegionA", dataManage);
+    createTestCommand("remove --region=RegionA --key=key1", regionAWrite);
     createTestCommand("query --query='SELECT * FROM /RegionA'", regionARead);
     createTestCommand("locate entry --key=k1 --region=RegionA", regionARead);
 


Mime
View raw message