Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fail proxies creation if any of permissions is missing in CreateProxiesMessageTask [HZ-3464] [5.3.3] #25711

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.hazelcast.spi.impl.proxyservice.impl.ProxyInfo;
import com.hazelcast.spi.impl.proxyservice.impl.operations.PostJoinProxyOperation;

import java.security.AccessControlException;
import java.security.Permission;
import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -40,6 +41,8 @@
public class CreateProxiesMessageTask extends AbstractMultiTargetMessageTask<List<Map.Entry<String, String>>>
implements Supplier<Operation> {

private List<Map.Entry<String, String>> filteredProxies;

public CreateProxiesMessageTask(ClientMessage clientMessage, Node node, Connection connection) {
super(clientMessage, node, connection);
}
Expand All @@ -50,8 +53,8 @@ protected Supplier<Operation> createOperationSupplier() {

@Override
public Operation get() {
List<ProxyInfo> proxyInfos = new ArrayList<ProxyInfo>(parameters.size());
for (Map.Entry<String, String> proxy : parameters) {
List<ProxyInfo> proxyInfos = new ArrayList<ProxyInfo>(filteredProxies.size());
for (Map.Entry<String, String> proxy : filteredProxies) {
proxyInfos.add(new ProxyInfo(proxy.getValue(), proxy.getKey(), endpoint.getUuid()));
}
return new PostJoinProxyOperation(proxyInfos);
Expand Down Expand Up @@ -95,16 +98,32 @@ protected void beforeProcess() {
// replacement for getRequiredPermission-based checks, we have to check multiple permission
SecurityContext securityContext = clientEngine.getSecurityContext();
if (securityContext != null) {
filteredProxies = new ArrayList<>(parameters.size());
ProxyService proxyService = clientEngine.getProxyService();
for (Map.Entry<String, String> proxy : parameters) {
String objectName = proxy.getKey();
String serviceName = proxy.getValue();
if (proxyService.existsDistributedObject(serviceName, objectName)) {
continue;
}
Permission permission = ActionConstants.getPermission(objectName, serviceName, ActionConstants.ACTION_CREATE);
securityContext.checkPermission(endpoint.getSubject(), permission);
try {
Permission permission = ActionConstants.getPermission(objectName, serviceName,
ActionConstants.ACTION_CREATE);
securityContext.checkPermission(endpoint.getSubject(), permission);
filteredProxies.add(proxy);
} catch (AccessControlException ace) {
logger.info("Insufficient client permissions. Proxy won't be created for type '" + serviceName + "': "
+ objectName);
if (logger.isFineEnabled()) {
logger.fine("Skipping proxy creation due to AccessControlException", ace);
}
} catch (Exception e) {
// unknown serviceName or another unexpected issue
logger.warning("Proxy won't be created for type '" + serviceName + "': " + objectName, e);
}
}
} else {
filteredProxies = parameters;
}
super.beforeProcess();
}
Expand Down