You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/10/14 19:22:06 UTC

[07/15] jena git commit: Corrections for jena-jdbc and Fuseki1 to account for HttpClient 4

Corrections for jena-jdbc and Fuseki1 to account for HttpClient 4


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/39b708f2
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/39b708f2
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/39b708f2

Branch: refs/heads/master
Commit: 39b708f2522c1c1000a923cf177dd5c7d5215bd1
Parents: 1911547
Author: ajs6f <aj...@virginia.edu>
Authored: Sat Aug 20 13:00:32 2016 -0400
Committer: ajs6f <aj...@virginia.edu>
Committed: Thu Oct 13 16:09:42 2016 -0400

----------------------------------------------------------------------
 .../java/org/apache/jena/riot/web/HttpOp.java   |   8 +-
 .../jena/sparql/engine/http/HttpQuery.java      |  25 ++-
 .../sparql/engine/http/QueryEngineHTTP.java     |  40 ++--
 .../java/org/apache/jena/fuseki/ServerTest.java |  47 ++--
 .../java/org/apache/jena/fuseki/TestAuth.java   | 212 ++++++++++---------
 .../java/org/apache/jena/fuseki/TestQuery.java  |  11 -
 .../jdbc/results/AbstractResultSetTests.java    |   8 +-
 .../org/apache/jena/jdbc/utils/TestUtils.java   |   6 +-
 .../jena/jdbc/remote/RemoteEndpointDriver.java  | 163 +++-----------
 .../connections/RemoteEndpointConnection.java   |  23 +-
 .../RemoteEndpointPreparedStatement.java        |  20 +-
 .../statements/RemoteEndpointStatement.java     |  20 +-
 .../TestRemoteEndpointConnectionWithAuth.java   |  24 ++-
 .../results/TestRemoteEndpointResults.java      |   5 +-
 .../TestRemoteEndpointResultsWithAuth.java      |  21 +-
 .../TestRemoteEndpointResultsWithGraphUris.java |  10 +-
 ...RemoteEndpointResultsWithResultSetTypes.java |   3 +-
 17 files changed, 288 insertions(+), 358 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java b/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java
index 3bd97c7..dd06c58 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java
@@ -37,6 +37,8 @@ import org.apache.http.entity.StringEntity ;
 import org.apache.http.impl.client.HttpClientBuilder ;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.impl.client.cache.CachingHttpClientBuilder;
+import org.apache.http.impl.conn.PoolingClientConnectionManager;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.apache.http.message.BasicNameValuePair ;
 import org.apache.http.protocol.HttpContext ;
 import org.apache.http.util.EntityUtils ;
@@ -1068,15 +1070,13 @@ public class HttpOp {
      * Ensures that a HTTP Client is non-null
      * <p>
      * Prefers the {@link HttpClient} provided for the request if available.
-     * Then it tries to use a Jena-wide user configurable
-     * {@link HttpClient} if available.
+     * Then it tries to use a Jena-wide user configurable {@link HttpClient} if available.
      * </p>
      * <p>
      * In all other cases it creates a fresh instance of a client each time.
      * </p>
      * 
-     * @param client
-     *            HTTP Client
+     * @param client HTTP Client
      * @return HTTP Client
      */
     public static HttpClient ensureClient(HttpClient client) {

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/HttpQuery.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/HttpQuery.java b/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/HttpQuery.java
index aceeb13..c9673d9 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/HttpQuery.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/HttpQuery.java
@@ -70,7 +70,7 @@ public class HttpQuery extends Params {
     private HttpClient client;
     private boolean requireClientShutdown = true;
 
-    private HttpClientContext context = new HttpClientContext();
+    private HttpClientContext context;
 
     /**
      * Create a execution object for a whole model GET
@@ -175,6 +175,14 @@ public class HttpQuery extends Params {
     }
     
     /**
+     * Sets the context to use
+     * @param context HTTP context
+     */
+    public void setContext(HttpClientContext context) {
+        this.context = context;
+    }
+    
+    /**
      * Gets the HTTP client that is being used, may be null if no request has yet been made
      * @return HTTP Client or null
      */
@@ -192,6 +200,15 @@ public class HttpQuery extends Params {
     }
     
     /**
+     * Gets the HTTP context that is being used, or sets and returns a default
+     * @return the {@code HttpClientContext} in scope
+     */
+    public HttpClientContext getContext() {
+        if (context == null) context = new HttpClientContext();
+        return context;
+    }
+    
+    /**
      * Gets whether the HTTP client used should be shutdown
      * @return True if the client should be shutdown, false otherwise
      */
@@ -283,7 +300,7 @@ public class HttpQuery extends Params {
     }
     
     private void contextualizeCompressionSettings() {
-        final RequestConfig.Builder builder = RequestConfig.copy(context.getRequestConfig());
+        final RequestConfig.Builder builder = RequestConfig.copy(getContext().getRequestConfig());
         builder.setContentCompressionEnabled(allowCompression);
         context.setRequestConfig(builder.build());
     }
@@ -313,7 +330,7 @@ public class HttpQuery extends Params {
         try {
             try {
                 // Get the actual response stream
-                TypedInputStream stream = HttpOp.execHttpGet(target.toString(), contentTypeResult, client, context);
+                TypedInputStream stream = HttpOp.execHttpGet(target.toString(), contentTypeResult, client, getContext());
                 if (stream == null)
                     throw new QueryExceptionHTTP(404);
                 return execCommon(stream);
@@ -341,7 +358,7 @@ public class HttpQuery extends Params {
 
         try {
             // Get the actual response stream
-            TypedInputStream stream = HttpOp.execHttpPostFormStream(serviceURL, this, contentTypeResult, client, context);
+            TypedInputStream stream = HttpOp.execHttpPostFormStream(serviceURL, this, contentTypeResult, client, getContext());
             if (stream == null)
                 throw new QueryExceptionHTTP(404);
             return execCommon(stream);

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java b/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java
index 484111d..7833ab3 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java
@@ -27,6 +27,7 @@ import java.util.Map ;
 import java.util.concurrent.TimeUnit ;
 
 import org.apache.http.client.HttpClient ;
+import org.apache.http.client.protocol.HttpClientContext;
 import org.apache.jena.atlas.RuntimeIOException;
 import org.apache.jena.atlas.io.IO ;
 import org.apache.jena.atlas.lib.Pair ;
@@ -70,6 +71,7 @@ public class QueryEngineHTTP implements QueryExecution {
     private List<String> defaultGraphURIs = new ArrayList<>();
     private List<String> namedGraphURIs = new ArrayList<>();
     private HttpClient client;
+    private HttpClientContext httpContext;
 
     private boolean closed = false;
 
@@ -300,12 +302,29 @@ public class QueryEngineHTTP implements QueryExecution {
     /**
      * Get the HTTP client in use, if none is set then null.
      * 
-     * @param client
-     *            HTTP client
+     * @param client HTTP client
      */
     public HttpClient getClient() {
         return client;
     }
+    
+    /**
+     * Sets the HTTP context to use, if none is set then the default context is used.
+     * 
+     * @param context HTTP context
+     */
+    public void setHttpContext(HttpClientContext context) {
+        this.httpContext = context;
+    }
+    
+    /**
+     * Get the HTTP context in use, if none is set then null.
+     * 
+     * @return the {@code HttpClientContext} in scope
+     */
+    public HttpClientContext getHttpContext() {
+        return httpContext;
+    }
 
     /** The Content-Type response header received (null before the remote operation is attempted). */
     public String getHttpResponseContentType() {
@@ -591,21 +610,16 @@ public class QueryEngineHTTP implements QueryExecution {
             httpQuery.addParam( HttpParams.pNamedGraph, name );
         }
 
-        if (params != null)
-            httpQuery.merge(params);
+        if (params != null) httpQuery.merge(params);
 
         httpQuery.setAllowCompression(allowCompression);
-
-
         httpQuery.setClient(client);
-
+        httpQuery.setContext(getHttpContext());
+        
         // Apply timeouts
-        if (connectTimeout > 0) {
-            httpQuery.setConnectTimeout((int) connectTimeoutUnit.toMillis(connectTimeout));
-        }
-        if (readTimeout > 0) {
-            httpQuery.setReadTimeout((int) readTimeoutUnit.toMillis(readTimeout));
-        }
+        if (connectTimeout > 0) httpQuery.setConnectTimeout((int) connectTimeoutUnit.toMillis(connectTimeout));
+
+        if (readTimeout > 0) httpQuery.setReadTimeout((int) readTimeoutUnit.toMillis(readTimeout));
 
         return httpQuery;
     }

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-fuseki1/src/test/java/org/apache/jena/fuseki/ServerTest.java
----------------------------------------------------------------------
diff --git a/jena-fuseki1/src/test/java/org/apache/jena/fuseki/ServerTest.java b/jena-fuseki1/src/test/java/org/apache/jena/fuseki/ServerTest.java
index 03b06b0..9ace6eb 100644
--- a/jena-fuseki1/src/test/java/org/apache/jena/fuseki/ServerTest.java
+++ b/jena-fuseki1/src/test/java/org/apache/jena/fuseki/ServerTest.java
@@ -20,7 +20,7 @@ package org.apache.jena.fuseki;
 
 import java.io.IOException ;
 import java.net.ServerSocket ;
-import java.util.Arrays ;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.jena.fuseki.server.DatasetRegistry ;
 import org.apache.jena.graph.Graph ;
@@ -48,9 +48,8 @@ import org.apache.jena.update.UpdateProcessor ;
 public class ServerTest
 {
     // Abstraction that runs a SPARQL server for tests.
-    
     // Different to the Fuseki2 test ports.
-    public static final int port             = choosePort(3635, 3634, 3653, 3652, 103635, 103634, 103653, 103652) ;
+    public static final int port             = choosePort() ;   // Different to the Fuseki2 test ports.
     public static final String urlRoot       = "http://localhost:"+port+"/" ;
     public static final String datasetPath   = "/dataset" ;
     public static final String serviceUpdate = "http://localhost:"+port+datasetPath+"/update" ; 
@@ -75,20 +74,18 @@ public class ServerTest
     private static EmbeddedFusekiServer1 server = null ;
     
     // reference count of start/stop server
-    private static int countServer = 0 ; 
+    private static AtomicInteger countServer = new AtomicInteger() ; 
     
+    // This will cause there to be one server over all tests.
+    // Must be after initialization of counters 
+    static { allocServer(); }
+
     static public void allocServer() {
-        if ( countServer == 0 )
-            setupServer() ;
-        countServer++ ;
+        if (countServer.getAndIncrement() == 0) setupServer();
     }
     
     static public void freeServer() {
-        if ( countServer >= 0 ) {
-            countServer -- ;
-            if ( countServer == 0 )
-                teardownServer() ;
-        }
+        if (countServer.decrementAndGet() == 0) teardownServer();
     }
     
     @SuppressWarnings("deprecation")
@@ -105,25 +102,21 @@ public class ServerTest
             server.stop() ;
         server = null ;
     }
-    public static void resetServer() {
+
+    public static void resetServer()
+    {
+        if (countServer.get() == 0)  throw new RuntimeException("No server started!");
         Update clearRequest = new UpdateDrop(Target.ALL) ;
         UpdateProcessor proc = UpdateExecutionFactory.createRemote(clearRequest, ServerTest.serviceUpdate) ;
-        proc.execute() ;
+        try {proc.execute() ; }
+        catch (Throwable e) {e.printStackTrace(); throw e;}
     }
     
-    // Imperfect probing for a port.
-    // There is a race condition on finding a free port and using it in the tests. 
-    private static int choosePort(int... ports) {
-        for (int port : ports) {
-            try {
-                @SuppressWarnings("resource")
-                ServerSocket s = new ServerSocket(port) ;
-                s.close();
-                return s.getLocalPort() ; // OK to call after close.
-            } catch (IOException ex) { 
-                continue;
-            }
+    static int choosePort() {
+        try (ServerSocket s = new ServerSocket(0)) {
+            return s.getLocalPort();
+        } catch (IOException ex) {
+            throw new FusekiException("Failed to find a port for tests!");
         }
-        throw new FusekiException("Failed to find a port in :"+Arrays.asList(ports)) ;
     }
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-fuseki1/src/test/java/org/apache/jena/fuseki/TestAuth.java
----------------------------------------------------------------------
diff --git a/jena-fuseki1/src/test/java/org/apache/jena/fuseki/TestAuth.java b/jena-fuseki1/src/test/java/org/apache/jena/fuseki/TestAuth.java
index 0452b72..00fc7cb 100644
--- a/jena-fuseki1/src/test/java/org/apache/jena/fuseki/TestAuth.java
+++ b/jena-fuseki1/src/test/java/org/apache/jena/fuseki/TestAuth.java
@@ -26,12 +26,18 @@ import java.net.URISyntaxException ;
 import java.util.HashMap ;
 import java.util.Map ;
 
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.AuthCache;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.protocol.HttpClientContext;
+import org.apache.http.impl.auth.BasicScheme;
+import org.apache.http.impl.client.BasicAuthCache;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.HttpClients;
 import org.apache.jena.atlas.logging.LogCtl ;
 import org.apache.jena.atlas.web.HttpException ;
-import org.apache.jena.atlas.web.auth.PreemptiveBasicAuthenticator ;
-import org.apache.jena.atlas.web.auth.ScopedAuthenticator ;
-import org.apache.jena.atlas.web.auth.ServiceAuthenticator ;
-import org.apache.jena.atlas.web.auth.SimpleAuthenticator ;
 import org.apache.jena.fuseki.server.FusekiConfig ;
 import org.apache.jena.fuseki.server.SPARQLServer ;
 import org.apache.jena.fuseki.server.ServerConfig ;
@@ -40,6 +46,7 @@ import org.apache.jena.query.DatasetAccessor ;
 import org.apache.jena.query.DatasetAccessorFactory ;
 import org.apache.jena.query.QueryExecutionFactory ;
 import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.riot.web.HttpOp;
 import org.apache.jena.sparql.core.DatasetGraph ;
 import org.apache.jena.sparql.core.DatasetGraphFactory ;
 import org.apache.jena.sparql.engine.http.QueryEngineHTTP ;
@@ -61,9 +68,9 @@ import org.junit.Test ;
 public class TestAuth {
     // Use different port etc because sometimes the previous testing servers
     // don't release ports fast enough (OS issue / Linux)
-    public static final int authPort             = ServerTest.port+10 ;
+    public static final int authPort             = ServerTest.choosePort() ;
     public static final String authUrlRoot       = "http://localhost:"+authPort+"/" ;
-    public static final String authDatasetPath   = "/dataset" ;
+    public static final String authDatasetPath   = "/authDataset" ;
     public static final String authServiceUpdate = "http://localhost:"+authPort+authDatasetPath+"/update" ; 
     public static final String authServiceQuery  = "http://localhost:"+authPort+authDatasetPath+"/query" ; 
     public static final String authServiceREST   = "http://localhost:"+authPort+authDatasetPath+"/data" ;
@@ -78,6 +85,7 @@ public class TestAuth {
      */
     @BeforeClass
     public static void setup() throws IOException {
+        HttpOp.setDefaultHttpClient(null);
         realmFile = File.createTempFile("realm", ".properties");
 
         try(FileWriter writer = new FileWriter(realmFile)) {
@@ -106,22 +114,34 @@ public class TestAuth {
     @AfterClass
     public static void teardown() {
         server.stop();
-
         realmFile.delete();
     }
-
+    
+    private static HttpClient withCreds(String uname, String password) {
+        BasicCredentialsProvider credsProv = new BasicCredentialsProvider();
+        credsProv.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(uname, password));
+        return HttpClients.custom().setDefaultCredentialsProvider(credsProv).build();
+    }
+    
+    private static HttpClient withCreds(URI scope, String uname, String password) {
+        BasicCredentialsProvider credsProv = new BasicCredentialsProvider();
+        credsProv.setCredentials(new AuthScope(scope.getHost(), scope.getPort()),
+                new UsernamePasswordCredentials(uname, password));
+        return HttpClients.custom().setDefaultCredentialsProvider(credsProv).build();
+    }
+    
     @Test(expected = QueryExceptionHTTP.class)
     public void query_with_auth_01() {
         QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
         // No auth credentials should result in an error
-        qe.execAsk();
+        qe.execAsk();   
     }
 
     @Test(expected = QueryExceptionHTTP.class)
     public void query_with_auth_02() {
         QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
         // Auth credentials for valid user with bad password
-        qe.setBasicAuthentication("allowed", "incorrect".toCharArray());
+        qe.setClient(withCreds("allowed", "incorrect"));
         qe.execAsk();
     }
 
@@ -129,16 +149,15 @@ public class TestAuth {
     public void query_with_auth_03() {
         QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
         // Auth credentials for valid user with correct password
-        qe.setBasicAuthentication("allowed", "password".toCharArray());
+        qe.setClient(withCreds("allowed", "password"));
         Assert.assertTrue(qe.execAsk());
     }
 
     @Test(expected = QueryExceptionHTTP.class)
     public void query_with_auth_04() {
         QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
-        // Auth credentials for valid user with correct password BUT not in
-        // correct role
-        qe.setBasicAuthentication("forbidden", "password".toCharArray());
+        // Auth credentials for valid user with correct password BUT not in correct role
+        qe.setClient(withCreds("forbidden", "password"));
         qe.execAsk();
     }
 
@@ -146,11 +165,9 @@ public class TestAuth {
     public void query_with_auth_05() {
         // Uses auth and enables compression
         QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
-        qe.setAllowDeflate(true);
-        qe.setAllowGZip(true);
-
+        qe.setAllowCompression(true);
         // Auth credentials for valid user with correct password
-        qe.setBasicAuthentication("allowed", "password".toCharArray());
+        qe.setClient(withCreds("allowed", "password"));
         Assert.assertTrue(qe.execAsk());
     }
 
@@ -158,45 +175,50 @@ public class TestAuth {
     public void query_with_auth_06() {
         // Uses auth and enables compression
         QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
-        qe.setAllowDeflate(true);
-        qe.setAllowGZip(true);
-
+        qe.setAllowCompression(true);
         // Auth credentials for valid user with bad password
-        qe.setBasicAuthentication("allowed", "incorrect".toCharArray());
+        qe.setClient(withCreds("allowed", "incorrect"));
         qe.execAsk();
     }
 
     @Test(expected = QueryExceptionHTTP.class)
     public void query_with_auth_07() throws URISyntaxException {
         QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
-
-        // Auth credentials for valid user with correct password but scoped to
-        // wrong URI
-        ScopedAuthenticator authenticator = new ScopedAuthenticator(new URI("http://example"), "allowed",
-                "password".toCharArray());
-        qe.setAuthenticator(authenticator);
+        // Auth credentials for valid user with correct password but scoped to wrong URI
+        qe.setClient(withCreds(new URI("http://example"), "allowed", "password"));
         qe.execAsk();
     }
 
     @Test
     public void query_with_auth_08() throws URISyntaxException {
         QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
-
-        // Auth credentials for valid user with correct password and scoped to
-        // correct URI
-        ScopedAuthenticator authenticator = new ScopedAuthenticator(new URI(authServiceQuery), "allowed", "password".toCharArray());
-        qe.setAuthenticator(authenticator);
+        // Auth credentials for valid user with correct password and scoped to correct URI
+        qe.setClient(withCreds(new URI(authServiceQuery), "allowed", "password"));
         Assert.assertTrue(qe.execAsk());
     }
 
     @Test
-    public void query_with_auth_09() throws URISyntaxException {
+    public void query_with_auth_09() {
         QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
-
-        // Auth credentials for valid user with correct password using
-        // pre-emptive auth
-        ScopedAuthenticator authenticator = new ScopedAuthenticator(new URI(authServiceQuery), "allowed", "password".toCharArray());
-        qe.setAuthenticator(new PreemptiveBasicAuthenticator(authenticator));
+        // Auth credentials for valid user with correct password using pre-emptive auth
+        BasicCredentialsProvider credsProv = new BasicCredentialsProvider();
+        URI scope = URI.create(authServiceUpdate);
+        credsProv.setCredentials(new AuthScope(scope.getHost(), scope.getPort()),
+                new UsernamePasswordCredentials("allowed", "password"));
+        // Create AuthCache instance
+        AuthCache authCache = new BasicAuthCache();
+        // Generate BASIC scheme object and add it to the local auth cache
+        BasicScheme basicAuth = new BasicScheme();
+        authCache.put(new HttpHost(scope.getHost()), basicAuth);
+
+        // Add AuthCache to the execution context
+        HttpClientContext context = HttpClientContext.create();
+        context.setCredentialsProvider(credsProv);
+        context.setAuthCache(authCache);
+        HttpClient client = HttpClients.custom().setDefaultCredentialsProvider(credsProv).build();
+        qe.setClient(client);
+        qe.setHttpContext(context);
+        qe.setClient(withCreds(URI.create(authServiceQuery), "allowed", "password"));
         Assert.assertTrue(qe.execAsk());
     }
 
@@ -206,17 +228,13 @@ public class TestAuth {
         try {
             QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
 
-            // Auth credentials for valid user with correct password and scoped
-            // to correct URI
-            // Provided via Service Context and its associated authenticator
-            Map<String, Context> serviceContext = new HashMap<String, Context>();
+            // Auth credentials for valid user with correct password and scoped to correct URI
+            // Provided via Service Context
+            Map<String, Context> serviceContext = new HashMap<>();
             Context authContext = new Context();
-            authContext.put(Service.queryAuthUser, "allowed");
-            authContext.put(Service.queryAuthPwd, "password");
+            authContext.put(Service.queryClient, withCreds("allowed", "password"));
             serviceContext.put(authServiceQuery, authContext);
             ctx.put(Service.serviceContext, serviceContext);
-
-            qe.setAuthenticator(new ServiceAuthenticator());
             Assert.assertTrue(qe.execAsk());
         } finally {
             ctx.remove(Service.serviceContext);
@@ -229,17 +247,13 @@ public class TestAuth {
         try {
             QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
 
-            // Auth credentials for valid user with correct password and scoped
-            // to base URI of the actual service URL
-            // Provided via Service Context and its associated authenticator
-            Map<String, Context> serviceContext = new HashMap<String, Context>();
+            // Auth credentials for valid user with correct password and scoped to base URI of the actual service URL
+            // Provided via Service Context
+            Map<String, Context> serviceContext = new HashMap<>();
             Context authContext = new Context();
-            authContext.put(Service.queryAuthUser, "allowed");
-            authContext.put(Service.queryAuthPwd, "password");
-            serviceContext.put(authUrlRoot, authContext);
+            authContext.put(Service.queryClient, withCreds(URI.create(authUrlRoot), "allowed", "password"));
+            serviceContext.put(authServiceQuery, authContext);
             ctx.put(Service.serviceContext, serviceContext);
-
-            qe.setAuthenticator(new ServiceAuthenticator());
             Assert.assertTrue(qe.execAsk());
         } finally {
             ctx.remove(Service.serviceContext);
@@ -249,12 +263,9 @@ public class TestAuth {
     @Test
     public void query_with_auth_12() {
         ARQ.getContext().remove(Service.serviceContext);
-
         QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
-
         // Auth credentials for valid user with correct password
-        // Use service authenticator with fallback credentials.
-        qe.setAuthenticator(new ServiceAuthenticator("allowed", "password".toCharArray()));
+        qe.setClient(withCreds("allowed", "password"));
         Assert.assertTrue(qe.execAsk());
      }
     
@@ -262,10 +273,8 @@ public class TestAuth {
     public void query_with_auth_13() throws URISyntaxException {
         QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
 
-        // Auth credentials for valid user with correct password and scoped to
-        // base URI of the actual service URL
-        ScopedAuthenticator authenticator = new ScopedAuthenticator(new URI(authUrlRoot), "allowed", "password".toCharArray());
-        qe.setAuthenticator(authenticator);
+        // Auth credentials for valid user with correct password and scoped to base URI of the actual service URL
+        qe.setClient(withCreds(new URI(authUrlRoot), "allowed", "password"));
         Assert.assertTrue(qe.execAsk());
     }
     
@@ -273,10 +282,8 @@ public class TestAuth {
     public void query_with_auth_14() throws URISyntaxException {
         QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
 
-        // Auth credentials for valid user with correct password and scoped to
-        // base URI of the actual service URL
-        ScopedAuthenticator authenticator = new ScopedAuthenticator(new URI("http://localhost:" + authPort), "allowed", "password".toCharArray());
-        qe.setAuthenticator(authenticator);
+        // Auth credentials for valid user with correct password and scoped to base URI of the actual service URL
+        qe.setClient(withCreds(new URI("http://localhost:" + authPort), "allowed", "password"));
         Assert.assertTrue(qe.execAsk());
     }
 
@@ -293,7 +300,7 @@ public class TestAuth {
         UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
         UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates, authServiceUpdate);
         // Auth credentials for valid user with bad password
-        ue.setAuthentication("allowed", "incorrect".toCharArray());
+        ue.setClient(withCreds("allowed", "incorrect"));
         ue.execute();
     }
 
@@ -302,7 +309,7 @@ public class TestAuth {
         UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
         UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates, authServiceUpdate);
         // Auth credentials for valid user with correct password
-        ue.setAuthentication("allowed", "password".toCharArray());
+        ue.setClient(withCreds("allowed", "password"));
         ue.execute();
     }
 
@@ -310,9 +317,8 @@ public class TestAuth {
     public void update_with_auth_04() {
         UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
         UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates, authServiceUpdate);
-        // Auth credentials for valid user with correct password BUT not in
-        // correct role
-        ue.setAuthentication("forbidden", "password".toCharArray());
+        // Auth credentials for valid user with correct password BUT not in correct role
+        ue.setClient(withCreds("forbidden", "password"));
         ue.execute();
     }
 
@@ -329,7 +335,7 @@ public class TestAuth {
         UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
         UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemoteForm(updates, authServiceUpdate);
         // Auth credentials for valid user with bad password
-        ue.setAuthentication("allowed", "incorrect".toCharArray());
+        ue.setClient(withCreds("allowed", "incorrect"));
         ue.execute();
     }
 
@@ -338,7 +344,7 @@ public class TestAuth {
         UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
         UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemoteForm(updates, authServiceUpdate);
         // Auth credentials for valid user with correct password
-        ue.setAuthentication("allowed", "password".toCharArray());
+        ue.setClient(withCreds("allowed", "password"));
         ue.execute();
     }
 
@@ -346,22 +352,17 @@ public class TestAuth {
     public void update_with_auth_08() {
         UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
         UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemoteForm(updates, authServiceUpdate);
-        // Auth credentials for valid user with correct password BUT not in
-        // correct role
-        ue.setAuthentication("forbidden", "password".toCharArray());
+        // Auth credentials for valid user with correct password BUT not in correct role
+        ue.setClient(withCreds("forbidden", "password"));
         ue.execute();
     }
 
     @Test(expected = HttpException.class)
-    public void update_with_auth_09() throws URISyntaxException {
+    public void update_with_auth_09() {
         UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
         UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates, authServiceUpdate);
-
-        // Auth credentials for valid user with correct password but scoped to
-        // wrong URI
-        ScopedAuthenticator authenticator = new ScopedAuthenticator(new URI("http://example"), "allowed",
-                "password".toCharArray());
-        ue.setAuthenticator(authenticator);
+        // Auth credentials for valid user with correct password but scoped to wrong URI
+        ue.setClient(withCreds(URI.create("http://example"), "allowed", "password"));
         ue.execute();
     }
 
@@ -370,23 +371,36 @@ public class TestAuth {
         UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
         UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates, authServiceUpdate);
 
-        // Auth credentials for valid user with correct password scoped to
-        // correct URI
-        ScopedAuthenticator authenticator = new ScopedAuthenticator(new URI(authServiceUpdate), "allowed", "password".toCharArray());
-        ue.setAuthenticator(authenticator);
+        // Auth credentials for valid user with correct password scoped to correct URI
+        ue.setClient(withCreds(URI.create(authServiceUpdate), "allowed", "password"));
         ue.execute();
     }
 
     @Test
-    public void update_with_auth_11() throws URISyntaxException {
+    public void update_with_auth_11() {
         UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
-        UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates, authServiceUpdate);
+        UpdateProcessRemoteBase ue = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates,
+                authServiceUpdate);
 
-        // Auth credentials for valid user with correct password scoped to
-        // correct URI
+        // Auth credentials for valid user with correct password scoped to correct URI
         // Also using pre-emptive auth
-        ScopedAuthenticator authenticator = new ScopedAuthenticator(new URI(authServiceUpdate), "allowed", "password".toCharArray());
-        ue.setAuthenticator(new PreemptiveBasicAuthenticator(authenticator));
+        BasicCredentialsProvider credsProv = new BasicCredentialsProvider();
+        URI scope = URI.create(authServiceUpdate);
+        credsProv.setCredentials(new AuthScope(scope.getHost(), scope.getPort()),
+                new UsernamePasswordCredentials("allowed", "password"));
+        // Create AuthCache instance
+        AuthCache authCache = new BasicAuthCache();
+        // Generate BASIC scheme object and add it to the local auth cache
+        BasicScheme basicAuth = new BasicScheme();
+        authCache.put(new HttpHost(scope.getHost()), basicAuth);
+
+        // Add AuthCache to the execution context
+        HttpClientContext context = HttpClientContext.create();
+        context.setCredentialsProvider(credsProv);
+        context.setAuthCache(authCache);
+        HttpClient client = HttpClients.custom().setDefaultCredentialsProvider(credsProv).build();
+        ue.setClient(client);
+        ue.setHttpContext(context);
         ue.execute();
     }
     
@@ -400,14 +414,14 @@ public class TestAuth {
     @Test(expected = HttpException.class)
     public void graphstore_with_auth_02() {
         // Incorrect auth credentials
-        DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(authServiceREST, new SimpleAuthenticator("allowed", "incorrect".toCharArray()));
+        DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(authServiceREST, withCreds("allowed", "incorrect"));
         accessor.getModel();
     }
     
     @Test
     public void graphstore_with_auth_03() {
         // Correct auth credentials
-        DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(authServiceREST, new SimpleAuthenticator("allowed", "password".toCharArray()));
+        DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(authServiceREST, withCreds("allowed", "password"));
         Model m = accessor.getModel();
         Assert.assertTrue(m.isEmpty());
     }
@@ -415,14 +429,14 @@ public class TestAuth {
     @Test(expected = HttpException.class)
     public void graphstore_with_auth_04() throws URISyntaxException {
         // Correct auth credentials scoped to wrong URI
-        DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(authServiceREST, new ScopedAuthenticator(new URI("http://example.org/"), "allowed", "password".toCharArray()));
+        DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(authServiceREST, withCreds(new URI("http://example.org/"), "allowed", "password"));
         accessor.getModel();
     }
     
     @Test
     public void graphstore_with_auth_05() throws URISyntaxException {
         // Correct auth credentials scoped to correct URI
-        DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(authServiceREST, new ScopedAuthenticator(new URI(authServiceREST), "allowed", "password".toCharArray()));
+        DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(authServiceREST, withCreds(new URI(authServiceREST), "allowed", "password"));
         accessor.getModel();
     }
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-fuseki1/src/test/java/org/apache/jena/fuseki/TestQuery.java
----------------------------------------------------------------------
diff --git a/jena-fuseki1/src/test/java/org/apache/jena/fuseki/TestQuery.java b/jena-fuseki1/src/test/java/org/apache/jena/fuseki/TestQuery.java
index 5c0674f..ee00523 100644
--- a/jena-fuseki1/src/test/java/org/apache/jena/fuseki/TestQuery.java
+++ b/jena-fuseki1/src/test/java/org/apache/jena/fuseki/TestQuery.java
@@ -31,7 +31,6 @@ import org.apache.jena.atlas.junit.BaseTest ;
 import org.apache.jena.query.* ;
 import org.apache.jena.sparql.core.Var ;
 import org.apache.jena.sparql.engine.binding.Binding ;
-import org.apache.jena.sparql.resultset.ResultSetCompare ;
 import org.apache.jena.sparql.sse.Item ;
 import org.apache.jena.sparql.sse.SSE ;
 import org.apache.jena.sparql.sse.builders.BuilderResultSet ;
@@ -57,8 +56,6 @@ public class TestQuery extends BaseTest
     
     @AfterClass public static void afterClass()
     {
-        DatasetAccessor du = DatasetAccessorFactory.createHTTP(serviceREST) ;
-        du.deleteDefault() ;
         ServerTest.freeServer() ;
     }
     
@@ -105,12 +102,4 @@ public class TestQuery extends BaseTest
         int x = ResultSetFormatter.consume(rs) ;
         assertEquals(exceptedRowCount, x) ;
     }
-    
-    private void execQuery(String queryString, ResultSet expectedResultSet)
-    {
-        QueryExecution qExec = QueryExecutionFactory.sparqlService(serviceQuery, queryString) ;
-        ResultSet rs = qExec.execSelect() ;
-        boolean b = ResultSetCompare.equalsByTerm(rs, expectedResultSet) ;
-        assertTrue("Result sets different", b) ;
-    }
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/results/AbstractResultSetTests.java
----------------------------------------------------------------------
diff --git a/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/results/AbstractResultSetTests.java b/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/results/AbstractResultSetTests.java
index bd468cf..6e93244 100644
--- a/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/results/AbstractResultSetTests.java
+++ b/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/results/AbstractResultSetTests.java
@@ -3413,13 +3413,9 @@ public abstract class AbstractResultSetTests {
      */
     @Test(expected = SQLFeatureNotSupportedException.class)
     public void results_bad_updates_60() throws SQLException {
-        ResultSet rset = this.createResults(ds, "SELECT * WHERE { ?s ?p ?o }");
-
-        try {
+        try (ResultSet rset = this.createResults(ds, "SELECT * WHERE { ?s ?p ?o }")) {
             rset.updateNCharacterStream("s", (Reader) null);
-        } finally {
-            rset.close();
-        }
+        } 
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/utils/TestUtils.java
----------------------------------------------------------------------
diff --git a/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/utils/TestUtils.java b/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/utils/TestUtils.java
index ea7fcc5..42a1c08 100644
--- a/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/utils/TestUtils.java
+++ b/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/utils/TestUtils.java
@@ -20,7 +20,7 @@ package org.apache.jena.jdbc.utils;
 
 import java.util.Iterator;
 
-import org.apache.jena.atlas.web.auth.HttpAuthenticator;
+import org.apache.http.client.HttpClient;
 import org.apache.jena.graph.Node ;
 import org.apache.jena.query.Dataset ;
 import org.apache.jena.query.DatasetAccessor ;
@@ -144,8 +144,8 @@ public class TestUtils {
      * @param authenticator
      *            HTTP Authenticator
      */
-    public static void copyToRemoteDataset(Dataset source, String service, HttpAuthenticator authenticator) {
-        DatasetAccessor target = DatasetAccessorFactory.createHTTP(service, authenticator);
+    public static void copyToRemoteDataset(Dataset source, String service, HttpClient client) {
+        DatasetAccessor target = DatasetAccessorFactory.createHTTP(service, client);
         target.putModel(source.getDefaultModel());
         Iterator<String> uris = source.listNames();
         while (uris.hasNext()) {

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java
----------------------------------------------------------------------
diff --git a/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java b/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java
index 74e91d4..269cd90 100644
--- a/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java
+++ b/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java
@@ -23,16 +23,19 @@ import java.net.URISyntaxException;
 import java.sql.DriverManager;
 import java.sql.DriverPropertyInfo;
 import java.sql.SQLException;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 
-import org.apache.jena.atlas.web.auth.* ;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.HttpClient;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.HttpClients;
 import org.apache.jena.jdbc.JdbcCompatibility;
 import org.apache.jena.jdbc.JenaDriver;
 import org.apache.jena.jdbc.connections.JenaConnection;
 import org.apache.jena.jdbc.remote.connections.RemoteEndpointConnection;
+import org.apache.jena.riot.web.HttpOp;
 import org.apache.jena.system.JenaSystem ;
 
 /**
@@ -87,29 +90,12 @@ import org.apache.jena.system.JenaSystem ;
  * <p>
  * The driver also supports the standard JDBC {@code user} and {@code password}
  * parameters which are used to set user credentials for authenticating to the
- * remote HTTP server. This uses the ARQ HTTP authenticator API behind the
- * scenes so the following parameters may also be used to configure desired
- * behavior:
+ * remote HTTP server.
  * </p>
- * <ul>
- * <li>{@code preemptive-auth} - Sets a boolean indicating whether preemptive
- * basic authentication should be enabled, disabled by default.</li>
- * <li>{@code form-url} - Sets a URL to use for form based login.</li>
- * <li>{@code form-user-field} - Sets the name of the user name field used for
- * form based login. If omitted but {@code form-url} is used then the default
- * value {@code httpd_username} is used i.e. we assume you are communicating
- * with a Apache mod_auth_form protected site that uses the default form
- * configuration.</li>
- * <li>{@code form-password-field} - Sets the name of the password field used
- * for form based login. If omitted but {@code form-url} is used then the
- * default value {@code httpd_password} is used i.e. we assume you are
- * communicating with a Apache mod_auth_form protected site that uses the
- * default form configuration.</li>
- * </ul>
  * <p>
- * Alternatively you may use the {@code authenticator} parameter to set a
- * specific authenticator implementation to use, must be passed an instance of
- * {@link HttpAuthenticator} so can only be passed via the {@link Properties}
+ * Alternatively you may use the {@code client} parameter to set a
+ * specific client implementation to use, must be passed an instance of
+ * {@link HttpClient} so can only be passed via the {@link Properties}
  * object and not via the connection URL. If this parameter is used then all
  * other authentication parameters are ignored.
  * </p>
@@ -176,40 +162,17 @@ public class RemoteEndpointDriver extends JenaDriver {
     public static final String PARAM_MODEL_RESULTS_TYPE = "model-results-type";
 
     /**
-     * Constant for the connection URL parameter that sets the URL to use for
-     * form based login.
-     */
-    public static final String PARAM_FORMS_LOGIN_URL = "form-url";
-
-    /**
-     * Constant for the connection URL parameter that sets the user name field
-     * to use for form based logins
-     */
-    public static final String PARAM_FORMS_LOGIN_USER_FIELD = "form-user-field";
-
-    /**
-     * Constant for the connection URL parameter that sets the password field to
-     * use for form based logins
-     */
-    public static final String PARAM_FORMS_LOGIN_PASSWORD_FIELD = "form-password-field";
-
-    /**
-     * Constant for the connection URL parameter that sets that preemptive
-     * authentication should be enabled.
-     */
-    public static final String PARAM_PREEMPTIVE_AUTH = "preemptive-auth";
-
-    /**
-     * Constant for the parameter used to specify an authenticator used.
+     * Constant for the parameter used to specify a client used.
      * <p>
      * It is <strong>important</strong> to be aware that you must pass in an
-     * actual instance of a {@link HttpAuthenticator} for this parameter so you
+     * actual instance of a {@link HttpClient} for this parameter so you
      * cannot use directly in the Connection URL and must pass in via the
      * {@link Properties} object.
      * </p>
      */
-    public static final String PARAM_AUTHENTICATOR = "authenticator";
+    public static final String PARAM_CLIENT = "client";
 
+    
     /**
      * Static initializer block which ensures the driver gets registered
      */
@@ -271,7 +234,7 @@ public class RemoteEndpointDriver extends JenaDriver {
         List<String> usingNamedGraphs = this.getValues(props, PARAM_USING_NAMED_GRAPH_URI);
 
         // Authentication settings
-        HttpAuthenticator authenticator = this.configureAuthenticator(queryEndpoint, updateEndpoint, props);
+        HttpClient client = this.configureClient(props);
 
         // Result Types
         String selectResultsType = props.getProperty(PARAM_SELECT_RESULTS_TYPE, null);
@@ -279,88 +242,30 @@ public class RemoteEndpointDriver extends JenaDriver {
 
         // Create connection
         return openConnection(queryEndpoint, updateEndpoint, defaultGraphs, namedGraphs, usingGraphs, usingNamedGraphs,
-                authenticator, JenaConnection.DEFAULT_HOLDABILITY, compatibilityLevel, selectResultsType, modelResultsType);
+                client, JenaConnection.DEFAULT_HOLDABILITY, compatibilityLevel, selectResultsType, modelResultsType);
     }
-
-    protected HttpAuthenticator configureAuthenticator(String queryEndpoint, String updateEndpoint, Properties props)
-            throws SQLException {
-        // Is there a specific authenticator to use?
-        Object authObj = props.get(PARAM_AUTHENTICATOR);
-        if (authObj != null) {
-            if (authObj instanceof HttpAuthenticator) {
-                return (HttpAuthenticator) authObj;
-            } else {
-                throw new SQLException(
-                        "The "
-                                + PARAM_AUTHENTICATOR
-                                + " parameter is specified but the value is not an object implementing the required HttpAuthenticator interface");
-            }
-        }
-
-        // Otherwise get credentials to use
+    
+    protected HttpClient configureClient(Properties props) throws SQLException {
+        // Try to get credentials to use
         String user = props.getProperty(PARAM_USERNAME, null);
-        if (user != null && user.trim().length() == 0)
-            user = null;
+        if (user != null && user.trim().isEmpty()) user = null;
         String password = props.getProperty(PARAM_PASSWORD, null);
-        if (password != null && password.trim().length() == 0)
-            password = null;
+        if (password != null && password.trim().isEmpty()) password = null;
 
-        // If no credentials then we won't configure anything
-        if (user == null || password == null)
-            return null;
-
-        // Are we using HTTP or form based login?
-        String loginURL = props.getProperty(PARAM_FORMS_LOGIN_URL);
-        if (loginURL != null) {
-            // Determine login fields
-            String userField = props.getProperty(PARAM_FORMS_LOGIN_USER_FIELD, ApacheModAuthFormLogin.USER_FIELD);
-            String pwdField = props.getProperty(PARAM_FORMS_LOGIN_PASSWORD_FIELD, ApacheModAuthFormLogin.PASSWORD_FIELD);
-
-            // Create logins
-            Map<URI, FormLogin> logins = new HashMap<URI, FormLogin>();
-            String baseUri = this.getCommonBase(queryEndpoint, updateEndpoint);
-            if (baseUri != null) {
-                // One/both endpoints are specified and they have a common
-                // Base URI so we'll create a single login
-                try {
-                    logins.put(new URI(baseUri), new FormLogin(loginURL, userField, pwdField, user, password.toCharArray()));
-                } catch (URISyntaxException e) {
-                    throw new SQLException("Unable to configure form based login due to invalid Base URI", e);
-                }
-            } else {
-                // Only one endpoint is specified or they did not share a common
-                // base
-                if (queryEndpoint != null) {
-                    // Add a query endpoint specific login
-                    try {
-                        logins.put(new URI(queryEndpoint),
-                                new FormLogin(loginURL, userField, pwdField, user, password.toCharArray()));
-                    } catch (URISyntaxException e) {
-                        throw new SQLException("Unable to configure form based login due to invalid Query Endpoint URI", e);
-                    }
-                }
-                if (updateEndpoint != null) {
-                    // Add an update endpoint specific login
-                    try {
-                        logins.put(new URI(updateEndpoint),
-                                new FormLogin(loginURL, userField, pwdField, user, password.toCharArray()));
-                    } catch (URISyntaxException e) {
-                        throw new SQLException("Unable to configure form based login due to invalid Update Endpoint URI", e);
-                    }
-                }
-            }
-            return new FormsAuthenticator(logins);
-        } else {
-            // Do we want preemptive authentication?
-            if (this.isTrue(props, PARAM_PREEMPTIVE_AUTH)) {
-                return new PreemptiveBasicAuthenticator(new SimpleAuthenticator(user, password.toCharArray()));
-            } else {
-                // Use simple authenticator
-                return new SimpleAuthenticator(user, password.toCharArray());
-            }
+        // If credentials then we use them
+        if (user != null && password != null) {
+            BasicCredentialsProvider credsProv = new BasicCredentialsProvider();
+            credsProv.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(user, password));
+            return HttpClients.custom().setDefaultCredentialsProvider(credsProv).build();
         }
+        // else use a supplied or default client
+        Object client = props.get(PARAM_CLIENT);
+        if (client != null && !(client instanceof HttpClient)) { throw new SQLException("The " + PARAM_CLIENT
+                + " parameter is specified but the value is not an object implementing the required HttpClient interface"); }
+        return HttpOp.ensureClient((HttpClient) client);
     }
 
+
     /**
      * Determines the common base of the two URIs if there is one. The common
      * base will have irrelevant components (fragment and query string) stripped
@@ -522,10 +427,10 @@ public class RemoteEndpointDriver extends JenaDriver {
      * @throws SQLException
      */
     protected RemoteEndpointConnection openConnection(String queryEndpoint, String updateEndpoint, List<String> defaultGraphs,
-            List<String> namedGraphs, List<String> usingGraphs, List<String> usingNamedGraphs, HttpAuthenticator authenticator,
+            List<String> namedGraphs, List<String> usingGraphs, List<String> usingNamedGraphs, HttpClient client,
             int holdability, int compatibilityLevel, String selectResultsType, String modelResultsType) throws SQLException {
         return new RemoteEndpointConnection(queryEndpoint, updateEndpoint, defaultGraphs, namedGraphs, usingGraphs,
-                usingNamedGraphs, authenticator, holdability, compatibilityLevel, selectResultsType, modelResultsType);
+                usingNamedGraphs, client, holdability, compatibilityLevel, selectResultsType, modelResultsType);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/connections/RemoteEndpointConnection.java
----------------------------------------------------------------------
diff --git a/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/connections/RemoteEndpointConnection.java b/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/connections/RemoteEndpointConnection.java
index 85a0115..2f26ac9 100644
--- a/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/connections/RemoteEndpointConnection.java
+++ b/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/connections/RemoteEndpointConnection.java
@@ -25,7 +25,7 @@ import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.util.List;
 
-import org.apache.jena.atlas.web.auth.HttpAuthenticator;
+import org.apache.http.client.HttpClient;
 import org.apache.jena.jdbc.JdbcCompatibility;
 import org.apache.jena.jdbc.connections.JenaConnection;
 import org.apache.jena.jdbc.remote.metadata.RemoteEndpointMetadata;
@@ -47,7 +47,7 @@ public class RemoteEndpointConnection extends JenaConnection {
     private List<String> namedGraphUris;
     private List<String> usingGraphUris;
     private List<String> usingNamedGraphUris;
-    private HttpAuthenticator authenticator;
+    private HttpClient client;
     private DatabaseMetaData metadata;
     private String selectResultsType, modelResultsType;
 
@@ -102,7 +102,7 @@ public class RemoteEndpointConnection extends JenaConnection {
      */
     public RemoteEndpointConnection(String queryEndpoint, String updateEndpoint, List<String> defaultGraphUris,
             List<String> namedGraphUris, List<String> usingGraphUris, List<String> usingNamedGraphUris,
-            HttpAuthenticator authenticator, int holdability, int compatibilityLevel, String selectResultsType,
+            HttpClient client, int holdability, int compatibilityLevel, String selectResultsType,
             String modelResultsType) throws SQLException {
         super(holdability, true, Connection.TRANSACTION_NONE, compatibilityLevel);
         if (queryEndpoint == null && updateEndpoint == null)
@@ -114,7 +114,7 @@ public class RemoteEndpointConnection extends JenaConnection {
         this.namedGraphUris = namedGraphUris;
         this.usingGraphUris = usingGraphUris;
         this.usingNamedGraphUris = usingNamedGraphUris;
-        this.authenticator = authenticator;
+        this.client = client;
         this.metadata = new RemoteEndpointMetadata(this);
         this.selectResultsType = selectResultsType;
         this.modelResultsType = modelResultsType;
@@ -211,7 +211,7 @@ public class RemoteEndpointConnection extends JenaConnection {
                     "Remote endpoint backed connection do not support scroll sensitive result sets");
         if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY)
             throw new SQLFeatureNotSupportedException("Remote endpoint backed connections only support read-only result sets");
-        return new RemoteEndpointStatement(this, this.authenticator, resultSetType, ResultSet.FETCH_FORWARD, 0,
+        return new RemoteEndpointStatement(this, this.client, resultSetType, ResultSet.FETCH_FORWARD, 0,
                 resultSetHoldability);
     }
 
@@ -225,7 +225,7 @@ public class RemoteEndpointConnection extends JenaConnection {
                     "Remote endpoint backed connection do not support scroll sensitive result sets");
         if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY)
             throw new SQLFeatureNotSupportedException("Remote endpoint backed connections only support read-only result sets");
-        return new RemoteEndpointPreparedStatement(sparql, this, this.authenticator, resultSetType, ResultSet.FETCH_FORWARD, 0,
+        return new RemoteEndpointPreparedStatement(sparql, this, this.client, resultSetType, ResultSet.FETCH_FORWARD, 0,
                 resultSetHoldability);
     }
 
@@ -281,15 +281,4 @@ public class RemoteEndpointConnection extends JenaConnection {
             throw new SQLFeatureNotSupportedException("Transactions are not supported for remote endpoint backed connections");
         }
     }
-
-    /**
-     * Gets whether any HTTP authenticator has been provided. Note that the
-     * provision of an authenticator does not guarantee authentication since
-     * that will be down to the configuration of the given authenticator.
-     * 
-     * @return True if an authenticator is provided, false otherwise
-     */
-    public boolean isUsingAuthentication() {
-        return this.authenticator != null;
-    }
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointPreparedStatement.java
----------------------------------------------------------------------
diff --git a/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointPreparedStatement.java b/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointPreparedStatement.java
index 5d923d9..91a15d7 100644
--- a/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointPreparedStatement.java
+++ b/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointPreparedStatement.java
@@ -22,7 +22,7 @@ import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 
-import org.apache.jena.atlas.web.auth.HttpAuthenticator;
+import org.apache.http.client.HttpClient;
 import org.apache.jena.jdbc.remote.connections.RemoteEndpointConnection;
 import org.apache.jena.jdbc.statements.JenaPreparedStatement;
 import org.apache.jena.query.Query ;
@@ -42,7 +42,7 @@ import org.apache.jena.update.UpdateRequest ;
 public class RemoteEndpointPreparedStatement extends JenaPreparedStatement {
 
     private RemoteEndpointConnection remoteConn;
-    private HttpAuthenticator authenticator;
+    private HttpClient client;
 
     /**
      * Creates a new statement
@@ -79,11 +79,11 @@ public class RemoteEndpointPreparedStatement extends JenaPreparedStatement {
      *             Thrown if there is an error with the statement parameters
      * 
      */
-    public RemoteEndpointPreparedStatement(String sparql, RemoteEndpointConnection connection, HttpAuthenticator authenticator,
+    public RemoteEndpointPreparedStatement(String sparql, RemoteEndpointConnection connection, HttpClient client,
             int type, int fetchDir, int fetchSize, int holdability) throws SQLException {
         super(sparql, connection, type, fetchDir, fetchSize, holdability, false, Connection.TRANSACTION_NONE);
         this.remoteConn = connection;
-        this.authenticator = authenticator;
+        this.client = client;
     }
 
     @Override
@@ -94,9 +94,9 @@ public class RemoteEndpointPreparedStatement extends JenaPreparedStatement {
         // Create basic execution
         QueryEngineHTTP exec = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(this.remoteConn.getQueryEndpoint(), q);
 
-        // Apply authentication settings
-        if (this.authenticator != null) {
-            exec.setAuthenticator(this.authenticator);
+        // Apply HTTP settings
+        if (this.client != null) {
+            exec.setClient(this.client);
         }
 
         // Apply default and named graphs if appropriate
@@ -124,9 +124,9 @@ public class RemoteEndpointPreparedStatement extends JenaPreparedStatement {
         UpdateProcessRemoteBase proc = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(u,
                 this.remoteConn.getUpdateEndpoint());
 
-        // Apply authentication settings
-        if (this.authenticator != null) {
-            proc.setAuthenticator(this.authenticator);
+        // Apply HTTP settings
+        if (this.client != null) {
+            proc.setClient(this.client);
         }
 
         // Apply default and named graphs if appropriate

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointStatement.java
----------------------------------------------------------------------
diff --git a/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointStatement.java b/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointStatement.java
index 1f08e45..d75c246 100644
--- a/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointStatement.java
+++ b/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointStatement.java
@@ -22,7 +22,7 @@ import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 
-import org.apache.jena.atlas.web.auth.HttpAuthenticator;
+import org.apache.http.client.HttpClient;
 import org.apache.jena.jdbc.remote.connections.RemoteEndpointConnection;
 import org.apache.jena.jdbc.statements.JenaStatement;
 import org.apache.jena.query.Query ;
@@ -42,7 +42,7 @@ import org.apache.jena.update.UpdateRequest ;
 public class RemoteEndpointStatement extends JenaStatement {
 
     private RemoteEndpointConnection remoteConn;
-    private HttpAuthenticator authenticator;
+    private HttpClient client;
 
     /**
      * Creates a new statement
@@ -74,11 +74,11 @@ public class RemoteEndpointStatement extends JenaStatement {
      *             Thrown if there is an error with the statement parameters
      * 
      */
-    public RemoteEndpointStatement(RemoteEndpointConnection connection, HttpAuthenticator authenticator, int type, int fetchDir,
+    public RemoteEndpointStatement(RemoteEndpointConnection connection, HttpClient client, int type, int fetchDir,
             int fetchSize, int holdability) throws SQLException {
         super(connection, type, fetchDir, fetchSize, holdability, false, Connection.TRANSACTION_NONE);
         this.remoteConn = connection;
-        this.authenticator = authenticator;
+        this.client = client;
     }
 
     @Override
@@ -89,9 +89,9 @@ public class RemoteEndpointStatement extends JenaStatement {
         // Create basic execution
         QueryEngineHTTP exec = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(this.remoteConn.getQueryEndpoint(), q);
 
-        // Apply authentication settings
-        if (this.authenticator != null) {
-            exec.setAuthenticator(authenticator);
+        // Apply HTTP settings
+        if (this.client != null) {
+            exec.setClient(client);
         }
 
         // Apply default and named graphs if appropriate
@@ -119,9 +119,9 @@ public class RemoteEndpointStatement extends JenaStatement {
         UpdateProcessRemoteBase proc = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(u,
                 this.remoteConn.getUpdateEndpoint());
 
-        // Apply authentication settings
-        if (this.authenticator != null) {
-            proc.setAuthenticator(this.authenticator);
+        // Apply HTTP settings
+        if (this.client != null) {
+            proc.setClient(this.client);
         }
 
         // Apply default and named graphs if appropriate

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/connections/TestRemoteEndpointConnectionWithAuth.java
----------------------------------------------------------------------
diff --git a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/connections/TestRemoteEndpointConnectionWithAuth.java b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/connections/TestRemoteEndpointConnectionWithAuth.java
index 2355c7a..62a76de 100644
--- a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/connections/TestRemoteEndpointConnectionWithAuth.java
+++ b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/connections/TestRemoteEndpointConnectionWithAuth.java
@@ -23,8 +23,11 @@ import java.io.FileWriter ;
 import java.io.IOException ;
 import java.sql.SQLException ;
 
-import org.apache.jena.atlas.web.auth.HttpAuthenticator ;
-import org.apache.jena.atlas.web.auth.SimpleAuthenticator ;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.HttpClient;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.HttpClients;
 import org.apache.jena.fuseki.ServerTest ;
 import org.apache.jena.fuseki.server.FusekiConfig ;
 import org.apache.jena.fuseki.server.SPARQLServer ;
@@ -57,7 +60,7 @@ public class TestRemoteEndpointConnectionWithAuth extends AbstractRemoteEndpoint
     private static String PASSWORD = "letmein";
     private static File realmFile;
     private static SPARQLServer server;
-    private static HttpAuthenticator authenticator;
+    private static HttpClient client;
 
     /**
      * Setup for the tests by allocating a Fuseki instance to work with
@@ -65,8 +68,10 @@ public class TestRemoteEndpointConnectionWithAuth extends AbstractRemoteEndpoint
      */
     @BeforeClass
     public static void setup() throws IOException {
-        authenticator = new SimpleAuthenticator(USER, PASSWORD.toCharArray());
-        
+        BasicCredentialsProvider credsProv = new BasicCredentialsProvider();
+        credsProv.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(USER, PASSWORD));
+        client = HttpClients.custom().setDefaultCredentialsProvider(credsProv).build();
+
         realmFile = File.createTempFile("realm", ".properties");
 
         try(FileWriter writer = new FileWriter(realmFile)) {
@@ -74,6 +79,7 @@ public class TestRemoteEndpointConnectionWithAuth extends AbstractRemoteEndpoint
         }
 
         DatasetGraph dsg = DatasetGraphFactory.create();
+
         // This must agree with ServerTest
         ServerConfig conf = FusekiConfig.defaultConfiguration(ServerTest.datasetPath, dsg, true, false);
         conf.port = ServerTest.port;
@@ -90,7 +96,7 @@ public class TestRemoteEndpointConnectionWithAuth extends AbstractRemoteEndpoint
     @After
     public void cleanupTest() {
         Update clearRequest = new UpdateDrop(Target.ALL) ;
-        UpdateProcessor proc = UpdateExecutionFactory.createRemote(clearRequest, ServerTest.serviceUpdate, authenticator) ;
+        UpdateProcessor proc = UpdateExecutionFactory.createRemote(clearRequest, ServerTest.serviceUpdate, client) ;
         proc.execute() ;
     }
 
@@ -113,16 +119,16 @@ public class TestRemoteEndpointConnectionWithAuth extends AbstractRemoteEndpoint
     @Override
     protected JenaConnection getConnection() throws SQLException {
         return new RemoteEndpointConnection(ServerTest.serviceQuery, ServerTest.serviceUpdate, null, null, null, null,
-                authenticator, JenaConnection.DEFAULT_HOLDABILITY,
+                client, JenaConnection.DEFAULT_HOLDABILITY,
                 JdbcCompatibility.DEFAULT, null, null);
     }
 
     @Override
     protected JenaConnection getConnection(Dataset ds) throws SQLException {
         // Set up the dataset
-        TestUtils.copyToRemoteDataset(ds, ServerTest.serviceREST, authenticator);
+        TestUtils.copyToRemoteDataset(ds, ServerTest.serviceREST, client);
         return new RemoteEndpointConnection(ServerTest.serviceQuery, ServerTest.serviceUpdate, null, null, null, null,
-                authenticator, JenaConnection.DEFAULT_HOLDABILITY,
+                client, JenaConnection.DEFAULT_HOLDABILITY,
                 JdbcCompatibility.DEFAULT, null, null);
     }
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResults.java
----------------------------------------------------------------------
diff --git a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResults.java b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResults.java
index 0418858..12769c4 100644
--- a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResults.java
+++ b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResults.java
@@ -28,6 +28,7 @@ import org.apache.jena.jdbc.connections.JenaConnection;
 import org.apache.jena.jdbc.remote.connections.RemoteEndpointConnection;
 import org.apache.jena.jdbc.utils.TestUtils;
 import org.apache.jena.query.Dataset ;
+import org.apache.jena.riot.web.HttpOp;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -46,8 +47,8 @@ public class TestRemoteEndpointResults extends AbstractRemoteEndpointResultSetTe
      */
     @BeforeClass
     public static void setup() throws SQLException {
-    	ServerTest.allocServer();
-        
+        ServerTest.allocServer();
+    	    HttpOp.setDefaultHttpClient(null);
         connection = new RemoteEndpointConnection(ServerTest.serviceQuery, ServerTest.serviceUpdate, JenaConnection.DEFAULT_HOLDABILITY, JdbcCompatibility.DEFAULT);
         connection.setJdbcCompatibilityLevel(JdbcCompatibility.HIGH);
     }

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithAuth.java
----------------------------------------------------------------------
diff --git a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithAuth.java b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithAuth.java
index 8295116..f4241e5 100644
--- a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithAuth.java
+++ b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithAuth.java
@@ -25,8 +25,11 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 
-import org.apache.jena.atlas.web.auth.HttpAuthenticator;
-import org.apache.jena.atlas.web.auth.SimpleAuthenticator;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.HttpClient;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.HttpClients;
 import org.apache.jena.fuseki.ServerTest;
 import org.apache.jena.fuseki.server.FusekiConfig;
 import org.apache.jena.fuseki.server.SPARQLServer;
@@ -61,7 +64,7 @@ public class TestRemoteEndpointResultsWithAuth extends AbstractRemoteEndpointRes
     private static String PASSWORD = "letmein";
     private static File realmFile;
     private static SPARQLServer server;
-    private static HttpAuthenticator authenticator;
+    private static HttpClient client;
 
     /**
      * Setup for the tests by allocating a Fuseki instance to work with
@@ -71,7 +74,10 @@ public class TestRemoteEndpointResultsWithAuth extends AbstractRemoteEndpointRes
      */
     @BeforeClass
     public static void setup() throws SQLException, IOException {
-        authenticator = new SimpleAuthenticator(USER, PASSWORD.toCharArray());
+
+        BasicCredentialsProvider credsProv = new BasicCredentialsProvider();
+        credsProv.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(USER, PASSWORD));
+        client = HttpClients.custom().setDefaultCredentialsProvider(credsProv).build();
 
         realmFile = File.createTempFile("realm", ".properties");
 
@@ -80,6 +86,7 @@ public class TestRemoteEndpointResultsWithAuth extends AbstractRemoteEndpointRes
         }
 
         DatasetGraph dsg = DatasetGraphFactory.create();
+
         // This must agree with ServerTest
         ServerConfig conf = FusekiConfig.defaultConfiguration(ServerTest.datasetPath, dsg, true, false);
         conf.port = ServerTest.port;
@@ -90,7 +97,7 @@ public class TestRemoteEndpointResultsWithAuth extends AbstractRemoteEndpointRes
         server.start();
 
         connection = new RemoteEndpointConnection(ServerTest.serviceQuery, ServerTest.serviceUpdate, null, null, null, null,
-                authenticator, JenaConnection.DEFAULT_HOLDABILITY, JdbcCompatibility.DEFAULT, null, null);
+                client, JenaConnection.DEFAULT_HOLDABILITY, JdbcCompatibility.DEFAULT, null, null);
         connection.setJdbcCompatibilityLevel(JdbcCompatibility.HIGH);
     }
 
@@ -100,7 +107,7 @@ public class TestRemoteEndpointResultsWithAuth extends AbstractRemoteEndpointRes
     @After
     public void cleanupTest() {
         Update clearRequest = new UpdateDrop(Target.ALL) ;
-        UpdateProcessor proc = UpdateExecutionFactory.createRemote(clearRequest, ServerTest.serviceUpdate, authenticator) ;
+        UpdateProcessor proc = UpdateExecutionFactory.createRemote(clearRequest, ServerTest.serviceUpdate, client) ;
         proc.execute() ;
     }
 
@@ -126,7 +133,7 @@ public class TestRemoteEndpointResultsWithAuth extends AbstractRemoteEndpointRes
 
     @Override
     protected ResultSet createResults(Dataset ds, String query, int resultSetType) throws SQLException {
-        TestUtils.copyToRemoteDataset(ds, ServerTest.serviceREST, authenticator);
+        TestUtils.copyToRemoteDataset(ds, ServerTest.serviceREST, client);
         Statement stmt = connection.createStatement(resultSetType, ResultSet.CONCUR_READ_ONLY);
         return stmt.executeQuery(query);
     }

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithGraphUris.java
----------------------------------------------------------------------
diff --git a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithGraphUris.java b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithGraphUris.java
index 67c399d..dfeb69d 100644
--- a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithGraphUris.java
+++ b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithGraphUris.java
@@ -21,15 +21,16 @@ package org.apache.jena.jdbc.remote.results;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
-import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.jena.ext.com.google.common.collect.Lists;
 import org.apache.jena.fuseki.ServerTest;
 import org.apache.jena.jdbc.JdbcCompatibility;
 import org.apache.jena.jdbc.connections.JenaConnection;
 import org.apache.jena.jdbc.remote.connections.RemoteEndpointConnection;
 import org.apache.jena.jdbc.utils.TestUtils;
 import org.apache.jena.query.Dataset ;
+import org.apache.jena.riot.web.HttpOp;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -54,9 +55,8 @@ public class TestRemoteEndpointResultsWithGraphUris extends AbstractRemoteEndpoi
     @BeforeClass
     public static void setup() throws SQLException {
         ServerTest.allocServer();
-        
-        List<String> defaultGraphUris = new ArrayList<String>();
-        defaultGraphUris.add(DEFAULT_GRAPH_URI);
+        HttpOp.setDefaultHttpClient(null);
+        List<String> defaultGraphUris = Lists.newArrayList(DEFAULT_GRAPH_URI);
         connection = new RemoteEndpointConnection(ServerTest.serviceQuery, ServerTest.serviceUpdate, defaultGraphUris, null, defaultGraphUris, null, null, JenaConnection.DEFAULT_HOLDABILITY, JdbcCompatibility.DEFAULT, null, null);
         connection.setJdbcCompatibilityLevel(JdbcCompatibility.HIGH);
     }
@@ -91,6 +91,4 @@ public class TestRemoteEndpointResultsWithGraphUris extends AbstractRemoteEndpoi
         Statement stmt = connection.createStatement(resultSetType, ResultSet.CONCUR_READ_ONLY);
         return stmt.executeQuery(query);
     }
-    
-
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/39b708f2/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithResultSetTypes.java
----------------------------------------------------------------------
diff --git a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithResultSetTypes.java b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithResultSetTypes.java
index 7367f2a..3b88663 100644
--- a/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithResultSetTypes.java
+++ b/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithResultSetTypes.java
@@ -29,6 +29,7 @@ import org.apache.jena.jdbc.remote.connections.RemoteEndpointConnection;
 import org.apache.jena.jdbc.utils.TestUtils;
 import org.apache.jena.query.Dataset ;
 import org.apache.jena.riot.WebContent;
+import org.apache.jena.riot.web.HttpOp;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -48,7 +49,7 @@ public class TestRemoteEndpointResultsWithResultSetTypes extends AbstractRemoteE
     @BeforeClass
     public static void setup() throws SQLException {
         ServerTest.allocServer();
-
+        HttpOp.setDefaultHttpClient(null);
         connection = new RemoteEndpointConnection(ServerTest.serviceQuery, ServerTest.serviceUpdate, null, null, null, null, null, JenaConnection.DEFAULT_HOLDABILITY, JdbcCompatibility.DEFAULT, WebContent.contentTypeTextTSV, WebContent.contentTypeRdfJson);
         connection.setJdbcCompatibilityLevel(JdbcCompatibility.HIGH);
     }