Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7A027200CA3 for ; Thu, 1 Jun 2017 21:05:35 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 784C0160BDF; Thu, 1 Jun 2017 19:05:35 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 009DD160BC4 for ; Thu, 1 Jun 2017 21:05:32 +0200 (CEST) Received: (qmail 66695 invoked by uid 500); 1 Jun 2017 19:05:32 -0000 Mailing-List: contact commits-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list commits@geode.apache.org Received: (qmail 66675 invoked by uid 99); 1 Jun 2017 19:05:32 -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, 01 Jun 2017 19:05:32 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 03715E0285; Thu, 1 Jun 2017 19:05:32 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: klund@apache.org To: commits@geode.apache.org Date: Thu, 01 Jun 2017 19:05:33 -0000 Message-Id: In-Reply-To: <5d23070eae474e27b8343fb137befa27@git.apache.org> References: <5d23070eae474e27b8343fb137befa27@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [03/10] geode git commit: milestone archived-at: Thu, 01 Jun 2017 19:05:35 -0000 http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java b/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java index 3e6e4484..554dc66 100755 --- a/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java @@ -91,7 +91,7 @@ public class ManagementAgent { private JMXConnectorServer jmxConnectorServer; private JMXShiroAuthenticator shiroAuthenticator; private final DistributionConfig config; - private SecurityService securityService = SecurityService.getSecurityService(); + private final SecurityService securityService; private boolean isHttpServiceRunning = false; /** @@ -103,8 +103,9 @@ public class ManagementAgent { private static final String PULSE_USESSL_MANAGER = "pulse.useSSL.manager"; private static final String PULSE_USESSL_LOCATOR = "pulse.useSSL.locator"; - public ManagementAgent(DistributionConfig config) { + public ManagementAgent(DistributionConfig config, SecurityService securityService) { this.config = config; + this.securityService = securityService; } public synchronized boolean isRunning() { @@ -465,14 +466,14 @@ public class ManagementAgent { }; if (securityService.isIntegratedSecurity()) { - shiroAuthenticator = new JMXShiroAuthenticator(); + shiroAuthenticator = new JMXShiroAuthenticator(this.securityService); env.put(JMXConnectorServer.AUTHENTICATOR, shiroAuthenticator); jmxConnectorServer.addNotificationListener(shiroAuthenticator, null, jmxConnectorServer.getAttributes()); // always going to assume authorization is needed as well, if no custom AccessControl, then // the CustomAuthRealm // should take care of that - MBeanServerWrapper mBeanServerWrapper = new MBeanServerWrapper(); + MBeanServerWrapper mBeanServerWrapper = new MBeanServerWrapper(this.securityService); jmxConnectorServer.setMBeanServerForwarder(mBeanServerWrapper); registerAccessControlMBean(); } else { @@ -501,7 +502,7 @@ public class ManagementAgent { private void registerAccessControlMBean() { try { - AccessControlMBean acc = new AccessControlMBean(); + AccessControlMBean acc = new AccessControlMBean(this.securityService); ObjectName accessControlMBeanON = new ObjectName(ResourceConstants.OBJECT_NAME_ACCESSCONTROL); MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer(); http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/management/internal/SystemManagementService.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/SystemManagementService.java b/geode-core/src/main/java/org/apache/geode/management/internal/SystemManagementService.java index fc8eb97..11402f1 100755 --- a/geode-core/src/main/java/org/apache/geode/management/internal/SystemManagementService.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/SystemManagementService.java @@ -144,7 +144,7 @@ public class SystemManagementService extends BaseManagementService { this.notificationHub = new NotificationHub(repo); if (system.getConfig().getJmxManager()) { - this.agent = new ManagementAgent(system.getConfig()); + this.agent = new ManagementAgent(system.getConfig(), cache.getSecurityService()); } else { this.agent = null; } http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupport.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupport.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupport.java index 26b903b..31d6c0a 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupport.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AbstractCommandsSupport.java @@ -50,7 +50,6 @@ import java.util.Set; */ @SuppressWarnings("unused") public abstract class AbstractCommandsSupport implements CommandMarker { - protected static SecurityService securityService = SecurityService.getSecurityService(); protected static void assertArgument(final boolean valid, final String message, final Object... args) { http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java index 6e1a74e..f998289 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java @@ -89,8 +89,6 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport { public static final Set PERSISTENT_OVERFLOW_SHORTCUTS = new TreeSet<>(); - private SecurityService securityService = IntegratedSecurityService.getSecurityService(); - static { PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.PARTITION_PERSISTENT); PERSISTENT_OVERFLOW_SHORTCUTS.add(RegionShortcut.PARTITION_REDUNDANT_PERSISTENT); @@ -426,7 +424,7 @@ public class CreateAlterDestroyRegionCommands extends AbstractCommandsSupport { Result result; AtomicReference xmlEntity = new AtomicReference<>(); - this.securityService.authorizeRegionManage(regionPath); + getCache().getSecurityService().authorizeRegionManage(regionPath); try { InternalCache cache = getCache(); http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java index a38e545..19fe464 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java @@ -33,8 +33,6 @@ import org.apache.geode.cache.execute.ResultCollector; import org.apache.geode.cache.partition.PartitionRebalanceInfo; import org.apache.geode.distributed.DistributedMember; import org.apache.geode.internal.cache.InternalCache; -import org.apache.geode.internal.security.IntegratedSecurityService; -import org.apache.geode.internal.security.SecurityService; import org.apache.geode.management.DistributedRegionMXBean; import org.apache.geode.management.ManagementService; import org.apache.geode.management.cli.CliMetaData; @@ -49,6 +47,7 @@ import org.apache.geode.management.internal.cli.functions.DataCommandFunction; import org.apache.geode.management.internal.cli.functions.ExportDataFunction; import org.apache.geode.management.internal.cli.functions.ImportDataFunction; import org.apache.geode.management.internal.cli.functions.RebalanceFunction; +import org.apache.geode.management.internal.cli.functions.SelectExecStep; import org.apache.geode.management.internal.cli.i18n.CliStrings; import org.apache.geode.management.internal.cli.multistep.CLIMultiStepHelper; import org.apache.geode.management.internal.cli.multistep.CLIStep; @@ -93,8 +92,6 @@ public class DataCommands implements CommandMarker { private final ImportDataFunction importDataFunction = new ImportDataFunction(); - private SecurityService securityService = IntegratedSecurityService.getSecurityService(); - private Gfsh getGfsh() { return Gfsh.getCurrentInstance(); } @@ -750,7 +747,7 @@ public class DataCommands implements CommandMarker { optionContext = ConverterHint.MEMBERIDNAME, mandatory = true, help = CliStrings.EXPORT_DATA__MEMBER__HELP) String memberNameOrId) { - this.securityService.authorizeRegionRead(regionName); + getCache().getSecurityService().authorizeRegionRead(regionName); final DistributedMember targetMember = CliUtil.getDistributedMemberByNameOrId(memberNameOrId); Result result; @@ -808,7 +805,7 @@ public class DataCommands implements CommandMarker { @CliOption(key = CliStrings.IMPORT_DATA__INVOKE_CALLBACKS, unspecifiedDefaultValue = "false", help = CliStrings.IMPORT_DATA__INVOKE_CALLBACKS__HELP) boolean invokeCallbacks) { - this.securityService.authorizeRegionWrite(regionName); + getCache().getSecurityService().authorizeRegionWrite(regionName); Result result; @@ -869,8 +866,8 @@ public class DataCommands implements CommandMarker { @CliOption(key = {CliStrings.PUT__PUTIFABSENT}, help = CliStrings.PUT__PUTIFABSENT__HELP, unspecifiedDefaultValue = "false") boolean putIfAbsent) { - this.securityService.authorizeRegionWrite(regionPath); InternalCache cache = getCache(); + cache.getSecurityService().authorizeRegionWrite(regionPath); DataCommandResult dataResult; if (StringUtils.isEmpty(regionPath)) { return makePresentationResult(DataCommandResult.createPutResult(key, null, null, @@ -940,9 +937,9 @@ public class DataCommands implements CommandMarker { @CliOption(key = CliStrings.GET__LOAD, unspecifiedDefaultValue = "true", specifiedDefaultValue = "true", help = CliStrings.GET__LOAD__HELP) Boolean loadOnCacheMiss) { - this.securityService.authorizeRegionRead(regionPath, key); InternalCache cache = getCache(); + cache.getSecurityService().authorizeRegionRead(regionPath, key); DataCommandResult dataResult; if (StringUtils.isEmpty(regionPath)) { @@ -968,7 +965,7 @@ public class DataCommands implements CommandMarker { request.setRegionName(regionPath); request.setValueClass(valueClass); request.setLoadOnCacheMiss(loadOnCacheMiss); - Subject subject = this.securityService.getSubject(); + Subject subject = cache.getSecurityService().getSubject(); if (subject != null) { request.setPrincipal(subject.getPrincipal()); } @@ -979,7 +976,7 @@ public class DataCommands implements CommandMarker { false); } } else { - dataResult = getfn.get(null, key, keyClass, valueClass, regionPath, loadOnCacheMiss); + dataResult = getfn.get(null, key, keyClass, valueClass, regionPath, loadOnCacheMiss, cache.getSecurityService()); } dataResult.setKeyClass(keyClass); if (valueClass != null) { @@ -1005,7 +1002,7 @@ public class DataCommands implements CommandMarker { help = CliStrings.LOCATE_ENTRY__RECURSIVE__HELP, unspecifiedDefaultValue = "false") boolean recursive) { - this.securityService.authorizeRegionRead(regionPath, key); + getCache().getSecurityService().authorizeRegionRead(regionPath, key); DataCommandResult dataResult; @@ -1068,9 +1065,9 @@ public class DataCommands implements CommandMarker { } if (removeAllKeys) { - this.securityService.authorizeRegionWrite(regionPath); + cache.getSecurityService().authorizeRegionWrite(regionPath); } else { - this.securityService.authorizeRegionWrite(regionPath, key); + cache.getSecurityService().authorizeRegionWrite(regionPath, key); } @SuppressWarnings("rawtypes") @@ -1116,7 +1113,7 @@ public class DataCommands implements CommandMarker { } Object[] arguments = new Object[] {query, stepName, interactive}; - CLIStep exec = new DataCommandFunction.SelectExecStep(arguments); + CLIStep exec = new SelectExecStep(arguments); CLIStep display = new DataCommandFunction.SelectDisplayStep(arguments); CLIStep move = new DataCommandFunction.SelectMoveStep(arguments); CLIStep quit = new DataCommandFunction.SelectQuitStep(arguments); http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java index 544a517..dccb713 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java @@ -17,6 +17,7 @@ package org.apache.geode.management.internal.cli.commands; import org.apache.geode.SystemFailure; import org.apache.geode.cache.execute.ResultCollector; import org.apache.geode.distributed.DistributedMember; +import org.apache.geode.internal.security.SecurityService; import org.apache.geode.management.cli.CliMetaData; import org.apache.geode.management.cli.ConverterHint; import org.apache.geode.management.cli.Result; @@ -84,6 +85,7 @@ public class DeployCommands extends AbstractCommandsSupport { // since deploy function can potentially do a lot of damage to security, this action should // require these following privileges + SecurityService securityService = getCache().getSecurityService(); securityService.authorizeClusterManage(); securityService.authorizeClusterWrite(); securityService.authorizeDataManage(); http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java index 407424a..51e378a 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java @@ -84,8 +84,6 @@ public class IndexCommands extends AbstractCommandsSupport { private static final Set indexDefinitions = Collections.synchronizedSet(new HashSet()); - private SecurityService securityService = IntegratedSecurityService.getSecurityService(); - @Override protected Set getMembers(final InternalCache cache) { // TODO determine what this does (as it is untested and unmockable!) @@ -202,7 +200,7 @@ public class IndexCommands extends AbstractCommandsSupport { Result result = null; AtomicReference xmlEntity = new AtomicReference<>(); - this.securityService.authorizeRegionManage(regionPath); + getCache().getSecurityService().authorizeRegionManage(regionPath); try { final Cache cache = CacheFactory.getAnyInstance(); @@ -361,9 +359,9 @@ public class IndexCommands extends AbstractCommandsSupport { // requires data manage permission on all regions if (StringUtils.isNotBlank(regionPath)) { regionName = regionPath.startsWith("/") ? regionPath.substring(1) : regionPath; - this.securityService.authorizeRegionManage(regionName); + getCache().getSecurityService().authorizeRegionManage(regionName); } else { - this.securityService.authorizeDataManage(); + getCache().getSecurityService().authorizeDataManage(); } IndexInfo indexInfo = new IndexInfo(indexName, regionName); @@ -485,7 +483,7 @@ public class IndexCommands extends AbstractCommandsSupport { Result result = null; XmlEntity xmlEntity = null; - this.securityService.authorizeRegionManage(regionPath); + getCache().getSecurityService().authorizeRegionManage(regionPath); int idxType = IndexInfo.RANGE_INDEX; http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java index e2164a3..4621a86 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java @@ -94,9 +94,6 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti protected static final String SELECT_STEP_EXEC = "SELECT_EXEC"; private static final int NESTED_JSON_LENGTH = 20; - // this needs to be static so that it won't get serialized - private static SecurityService securityService = SecurityService.getSecurityService(); - @Override public String getId() { return DataCommandFunction.class.getName(); @@ -136,7 +133,7 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti } DataCommandResult result = null; if (request.isGet()) { - result = get(request); + result = get(request, cache.getSecurityService()); } else if (request.isLocateEntry()) { result = locateEntry(request); } else if (request.isPut()) { @@ -169,13 +166,13 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti return remove(key, keyClass, regionName, removeAllKeys); } - public DataCommandResult get(DataCommandRequest request) { + public DataCommandResult get(DataCommandRequest request, SecurityService securityService) { String key = request.getKey(); String keyClass = request.getKeyClass(); String valueClass = request.getValueClass(); String regionName = request.getRegionName(); Boolean loadOnCacheMiss = request.isLoadOnCacheMiss(); - return get(request.getPrincipal(), key, keyClass, valueClass, regionName, loadOnCacheMiss); + return get(request.getPrincipal(), key, keyClass, valueClass, regionName, loadOnCacheMiss, securityService); } public DataCommandResult locateEntry(DataCommandRequest request) { @@ -296,7 +293,7 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti List list, AtomicInteger nestedObjectCount) throws GfJsonException { for (Object object : selectResults) { // Post processing - object = securityService.postProcess(principal, null, null, object, false); + object = getCache().getSecurityService().postProcess(principal, null, null, object, false); if (object instanceof Struct) { StructImpl impl = (StructImpl) object; @@ -434,7 +431,7 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti @SuppressWarnings({"rawtypes"}) public DataCommandResult get(Object principal, String key, String keyClass, String valueClass, - String regionName, Boolean loadOnCacheMiss) { + String regionName, Boolean loadOnCacheMiss, SecurityService securityService) { InternalCache cache = getCache(); @@ -836,7 +833,7 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti return list; } - private static DataCommandResult cachedResult = null; + static DataCommandResult cachedResult = null; public static class SelectDisplayStep extends CLIMultiStepHelper.LocalStep { @@ -915,107 +912,6 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti } } - public static class SelectExecStep extends CLIMultiStepHelper.RemoteStep { - - private static final long serialVersionUID = 1L; - - private static SecurityService securityService = SecurityService.getSecurityService(); - - public SelectExecStep(Object[] arguments) { - super(SELECT_STEP_EXEC, arguments); - } - - @Override - public Result exec() { - String remainingQuery = (String) commandArguments[0]; - boolean interactive = (Boolean) commandArguments[2]; - DataCommandResult result = _select(remainingQuery); - int endCount = 0; - cachedResult = result; - if (interactive) { - endCount = getPageSize(); - } else { - if (result.getSelectResult() != null) { - endCount = result.getSelectResult().size(); - } - } - if (interactive) { - return result.pageResult(0, endCount, SELECT_STEP_DISPLAY); - } else { - return CLIMultiStepHelper.createBannerResult(new String[] {}, new Object[] {}, - SELECT_STEP_END); - } - } - - public DataCommandResult _select(String query) { - InternalCache cache = (InternalCache) CacheFactory.getAnyInstance(); - DataCommandResult dataResult; - - if (StringUtils.isEmpty(query)) { - dataResult = DataCommandResult.createSelectInfoResult(null, null, -1, null, - CliStrings.QUERY__MSG__QUERY_EMPTY, false); - return dataResult; - } - - Object array[] = DataCommands.replaceGfshEnvVar(query, CommandExecutionContext.getShellEnv()); - query = (String) array[1]; - query = addLimit(query); - - @SuppressWarnings("deprecation") - QCompiler compiler = new QCompiler(); - Set regionsInQuery; - try { - CompiledValue compiledQuery = compiler.compileQuery(query); - Set regions = new HashSet<>(); - compiledQuery.getRegionsInQuery(regions, null); - - // authorize data read on these regions - for (String region : regions) { - securityService.authorizeRegionRead(region); - } - - regionsInQuery = Collections.unmodifiableSet(regions); - if (regionsInQuery.size() > 0) { - Set members = - DataCommands.getQueryRegionsAssociatedMembers(regionsInQuery, cache, false); - if (members != null && members.size() > 0) { - DataCommandFunction function = new DataCommandFunction(); - DataCommandRequest request = new DataCommandRequest(); - request.setCommand(CliStrings.QUERY); - request.setQuery(query); - Subject subject = securityService.getSubject(); - if (subject != null) { - request.setPrincipal(subject.getPrincipal()); - } - dataResult = DataCommands.callFunctionForRegion(request, function, members); - dataResult.setInputQuery(query); - return dataResult; - } else { - return DataCommandResult.createSelectInfoResult(null, null, -1, null, CliStrings.format( - CliStrings.QUERY__MSG__REGIONS_NOT_FOUND, regionsInQuery.toString()), false); - } - } else { - return DataCommandResult.createSelectInfoResult(null, null, -1, null, - CliStrings.format(CliStrings.QUERY__MSG__INVALID_QUERY, - "Region mentioned in query probably missing /"), - false); - } - } catch (QueryInvalidException qe) { - logger.error("{} Failed Error {}", query, qe.getMessage(), qe); - return DataCommandResult.createSelectInfoResult(null, null, -1, null, - CliStrings.format(CliStrings.QUERY__MSG__INVALID_QUERY, qe.getMessage()), false); - } - } - - private String addLimit(String query) { - if (StringUtils.containsIgnoreCase(query, " limit") - || StringUtils.containsIgnoreCase(query, " count(")) { - return query; - } - return query + " limit " + getFetchSize(); - } - } - public static class SelectQuitStep extends CLIMultiStepHelper.RemoteStep { public SelectQuitStep(Object[] arguments) { @@ -1063,7 +959,7 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnti return pageSize; } - private static int getFetchSize() { + static int getFetchSize() { return CommandExecutionContext.getShellFetchSize(); } http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/SelectExecStep.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/SelectExecStep.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/SelectExecStep.java new file mode 100644 index 0000000..bd58534 --- /dev/null +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/SelectExecStep.java @@ -0,0 +1,139 @@ +/* + * 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 org.apache.geode.management.internal.cli.functions; + +import org.apache.commons.lang.StringUtils; +import org.apache.geode.cache.CacheFactory; +import org.apache.geode.cache.query.QueryInvalidException; +import org.apache.geode.cache.query.internal.CompiledValue; +import org.apache.geode.cache.query.internal.QCompiler; +import org.apache.geode.distributed.DistributedMember; +import org.apache.geode.internal.cache.InternalCache; +import org.apache.geode.internal.logging.LogService; +import org.apache.geode.management.cli.Result; +import org.apache.geode.management.internal.cli.commands.DataCommands; +import org.apache.geode.management.internal.cli.domain.DataCommandRequest; +import org.apache.geode.management.internal.cli.domain.DataCommandResult; +import org.apache.geode.management.internal.cli.i18n.CliStrings; +import org.apache.geode.management.internal.cli.multistep.CLIMultiStepHelper; +import org.apache.geode.management.internal.cli.remote.CommandExecutionContext; +import org.apache.logging.log4j.Logger; +import org.apache.shiro.subject.Subject; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +public class SelectExecStep extends CLIMultiStepHelper.RemoteStep { + private static final Logger logger = LogService.getLogger(); + + private static final long serialVersionUID = 1L; + + public SelectExecStep(Object[] arguments) { + super(DataCommandFunction.SELECT_STEP_EXEC, arguments); + } + + @Override + public Result exec() { + String remainingQuery = (String) commandArguments[0]; + boolean interactive = (Boolean) commandArguments[2]; + DataCommandResult result = _select(remainingQuery); + int endCount = 0; + DataCommandFunction.cachedResult = result; + if (interactive) { + endCount = DataCommandFunction.getPageSize(); + } else { + if (result.getSelectResult() != null) { + endCount = result.getSelectResult().size(); + } + } + if (interactive) { + return result.pageResult(0, endCount, DataCommandFunction.SELECT_STEP_DISPLAY); + } else { + return CLIMultiStepHelper.createBannerResult(new String[] {}, new Object[] {}, + DataCommandFunction.SELECT_STEP_END); + } + } + + public DataCommandResult _select(String query) { + InternalCache cache = (InternalCache) CacheFactory.getAnyInstance(); + DataCommandResult dataResult; + + if (StringUtils.isEmpty(query)) { + dataResult = DataCommandResult.createSelectInfoResult(null, null, -1, null, + CliStrings.QUERY__MSG__QUERY_EMPTY, false); + return dataResult; + } + + Object array[] = DataCommands.replaceGfshEnvVar(query, CommandExecutionContext.getShellEnv()); + query = (String) array[1]; + query = addLimit(query); + + @SuppressWarnings("deprecation") + QCompiler compiler = new QCompiler(); + Set regionsInQuery; + try { + CompiledValue compiledQuery = compiler.compileQuery(query); + Set regions = new HashSet<>(); + compiledQuery.getRegionsInQuery(regions, null); + + // authorize data read on these regions + for (String region : regions) { + cache.getSecurityService().authorizeRegionRead(region); + } + + regionsInQuery = Collections.unmodifiableSet(regions); + if (regionsInQuery.size() > 0) { + Set members = + DataCommands.getQueryRegionsAssociatedMembers(regionsInQuery, cache, false); + if (members != null && members.size() > 0) { + DataCommandFunction function = new DataCommandFunction(); + DataCommandRequest request = new DataCommandRequest(); + request.setCommand(CliStrings.QUERY); + request.setQuery(query); + Subject subject = cache.getSecurityService().getSubject(); + if (subject != null) { + request.setPrincipal(subject.getPrincipal()); + } + dataResult = DataCommands.callFunctionForRegion(request, function, members); + dataResult.setInputQuery(query); + return dataResult; + } else { + return DataCommandResult.createSelectInfoResult(null, null, -1, null, CliStrings.format( + CliStrings.QUERY__MSG__REGIONS_NOT_FOUND, regionsInQuery.toString()), false); + } + } else { + return DataCommandResult.createSelectInfoResult(null, null, -1, null, + CliStrings.format(CliStrings.QUERY__MSG__INVALID_QUERY, + "Region mentioned in query probably missing /"), + false); + } + } catch (QueryInvalidException qe) { + logger.error("{} Failed Error {}", query, qe.getMessage(), qe); + return DataCommandResult.createSelectInfoResult(null, null, -1, null, + CliStrings.format(CliStrings.QUERY__MSG__INVALID_QUERY, qe.getMessage()), false); + } + } + + private String addLimit(String query) { + if (StringUtils.containsIgnoreCase(query, " limit") + || StringUtils.containsIgnoreCase(query, " count(")) { + return query; + } + return query + " limit " + DataCommandFunction.getFetchSize(); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/CommandProcessor.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/CommandProcessor.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/CommandProcessor.java index c2c6e14..f7d78cc 100755 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/CommandProcessor.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/CommandProcessor.java @@ -14,6 +14,7 @@ */ package org.apache.geode.management.internal.cli.remote; +import org.apache.geode.internal.security.DisabledSecurityService; import org.apache.geode.internal.security.IntegratedSecurityService; import org.apache.geode.internal.security.SecurityService; import org.apache.geode.management.cli.CommandProcessingException; @@ -49,16 +50,17 @@ public class CommandProcessor { private volatile boolean isStopped = false; - private SecurityService securityService = IntegratedSecurityService.getSecurityService(); + private final SecurityService securityService; public CommandProcessor() throws ClassNotFoundException, IOException { - this(null); + this(null, new DisabledSecurityService()); } - public CommandProcessor(Properties cacheProperties) throws ClassNotFoundException, IOException { + public CommandProcessor(Properties cacheProperties, SecurityService securityService) throws ClassNotFoundException, IOException { this.gfshParser = new GfshParser(cacheProperties); this.executionStrategy = new RemoteExecutionStrategy(); this.logWrapper = LogWrapper.getInstance(); + this.securityService = securityService; } protected RemoteExecutionStrategy getExecutionStrategy() { http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/MemberCommandService.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/MemberCommandService.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/MemberCommandService.java index a19c5cb..ed9d6ae 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/MemberCommandService.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/MemberCommandService.java @@ -17,24 +17,22 @@ package org.apache.geode.management.internal.cli.remote; import java.io.IOException; import java.util.Map; -import org.apache.geode.cache.Cache; +import org.apache.geode.internal.cache.InternalCache; import org.apache.geode.management.cli.CommandService; import org.apache.geode.management.cli.CommandServiceException; import org.apache.geode.management.cli.CommandStatement; import org.apache.geode.management.cli.Result; -/** - */ public class MemberCommandService extends CommandService { private final Object modLock = new Object(); - private Cache cache; + private InternalCache cache; private CommandProcessor commandProcessor; - public MemberCommandService(Cache cache) throws CommandServiceException { + public MemberCommandService(InternalCache cache) throws CommandServiceException { this.cache = cache; try { - this.commandProcessor = new CommandProcessor(cache.getDistributedSystem().getProperties()); + this.commandProcessor = new CommandProcessor(cache.getDistributedSystem().getProperties(), cache.getSecurityService()); } catch (ClassNotFoundException e) { throw new CommandServiceException("Could not load commands.", e); } catch (IOException e) { @@ -70,12 +68,4 @@ public class MemberCommandService extends CommandService { return (this.cache != null && !this.cache.isClosed()); } - // @Override - // public void stop() { - // cache = null; - // synchronized (modLock) { - // this.commandProcessor.stop(); - // this.commandProcessor = null; - // } - // } } http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/management/internal/security/AccessControlMBean.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/security/AccessControlMBean.java b/geode-core/src/main/java/org/apache/geode/management/internal/security/AccessControlMBean.java index 6514a33..dbc6c6b 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/security/AccessControlMBean.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/security/AccessControlMBean.java @@ -26,7 +26,11 @@ import org.apache.geode.security.GemFireSecurityException; */ public class AccessControlMBean implements AccessControlMXBean { - private SecurityService securityService = IntegratedSecurityService.getSecurityService(); + private final SecurityService securityService; + + public AccessControlMBean(SecurityService securityService) { + this.securityService = securityService; + } @Override public boolean authorize(String resource, String permission) { http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/management/internal/security/MBeanServerWrapper.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/security/MBeanServerWrapper.java b/geode-core/src/main/java/org/apache/geode/management/internal/security/MBeanServerWrapper.java index fe79efb..345d688 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/security/MBeanServerWrapper.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/security/MBeanServerWrapper.java @@ -14,6 +14,11 @@ */ package org.apache.geode.management.internal.security; +import org.apache.geode.internal.security.SecurityService; +import org.apache.geode.management.internal.ManagementConstants; +import org.apache.geode.security.GemFireSecurityException; +import org.apache.geode.security.ResourcePermission; + import java.io.ObjectInputStream; import java.util.Set; import javax.management.Attribute; @@ -42,25 +47,22 @@ import javax.management.ReflectionException; import javax.management.loading.ClassLoaderRepository; import javax.management.remote.MBeanServerForwarder; -import org.apache.geode.internal.security.IntegratedSecurityService; -import org.apache.geode.internal.security.SecurityService; -import org.apache.geode.management.internal.ManagementConstants; -import org.apache.geode.security.GemFireSecurityException; -import org.apache.geode.security.ResourcePermission; - /** * This class intercepts all MBean requests for GemFire MBeans and passed it to * ManagementInterceptor for authorization * * @since Geode 1.0 - * */ public class MBeanServerWrapper implements MBeanServerForwarder { + + // TODO: make volatile or verify this is thread-safe private MBeanServer mbs; - private SecurityService securityService = IntegratedSecurityService.getSecurityService(); + private final SecurityService securityService; - public MBeanServerWrapper() {} + public MBeanServerWrapper(SecurityService securityService) { + this.securityService = securityService; + } private void checkDomain(ObjectName name) { if (ManagementConstants.OBJECTNAME__DEFAULTDOMAIN.equals(name.getDomain())) http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java index 54c29f8..0a18ec5 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/AbstractCommandsController.java @@ -12,7 +12,6 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ - package org.apache.geode.management.internal.web.controllers; import org.apache.geode.internal.cache.GemFireCacheImpl; @@ -20,8 +19,6 @@ import org.apache.geode.internal.cache.InternalCache; import org.apache.geode.internal.lang.StringUtils; import org.apache.geode.internal.logging.LogService; import org.apache.geode.internal.logging.log4j.LogMarker; -import org.apache.geode.internal.security.IntegratedSecurityService; -import org.apache.geode.internal.security.SecurityService; import org.apache.geode.internal.util.ArrayUtils; import org.apache.geode.management.DistributedSystemMXBean; import org.apache.geode.management.ManagementService; @@ -85,8 +82,6 @@ public abstract class AbstractCommandsController { private MemberMXBean managingMemberMXBeanProxy; - private SecurityService securityService = IntegratedSecurityService.getSecurityService(); - private Class accessControlKlass; private InternalCache getCache() { @@ -576,10 +571,9 @@ public abstract class AbstractCommandsController { return new ResponseEntity(result, HttpStatus.OK); } }; - return this.securityService.associateWith(callable); + return getCache().getSecurityService().associateWith(callable); } - /** * 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 http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptor.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptor.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptor.java index 56d9b9e..ffe1895 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptor.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptor.java @@ -14,10 +14,11 @@ */ package org.apache.geode.management.internal.web.controllers.support; -import org.apache.geode.cache.Cache; import org.apache.geode.distributed.internal.DistributionConfig; +import org.apache.geode.internal.cache.GemFireCacheImpl; +import org.apache.geode.internal.cache.InternalCache; import org.apache.geode.internal.logging.LogService; -import org.apache.geode.internal.security.IntegratedSecurityService; +import org.apache.geode.internal.security.DisabledSecurityService; import org.apache.geode.internal.security.SecurityService; import org.apache.geode.management.internal.cli.multistep.CLIMultiStepHelper; import org.apache.geode.management.internal.security.ResourceConstants; @@ -48,9 +49,7 @@ public class LoginHandlerInterceptor extends HandlerInterceptorAdapter { private static final Logger logger = LogService.getLogger(); - private Cache cache; - - private SecurityService securityService = IntegratedSecurityService.getSecurityService(); + private final SecurityService securityService; private static final ThreadLocal> ENV = new ThreadLocal>() { @@ -65,10 +64,26 @@ public class LoginHandlerInterceptor extends HandlerInterceptorAdapter { protected static final String SECURITY_VARIABLE_REQUEST_HEADER_PREFIX = DistributionConfig.SECURITY_PREFIX_NAME; + public LoginHandlerInterceptor() { + this(findSecurityService()); + } + + LoginHandlerInterceptor(SecurityService securityService) { + this.securityService = securityService; + } + public static Map getEnvironment() { return ENV.get(); } + private static SecurityService findSecurityService() { + InternalCache cache = GemFireCacheImpl.getInstance(); + if (cache != null) { + return cache.getSecurityService(); + } + return new DisabledSecurityService(); + } + @Override public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) throws Exception { @@ -104,11 +119,6 @@ public class LoginHandlerInterceptor extends HandlerInterceptorAdapter { return true; } - public void setSecurityService(SecurityService securityService) { - this.securityService = securityService; - } - - @Override public void afterCompletion(final HttpServletRequest request, final HttpServletResponse response, final Object handler, final Exception ex) throws Exception { http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/main/java/org/apache/geode/security/PostProcessor.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/security/PostProcessor.java b/geode-core/src/main/java/org/apache/geode/security/PostProcessor.java index 707e3cf..bad58d8 100644 --- a/geode-core/src/main/java/org/apache/geode/security/PostProcessor.java +++ b/geode-core/src/main/java/org/apache/geode/security/PostProcessor.java @@ -28,7 +28,7 @@ public interface PostProcessor { * Given the security props of the server, properly initialize the post processor for the server. * Initialized at cache creation * - * @param securityProps + * @param securityProps security properties */ default void init(Properties securityProps) {} http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/test/java/org/apache/geode/internal/cache/ha/BlockingHARegionJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/ha/BlockingHARegionJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/ha/BlockingHARegionJUnitTest.java index d0f5793..ee8b6fa 100755 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/ha/BlockingHARegionJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/ha/BlockingHARegionJUnitTest.java @@ -390,7 +390,8 @@ public class BlockingHARegionJUnitTest { } } catch (Exception e) { exceptionOccurred = true; - exceptionString.append(" Exception occurred due to " + e); + exceptionString.append(" Exception occurred due to ").append(e); + break; } } } @@ -414,9 +415,13 @@ public class BlockingHARegionJUnitTest { for (int i = 0; i < numberOfTakes; i++) { try { assertNotNull(this.regionQueue.take()); + if (Thread.currentThread().isInterrupted()) { + break; + } } catch (Exception e) { exceptionOccurred = true; - exceptionString.append(" Exception occurred due to " + e); + exceptionString.append(" Exception occurred due to ").append(e); + break; } } } http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionTest.java index 153e77b..794c610 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionTest.java @@ -27,7 +27,9 @@ import static org.mockito.Mockito.when; import org.apache.geode.cache.Cache; import org.apache.geode.internal.Version; +import org.apache.geode.internal.cache.InternalCache; import org.apache.geode.internal.cache.tier.Acceptor; +import org.apache.geode.internal.security.SecurityService; import org.apache.geode.security.AuthenticationRequiredException; import org.apache.geode.test.junit.categories.UnitTest; import org.junit.Before; @@ -64,10 +66,11 @@ public class ServerConnectionTest { Socket socket = mock(Socket.class); when(socket.getInetAddress()).thenReturn(inetAddress); - Cache cache = mock(Cache.class); + InternalCache cache = mock(InternalCache.class); + SecurityService securityService = mock(SecurityService.class); serverConnection = new ServerConnection(socket, cache, null, null, 0, 0, null, - Acceptor.PRIMARY_SERVER_TO_CLIENT, acceptor); + Acceptor.PRIMARY_SERVER_TO_CLIENT, acceptor, securityService); MockitoAnnotations.initMocks(this); } http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKey66Test.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKey66Test.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKey66Test.java index 3a6c2a3..591aba9 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKey66Test.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKey66Test.java @@ -100,7 +100,7 @@ public class ContainsKey66Test { public void noSecurityShouldSucceed() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(false); - this.containsKey66.cmdExecute(this.message, this.serverConnection, 0); + this.containsKey66.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.responseMessage).send(this.serverConnection); } @@ -110,7 +110,7 @@ public class ContainsKey66Test { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(true); - this.containsKey66.cmdExecute(this.message, this.serverConnection, 0); + this.containsKey66.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeRegionRead(eq(REGION_NAME), eq(KEY)); verify(this.responseMessage).send(this.serverConnection); @@ -123,7 +123,7 @@ public class ContainsKey66Test { doThrow(new NotAuthorizedException("")).when(this.securityService) .authorizeRegionRead(eq(REGION_NAME), eq(KEY)); - this.containsKey66.cmdExecute(this.message, this.serverConnection, 0); + this.containsKey66.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeRegionRead(eq(REGION_NAME), eq(KEY)); verify(this.errorResponseMessage).send(eq(this.serverConnection)); @@ -134,7 +134,7 @@ public class ContainsKey66Test { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); - this.containsKey66.cmdExecute(this.message, this.serverConnection, 0); + this.containsKey66.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).containsKeyAuthorize(eq(REGION_NAME), eq(KEY)); verify(this.responseMessage).send(this.serverConnection); @@ -147,7 +147,7 @@ public class ContainsKey66Test { doThrow(new NotAuthorizedException("")).when(this.authzRequest) .containsKeyAuthorize(eq(REGION_NAME), eq(KEY)); - this.containsKey66.cmdExecute(this.message, this.serverConnection, 0); + this.containsKey66.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).containsKeyAuthorize(eq(REGION_NAME), eq(KEY)); verify(this.errorResponseMessage).send(eq(this.serverConnection)); http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKeyTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKeyTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKeyTest.java index bc1be3e..0492997 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKeyTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ContainsKeyTest.java @@ -88,7 +88,7 @@ public class ContainsKeyTest { public void noSecurityShouldSucceed() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(false); - containsKey.cmdExecute(this.message, this.serverConnection, 0); + containsKey.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.replyMessage).send(this.serverConnection); } @@ -98,7 +98,7 @@ public class ContainsKeyTest { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(true); - containsKey.cmdExecute(this.message, this.serverConnection, 0); + containsKey.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeRegionRead(eq(REGION_NAME), eq(KEY)); verify(this.replyMessage).send(this.serverConnection); @@ -111,7 +111,7 @@ public class ContainsKeyTest { doThrow(new NotAuthorizedException("")).when(this.securityService) .authorizeRegionRead(eq(REGION_NAME), eq(KEY)); - containsKey.cmdExecute(this.message, this.serverConnection, 0); + containsKey.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeRegionRead(eq(REGION_NAME), eq(KEY)); verify(this.errorResponseMessage).send(eq(this.serverConnection)); @@ -123,7 +123,7 @@ public class ContainsKeyTest { when(this.securityService.isIntegratedSecurity()).thenReturn(false); - containsKey.cmdExecute(this.message, this.serverConnection, 0); + containsKey.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).containsKeyAuthorize(eq(REGION_NAME), eq(KEY)); verify(this.replyMessage).send(this.serverConnection); @@ -136,7 +136,7 @@ public class ContainsKeyTest { doThrow(new NotAuthorizedException("")).when(this.authzRequest) .containsKeyAuthorize(eq(REGION_NAME), eq(KEY)); - containsKey.cmdExecute(this.message, this.serverConnection, 0); + containsKey.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).containsKeyAuthorize(eq(REGION_NAME), eq(KEY)); verify(this.errorResponseMessage).send(eq(this.serverConnection)); http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/CreateRegionTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/CreateRegionTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/CreateRegionTest.java index c946e8a..6d346f7 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/CreateRegionTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/CreateRegionTest.java @@ -98,7 +98,7 @@ public class CreateRegionTest { public void noSecurityShouldSucceed() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(false); - this.createRegion.cmdExecute(this.message, this.serverConnection, 0); + this.createRegion.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.responseMessage).send(this.serverConnection); } @@ -110,7 +110,7 @@ public class CreateRegionTest { when(this.securityService.isIntegratedSecurity()).thenReturn(true); // act - this.createRegion.cmdExecute(this.message, this.serverConnection, 0); + this.createRegion.cmdExecute(this.message, this.serverConnection, this.securityService, 0); // assert verify(this.securityService).authorizeDataManage(); @@ -123,7 +123,7 @@ public class CreateRegionTest { when(this.securityService.isIntegratedSecurity()).thenReturn(true); doThrow(new NotAuthorizedException("")).when(this.securityService).authorizeDataManage(); - this.createRegion.cmdExecute(this.message, this.serverConnection, 0); + this.createRegion.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeDataManage(); verify(this.errorResponseMessage).send(eq(this.serverConnection)); @@ -134,7 +134,7 @@ public class CreateRegionTest { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); - this.createRegion.cmdExecute(this.message, this.serverConnection, 0); + this.createRegion.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).createRegionAuthorize(eq(PARENT_REGION_NAME + '/' + REGION_NAME)); verify(this.responseMessage).send(this.serverConnection); @@ -147,7 +147,7 @@ public class CreateRegionTest { doThrow(new NotAuthorizedException("")).when(this.authzRequest) .createRegionAuthorize(eq(PARENT_REGION_NAME + '/' + REGION_NAME)); - this.createRegion.cmdExecute(this.message, this.serverConnection, 0); + this.createRegion.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).createRegionAuthorize(eq(PARENT_REGION_NAME + '/' + REGION_NAME)); verify(this.errorResponseMessage).send(eq(this.serverConnection)); http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/Destroy65Test.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/Destroy65Test.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/Destroy65Test.java index d3f68f2..a482a8c 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/Destroy65Test.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/Destroy65Test.java @@ -118,7 +118,7 @@ public class Destroy65Test { public void noSecurityShouldSucceed() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(false); - this.destroy65.cmdExecute(this.message, this.serverConnection, 0); + this.destroy65.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.responseMessage).send(this.serverConnection); } @@ -128,7 +128,7 @@ public class Destroy65Test { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(true); - this.destroy65.cmdExecute(this.message, this.serverConnection, 0); + this.destroy65.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeRegionWrite(eq(REGION_NAME), eq(KEY)); verify(this.responseMessage).send(this.serverConnection); @@ -141,7 +141,7 @@ public class Destroy65Test { doThrow(new NotAuthorizedException("")).when(this.securityService) .authorizeRegionWrite(eq(REGION_NAME), eq(KEY)); - this.destroy65.cmdExecute(this.message, this.serverConnection, 0); + this.destroy65.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeRegionWrite(eq(REGION_NAME), eq(KEY)); verify(this.errorResponseMessage).send(eq(this.serverConnection)); @@ -152,7 +152,7 @@ public class Destroy65Test { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); - this.destroy65.cmdExecute(this.message, this.serverConnection, 0); + this.destroy65.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).destroyAuthorize(eq(REGION_NAME), eq(KEY), eq(CALLBACK_ARG)); verify(this.responseMessage).send(this.serverConnection); @@ -165,7 +165,7 @@ public class Destroy65Test { doThrow(new NotAuthorizedException("")).when(this.authzRequest) .destroyAuthorize(eq(REGION_NAME), eq(KEY), eq(CALLBACK_ARG)); - this.destroy65.cmdExecute(this.message, this.serverConnection, 0); + this.destroy65.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).destroyAuthorize(eq(REGION_NAME), eq(KEY), eq(CALLBACK_ARG)); verify(this.errorResponseMessage).send(eq(this.serverConnection)); http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/DestroyRegionTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/DestroyRegionTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/DestroyRegionTest.java index 4abdebf..6b367c1 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/DestroyRegionTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/DestroyRegionTest.java @@ -110,7 +110,7 @@ public class DestroyRegionTest { public void noSecurityShouldSucceed() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(false); - this.destroyRegion.cmdExecute(this.message, this.serverConnection, 0); + this.destroyRegion.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeDataManage(); verify(this.responseMessage).send(this.serverConnection); @@ -121,7 +121,7 @@ public class DestroyRegionTest { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(true); - this.destroyRegion.cmdExecute(this.message, this.serverConnection, 0); + this.destroyRegion.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeDataManage(); verify(this.responseMessage).send(this.serverConnection); @@ -133,7 +133,7 @@ public class DestroyRegionTest { when(this.securityService.isIntegratedSecurity()).thenReturn(true); doThrow(new NotAuthorizedException("")).when(this.securityService).authorizeDataManage(); - this.destroyRegion.cmdExecute(this.message, this.serverConnection, 0); + this.destroyRegion.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.errorResponseMessage).send(this.serverConnection); } @@ -143,7 +143,7 @@ public class DestroyRegionTest { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); - this.destroyRegion.cmdExecute(this.message, this.serverConnection, 0); + this.destroyRegion.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).destroyRegionAuthorize(eq(REGION_NAME), eq(CALLBACK_ARG)); verify(this.responseMessage).send(this.serverConnection); @@ -156,7 +156,7 @@ public class DestroyRegionTest { doThrow(new NotAuthorizedException("")).when(this.authzRequest) .destroyRegionAuthorize(eq(REGION_NAME), eq(CALLBACK_ARG)); - this.destroyRegion.cmdExecute(this.message, this.serverConnection, 0); + this.destroyRegion.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).destroyRegionAuthorize(eq(REGION_NAME), eq(CALLBACK_ARG)); verify(this.errorResponseMessage).send(this.serverConnection); http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/DestroyTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/DestroyTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/DestroyTest.java index 24105a6..a4a6820 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/DestroyTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/DestroyTest.java @@ -121,7 +121,7 @@ public class DestroyTest { public void noSecurityShouldSucceed() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(false); - this.destroy.cmdExecute(this.message, this.serverConnection, 0); + this.destroy.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.replyMessage).send(this.serverConnection); } @@ -131,7 +131,7 @@ public class DestroyTest { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(true); - this.destroy.cmdExecute(this.message, this.serverConnection, 0); + this.destroy.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeRegionWrite(eq(REGION_NAME), eq(KEY)); verify(this.replyMessage).send(this.serverConnection); @@ -144,7 +144,7 @@ public class DestroyTest { doThrow(new NotAuthorizedException("")).when(this.securityService) .authorizeRegionWrite(eq(REGION_NAME), eq(KEY)); - this.destroy.cmdExecute(this.message, this.serverConnection, 0); + this.destroy.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.errorResponseMessage).send(eq(this.serverConnection)); @@ -155,7 +155,7 @@ public class DestroyTest { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); - this.destroy.cmdExecute(this.message, this.serverConnection, 0); + this.destroy.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).destroyAuthorize(eq(REGION_NAME), eq(KEY), eq(CALLBACK_ARG)); verify(this.replyMessage).send(this.serverConnection); @@ -168,7 +168,7 @@ public class DestroyTest { doThrow(new NotAuthorizedException("")).when(this.authzRequest) .destroyAuthorize(eq(REGION_NAME), eq(KEY), eq(CALLBACK_ARG)); - this.destroy.cmdExecute(this.message, this.serverConnection, 0); + this.destroy.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).destroyAuthorize(eq(REGION_NAME), eq(KEY), eq(CALLBACK_ARG)); verify(this.errorResponseMessage).send(eq(this.serverConnection)); http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction65Test.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction65Test.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction65Test.java index 8df33ab..c64bbb9 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction65Test.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction65Test.java @@ -41,7 +41,6 @@ import org.apache.geode.internal.cache.GemFireCacheImpl; import org.apache.geode.internal.cache.LocalRegion; import org.apache.geode.internal.cache.control.HeapMemoryMonitor; import org.apache.geode.internal.cache.control.InternalResourceManager; -import org.apache.geode.internal.cache.execute.AbstractExecution; import org.apache.geode.internal.cache.tier.CachedRegionHelper; import org.apache.geode.internal.cache.tier.sockets.AcceptorImpl; import org.apache.geode.internal.cache.tier.sockets.ChunkedMessage; @@ -153,7 +152,7 @@ public class ExecuteFunction65Test { public void nonSecureShouldSucceed() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(false); - this.executeFunction65.cmdExecute(this.message, this.serverConnection, 0); + this.executeFunction65.cmdExecute(this.message, this.serverConnection, this.securityService, 0); // verify(this.functionResponseMessage).sendChunk(this.serverConnection); // TODO: why do none // of the reply message types get sent? @@ -164,7 +163,7 @@ public class ExecuteFunction65Test { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(true); - this.executeFunction65.cmdExecute(this.message, this.serverConnection, 0); + this.executeFunction65.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeDataWrite(); // verify(this.replyMessage).send(this.serverConnection); TODO: why do none of the reply message @@ -177,7 +176,7 @@ public class ExecuteFunction65Test { when(this.securityService.isIntegratedSecurity()).thenReturn(true); doThrow(new NotAuthorizedException("")).when(this.securityService).authorizeDataWrite(); - this.executeFunction65.cmdExecute(this.message, this.serverConnection, 0); + this.executeFunction65.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeDataWrite(); // verify(this.chunkedResponseMessage).sendChunk(this.serverConnection); @@ -188,7 +187,7 @@ public class ExecuteFunction65Test { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); - this.executeFunction65.cmdExecute(this.message, this.serverConnection, 0); + this.executeFunction65.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).executeFunctionAuthorize(eq(FUNCTION_ID), any(), any(), any(), eq(false)); @@ -203,7 +202,7 @@ public class ExecuteFunction65Test { doThrow(new NotAuthorizedException("")).when(this.authzRequest) .executeFunctionAuthorize(eq(FUNCTION_ID), any(), any(), any(), eq(false)); - this.executeFunction65.cmdExecute(this.message, this.serverConnection, 0); + this.executeFunction65.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeDataWrite(); // verify(this.chunkedResponseMessage).sendChunk(this.serverConnection); http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction66Test.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction66Test.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction66Test.java index 3c60419..fe49544 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction66Test.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunction66Test.java @@ -150,7 +150,7 @@ public class ExecuteFunction66Test { public void nonSecureShouldSucceed() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(false); - this.executeFunction66.cmdExecute(this.message, this.serverConnection, 0); + this.executeFunction66.cmdExecute(this.message, this.serverConnection, this.securityService, 0); // verify(this.functionResponseMessage).sendChunk(this.serverConnection); // TODO: why do none // of the reply message types get sent? @@ -161,7 +161,7 @@ public class ExecuteFunction66Test { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(true); - this.executeFunction66.cmdExecute(this.message, this.serverConnection, 0); + this.executeFunction66.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeDataWrite(); // verify(this.replyMessage).send(this.serverConnection); TODO: why do none of the reply message @@ -175,7 +175,7 @@ public class ExecuteFunction66Test { doThrow(new NotAuthorizedException("")).when(this.securityService).authorizeDataWrite(); assertThatThrownBy( - () -> this.executeFunction66.cmdExecute(this.message, this.serverConnection, 0)) + () -> this.executeFunction66.cmdExecute(this.message, this.serverConnection, this.securityService, 0)) .isExactlyInstanceOf(NullPointerException.class); verify(this.securityService).authorizeDataWrite(); @@ -187,7 +187,7 @@ public class ExecuteFunction66Test { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); - this.executeFunction66.cmdExecute(this.message, this.serverConnection, 0); + this.executeFunction66.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).executeFunctionAuthorize(eq(FUNCTION_ID), any(), any(), any(), eq(false)); @@ -203,7 +203,7 @@ public class ExecuteFunction66Test { .executeFunctionAuthorize(eq(FUNCTION_ID), any(), any(), any(), eq(false)); assertThatThrownBy( - () -> this.executeFunction66.cmdExecute(this.message, this.serverConnection, 0)) + () -> this.executeFunction66.cmdExecute(this.message, this.serverConnection, this.securityService, 0)) .isExactlyInstanceOf(NullPointerException.class); verify(this.securityService).authorizeDataWrite(); http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunctionTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunctionTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunctionTest.java index 67b5ca6..a9d9498 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunctionTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteFunctionTest.java @@ -33,7 +33,6 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.apache.geode.CancelCriterion; -import org.apache.geode.cache.control.ResourceManager; import org.apache.geode.cache.execute.FunctionService; import org.apache.geode.cache.operations.ExecuteFunctionOperationContext; import org.apache.geode.distributed.internal.DistributionConfig; @@ -156,7 +155,7 @@ public class ExecuteFunctionTest { public void nonSecureShouldSucceed() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(false); - this.executeFunction.cmdExecute(this.message, this.serverConnection, 0); + this.executeFunction.cmdExecute(this.message, this.serverConnection, this.securityService, 0); // verify(this.functionResponseMessage).sendChunk(this.serverConnection); // TODO: why do none // of the reply message types get sent? @@ -167,7 +166,7 @@ public class ExecuteFunctionTest { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(true); - this.executeFunction.cmdExecute(this.message, this.serverConnection, 0); + this.executeFunction.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeDataWrite(); // verify(this.replyMessage).send(this.serverConnection); TODO: why do none of the reply message @@ -180,7 +179,7 @@ public class ExecuteFunctionTest { when(this.securityService.isIntegratedSecurity()).thenReturn(true); doThrow(new NotAuthorizedException("")).when(this.securityService).authorizeDataWrite(); - this.executeFunction.cmdExecute(this.message, this.serverConnection, 0); + this.executeFunction.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeDataWrite(); verify(this.chunkedResponseMessage).sendChunk(this.serverConnection); @@ -191,7 +190,7 @@ public class ExecuteFunctionTest { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); - this.executeFunction.cmdExecute(this.message, this.serverConnection, 0); + this.executeFunction.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).executeFunctionAuthorize(eq(FUNCTION_ID), any(), any(), any(), eq(false)); @@ -206,7 +205,7 @@ public class ExecuteFunctionTest { doThrow(new NotAuthorizedException("")).when(this.authzRequest) .executeFunctionAuthorize(eq(FUNCTION_ID), any(), any(), any(), eq(false)); - this.executeFunction.cmdExecute(this.message, this.serverConnection, 0); + this.executeFunction.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.chunkedResponseMessage).sendChunk(this.serverConnection); } http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/Get70Test.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/Get70Test.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/Get70Test.java index d81dfd7..734eb51 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/Get70Test.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/Get70Test.java @@ -114,7 +114,7 @@ public class Get70Test { public void noSecurityShouldSucceed() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(false); - this.get70.cmdExecute(this.message, this.serverConnection, 0); + this.get70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.responseMessage).send(this.serverConnection); } @@ -123,7 +123,7 @@ public class Get70Test { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(true); - this.get70.cmdExecute(this.message, this.serverConnection, 0); + this.get70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeRegionRead(eq(REGION_NAME), eq(KEY)); verify(this.responseMessage).send(this.serverConnection); @@ -136,7 +136,7 @@ public class Get70Test { doThrow(new NotAuthorizedException("")).when(this.securityService) .authorizeRegionRead(eq(REGION_NAME), eq(KEY)); - this.get70.cmdExecute(this.message, this.serverConnection, 0); + this.get70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.securityService).authorizeRegionRead(eq(REGION_NAME), eq(KEY)); verify(this.errorResponseMessage).send(eq(this.serverConnection)); @@ -147,7 +147,7 @@ public class Get70Test { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); - this.get70.cmdExecute(this.message, this.serverConnection, 0); + this.get70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(KEY), eq(CALLBACK_ARG)); verify(this.responseMessage).send(this.serverConnection); @@ -160,7 +160,7 @@ public class Get70Test { doThrow(new NotAuthorizedException("")).when(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(KEY), eq(CALLBACK_ARG)); - this.get70.cmdExecute(this.message, this.serverConnection, 0); + this.get70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(KEY), eq(CALLBACK_ARG)); verify(this.errorResponseMessage).send(eq(this.serverConnection)); http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/GetAll651Test.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/GetAll651Test.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/GetAll651Test.java index 974fa05..4bf4a5c 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/GetAll651Test.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/GetAll651Test.java @@ -100,7 +100,7 @@ public class GetAll651Test { public void noSecurityShouldSucceed() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(false); - this.getAll651.cmdExecute(this.message, this.serverConnection, 0); + this.getAll651.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); } @@ -110,7 +110,7 @@ public class GetAll651Test { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(true); - this.getAll651.cmdExecute(this.message, this.serverConnection, 0); + this.getAll651.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); @@ -136,7 +136,7 @@ public class GetAll651Test { .authorizeRegionRead(eq(REGION_NAME), eq(key.toString())); } - this.getAll651.cmdExecute(this.message, this.serverConnection, 0); + this.getAll651.cmdExecute(this.message, this.serverConnection, this.securityService, 0); for (Object key : KEYS) { verify(this.securityService).authorizeRegionRead(eq(REGION_NAME), eq(key.toString())); @@ -158,7 +158,7 @@ public class GetAll651Test { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); - this.getAll651.cmdExecute(this.message, this.serverConnection, 0); + this.getAll651.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); @@ -184,7 +184,7 @@ public class GetAll651Test { doThrow(new NotAuthorizedException("")).when(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } - this.getAll651.cmdExecute(this.message, this.serverConnection, 0); + this.getAll651.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); http://git-wip-us.apache.org/repos/asf/geode/blob/13b94704/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/GetAll70Test.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/GetAll70Test.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/GetAll70Test.java index 018993c..95e95f5 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/GetAll70Test.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/command/GetAll70Test.java @@ -113,7 +113,7 @@ public class GetAll70Test { public void noSecurityShouldSucceed() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(false); - this.getAll70.cmdExecute(this.message, this.serverConnection, 0); + this.getAll70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.chunkedResponseMessage).sendChunk(this.serverConnection); } @@ -123,7 +123,7 @@ public class GetAll70Test { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(true); - this.getAll70.cmdExecute(this.message, this.serverConnection, 0); + this.getAll70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPartNoCopying(argument.capture()); @@ -149,7 +149,7 @@ public class GetAll70Test { .authorizeRegionRead(eq(REGION_NAME), eq(key.toString())); } - this.getAll70.cmdExecute(this.message, this.serverConnection, 0); + this.getAll70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); for (Object key : KEYS) { verify(this.securityService).authorizeRegionRead(eq(REGION_NAME), eq(key.toString())); @@ -171,7 +171,7 @@ public class GetAll70Test { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); - this.getAll70.cmdExecute(this.message, this.serverConnection, 0); + this.getAll70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPartNoCopying(argument.capture()); @@ -198,7 +198,7 @@ public class GetAll70Test { eq(key.toString()), eq(null)); } - this.getAll70.cmdExecute(this.message, this.serverConnection, 0); + this.getAll70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPartNoCopying(argument.capture());