diff --git a/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/DocumentSubsetReader.java b/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/DocumentSubsetReader.java index 405dcc56cd0..126b0b5da8a 100644 --- a/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/DocumentSubsetReader.java +++ b/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/DocumentSubsetReader.java @@ -65,6 +65,10 @@ public final class DocumentSubsetReader extends FilterLeafReader { } } + @Override + public Object getCoreCacheKey() { + return in.getCoreCacheKey(); + } } private final BitSet roleQueryBits; diff --git a/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/FieldSubsetReader.java b/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/FieldSubsetReader.java index 7b74d01cd44..0f494b56d1d 100644 --- a/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/FieldSubsetReader.java +++ b/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/FieldSubsetReader.java @@ -81,6 +81,11 @@ public final class FieldSubsetReader extends FilterLeafReader { } } } + + @Override + public Object getCoreCacheKey() { + return in.getCoreCacheKey(); + } } /** List of filtered fields */ @@ -215,11 +220,6 @@ public final class FieldSubsetReader extends FilterLeafReader { // we share core cache keys (for e.g. fielddata) - @Override - public Object getCombinedCoreAndDeletesKey() { - return in.getCombinedCoreAndDeletesKey(); - } - @Override public Object getCoreCacheKey() { return in.getCoreCacheKey(); diff --git a/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapper.java b/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapper.java index 52afb3298d2..d650635bd6e 100644 --- a/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapper.java +++ b/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapper.java @@ -14,6 +14,8 @@ import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.logging.ESLogger; +import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.support.LoggerMessageFormat; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.cache.bitset.BitsetFilterCache; @@ -49,18 +51,19 @@ import static org.apache.lucene.search.BooleanClause.Occur.FILTER; * Document level security is enabled by wrapping the original {@link DirectoryReader} in a {@link DocumentSubsetReader} * instance. */ -public final class ShieldIndexSearcherWrapper extends AbstractComponent implements IndexSearcherWrapper { +public final class ShieldIndexSearcherWrapper extends IndexSearcherWrapper { private final MapperService mapperService; private final Set allowedMetaFields; private final IndexQueryParserService parserService; private final BitsetFilterCache bitsetFilterCache; private final ShieldLicenseState shieldLicenseState; + private final ESLogger logger; @Inject public ShieldIndexSearcherWrapper(@IndexSettings Settings indexSettings, IndexQueryParserService parserService, MapperService mapperService, BitsetFilterCache bitsetFilterCache, ShieldLicenseState shieldLicenseState) { - super(indexSettings); + this.logger = Loggers.getLogger(getClass(), indexSettings); this.mapperService = mapperService; this.parserService = parserService; this.bitsetFilterCache = bitsetFilterCache; @@ -76,7 +79,7 @@ public final class ShieldIndexSearcherWrapper extends AbstractComponent implemen } @Override - public DirectoryReader wrap(DirectoryReader reader) { + protected DirectoryReader wrap(DirectoryReader reader) { if (shieldLicenseState.documentAndFieldLevelSecurityEnabled() == false) { return reader; } @@ -131,7 +134,7 @@ public final class ShieldIndexSearcherWrapper extends AbstractComponent implemen } @Override - public IndexSearcher wrap(EngineConfig engineConfig, IndexSearcher searcher) throws EngineException { + protected IndexSearcher wrap(EngineConfig engineConfig, IndexSearcher searcher) throws EngineException { if (shieldLicenseState.documentAndFieldLevelSecurityEnabled() == false) { return searcher; } diff --git a/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/DocumentSubsetReaderTests.java b/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/DocumentSubsetReaderTests.java index ee0e948762e..49a55622c4a 100644 --- a/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/DocumentSubsetReaderTests.java +++ b/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/DocumentSubsetReaderTests.java @@ -196,9 +196,6 @@ public class DocumentSubsetReaderTests extends ESTestCase { assertEquals(1, ir2.leaves().size()); assertSame(ir.leaves().get(0).reader().getCoreCacheKey(), ir2.leaves().get(0).reader().getCoreCacheKey()); - // this is kind of stupid, but for now its here - assertNotSame(ir.leaves().get(0).reader().getCombinedCoreAndDeletesKey(), ir2.leaves().get(0).reader().getCombinedCoreAndDeletesKey()); - TestUtil.checkReader(ir); IOUtils.close(ir, ir2, iw, dir); } diff --git a/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/FieldSubsetReaderTests.java b/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/FieldSubsetReaderTests.java index a39a05fc439..953afe5d65c 100644 --- a/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/FieldSubsetReaderTests.java +++ b/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/FieldSubsetReaderTests.java @@ -707,9 +707,6 @@ public class FieldSubsetReaderTests extends ESTestCase { assertEquals(1, ir2.leaves().size()); assertSame(ir.leaves().get(0).reader().getCoreCacheKey(), ir2.leaves().get(0).reader().getCoreCacheKey()); - // this is kind of stupid, but for now its here - assertNotSame(ir.leaves().get(0).reader().getCombinedCoreAndDeletesKey(), ir2.leaves().get(0).reader().getCombinedCoreAndDeletesKey()); - TestUtil.checkReader(ir); IOUtils.close(ir, ir2, iw, dir); }