fixed compile error due to an upstream change in the MetaData class
Original commit: elastic/x-pack-elasticsearch@b74276d43c
This commit is contained in:
parent
868b6b01cf
commit
3abe6e02d6
|
@ -17,6 +17,7 @@ import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
||||||
import org.elasticsearch.action.search.ClearScrollAction;
|
import org.elasticsearch.action.search.ClearScrollAction;
|
||||||
import org.elasticsearch.action.search.SearchScrollAction;
|
import org.elasticsearch.action.search.SearchScrollAction;
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
|
import org.elasticsearch.cluster.metadata.AliasOrIndex;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.common.component.AbstractComponent;
|
import org.elasticsearch.common.component.AbstractComponent;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -30,7 +31,7 @@ import org.elasticsearch.shield.authz.indicesresolver.IndicesResolver;
|
||||||
import org.elasticsearch.shield.authz.store.RolesStore;
|
import org.elasticsearch.shield.authz.store.RolesStore;
|
||||||
import org.elasticsearch.transport.TransportRequest;
|
import org.elasticsearch.transport.TransportRequest;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.elasticsearch.shield.support.Exceptions.authenticationError;
|
import static org.elasticsearch.shield.support.Exceptions.authenticationError;
|
||||||
|
@ -76,15 +77,11 @@ public class InternalAuthorizationService extends AbstractComponent implements A
|
||||||
ImmutableList.Builder<String> indicesAndAliases = ImmutableList.builder();
|
ImmutableList.Builder<String> indicesAndAliases = ImmutableList.builder();
|
||||||
Predicate<String> predicate = Predicates.or(predicates.build());
|
Predicate<String> predicate = Predicates.or(predicates.build());
|
||||||
MetaData metaData = clusterService.state().metaData();
|
MetaData metaData = clusterService.state().metaData();
|
||||||
for (String index : metaData.concreteAllIndices()) {
|
// TODO: can this be done smarter? I think there are usually more indices/aliases in the cluster then indices defined a roles?
|
||||||
if (predicate.apply(index)) {
|
for (Map.Entry<String, AliasOrIndex> entry : metaData.getAliasAndIndexLookup().entrySet()) {
|
||||||
indicesAndAliases.add(index);
|
String aliasOrIndex = entry.getKey();
|
||||||
}
|
if (predicate.apply(aliasOrIndex)) {
|
||||||
}
|
indicesAndAliases.add(aliasOrIndex);
|
||||||
for (Iterator<String> iter = metaData.getAliases().keysIt(); iter.hasNext(); ) {
|
|
||||||
String alias = iter.next();
|
|
||||||
if (predicate.apply(alias)) {
|
|
||||||
indicesAndAliases.add(alias);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return indicesAndAliases.build();
|
return indicesAndAliases.build();
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.shield.authz.indicesresolver;
|
package org.elasticsearch.shield.authz.indicesresolver;
|
||||||
|
|
||||||
import com.carrotsearch.hppc.ObjectLookupContainer;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -13,6 +12,7 @@ import org.elasticsearch.action.AliasesRequest;
|
||||||
import org.elasticsearch.action.CompositeIndicesRequest;
|
import org.elasticsearch.action.CompositeIndicesRequest;
|
||||||
import org.elasticsearch.action.IndicesRequest;
|
import org.elasticsearch.action.IndicesRequest;
|
||||||
import org.elasticsearch.action.support.IndicesOptions;
|
import org.elasticsearch.action.support.IndicesOptions;
|
||||||
|
import org.elasticsearch.cluster.metadata.AliasOrIndex;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
|
@ -99,9 +99,10 @@ public class DefaultIndicesResolver implements IndicesResolver<TransportRequest>
|
||||||
|
|
||||||
private List<String> loadAuthorizedAliases(List<String> authorizedIndices, MetaData metaData) {
|
private List<String> loadAuthorizedAliases(List<String> authorizedIndices, MetaData metaData) {
|
||||||
List<String> authorizedAliases = Lists.newArrayList();
|
List<String> authorizedAliases = Lists.newArrayList();
|
||||||
ObjectLookupContainer<String> existingAliases = metaData.aliases().keys();
|
SortedMap<String, AliasOrIndex> existingAliases = metaData.getAliasAndIndexLookup();
|
||||||
for (String authorizedIndex : authorizedIndices) {
|
for (String authorizedIndex : authorizedIndices) {
|
||||||
if (existingAliases.contains(authorizedIndex)) {
|
AliasOrIndex aliasOrIndex = existingAliases.get(authorizedIndex);
|
||||||
|
if (aliasOrIndex != null && aliasOrIndex.isAlias()) {
|
||||||
authorizedAliases.add(authorizedIndex);
|
authorizedAliases.add(authorizedIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue