You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by an...@apache.org on 2015/05/20 00:51:44 UTC
svn commit: r1680415 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/bin/
solr/core/ solr/core/src/java/org/apache/solr/core/
solr/core/src/java/org/apache/solr/handler/component/
solr/core/src/java/org/apache/solr/security/ solr/core/src/java/org/a...
Author: anshum
Date: Tue May 19 22:51:44 2015
New Revision: 1680415
URL: http://svn.apache.org/r1680415
Log:
SOLR-7274: Pluggable authentication module in Solr. This defines an interface and a mechanism to create, load, and use an Authentication plugin.(merge from trunk)
Added:
lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/security/AuthenticationPlugin.java
- copied unchanged from r1680391, lucene/dev/trunk/solr/core/src/java/org/apache/solr/security/AuthenticationPlugin.java
lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/TestAuthenticationFramework.java
- copied unchanged from r1680391, lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/TestAuthenticationFramework.java
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/solr/ (props changed)
lucene/dev/branches/branch_5x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_5x/solr/bin/ (props changed)
lucene/dev/branches/branch_5x/solr/bin/solr
lucene/dev/branches/branch_5x/solr/bin/solr.in.sh
lucene/dev/branches/branch_5x/solr/core/ (props changed)
lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/CoreContainer.java
lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java
lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java
lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/util/SolrCLI.java
lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java
Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1680415&r1=1680414&r2=1680415&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Tue May 19 22:51:44 2015
@@ -143,6 +143,9 @@ New Features
without a known content type, as "application/octet-stream", provided it still is in the
allowed filetypes setting. (ehatcher)
+* SOLR-7274: Pluggable authentication module in Solr. This defines an interface and a mechanism to create,
+ load, and use an Authentication plugin. (Noble Paul, Ishan Chattopadhyaya, Gregory Chanan, Anshum Gupta)
+
Bug Fixes
----------------------
Modified: lucene/dev/branches/branch_5x/solr/bin/solr
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/bin/solr?rev=1680415&r1=1680414&r2=1680415&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/bin/solr (original)
+++ lucene/dev/branches/branch_5x/solr/bin/solr Tue May 19 22:51:44 2015
@@ -164,6 +164,12 @@ else
SOLR_JETTY_CONFIG+=("--module=http")
fi
+# Authentication options
+if [ "$SOLR_AUTHENTICATION_CLIENT_CONFIGURER" != "" ]; then
+ AUTHC_CLIENT_CONFIGURER_ARG="-Dsolr.authentication.httpclient.configurer=$SOLR_AUTHENTICATION_CLIENT_CONFIGURER"
+fi
+AUTHC_OPTS="$AUTHC_CLIENT_CONFIGURER_ARG $SOLR_AUTHENTICATION_OPTS"
+
# Set the SOLR_TOOL_HOST variable for use when connecting to a running Solr instance
if [ "$SOLR_HOST" != "" ]; then
SOLR_TOOL_HOST="$SOLR_HOST"
@@ -414,7 +420,7 @@ function run_tool() {
"${UNPACK_WAR_CMD[@]}" "$DEFAULT_SERVER_DIR/webapps/solr.war")
fi
- "$JAVA" $SOLR_SSL_OPTS -Dsolr.install.dir="$SOLR_TIP" \
+ "$JAVA" $SOLR_SSL_OPTS $AUTHC_OPTS -Dsolr.install.dir="$SOLR_TIP" \
-Dlog4j.configuration="file:$DEFAULT_SERVER_DIR/scripts/cloud-scripts/log4j.properties" \
-classpath "$DEFAULT_SERVER_DIR/solr-webapp/webapp/WEB-INF/lib/*:$DEFAULT_SERVER_DIR/lib/ext/*" \
org.apache.solr.util.SolrCLI "$@"
@@ -474,7 +480,7 @@ function stop_solr() {
if [ "$SOLR_PID" != "" ]; then
echo -e "Sending stop command to Solr running on port $SOLR_PORT ... waiting 5 seconds to allow Jetty process $SOLR_PID to stop gracefully."
- "$JAVA" $SOLR_SSL_OPTS -jar "$DIR/start.jar" "STOP.PORT=$STOP_PORT" "STOP.KEY=$STOP_KEY" --stop || true
+ "$JAVA" $SOLR_SSL_OPTS $AUTHC_OPTS -jar "$DIR/start.jar" "STOP.PORT=$STOP_PORT" "STOP.KEY=$STOP_KEY" --stop || true
(sleep 5) &
spinner $!
rm -f "$SOLR_PID_DIR/solr-$SOLR_PORT.pid"
@@ -1328,6 +1334,11 @@ function launch_solr() {
SOLR_OPTS+=($SOLR_SSL_OPTS "$SSL_PORT_PROP")
fi
+ # If authentication system props are set, add them to SOLR_OPTS
+ if [ -n "$AUTHC_OPTS" ]; then
+ SOLR_OPTS+=($AUTHC_OPTS)
+ fi
+
if $verbose ; then
echo -e "\nStarting Solr using the following settings:"
echo -e " JAVA = $JAVA"
Modified: lucene/dev/branches/branch_5x/solr/bin/solr.in.sh
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/bin/solr.in.sh?rev=1680415&r1=1680414&r2=1680415&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/bin/solr.in.sh (original)
+++ lucene/dev/branches/branch_5x/solr/bin/solr.in.sh Tue May 19 22:51:44 2015
@@ -110,3 +110,8 @@ ENABLE_REMOTE_JMX_OPTS="false"
#SOLR_SSL_CLIENT_KEY_STORE_PASSWORD=
#SOLR_SSL_CLIENT_TRUST_STORE=
#SOLR_SSL_CLIENT_TRUST_STORE_PASSWORD=
+
+# Settings for authentication
+#SOLR_AUTHENTICATION_CLIENT_CONFIGURER=
+#SOLR_AUTHENTICATION_OPTS=
+
Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/CoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/CoreContainer.java?rev=1680415&r1=1680414&r2=1680415&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/CoreContainer.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/CoreContainer.java Tue May 19 22:51:44 2015
@@ -31,6 +31,9 @@ import java.util.concurrent.ExecutorServ
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
+
+import org.apache.solr.client.solrj.impl.HttpClientConfigurer;
+import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.cloud.ZkController;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
@@ -40,10 +43,12 @@ import org.apache.solr.handler.RequestHa
import org.apache.solr.handler.admin.CollectionsHandler;
import org.apache.solr.handler.admin.CoreAdminHandler;
import org.apache.solr.handler.admin.InfoHandler;
+import org.apache.solr.handler.component.HttpShardHandlerFactory;
import org.apache.solr.handler.component.ShardHandlerFactory;
import org.apache.solr.logging.LogWatcher;
import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.security.AuthorizationPlugin;
+import org.apache.solr.security.AuthenticationPlugin;
import org.apache.solr.update.UpdateShardHandler;
import org.apache.solr.util.DefaultSolrThreadFactory;
import org.apache.solr.util.FileUtils;
@@ -66,6 +71,8 @@ public class CoreContainer {
protected AuthorizationPlugin authorizationPlugin;
+ protected AuthenticationPlugin authenticationPlugin;
+
public static class CoreLoadFailure {
public final CoreDescriptor cd;
@@ -110,6 +117,8 @@ public class CoreContainer {
public static final String COLLECTIONS_HANDLER_PATH = "/admin/collections";
public static final String INFO_HANDLER_PATH = "/admin/info";
+ final public static String AUTHENTICATION_PLUGIN_PROP = "authenticationPlugin";
+
private PluginBag<SolrRequestHandler> containerHandlers = new PluginBag<>(SolrRequestHandler.class, null);
public ExecutorService getCoreZkRegisterExecutorService() {
@@ -203,6 +212,61 @@ public class CoreContainer {
}
}
+ private void initializeAuthenticationPlugin() {
+ String pluginClassName = null;
+ Map<String, Object> authenticationConfig = null;
+
+ if (isZooKeeperAware()) {
+ Map securityProps = getZkController().getZkStateReader().getSecurityProps();
+ if (securityProps != null) {
+ authenticationConfig = (Map<String, Object>) securityProps.get("authentication");
+ if (authenticationConfig!=null) {
+ if (authenticationConfig.containsKey("class")) {
+ pluginClassName = String.valueOf(authenticationConfig.get("class"));
+ } else {
+ throw new SolrException(ErrorCode.SERVER_ERROR, "No 'class' specified for authentication in ZK.");
+ }
+ }
+ }
+ }
+
+ if (pluginClassName != null) {
+ log.info("Authentication plugin class obtained from ZK: "+pluginClassName);
+ } else if (System.getProperty(AUTHENTICATION_PLUGIN_PROP) != null) {
+ pluginClassName = System.getProperty(AUTHENTICATION_PLUGIN_PROP);
+ log.info("Authentication plugin class obtained from system property '" +
+ AUTHENTICATION_PLUGIN_PROP + "': " + pluginClassName);
+ } else {
+ log.info("No authentication plugin used.");
+ }
+
+ // Initialize the filter
+ if (pluginClassName != null) {
+ try {
+ Class cl = Class.forName(pluginClassName);
+ authenticationPlugin = (AuthenticationPlugin) cl.newInstance();
+ } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
+ throw new SolrException(ErrorCode.SERVER_ERROR, e);
+ }
+ }
+ if (authenticationPlugin != null) {
+ authenticationPlugin.init(authenticationConfig);
+
+ // Setup HttpClient to use the plugin's configurer for internode communication
+ HttpClientConfigurer configurer = authenticationPlugin.getDefaultConfigurer();
+ HttpClientUtil.setConfigurer(configurer);
+
+ // The default http client of the core container's shardHandlerFactory has already been created and
+ // configured using the default httpclient configurer. We need to reconfigure it using the plugin's
+ // http client configurer to set it up for internode communication.
+ log.info("Reconfiguring the shard handler factory and update shard handler.");
+ if (getShardHandlerFactory() instanceof HttpShardHandlerFactory) {
+ ((HttpShardHandlerFactory)getShardHandlerFactory()).reconfigureHttpClient(configurer);
+ }
+ getUpdateShardHandler().reconfigureHttpClient(configurer);
+ }
+ }
+
/**
* This method allows subclasses to construct a CoreContainer
* without any default init behavior.
@@ -273,6 +337,9 @@ public class CoreContainer {
log.info("Node Name: " + hostName);
zkSys.initZooKeeper(this, solrHome, cfg.getCloudConfig());
+
+ initializeAuthenticationPlugin();
+
if (isZooKeeperAware()) {
intializeAuthorizationPlugin();
}
@@ -436,6 +503,16 @@ public class CoreContainer {
log.warn("Exception while closing authorization plugin.", e);
}
+ // It should be safe to close the authentication plugin at this point.
+ try {
+ if(authenticationPlugin != null) {
+ authenticationPlugin.close();
+ authenticationPlugin = null;
+ }
+ } catch (Exception e) {
+ log.warn("Exception while closing authentication plugin.", e);
+ }
+
org.apache.lucene.util.IOUtils.closeWhileHandlingException(loader); // best effort
}
@@ -927,7 +1004,11 @@ public class CoreContainer {
public AuthorizationPlugin getAuthorizationPlugin() {
return authorizationPlugin;
}
-
+
+ public AuthenticationPlugin getAuthenticationPlugin() {
+ return authenticationPlugin;
+ }
+
}
class CloserThread extends Thread {
Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java?rev=1680415&r1=1680414&r2=1680415&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java Tue May 19 22:51:44 2015
@@ -21,6 +21,7 @@ import org.apache.http.client.HttpClient
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.HttpClientConfigurer;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.client.solrj.impl.LBHttpSolrClient;
import org.apache.solr.client.solrj.request.QueryRequest;
@@ -160,14 +161,8 @@ public class HttpShardHandlerFactory ext
new DefaultSolrThreadFactory("httpShardExecutor")
);
- ModifiableSolrParams clientParams = new ModifiableSolrParams();
- clientParams.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, maxConnectionsPerHost);
- clientParams.set(HttpClientUtil.PROP_MAX_CONNECTIONS, maxConnections);
- clientParams.set(HttpClientUtil.PROP_SO_TIMEOUT, soTimeout);
- clientParams.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT, connectionTimeout);
- if (!useRetries) {
- clientParams.set(HttpClientUtil.PROP_USE_RETRY, false);
- }
+ ModifiableSolrParams clientParams = getClientParams();
+
this.defaultClient = HttpClientUtil.createClient(clientParams);
// must come after createClient
@@ -179,6 +174,30 @@ public class HttpShardHandlerFactory ext
this.loadbalancer = createLoadbalancer(defaultClient);
}
+
+ protected ModifiableSolrParams getClientParams() {
+ ModifiableSolrParams clientParams = new ModifiableSolrParams();
+ clientParams.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, maxConnectionsPerHost);
+ clientParams.set(HttpClientUtil.PROP_MAX_CONNECTIONS, maxConnections);
+ clientParams.set(HttpClientUtil.PROP_SO_TIMEOUT, soTimeout);
+ clientParams.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT, connectionTimeout);
+ if (!useRetries) {
+ clientParams.set(HttpClientUtil.PROP_USE_RETRY, false);
+ }
+ return clientParams;
+ }
+
+ /**
+ * For an already created internal httpclient, this can be used to configure it
+ * again. Useful for authentication plugins.
+ * @param configurer an HttpClientConfigurer instance
+ */
+ public void reconfigureHttpClient(HttpClientConfigurer configurer) {
+ log.info("Reconfiguring the default client with: " + configurer);
+ synchronized (this.defaultClient) {
+ configurer.configure((DefaultHttpClient)this.defaultClient, getClientParams());
+ }
+ }
protected ThreadPoolExecutor getThreadPoolExecutor(){
return this.commExecutor;
Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java?rev=1680415&r1=1680414&r2=1680415&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java Tue May 19 22:51:44 2015
@@ -28,6 +28,8 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Properties;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -44,6 +46,7 @@ import org.apache.solr.core.NodeConfig;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.core.SolrXmlConfig;
+import org.apache.solr.security.AuthenticationPlugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -185,7 +188,18 @@ public class SolrDispatchFilter extends
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain, boolean retry) throws IOException, ServletException {
if (!(request instanceof HttpServletRequest)) return;
-
+
+ AtomicReference<ServletRequest> wrappedRequest = new AtomicReference();
+ if (!authenticateRequest(request, response, wrappedRequest)) { // the response and status code have already been sent
+ return;
+ }
+ if (wrappedRequest.get() != null) {
+ request = wrappedRequest.get();
+ }
+ if (cores.getAuthenticationPlugin() != null) {
+ log.debug("User principal: "+((HttpServletRequest)request).getUserPrincipal());
+ }
+
// No need to even create the HttpSolrCall object if this path is excluded.
if(excludePatterns != null) {
String servletPath = ((HttpServletRequest) request).getServletPath().toString();
@@ -216,4 +230,32 @@ public class SolrDispatchFilter extends
call.destroy();
}
}
+
+ private boolean authenticateRequest(ServletRequest request, ServletResponse response, final AtomicReference<ServletRequest> wrappedRequest) throws IOException {
+ final AtomicBoolean isAuthenticated = new AtomicBoolean(false);
+ AuthenticationPlugin authenticationPlugin = cores.getAuthenticationPlugin();
+ if (authenticationPlugin == null) {
+ return true;
+ } else {
+ try {
+ log.debug("Request to authenticate: "+request+", domain: "+request.getLocalName()+", port: "+request.getLocalPort());
+ // upon successful authentication, this should call the chain's next filter.
+ authenticationPlugin.doAuthenticate(request, response, new FilterChain() {
+ public void doFilter(ServletRequest req, ServletResponse rsp) throws IOException, ServletException {
+ isAuthenticated.set(true);
+ wrappedRequest.set(req);
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new SolrException(ErrorCode.SERVER_ERROR, "Error during request authentication, "+e);
+ }
+ }
+ // failed authentication?
+ if (!isAuthenticated.get()) {
+ response.flushBuffer();
+ return false;
+ }
+ return true;
+ }
}
Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java?rev=1680415&r1=1680414&r2=1680415&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java Tue May 19 22:51:44 2015
@@ -20,8 +20,10 @@ package org.apache.solr.update;
import org.apache.http.client.HttpClient;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.apache.http.impl.conn.SchemeRegistryFactory;
+import org.apache.solr.client.solrj.impl.HttpClientConfigurer;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.ModifiableSolrParams;
@@ -46,32 +48,39 @@ public class UpdateShardHandler {
private final CloseableHttpClient client;
+ private final UpdateShardHandlerConfig cfg;
+
@Deprecated
public UpdateShardHandler(NodeConfig cfg) {
this(cfg.getUpdateShardHandlerConfig());
}
public UpdateShardHandler(UpdateShardHandlerConfig cfg) {
-
+ this.cfg = cfg;
clientConnectionManager = new PoolingClientConnectionManager(SchemeRegistryFactory.createSystemDefault());
if (cfg != null ) {
clientConnectionManager.setMaxTotal(cfg.getMaxUpdateConnections());
clientConnectionManager.setDefaultMaxPerRoute(cfg.getMaxUpdateConnectionsPerHost());
}
-
- ModifiableSolrParams params = new ModifiableSolrParams();
+
+ ModifiableSolrParams clientParams = getClientParams();
+ log.info("Creating UpdateShardHandler HTTP client with params: {}", clientParams);
+ client = HttpClientUtil.createClient(clientParams, clientConnectionManager);
+ }
+
+ protected ModifiableSolrParams getClientParams() {
+ ModifiableSolrParams clientParams = new ModifiableSolrParams();
if (cfg != null) {
- params.set(HttpClientUtil.PROP_SO_TIMEOUT,
+ clientParams.set(HttpClientUtil.PROP_SO_TIMEOUT,
cfg.getDistributedSocketTimeout());
- params.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT,
+ clientParams.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT,
cfg.getDistributedConnectionTimeout());
}
// in the update case, we want to do retries, and to use
// the default Solr retry handler that createClient will
// give us
- params.set(HttpClientUtil.PROP_USE_RETRY, true);
- log.info("Creating UpdateShardHandler HTTP client with params: {}", params);
- client = HttpClientUtil.createClient(params, clientConnectionManager);
+ clientParams.set(HttpClientUtil.PROP_USE_RETRY, true);
+ return clientParams;
}
@@ -79,6 +88,13 @@ public class UpdateShardHandler {
return client;
}
+ public void reconfigureHttpClient(HttpClientConfigurer configurer) {
+ log.info("Reconfiguring the default client with: " + configurer);
+ synchronized (client) {
+ configurer.configure((DefaultHttpClient)client, getClientParams());
+ }
+ }
+
public ClientConnectionManager getConnectionManager() {
return clientConnectionManager;
}
Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/util/SolrCLI.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/util/SolrCLI.java?rev=1680415&r1=1680414&r2=1680415&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/util/SolrCLI.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/util/SolrCLI.java Tue May 19 22:51:44 2015
@@ -63,6 +63,7 @@ import org.apache.log4j.Logger;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.impl.HttpClientConfigurer;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.response.QueryResponse;
@@ -174,7 +175,19 @@ public class SolrCLI {
displayToolOptions(System.err);
System.exit(1);
}
-
+
+ String configurerClassName = System.getProperty("solr.authentication.httpclient.configurer");
+ if (configurerClassName!=null) {
+ try {
+ Class c = Class.forName(configurerClassName);
+ HttpClientConfigurer configurer = (HttpClientConfigurer)c.newInstance();
+ HttpClientUtil.setConfigurer(configurer);
+ log.info("Set HttpClientConfigurer from: "+configurerClassName);
+ } catch (Exception ex) {
+ throw new RuntimeException("Error during loading of configurer '"+configurerClassName+"'.", ex);
+ }
+ }
+
// Determine the tool
String toolType = args[0].trim().toLowerCase(Locale.ROOT);
Tool tool = newTool(toolType);
Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java?rev=1680415&r1=1680414&r2=1680415&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java Tue May 19 22:51:44 2015
@@ -59,10 +59,16 @@ import java.util.concurrent.atomic.Atomi
public class TestMiniSolrCloudCluster extends LuceneTestCase {
private static Logger log = LoggerFactory.getLogger(MiniSolrCloudCluster.class);
- private static final int NUM_SERVERS = 5;
- private static final int NUM_SHARDS = 2;
- private static final int REPLICATION_FACTOR = 2;
+ protected int NUM_SERVERS = 5;
+ protected int NUM_SHARDS = 2;
+ protected int REPLICATION_FACTOR = 2;
+ public TestMiniSolrCloudCluster () {
+ NUM_SERVERS = 5;
+ NUM_SHARDS = 2;
+ REPLICATION_FACTOR = 2;
+ }
+
@Rule
public TestRule solrTestRules = RuleChain
.outerRule(new SystemPropertiesRestoreRule());
@@ -79,7 +85,7 @@ public class TestMiniSolrCloudCluster ex
if (random().nextBoolean()) testCollectionCreateSearchDelete();
}
- private void testCollectionCreateSearchDelete() throws Exception {
+ protected void testCollectionCreateSearchDelete() throws Exception {
File solrXml = new File(SolrTestCaseJ4.TEST_HOME(), "solr-no-core.xml");
MiniSolrCloudCluster miniCluster = new MiniSolrCloudCluster(NUM_SERVERS, null, createTempDir().toFile(), solrXml, null, null);