From 661c024ae8cf1a66e3069b3a9a93772a4fd65b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Tue, 10 Jul 2018 15:10:06 +0200 Subject: [PATCH] Remove unused reference to filePermissionsCache Currently Role.Builder keeps a reference to the FieldPermissionsCache that is passed into its constructors. This seems to be unused except for passing it on to convertFromIndicesPrivileges() in the second ctor itself, but we don't need to keep the internal reference in that case, so it can be removed. Relates to #31876 --- .../xpack/core/security/authz/permission/Role.java | 11 ++--------- .../security/authz/store/CompositeRolesStore.java | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/Role.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/Role.java index 8fed501ece2c..a850a4a16f65 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/Role.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/Role.java @@ -55,11 +55,7 @@ public RunAsPermission runAs() { } public static Builder builder(String... names) { - return new Builder(names, null); - } - - public static Builder builder(String[] names, FieldPermissionsCache fieldPermissionsCache) { - return new Builder(names, fieldPermissionsCache); + return new Builder(names); } public static Builder builder(RoleDescriptor rd, FieldPermissionsCache fieldPermissionsCache) { @@ -94,16 +90,13 @@ public static class Builder { private ClusterPermission cluster = ClusterPermission.NONE; private RunAsPermission runAs = RunAsPermission.NONE; private List groups = new ArrayList<>(); - private FieldPermissionsCache fieldPermissionsCache = null; - private Builder(String[] names, FieldPermissionsCache fieldPermissionsCache) { + private Builder(String[] names) { this.names = names; - this.fieldPermissionsCache = fieldPermissionsCache; } private Builder(RoleDescriptor rd, @Nullable FieldPermissionsCache fieldPermissionsCache) { this.names = new String[] { rd.getName() }; - this.fieldPermissionsCache = fieldPermissionsCache; if (rd.getClusterPrivileges().length == 0) { cluster = ClusterPermission.NONE; } else { diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStore.java index b5a20af8d30b..1018ceeda093 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStore.java @@ -278,7 +278,7 @@ public static Role buildRoleFromDescriptors(Set roleDescriptors, final Set clusterPrivs = clusterPrivileges.isEmpty() ? null : clusterPrivileges; final Privilege runAsPrivilege = runAs.isEmpty() ? Privilege.NONE : new Privilege(runAs, runAs.toArray(Strings.EMPTY_ARRAY)); - Role.Builder builder = Role.builder(roleNames.toArray(new String[roleNames.size()]), fieldPermissionsCache) + Role.Builder builder = Role.builder(roleNames.toArray(new String[roleNames.size()])) .cluster(ClusterPrivilege.get(clusterPrivs)) .runAs(runAsPrivilege); indicesPrivilegesMap.entrySet().forEach((entry) -> {