You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by mp...@apache.org on 2016/08/17 09:56:35 UTC
[2/2] ambari git commit: AMBARI-18135. Enable Namenode HA failing at
install journal nodes with cluster operator user. (mpapirkovskyy)
AMBARI-18135. Enable Namenode HA failing at install journal nodes with cluster operator user. (mpapirkovskyy)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/639515be
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/639515be
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/639515be
Branch: refs/heads/trunk
Commit: 639515be3e372d0cb4035e325465796fa89b1dd2
Parents: 7187592
Author: Myroslav Papirkovskyi <mp...@hortonworks.com>
Authored: Wed Aug 17 12:53:08 2016 +0300
Committer: Myroslav Papirkovskyi <mp...@hortonworks.com>
Committed: Wed Aug 17 12:56:19 2016 +0300
----------------------------------------------------------------------
.../internal/ComponentResourceProvider.java | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/639515be/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
index c80881f..fe89752 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
@@ -119,8 +119,8 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
super(propertyIds, keyPropertyIds, managementController);
this.maintenanceStateHelper = maintenanceStateHelper;
- setRequiredCreateAuthorizations(EnumSet.of(RoleAuthorization.SERVICE_ADD_DELETE_SERVICES));
- setRequiredDeleteAuthorizations(EnumSet.of(RoleAuthorization.SERVICE_ADD_DELETE_SERVICES));
+ setRequiredCreateAuthorizations(EnumSet.of(RoleAuthorization.SERVICE_ADD_DELETE_SERVICES, RoleAuthorization.HOST_ADD_DELETE_COMPONENTS));
+ setRequiredDeleteAuthorizations(EnumSet.of(RoleAuthorization.SERVICE_ADD_DELETE_SERVICES, RoleAuthorization.HOST_ADD_DELETE_COMPONENTS));
setRequiredGetAuthorizations(RoleAuthorization.AUTHORIZATIONS_VIEW_SERVICE);
setRequiredGetAuthorizations(RoleAuthorization.AUTHORIZATIONS_VIEW_SERVICE);
setRequiredUpdateAuthorizations(RoleAuthorization.AUTHORIZATIONS_UPDATE_CLUSTER);
@@ -285,7 +285,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
Validate.notEmpty(request.getComponentName(), "component name should be non-empty");
Cluster cluster = getClusterForRequest(request, clusters);
- isAuthorized(cluster, RoleAuthorization.SERVICE_ADD_DELETE_SERVICES);
+ isAuthorized(cluster, getRequiredCreateAuthorizations());
setServiceNameIfAbsent(request, cluster, ambariMetaInfo);
debug("Received a createComponent request: {}", request);
@@ -774,8 +774,12 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
}
private void isAuthorized(final Cluster cluster, final RoleAuthorization roleAuthorization) throws AuthorizationException {
- if (!AuthorizationHelper.isAuthorized(ResourceType.CLUSTER, cluster.getResourceId(), roleAuthorization)) {
- throw new AuthorizationException("The user is not authorized to for role " + roleAuthorization.name());
+ isAuthorized(cluster, EnumSet.of(roleAuthorization));
+ }
+
+ private void isAuthorized(final Cluster cluster, final Set<RoleAuthorization> requiredAuthorizations) throws AuthorizationException {
+ if (!AuthorizationHelper.isAuthorized(ResourceType.CLUSTER, cluster.getResourceId(), requiredAuthorizations)) {
+ throw new AuthorizationException("The user is not authorized to for roles " + requiredAuthorizations);
}
}
@@ -815,4 +819,4 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
LOG.debug(format, arguments);
}
}
-}
\ No newline at end of file
+}