Return-Path: X-Original-To: apmail-geode-commits-archive@minotaur.apache.org Delivered-To: apmail-geode-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4165D18E20 for ; Thu, 31 Mar 2016 15:23:10 +0000 (UTC) Received: (qmail 64356 invoked by uid 500); 31 Mar 2016 15:23:10 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 64316 invoked by uid 500); 31 Mar 2016 15:23:10 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 64304 invoked by uid 99); 31 Mar 2016 15:23:10 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Mar 2016 15:23:10 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 9DBADC1B1D for ; Thu, 31 Mar 2016 15:23:09 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.216 X-Spam-Level: X-Spam-Status: No, score=-4.216 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.996] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id bvNuLXCROp6C for ; Thu, 31 Mar 2016 15:23:05 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with SMTP id 3F65A60E99 for ; Thu, 31 Mar 2016 15:22:29 +0000 (UTC) Received: (qmail 59454 invoked by uid 99); 31 Mar 2016 15:22:28 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Mar 2016 15:22:28 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5C79BE03A9; Thu, 31 Mar 2016 15:22:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jinmeiliao@apache.org To: commits@geode.incubator.apache.org Date: Thu, 31 Mar 2016 15:23:26 -0000 Message-Id: <06965df34dca4192a7e109b20d0e8eff@git.apache.org> In-Reply-To: <7088b0d9b38e4540bbb45d31b9a16f0b@git.apache.org> References: <7088b0d9b38e4540bbb45d31b9a16f0b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [63/64] [abbrv] incubator-geode git commit: Merge branch 'develop' into feature/GEODE-17-2 http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/cache/operations/OperationContext.java ---------------------------------------------------------------------- diff --cc geode-core/src/main/java/com/gemstone/gemfire/cache/operations/OperationContext.java index 3bd9bf6,9482d6b..c7cf4bc --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/operations/OperationContext.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/operations/OperationContext.java @@@ -25,110 -29,236 +25,101 @@@ import com.gemstone.gemfire.management. * operations will extend this with the specifics as required e.g. a getKey() * method for a GET operation. Implementations for all the cache operations that * require authorization are provided. - * + * * Implementations of this interface are not expected to be thread-safe. - * + * - * @author Sumedh Wale * @since 5.5 */ public abstract class OperationContext { -- -- /** -- * Enumeration for various cache operations. Implementations for each of the -- * supported operation listed here are provided. - * - * @author Sumedh Wale - * -- * @since 5.5 -- */ - public static final class OperationCode { - - private static final byte OP_GET = 1; - - private static final byte OP_PUT = 2; - - private static final byte OP_DESTROY = 3; - - private static final byte OP_INVALIDATE = 4; - - private static final byte OP_REGISTER_INTEREST = 5; - - private static final byte OP_UNREGISTER_INTEREST = 6; - - private static final byte OP_CONTAINS_KEY = 7; - - private static final byte OP_KEY_SET = 8; - - private static final byte OP_QUERY = 9; - - private static final byte OP_EXECUTE_CQ = 10; - - private static final byte OP_STOP_CQ = 11; - - private static final byte OP_CLOSE_CQ = 12; - - private static final byte OP_REGION_CLEAR = 13; - - private static final byte OP_REGION_CREATE = 14; - - private static final byte OP_REGION_DESTROY = 15; - - private static final byte OP_PUTALL = 16; - - private static final byte OP_EXECUTE_FUNCTION = 17; - - private static final byte OP_GET_DURABLE_CQS = 18; - - private static final byte OP_REMOVEALL = 19; - - private static final byte OP_RESOURCE = 20; - - private static final OperationCode[] VALUES = new OperationCode[22]; - - private static final Map OperationNameMap = new HashMap(); - - /** - * An entry get operation. - * - * @see Region#get(Object) - */ - public static final OperationCode GET = new OperationCode("GET", OP_GET); - - /** - * An entry create/update operation. - * - * @see Region#put(Object, Object) - */ - public static final OperationCode PUT = new OperationCode("PUT", OP_PUT); - - /** - * An map putAll operation. - * - * @see Region#putAll(Map map) - */ - public static final OperationCode PUTALL = new OperationCode("PUTALL", OP_PUTALL); - - /** - * A region removeAll operation. - * - * @see Region#removeAll(java.util.Collection) - * @since 8.1 - */ - public static final OperationCode REMOVEALL = new OperationCode("REMOVEALL", OP_REMOVEALL); - - /** - * An entry destroy operation. - * - * @see Region#destroy(Object, Object) - */ - public static final OperationCode DESTROY = new OperationCode("DESTROY", - OP_DESTROY); - - /** - * An entry invalidate operation. - * - * @see Region#invalidate(Object, Object) - */ - public static final OperationCode INVALIDATE = new OperationCode( - "INVALIDATE", OP_INVALIDATE); - - /** - * A register interest operation. - * - * @see Region#registerInterest(Object) - */ - public static final OperationCode REGISTER_INTEREST = new OperationCode( - "REGISTER_INTEREST", OP_REGISTER_INTEREST); - - /** - * An unregister interest operation. - * - * @see Region#unregisterInterest - */ - public static final OperationCode UNREGISTER_INTEREST = new OperationCode( - "UNREGISTER_INTEREST", OP_UNREGISTER_INTEREST); - - /** - * A region containsKey operation. - * - * @see Region#containsKey - */ - public static final OperationCode CONTAINS_KEY = new OperationCode( - "CONTAINS_KEY", OP_CONTAINS_KEY); - - /** - * A region keySet operation. - * - * @see Region#keySet - */ - public static final OperationCode KEY_SET = new OperationCode("KEY_SET", - OP_KEY_SET); - - /** - * A cache query operation. - * - * @see Region#query - */ - public static final OperationCode QUERY = new OperationCode("QUERY", - OP_QUERY); - - /** - * A continuous query execution operation. - */ - public static final OperationCode EXECUTE_CQ = new OperationCode( - "EXECUTE_CQ", OP_EXECUTE_CQ); - - /** - * A continuous query stop operation. - */ - public static final OperationCode STOP_CQ = new OperationCode("STOP_CQ", - OP_STOP_CQ); - - /** - * A continuous query close operation. - */ - public static final OperationCode CLOSE_CQ = new OperationCode("CLOSE_CQ", - OP_CLOSE_CQ); - - /** - * A region clear operation. - * - * @see Region#clear - */ - public static final OperationCode REGION_CLEAR = new OperationCode( - "REGION_CLEAR", OP_REGION_CLEAR); - - /** - * A region create operation. - * - * @see Region#createSubregion - * @see Cache#createRegion - */ - public static final OperationCode REGION_CREATE = new OperationCode( - "REGION_CREATE", OP_REGION_CREATE); - - /** - * A region destroy operation. - * - * @see Region#destroyRegion(Object) - */ - public static final OperationCode REGION_DESTROY = new OperationCode( - "REGION_DESTROY", OP_REGION_DESTROY); - - /** - * A function execution operation - */ - public static final OperationCode EXECUTE_FUNCTION = new OperationCode( - "EXECUTE_FUNCTION", OP_EXECUTE_FUNCTION); - - /** - * A get durable continuous query operation - */ - public static final OperationCode GET_DURABLE_CQS = new OperationCode( - "GET_DURABLE_CQS", OP_GET_DURABLE_CQS); - - - /** - * A resource operation. See ResourceOperationContext for more details - */ - public static final OperationCode RESOURCE = new OperationCode( - "RESOURCE", OP_RESOURCE); - - /** The name of this operation. */ - private final String name; - - /** - * One of the following: OP_GET, OP_CREATE, OP_UPDATE, OP_INVALIDATE, - * OP_DESTROY, OP_REGISTER_INTEREST, OP_REGISTER_INTEREST_REGEX, - * OP_UNREGISTER_INTEREST, OP_UNREGISTER_INTEREST_REGEX, OP_QUERY, - * OP_REGION_CREATE, OP_REGION_DESTROY, OP_PUTALL - */ - private final byte opCode; - - /** Creates a new instance of Operation. */ - private OperationCode(String name, byte opCode) { - this.name = name; - this.opCode = opCode; - VALUES[opCode] = this; - OperationNameMap.put(name, this); - } - - /** - * Returns true if this is a entry get operation. - */ + public enum OperationCode { + ALL, + ALTER, + ALTER_RUNTIME, + BACKUP, + BECOME_LOCK_GRANTOR, + CLOSE_CQ, + COMPACT, + COMPACT_DISKSTORE, // TODO: Do we need this? + CONFIGURE, + CONTAINS_KEY, + CREATE, + CREATE_MANAGER, // TODO: Do we need this? + CREATE_QUERY, + CREATE_REGION, // TODO: Do we need this? + DELETE, + DELETE_QUERY, + DEPLOY, + DESTROY, + DESTROY_INDEX, // TODO: Do we need this? + EXECUTE, + EXECUTE_CQ, + EXECUTE_FUNCTION, + EXPORT, + EXPORT_DATA, // TODO: Do we need this? + EXPORT_LOGS, + EXPORT_STACKTRACE, + FLUSH, + GC, + GET, + GET_DURABLE_CQS, + IMPORT, + IMPORT_DATA, // TODO: Do we need this? + INVALIDATE, + KEY_SET, + LIST, + LIST_DS, // TODO: Do we need this? + LOCATE_ENTRY, // TODO: Do we need this? + MANAGE, // TODO: Do we need this? + NETSTAT, + PAUSE, + PROCESS_COMMAND, + PULSE_DASHBOARD, + PULSE_DATABROWSER, + PUT, + PUTALL, + QUERY, + REBALANCE, + REGION_CLEAR, + REGION_CREATE, + REGION_DESTROY, + REGISTER_INTEREST, + REMOVEALL, + RENAME, + RESOURCE, + RESUME, + REVOKE_MISSING, + ROLL, + SET_ALERT_LEVEL, + SET_DISK_USAGE_CRITICAL, + SET_DISK_USAGE_WARNING, + SET_PULSE_URL, + SET_QUERY_RESULT_LIMIT, + SET_QUERY_COLLECTION_DEPTH, + SET_STATUS_MESSAGE, + SHOW_DEADLOCKS, + SHOW_LOG, + SHOW_METRICS, + SHOW_MISSING, + SHUTDOWN, + START, + STATUS, + STOP, + STOP_CONTINUOUS_QUERY, // TODO: Do we need this? + STOP_CQ, + UNDEPLOY, + UNREGISTER_INTEREST, + UPDATE_QUERY, + VALIDATE; + + /** + * Check if this is an entry get operation. + * + * @return true if this is an entry get operation + * @deprecated Use {@code getOperationCode() == GET} instead + */ + @Deprecated public boolean isGet() { - return (this.opCode == OP_GET); + return (this == GET); } /** http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/internal/security/AuthorizeRequest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/AsyncEventQueueMXBean.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/CacheServerMXBean.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/DiskStoreMXBean.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/DistributedLockServiceMXBean.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/DistributedRegionMXBean.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/DistributedSystemMXBean.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/GatewayReceiverMXBean.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/GatewaySenderMXBean.java ---------------------------------------------------------------------- diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/GatewaySenderMXBean.java index 80d4ea8,33c47a4..a1cb84b --- a/geode-core/src/main/java/com/gemstone/gemfire/management/GatewaySenderMXBean.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/management/GatewaySenderMXBean.java @@@ -25,6 -21,7 +25,7 @@@ import static com.gemstone.gemfire.cach /** * MBean that provides access to information and management functionality for a * {@link GatewaySender}. - * ++ * * @since 7.0 * */ http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/LocatorMXBean.java ---------------------------------------------------------------------- diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/LocatorMXBean.java index 4412f0b,ec4dd88..da0aef1 --- a/geode-core/src/main/java/com/gemstone/gemfire/management/LocatorMXBean.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/management/LocatorMXBean.java @@@ -25,10 -22,8 +25,9 @@@ import com.gemstone.gemfire.management. * MBean that provides access to information and management functionality for a * {@link Locator}. * - * @author rishim * @since 7.0 */ +@ResourceOperation(resource = Resource.JMX, operation = OperationContext.OperationCode.GET) public interface LocatorMXBean { /** http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/ManagerMXBean.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/MemberMXBean.java ---------------------------------------------------------------------- diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/MemberMXBean.java index f36cc7c,ed27569..fe35b00 --- a/geode-core/src/main/java/com/gemstone/gemfire/management/MemberMXBean.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/management/MemberMXBean.java @@@ -136,10 -133,9 +136,10 @@@ import static com.gemstone.gemfire.cach * Locator is Started in the VM * * - - * ++ * * @since 7.0 */ +@ResourceOperation(resource = Resource.JMX, operation = OperationCode.GET) public interface MemberMXBean { /** http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/RegionMXBean.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/ManagementAgent.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/SystemManagementService.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/beans/GatewaySenderMBean.java ---------------------------------------------------------------------- diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/internal/beans/GatewaySenderMBean.java index 536f9a2,4b226f4..aafa076 --- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/beans/GatewaySenderMBean.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/beans/GatewaySenderMBean.java @@@ -16,11 -16,15 +16,9 @@@ */ package com.gemstone.gemfire.management.internal.beans; - -import javax.management.NotificationBroadcasterSupport; -- import com.gemstone.gemfire.management.GatewaySenderMXBean; - +import javax.management.NotificationBroadcasterSupport; -/** - * - * - */ public class GatewaySenderMBean extends NotificationBroadcasterSupport implements GatewaySenderMXBean { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ClientCommands.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ConfigCommands.java ---------------------------------------------------------------------- diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ConfigCommands.java index e302b6d,a53790c..13cc8a5 --- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ConfigCommands.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ConfigCommands.java @@@ -62,15 -62,8 +62,14 @@@ import com.gemstone.gemfire.management. import com.gemstone.gemfire.management.internal.cli.shell.Gfsh; import com.gemstone.gemfire.management.internal.configuration.SharedConfigurationWriter; import com.gemstone.gemfire.management.internal.configuration.domain.XmlEntity; +import com.gemstone.gemfire.management.internal.security.Resource; +import com.gemstone.gemfire.management.internal.security.ResourceConstants; +import com.gemstone.gemfire.management.internal.security.ResourceOperation; + +import static com.gemstone.gemfire.cache.operations.OperationContext.OperationCode; + /**** * - * @author David Hoots * Sourabh Bansod * @since 7.0 * http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java ---------------------------------------------------------------------- diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java index 6ee840a,ad006b7..9adf24b --- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java @@@ -83,14 -60,28 +60,32 @@@ import com.gemstone.gemfire.management. import com.gemstone.gemfire.management.internal.cli.util.RegionPath; import com.gemstone.gemfire.management.internal.configuration.SharedConfigurationWriter; import com.gemstone.gemfire.management.internal.configuration.domain.XmlEntity; +import com.gemstone.gemfire.management.internal.security.Resource; +import com.gemstone.gemfire.management.internal.security.ResourceOperation; + +import static com.gemstone.gemfire.cache.operations.OperationContext.OperationCode; + import org.springframework.shell.core.annotation.CliAvailabilityIndicator; + import org.springframework.shell.core.annotation.CliCommand; + import org.springframework.shell.core.annotation.CliOption; + + import javax.management.MBeanServer; + import javax.management.MalformedObjectNameException; + import javax.management.ObjectName; + import java.text.MessageFormat; + import java.util.ArrayList; + import java.util.Arrays; + import java.util.Collections; + import java.util.HashSet; + import java.util.Iterator; + import java.util.List; + import java.util.Map; + import java.util.Map.Entry; + import java.util.Set; + import java.util.TreeSet; + import java.util.regex.Pattern; /** -- * - * @author Abhishek Chaudhari ++ * * @since 7.0 */ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/DataCommands.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/DeployCommands.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/DiskStoreCommands.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/DurableClientCommands.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ExportImportSharedConfigurationCommands.java ---------------------------------------------------------------------- diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ExportImportSharedConfigurationCommands.java index ef21179,88308a6..61bb6c6 --- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ExportImportSharedConfigurationCommands.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ExportImportSharedConfigurationCommands.java @@@ -41,19 -48,8 +41,18 @@@ import org.springframework.shell.core.a import org.springframework.shell.core.annotation.CliCommand; import org.springframework.shell.core.annotation.CliOption; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static com.gemstone.gemfire.cache.operations.OperationContext.OperationCode; + /**** * Commands for the shared configuration - * @author bansods * */ @SuppressWarnings("unused") http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/FunctionCommands.java ---------------------------------------------------------------------- diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/FunctionCommands.java index c18d0e3,9ea5a4c..c51c2b6 --- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/FunctionCommands.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/FunctionCommands.java @@@ -64,13 -63,8 +64,12 @@@ import com.gemstone.gemfire.management. 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.Resource; +import com.gemstone.gemfire.management.internal.security.ResourceOperation; + +import static com.gemstone.gemfire.cache.operations.OperationContext.OperationCode; /** - * @author David Hoots * * @since 7.0 */ http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/GfshHelpCommands.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/IndexCommands.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommands.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/MemberCommands.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/MiscellaneousCommands.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/QueueCommands.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/RegionCommands.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java ---------------------------------------------------------------------- diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java index 0443d36,daffa80..04fbf30 --- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java @@@ -55,43 -86,8 +55,42 @@@ import com.gemstone.gemfire.management. import com.gemstone.gemfire.management.internal.web.http.support.SimpleHttpRequester; import com.gemstone.gemfire.management.internal.web.shell.HttpOperationInvoker; import com.gemstone.gemfire.management.internal.web.shell.RestHttpOperationInvoker; +import org.springframework.shell.core.CommandMarker; +import org.springframework.shell.core.ExitShellRequest; +import org.springframework.shell.core.annotation.CliAvailabilityIndicator; +import org.springframework.shell.core.annotation.CliCommand; +import org.springframework.shell.core.annotation.CliOption; + +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManagerFactory; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Writer; +import java.net.ConnectException; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.KeyStore; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.Set; + +import static com.gemstone.gemfire.cache.operations.OperationContext.OperationCode; /** - * @author Abhishek Chaudhari * * @since 7.0 */ http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/StatusCommands.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/JmxOperationInvoker.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/controllers/AbstractCommandsController.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/controllers/ConfigCommandsController.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/controllers/DataCommandsController.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/controllers/DiskStoreCommandsController.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/controllers/FunctionCommandsController.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/controllers/MiscellaneousCommandsController.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/controllers/WanCommandsController.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/controllers/support/EnvironmentVariablesHandlerInterceptor.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/http/support/SimpleHttpRequester.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/shell/AbstractHttpOperationInvoker.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/shell/RestHttpOperationInvoker.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/shell/SimpleHttpOperationInvoker.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/security/AccessControl.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/main/java/com/gemstone/gemfire/security/Authenticator.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/extension/mock/MockExtensionCommands.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CommandManagerJUnitTest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/GfshParserJUnitTest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/HeadlessGfsh.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java ---------------------------------------------------------------------- diff --cc geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java index f01c951,7d8dc55..89069b4 --- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java @@@ -50,12 -50,10 +50,8 @@@ import java.util.regex.Pattern /** * Base class for all the CLI/gfsh command dunit tests. * - * @author Tushar Khairnar - * @author Abhishek Chaudhari - * @author David Hoots - * @author John Blum */ -public class CliCommandTestBase extends CacheTestCase { - - private static final long serialVersionUID = 1L; +public abstract class CliCommandTestBase extends CacheTestCase { protected static final String USE_HTTP_SYSTEM_PROPERTY = "useHTTP"; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/shell/GfshExecutionStrategyJUnitTest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/test/java/com/gemstone/gemfire/management/internal/unsafe/ReadOpFileAccessControllerJUnitTest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/867eb7f0/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java ---------------------------------------------------------------------- diff --cc geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java index f49eb52,eeb2c39..bcfd195 --- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java @@@ -44,214 -47,62 +47,62 @@@ import org.junit.experimental.categorie * of all operations with both valid and invalid credentials/modules with * pre-operation callbacks. It also checks for authorization in case of * failover. -- * - * @author sumedh ++ * * @since 5.5 */ - public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase { - - /** constructor */ - public ClientAuthorizationDUnitTest(String name) { - super(name); - } + @Category(DistributedTest.class) + public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestCase { @Override - public void setUp() throws Exception { - - super.setUp(); - final Host host = Host.getHost(0); - server1 = host.getVM(0); - server2 = host.getVM(1); - client1 = host.getVM(2); - client2 = host.getVM(3); - - server1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions )); - server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions )); - client1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions )); - client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions )); - SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions); + public final void preTearDownClientAuthorizationTestBase() throws Exception { + closeCache(); } - private Properties getUserPassword(String userName) { + @Test + public void testAllowPutsGets() { + AuthzCredentialGenerator gen = getXmlAuthzGenerator(); + CredentialGenerator cGen = gen.getCredentialGenerator(); + Properties extraAuthProps = cGen.getSystemProperties(); + Properties javaProps = cGen.getJavaProperties(); + Properties extraAuthzProps = gen.getSystemProperties(); + String authenticator = cGen.getAuthenticator(); + String authInit = cGen.getAuthInit(); + String accessor = gen.getAuthorizationCallback(); - Properties props = new Properties(); - props.setProperty(UserPasswordAuthInit.USER_NAME, userName); - props.setProperty(UserPasswordAuthInit.PASSWORD, userName); - return props; - } + getLogWriter().info("testAllowPutsGets: Using authinit: " + authInit); + getLogWriter().info("testAllowPutsGets: Using authenticator: " + authenticator); + getLogWriter().info("testAllowPutsGets: Using accessor: " + accessor); - private void executeRIOpBlock(List opBlock, Integer port1, Integer port2, - String authInit, Properties extraAuthProps, Properties extraAuthzProps, - Properties javaProps) { + // Start servers with all required properties + Properties serverProps = buildProperties(authenticator, accessor, false, extraAuthProps, extraAuthzProps); - Iterator opIter = opBlock.iterator(); - while (opIter.hasNext()) { - // Start client with valid credentials as specified in - // OperationWithAction - OperationWithAction currentOp = (OperationWithAction)opIter.next(); - OperationCode opCode = currentOp.getOperationCode(); - int opFlags = currentOp.getFlags(); - int clientNum = currentOp.getClientNum(); - VM clientVM = null; - boolean useThisVM = false; - switch (clientNum) { - case 1: - clientVM = client1; - break; - case 2: - clientVM = client2; - break; - case 3: - useThisVM = true; - break; - default: - fail("executeRIOpBlock: Unknown client number " + clientNum); - break; - } - LogWriterUtils.getLogWriter().info( - "executeRIOpBlock: performing operation number [" - + currentOp.getOpNum() + "]: " + currentOp); - if ((opFlags & OpFlags.USE_OLDCONN) == 0) { - Properties opCredentials = null; - String currentRegionName = '/' + regionName; - if ((opFlags & OpFlags.USE_SUBREGION) > 0) { - currentRegionName += ('/' + subregionName); - } - String credentialsTypeStr; - OperationCode authOpCode = currentOp.getAuthzOperationCode(); - if ((opFlags & OpFlags.CHECK_NOTAUTHZ) > 0 - || (opFlags & OpFlags.USE_NOTAUTHZ) > 0 - || !authOpCode.equals(opCode)) { - credentialsTypeStr = " unauthorized " + authOpCode; - if (authOpCode.isRegisterInterest()) { - opCredentials = getUserPassword("reader7"); - } - else if (authOpCode.isUnregisterInterest()) { - opCredentials = getUserPassword("reader6"); - } - else { - fail("executeRIOpBlock: cannot determine credentials for" - + credentialsTypeStr); - } - } - else { - credentialsTypeStr = " authorized " + authOpCode; - if (authOpCode.isRegisterInterest() - || authOpCode.isUnregisterInterest()) { - opCredentials = getUserPassword("reader5"); - } - else if (authOpCode.isPut()) { - opCredentials = getUserPassword("writer1"); - } - else if (authOpCode.isGet()) { - opCredentials = getUserPassword("reader1"); - } - else { - fail("executeRIOpBlock: cannot determine credentials for" - + credentialsTypeStr); - } - } - Properties clientProps = SecurityTestUtil - .concatProperties(new Properties[] { opCredentials, extraAuthProps, - extraAuthzProps }); - // Start the client with valid credentials but allowed or disallowed to - // perform an operation - LogWriterUtils.getLogWriter().info( - "executeRIOpBlock: For client" + clientNum + credentialsTypeStr - + " credentials: " + opCredentials); - if (useThisVM) { - createCacheClient(authInit, clientProps, javaProps, new Integer[] { - port1, port2 }, null, Boolean.valueOf(false), new Integer( - SecurityTestUtil.NO_EXCEPTION)); - } - else { - clientVM.invoke(ClientAuthorizationTestBase.class, - "createCacheClient", new Object[] { authInit, clientProps, - javaProps, new Integer[] { port1, port2 }, null, - Boolean.valueOf(false), - new Integer(SecurityTestUtil.NO_EXCEPTION) }); - } - } - int expectedResult; - if ((opFlags & OpFlags.CHECK_NOTAUTHZ) > 0) { - expectedResult = SecurityTestUtil.NOTAUTHZ_EXCEPTION; - } - else if ((opFlags & OpFlags.CHECK_EXCEPTION) > 0) { - expectedResult = SecurityTestUtil.OTHER_EXCEPTION; - } - else { - expectedResult = SecurityTestUtil.NO_EXCEPTION; - } + int port1 = createServer1(javaProps, serverProps); + int port2 = createServer2(javaProps, serverProps); - // Perform the operation from selected client - if (useThisVM) { - doOp(opCode, currentOp.getIndices(), new Integer( - opFlags), new Integer(expectedResult)); - } - else { - int[] indices = currentOp.getIndices(); - clientVM.invoke(() -> ClientAuthorizationTestBase.doOp(opCode, - indices, new Integer(opFlags), - new Integer(expectedResult) )); - } - } - } + // Start client1 with valid CREATE credentials + Properties createCredentials = gen.getAllowedCredentials(new OperationCode[] { OperationCode.PUT }, new String[] { regionName }, 1); + javaProps = cGen.getJavaProperties(); - // Region: Tests + getLogWriter().info("testAllowPutsGets: For first client credentials: " + createCredentials); - public void testAllowPutsGets() { - AuthzCredentialGenerator gen = getXmlAuthzGenerator(); - CredentialGenerator cGen = gen.getCredentialGenerator(); - Properties extraAuthProps = cGen.getSystemProperties(); - Properties javaProps = cGen.getJavaProperties(); - Properties extraAuthzProps = gen.getSystemProperties(); - String authenticator = cGen.getAuthenticator(); - String authInit = cGen.getAuthInit(); - String accessor = gen.getAuthorizationCallback(); - - LogWriterUtils.getLogWriter().info("testAllowPutsGets: Using authinit: " + authInit); - LogWriterUtils.getLogWriter().info( - "testAllowPutsGets: Using authenticator: " + authenticator); - LogWriterUtils.getLogWriter().info("testAllowPutsGets: Using accessor: " + accessor); - - // Start servers with all required properties - Properties serverProps = buildProperties(authenticator, accessor, false, - extraAuthProps, extraAuthzProps); - Integer port1 = createServer1(javaProps, serverProps); - Integer port2 = createServer2(javaProps, serverProps); - - // Start client1 with valid CREATE credentials - Properties createCredentials = gen.getAllowedCredentials( - new OperationCode[] { OperationCode.PUT }, - new String[] { regionName }, 1); - javaProps = cGen.getJavaProperties(); - LogWriterUtils.getLogWriter().info( - "testAllowPutsGets: For first client credentials: " - + createCredentials); - createClient1NoException(javaProps, authInit, port1, port2, - createCredentials); - - // Start client2 with valid GET credentials - Properties getCredentials = gen.getAllowedCredentials( - new OperationCode[] { OperationCode.GET }, - new String[] { regionName }, 2); - javaProps = cGen.getJavaProperties(); - LogWriterUtils.getLogWriter() - .info( - "testAllowPutsGets: For second client credentials: " - + getCredentials); - createClient2NoException(javaProps, authInit, port1, port2, - getCredentials); - - // Perform some put operations from client1 - client1.invoke(() -> SecurityTestUtil.doPuts( - new Integer(2), new Integer(SecurityTestUtil.NO_EXCEPTION) )); - - // Verify that the gets succeed - client2.invoke(() -> SecurityTestUtil.doGets( - new Integer(2), new Integer(SecurityTestUtil.NO_EXCEPTION) )); + createClient1NoException(javaProps, authInit, port1, port2, createCredentials); + + // Start client2 with valid GET credentials + Properties getCredentials = gen.getAllowedCredentials(new OperationCode[] { OperationCode.GET }, new String[] { regionName }, 2); + javaProps = cGen.getJavaProperties(); + + getLogWriter().info("testAllowPutsGets: For second client credentials: " + getCredentials); + + createClient2NoException(javaProps, authInit, port1, port2, getCredentials); + + // Perform some put operations from client1 + client1.invoke(() -> doPuts(2, NO_EXCEPTION)); + + // Verify that the gets succeed + client2.invoke(() -> doGets(2, NO_EXCEPTION)); } + @Test public void testPutAllWithSecurity() { AuthzCredentialGenerator gen = getXmlAuthzGenerator(); CredentialGenerator cGen = gen.getCredentialGenerator(); @@@ -789,24 -521,126 +521,125 @@@ OperationWithAction.OPBLOCK_END, // Test GET_ENTRY inside a TX, see #49951 - new OperationWithAction(OperationCode.GET, 2, - OpFlags.USE_GET_ENTRY_IN_TX | OpFlags.CHECK_FAIL, 4), + new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_GET_ENTRY_IN_TX | OpFlags.CHECK_FAIL, 4), OperationWithAction.OPBLOCK_END }; + } - runOpsWithFailover(allOps, "testAllOpsWithFailover"); + private Properties getUserPassword(final String userName) { + Properties props = new Properties(); + props.setProperty(UserPasswordAuthInit.USER_NAME, userName); + props.setProperty(UserPasswordAuthInit.PASSWORD, userName); + return props; } - // End Region: Tests + private void executeRIOpBlock(final List opBlock, final int port1, final int port2, final String authInit, final Properties extraAuthProps, final Properties extraAuthzProps, final Properties javaProps) throws InterruptedException { + for (Iterator opIter = opBlock.iterator(); opIter.hasNext();) { + // Start client with valid credentials as specified in OperationWithAction + OperationWithAction currentOp = (OperationWithAction)opIter.next(); + OperationCode opCode = currentOp.getOperationCode(); + int opFlags = currentOp.getFlags(); + int clientNum = currentOp.getClientNum(); + VM clientVM = null; + boolean useThisVM = false; - @Override - protected final void preTearDown() throws Exception { - // close the clients first - client1.invoke(() -> SecurityTestUtil.closeCache()); - client2.invoke(() -> SecurityTestUtil.closeCache()); - SecurityTestUtil.closeCache(); - // then close the servers - server1.invoke(() -> SecurityTestUtil.closeCache()); - server2.invoke(() -> SecurityTestUtil.closeCache()); + switch (clientNum) { + case 1: + clientVM = client1; + break; + case 2: + clientVM = client2; + break; + case 3: + useThisVM = true; + break; + default: + fail("executeRIOpBlock: Unknown client number " + clientNum); + break; + } + + getLogWriter().info( "executeRIOpBlock: performing operation number [" + currentOp.getOpNum() + "]: " + currentOp); + if ((opFlags & OpFlags.USE_OLDCONN) == 0) { + Properties opCredentials = null; + String currentRegionName = '/' + regionName; + if ((opFlags & OpFlags.USE_SUBREGION) > 0) { + currentRegionName += ('/' + SUBREGION_NAME); + } + String credentialsTypeStr; + OperationCode authOpCode = currentOp.getAuthzOperationCode(); + + if ((opFlags & OpFlags.CHECK_NOTAUTHZ) > 0 || (opFlags & OpFlags.USE_NOTAUTHZ) > 0 || !authOpCode.equals(opCode)) { + credentialsTypeStr = " unauthorized " + authOpCode; + if (authOpCode.isRegisterInterest()) { + opCredentials = getUserPassword("reader7"); + } else if (authOpCode.isUnregisterInterest()) { + opCredentials = getUserPassword("reader6"); + } else { + fail("executeRIOpBlock: cannot determine credentials for" + credentialsTypeStr); + } + + } else { + credentialsTypeStr = " authorized " + authOpCode; + if (authOpCode.isRegisterInterest() || authOpCode.isUnregisterInterest()) { + opCredentials = getUserPassword("reader5"); + } else if (authOpCode.isPut()) { + opCredentials = getUserPassword("writer1"); + } else if (authOpCode.isGet()) { + opCredentials = getUserPassword("reader1"); + } else { + fail("executeRIOpBlock: cannot determine credentials for" + credentialsTypeStr); + } + } + + Properties clientProps = concatProperties(new Properties[] { opCredentials, extraAuthProps, extraAuthzProps }); + + // Start the client with valid credentials but allowed or disallowed to perform an operation + getLogWriter().info("executeRIOpBlock: For client" + clientNum + credentialsTypeStr + " credentials: " + opCredentials); + if (useThisVM) { + createCacheClientWithDynamicRegion(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, false, NO_EXCEPTION); + } else { + clientVM.invoke(() -> createCacheClient(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, false, NO_EXCEPTION)); + } + + } + + int expectedResult; + if ((opFlags & OpFlags.CHECK_NOTAUTHZ) > 0) { + expectedResult = NOTAUTHZ_EXCEPTION; + } else if ((opFlags & OpFlags.CHECK_EXCEPTION) > 0) { + expectedResult = OTHER_EXCEPTION; + } else { + expectedResult = NO_EXCEPTION; + } + + // Perform the operation from selected client + if (useThisVM) { - doOp(new Byte(opCode.toOrdinal()), currentOp.getIndices(), opFlags, expectedResult); ++ doOp(opCode, currentOp.getIndices(), opFlags, expectedResult); + + } else { - byte ordinal = opCode.toOrdinal(); + int[] indices = currentOp.getIndices(); - clientVM.invoke(() -> ClientAuthorizationTestCase.doOp(ordinal, indices, opFlags, expectedResult)); ++ clientVM.invoke(() -> ClientAuthorizationTestCase.doOp(opCode, indices, opFlags, expectedResult)); + } + } + } + + private void createClient2NoException(final Properties javaProps, final String authInit, final int port1, final int port2, final Properties getCredentials) { + client2.invoke(() -> ClientAuthenticationTestUtils.createCacheClient(authInit, getCredentials, javaProps, port1, port2, 0, NO_EXCEPTION)); + } + + private void createClient1NoException(final Properties javaProps, final String authInit, final int port1, final int port2, final Properties createCredentials) { + client1.invoke(() -> ClientAuthenticationTestUtils.createCacheClient(authInit, createCredentials, javaProps, port1, port2, 0, NO_EXCEPTION)); + } + + private int createServer2(final Properties javaProps, final Properties serverProps) { + return server2.invoke(() -> ClientAuthorizationTestCase.createCacheServer(getLocatorPort(), serverProps, javaProps)); + } + + private int createServer1(final Properties javaProps, final Properties serverProps) { + return server1.invoke(() -> ClientAuthorizationTestCase.createCacheServer(getLocatorPort(), serverProps, javaProps)); + } + + private void createServer2(Properties javaProps, Properties serverProps, int port2) { + server2.invoke(() -> ClientAuthorizationTestCase.createCacheServer(getLocatorPort(), port2, serverProps, javaProps)); } }