Search in sources :

Example 1 with KerberosScheme

use of org.apache.http.impl.auth.KerberosScheme in project janusgraph by JanusGraph.

the class SolrIndex method configureSolrClientsForKerberos.

private void configureSolrClientsForKerberos() throws PermanentBackendException {
    String kerberosConfig = System.getProperty("java.security.auth.login.config");
    if (kerberosConfig == null) {
        throw new PermanentBackendException("Unable to configure kerberos for solr client. System property 'java.security.auth.login.config' is not set.");
    }
    logger.debug("Using kerberos configuration file located at '{}'.", kerberosConfig);
    try (Krb5HttpClientBuilder krbBuild = new Krb5HttpClientBuilder()) {
        SolrHttpClientBuilder kb = krbBuild.getBuilder();
        HttpClientUtil.setHttpClientBuilder(kb);
        HttpRequestInterceptor bufferedEntityInterceptor = (request, context) -> {
            if (request instanceof HttpEntityEnclosingRequest) {
                HttpEntityEnclosingRequest enclosingRequest = ((HttpEntityEnclosingRequest) request);
                HttpEntity requestEntity = enclosingRequest.getEntity();
                enclosingRequest.setEntity(new BufferedHttpEntity(requestEntity));
            }
        };
        HttpClientUtil.addRequestInterceptor(bufferedEntityInterceptor);
        HttpRequestInterceptor preemptiveAuth = new PreemptiveAuth(new KerberosScheme());
        HttpClientUtil.addRequestInterceptor(preemptiveAuth);
    }
}
Also used : PredicateCondition(org.janusgraph.graphdb.query.condition.PredicateCondition) Arrays(java.util.Arrays) DocCollection(org.apache.solr.common.cloud.DocCollection) KerberosScheme(org.apache.http.impl.auth.KerberosScheme) ClusterState(org.apache.solr.common.cloud.ClusterState) Geoshape(org.janusgraph.core.attribute.Geoshape) StringUtils(org.apache.commons.lang3.StringUtils) SolrServerException(org.apache.solr.client.solrj.SolrServerException) Cardinality(org.janusgraph.core.Cardinality) IndexEntry(org.janusgraph.diskstorage.indexing.IndexEntry) KeyInformation(org.janusgraph.diskstorage.indexing.KeyInformation) Map(java.util.Map) HttpRequestInterceptor(org.apache.http.HttpRequestInterceptor) ZkStateReader(org.apache.solr.common.cloud.ZkStateReader) And(org.janusgraph.graphdb.query.condition.And) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) Set(java.util.Set) UncheckedIOException(java.io.UncheckedIOException) IOUtils(org.apache.commons.io.IOUtils) Stream(java.util.stream.Stream) SolrQuery(org.apache.solr.client.solrj.SolrQuery) Joiner(com.google.common.base.Joiner) SolrHttpClientBuilder(org.apache.solr.client.solrj.impl.SolrHttpClientBuilder) SolrInputDocument(org.apache.solr.common.SolrInputDocument) PreInitializeConfigOptions(org.janusgraph.graphdb.configuration.PreInitializeConfigOptions) Not(org.janusgraph.graphdb.query.condition.Not) AttributeUtils(org.janusgraph.graphdb.database.serialize.AttributeUtils) SimpleDateFormat(java.text.SimpleDateFormat) Constructor(java.lang.reflect.Constructor) ArrayList(java.util.ArrayList) Cmp(org.janusgraph.core.attribute.Cmp) HttpClient(org.apache.http.client.HttpClient) CachingTokenFilter(org.apache.lucene.analysis.CachingTokenFilter) StreamSupport(java.util.stream.StreamSupport) JanusGraphElement(org.janusgraph.core.JanusGraphElement) Geo(org.janusgraph.core.attribute.Geo) JanusGraphPredicate(org.janusgraph.graphdb.query.JanusGraphPredicate) Slice(org.apache.solr.common.cloud.Slice) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) CollectionAdminResponse(org.apache.solr.client.solrj.response.CollectionAdminResponse) IOException(java.io.IOException) DefaultTransaction(org.janusgraph.diskstorage.util.DefaultTransaction) SolrClient(org.apache.solr.client.solrj.SolrClient) CommonParams(org.apache.solr.common.params.CommonParams) SolrDocument(org.apache.solr.common.SolrDocument) StringReader(java.io.StringReader) UpdateRequest(org.apache.solr.client.solrj.request.UpdateRequest) Preconditions(com.google.common.base.Preconditions) INDEX_NS(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.INDEX_NS) IndexMutation(org.janusgraph.diskstorage.indexing.IndexMutation) INDEX_MAX_RESULT_SET_SIZE(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.INDEX_MAX_RESULT_SET_SIZE) GeoToWktConverter(org.janusgraph.diskstorage.solr.transform.GeoToWktConverter) PreemptiveAuth(org.apache.solr.client.solrj.impl.PreemptiveAuth) HttpClientUtil(org.apache.solr.client.solrj.impl.HttpClientUtil) Date(java.util.Date) Spliterators(java.util.Spliterators) LoggerFactory(org.slf4j.LoggerFactory) ConfigOption(org.janusgraph.diskstorage.configuration.ConfigOption) BaseTransaction(org.janusgraph.diskstorage.BaseTransaction) IndexProvider(org.janusgraph.diskstorage.indexing.IndexProvider) Krb5HttpClientBuilder(org.apache.solr.client.solrj.impl.Krb5HttpClientBuilder) IndexQuery(org.janusgraph.diskstorage.indexing.IndexQuery) DateFormat(java.text.DateFormat) Mapping(org.janusgraph.core.schema.Mapping) TimeZone(java.util.TimeZone) Collection(java.util.Collection) HttpEntity(org.apache.http.HttpEntity) UUID(java.util.UUID) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) Replica(org.apache.solr.common.cloud.Replica) List(java.util.List) Parameter(org.janusgraph.core.schema.Parameter) HttpSolrClient(org.apache.solr.client.solrj.impl.HttpSolrClient) Optional(java.util.Optional) BufferedHttpEntity(org.apache.http.entity.BufferedHttpEntity) ClientUtils(org.apache.solr.client.solrj.util.ClientUtils) LBHttpSolrClient(org.apache.solr.client.solrj.impl.LBHttpSolrClient) Spliterator(java.util.Spliterator) CollectionAdminRequest(org.apache.solr.client.solrj.request.CollectionAdminRequest) Tokenizer(org.apache.lucene.analysis.Tokenizer) ConfigNamespace(org.janusgraph.diskstorage.configuration.ConfigNamespace) Condition(org.janusgraph.graphdb.query.condition.Condition) HashMap(java.util.HashMap) Function(java.util.function.Function) TemporaryBackendException(org.janusgraph.diskstorage.TemporaryBackendException) HashSet(java.util.HashSet) IndexFeatures(org.janusgraph.diskstorage.indexing.IndexFeatures) Or(org.janusgraph.graphdb.query.condition.Or) SimpleEntry(java.util.AbstractMap.SimpleEntry) TermToBytesRefAttribute(org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient) HttpEntityEnclosingRequest(org.apache.http.HttpEntityEnclosingRequest) BackendException(org.janusgraph.diskstorage.BackendException) Logger(org.slf4j.Logger) KeeperException(org.apache.zookeeper.KeeperException) Configuration(org.janusgraph.diskstorage.configuration.Configuration) BaseTransactionConfigurable(org.janusgraph.diskstorage.BaseTransactionConfigurable) RawQuery(org.janusgraph.diskstorage.indexing.RawQuery) Order(org.janusgraph.graphdb.internal.Order) Text(org.janusgraph.core.attribute.Text) BaseTransactionConfig(org.janusgraph.diskstorage.BaseTransactionConfig) ParameterType(org.janusgraph.graphdb.types.ParameterType) PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) Collections(java.util.Collections) HttpEntity(org.apache.http.HttpEntity) BufferedHttpEntity(org.apache.http.entity.BufferedHttpEntity) BufferedHttpEntity(org.apache.http.entity.BufferedHttpEntity) PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) HttpRequestInterceptor(org.apache.http.HttpRequestInterceptor) HttpEntityEnclosingRequest(org.apache.http.HttpEntityEnclosingRequest) SolrHttpClientBuilder(org.apache.solr.client.solrj.impl.SolrHttpClientBuilder) KerberosScheme(org.apache.http.impl.auth.KerberosScheme) PreemptiveAuth(org.apache.solr.client.solrj.impl.PreemptiveAuth) Krb5HttpClientBuilder(org.apache.solr.client.solrj.impl.Krb5HttpClientBuilder)

Aggregations

Joiner (com.google.common.base.Joiner)1 Preconditions (com.google.common.base.Preconditions)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 UncheckedIOException (java.io.UncheckedIOException)1 Constructor (java.lang.reflect.Constructor)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Instant (java.time.Instant)1 SimpleEntry (java.util.AbstractMap.SimpleEntry)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1