http://git-wip-us.apache.org/repos/asf/jena/blob/2e8fc564/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 52d1562..9f93160 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
@@ -22,8 +22,6 @@ import static java.lang.String.format ;
 
 import java.io.IOException ;
 import java.io.InputStream ;
-import java.net.URI ;
-import java.net.URISyntaxException ;
 import java.nio.charset.StandardCharsets ;
 import java.util.ArrayList ;
 import java.util.List ;
@@ -33,15 +31,12 @@ import org.apache.http.* ;
 import org.apache.http.client.HttpClient ;
 import org.apache.http.client.entity.UrlEncodedFormEntity ;
 import org.apache.http.client.methods.* ;
-import org.apache.http.conn.ClientConnectionManager ;
 import org.apache.http.entity.ContentType ;
 import org.apache.http.entity.InputStreamEntity ;
 import org.apache.http.entity.StringEntity ;
-import org.apache.http.impl.client.AbstractHttpClient ;
 import org.apache.http.impl.client.HttpClientBuilder ;
-import org.apache.http.impl.client.SystemDefaultHttpClient ;
-import org.apache.http.impl.conn.PoolingClientConnectionManager ;
-import org.apache.http.impl.conn.SchemeRegistryFactory ;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.client.cache.CachingHttpClientBuilder;
 import org.apache.http.message.BasicNameValuePair ;
 import org.apache.http.protocol.BasicHttpContext ;
 import org.apache.http.protocol.HttpContext ;
@@ -49,10 +44,7 @@ import org.apache.http.util.EntityUtils ;
 import org.apache.jena.atlas.io.IO ;
 import org.apache.jena.atlas.web.HttpException ;
 import org.apache.jena.atlas.web.TypedInputStream ;
-import org.apache.jena.atlas.web.auth.HttpAuthenticator ;
-import org.apache.jena.atlas.web.auth.ServiceAuthenticator ;
 import org.apache.jena.query.ARQ ;
-import org.apache.jena.riot.RiotException ;
 import org.apache.jena.riot.WebContent ;
 import org.apache.jena.sparql.engine.http.Params ;
 import org.apache.jena.sparql.engine.http.Params.Pair ;
@@ -89,8 +81,8 @@ public class HttpOp {
      * Test are in Fuseki (need a server to test against)
      * 
      * Pattern of functions provided: 1/ The full operation (includes
-     * HttpClient, HttpContext, HttpAuthenticator) any of which can be null for
-     * "default" 2/ Provide common use options without those three arguments.
+     * HttpClient, HttpContext) either of which can be null for
+     * "default" 2/ Provide common use options without those two arguments.
      * These all become the full operation. 3/ All calls go via exec for 
logging
      * and debugging.
      */
@@ -104,21 +96,11 @@ public class HttpOp {
     static private AtomicLong counter = new AtomicLong(0);
 
     /**
-     * Default HttpClient. This is used only if there is no authentication set.
+     * Default HttpClient.
      */
     static private HttpClient defaultHttpClient = null;
 
     /**
-     * Whether the default HttpClient is used in conjunction with 
authentication
-     */
-    static private boolean useDefaultClientWithAuthentication = false;
-
-    /**
-     * Default authenticator used for HTTP authentication
-     */
-    static private HttpAuthenticator defaultAuthenticator = new 
ServiceAuthenticator();
-
-    /**
      * Constant for the default User-Agent header that ARQ will use
      */
     public static final String ARQ_USER_AGENT = "Apache-Jena-ARQ/" + 
ARQ.VERSION;
@@ -173,29 +155,6 @@ public class HttpOp {
     }
 
     /**
-     * Gets the default authenticator used for authenticate requests if no
-     * specific authenticator is provided.
-     * 
-     * @return HTTP authenticator
-     */
-    public static HttpAuthenticator getDefaultAuthenticator() {
-        return defaultAuthenticator;
-    }
-
-    /**
-     * Sets the default authenticator used for authenticate requests if no
-     * specific authenticator is provided. May be set to null to turn off
-     * default authentication, when set to null users must manually configure
-     * authentication.
-     * 
-     * @param authenticator
-     *            Authenticator
-     */
-    public static void setDefaultAuthenticator(HttpAuthenticator 
authenticator) {
-        defaultAuthenticator = authenticator;
-    }
-
-    /**
      * Return the current default {@link HttpClient}. This may be null, meaning
      * a new {@link HttpClient} is created each time, if none is provided
      * in the HttpOp function call.
@@ -214,13 +173,6 @@ public class HttpOp {
      * sensitive).
      * </p>
      * <p>
-     * The default HttpClient is not used if an HttpAuthenticator is provided
-     * since this can potentially leak authentication credentials to be leaked
-     * between requests to different services. However in some cases it may be
-     * valuable to share the client regardless in which case you can also set
-     * the
-     * </p>
-     * <p>
      * Set to "null" to create a new HttpClient for each call (default
      * behaviour, more reliable, but slower when many HTTP operation are
      * attempted).
@@ -233,42 +185,11 @@ public class HttpOp {
     public static void setDefaultHttpClient(HttpClient httpClient) {
         defaultHttpClient = httpClient;
     }
-
-    /**
-     * Gets whether the configured default HttpClient will be used in
-     * conjunction with authentication.
-     * <p>
-     * This defaults to false because this can potentially leak authentication
-     * credentials between requests to different services. However in some 
cases
-     * it may be valuable to share the client regardless e.g. when you have a
-     * specially configured HttpClient for your environment.
-     * </p>
-     * 
-     * @return True if the configured default client will be used with
-     *         authentication, false otherwise
-     */
-    public static boolean getUseDefaultClientWithAuthentication() {
-        return useDefaultClientWithAuthentication;
-    }
-
+    
     /**
-     * Sets whether the configured default HttpClient will be used in
-     * conjunction with authentication.
-     * <p>
-     * This defaults to false because this can potentially leak authentication
-     * credentials between requests to different services. However in some 
cases
-     * it may be valuable to share the client regardless e.g. when you have a
-     * specially configured HttpClient for your environment.
-     * </p>
-     * 
-     * @param useWithAuth
-     *            True if the configured default client should be used with
-     *            authentication, false if it should not
+     * Create an HttpClient that performs connection pooling. This can be used
+     * with {@link #setDefaultHttpClient} or provided in the HttpOp calls.
      */
-    public static void setUseDefaultClientWithAuthentication(boolean 
useWithAuth) {
-        useDefaultClientWithAuthentication = useWithAuth;
-    }
-
     public static HttpClient createPoolingHttpClient() {
         String s = System.getProperty("http.maxConnections", "5");
         int max = Integer.parseInt(s);
@@ -278,34 +199,13 @@ public class HttpOp {
             .build() ;
     }
     
-//    /** @deprecated Use {@link #createPoolingHttpClient()} */
-//    @Deprecated
-//    public static HttpClient createCachingHttpClient() {
-//        return createPoolingHttpClient() ; 
-//    }
-    
-    /**
-     * Create an HttpClient that performs connection pooling. This can be used
-     * with {@link #setDefaultHttpClient} or provided in the HttpOp calls.
-     */
-    @SuppressWarnings("deprecation")
     public static HttpClient createCachingHttpClient() {
-        return new SystemDefaultHttpClient() {
-            /**
-             * See SystemDefaultHttpClient (4.2). This version always sets the
-             * connection cache
-             */
-            @Override
-            protected ClientConnectionManager createClientConnectionManager() {
-                PoolingClientConnectionManager connmgr = 
-                    new 
PoolingClientConnectionManager(SchemeRegistryFactory.createSystemDefault());
-                String s = System.getProperty("http.maxConnections", "5");
-                int max = Integer.parseInt(s);
-                connmgr.setDefaultMaxPerRoute(max);
-                connmgr.setMaxTotal(2 * max);
-                return connmgr;
-            }
-        };
+        String s = System.getProperty("http.maxConnections", "5");
+        int max = Integer.parseInt(s);
+        return CachingHttpClientBuilder.create()
+            .setMaxConnPerRoute(max)
+            .setMaxConnTotal(2*max)
+            .build() ;
     }
 
     /**
@@ -342,26 +242,7 @@ public class HttpOp {
      *            Response Handler
      */
     public static void execHttpGet(String url, String acceptHeader, 
HttpResponseHandler handler) {
-        execHttpGet(url, acceptHeader, handler, null, null, null);
-    }
-
-    /**
-     * Executes a HTTP Get request handling the response with the given 
handler.
-     * <p>
-     * HTTP responses 400 and 500 become exceptions.
-     * </p>
-     * 
-     * @param url
-     *            URL
-     * @param acceptHeader
-     *            Accept Header
-     * @param handler
-     *            Response Handler
-     * @param authenticator
-     *            HTTP Authenticator
-     */
-    public static void execHttpGet(String url, String acceptHeader, 
HttpResponseHandler handler, HttpAuthenticator authenticator) {
-        execHttpGet(url, acceptHeader, handler, null, null, authenticator);
+        execHttpGet(url, acceptHeader, handler, null, null);
     }
 
     /**
@@ -385,14 +266,12 @@ public class HttpOp {
      *            HTTP Client
      * @param httpContext
      *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
      */
     public static void execHttpGet(String url, String acceptHeader, 
HttpResponseHandler handler, HttpClient httpClient,
-            HttpContext httpContext, HttpAuthenticator authenticator) {
+            HttpContext httpContext) {
         String requestURI = determineRequestURI(url);
         HttpGet httpget = new HttpGet(requestURI);
-        exec(url, httpget, acceptHeader, handler, httpClient, httpContext, 
authenticator);
+        exec(url, httpget, acceptHeader, handler, httpClient, httpContext);
     }
 
     /**
@@ -408,7 +287,7 @@ public class HttpOp {
      */
     public static TypedInputStream execHttpGet(String url) {
         HttpCaptureResponse<TypedInputStream> handler = new CaptureInput();
-        execHttpGet(url, null, handler, null, null, null);
+        execHttpGet(url, null, handler, null, null);
         return handler.get();
     }
 
@@ -427,7 +306,7 @@ public class HttpOp {
      */
     public static TypedInputStream execHttpGet(String url, String 
acceptHeader) {
         HttpCaptureResponse<TypedInputStream> handler = new CaptureInput();
-        execHttpGet(url, acceptHeader, handler, null, null, null);
+        execHttpGet(url, acceptHeader, handler, null, null);
         return handler.get();
     }
 
@@ -446,15 +325,12 @@ public class HttpOp {
      *            HTTP Client
      * @param httpContext
      *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
      * @return TypedInputStream or null if the URL returns 404.
      */
-    public static TypedInputStream execHttpGet(String url, String 
acceptHeader, HttpClient httpClient, HttpContext httpContext,
-            HttpAuthenticator authenticator) {
+    public static TypedInputStream execHttpGet(String url, String 
acceptHeader, HttpClient httpClient, HttpContext httpContext) {
         HttpCaptureResponse<TypedInputStream> handler = new CaptureInput();
         try {
-            execHttpGet(url, acceptHeader, handler, httpClient, httpContext, 
authenticator);
+            execHttpGet(url, acceptHeader, handler, httpClient, httpContext);
         } catch (HttpException ex) {
             if (ex.getResponseCode() == HttpSC.NOT_FOUND_404)
                 return null;
@@ -510,7 +386,7 @@ public class HttpOp {
      *            Content to POST
      */
     public static void execHttpPost(String url, String contentType, String 
content) {
-        execHttpPost(url, contentType, content, null, nullHandler, null, null, 
defaultAuthenticator);
+        execHttpPost(url, contentType, content, null, nullHandler, null, null);
     }
 
     /**
@@ -526,7 +402,7 @@ public class HttpOp {
      *            Accept Type
      */
     public static TypedInputStream execHttpPostStream(String url, String 
contentType, String content, String acceptType) {
-        return execHttpPostStream(url, contentType, content, acceptType, null, 
null, null) ;
+        return execHttpPostStream(url, contentType, content, acceptType, null, 
null) ;
     }
 
     /**
@@ -543,19 +419,17 @@ public class HttpOp {
      *            HTTP Client
      * @param httpContext
      *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
      */
     public static void execHttpPost(String url, String contentType, String 
content, HttpClient httpClient,
-                                    HttpContext httpContext, HttpAuthenticator 
authenticator) {
-        execHttpPost(url, contentType, content, null, nullHandler, httpClient, 
httpContext, authenticator);
+                                    HttpContext httpContext) {
+        execHttpPost(url, contentType, content, null, nullHandler, httpClient, 
httpContext);
     }
 
     public static TypedInputStream execHttpPostStream(String url, String 
contentType, String content, String acceptType,
-                                                      HttpClient httpClient, 
HttpContext httpContext, HttpAuthenticator authenticator) {
+                                                      HttpClient httpClient, 
HttpContext httpContext) {
         CaptureInput handler = new CaptureInput();
         try {
-            execHttpPost(url, contentType, content, acceptType, handler, 
httpClient, httpContext, authenticator);
+            execHttpPost(url, contentType, content, acceptType, handler, 
httpClient, httpContext);
         } catch (HttpException ex) {
             if (ex.getResponseCode() == HttpSC.NOT_FOUND_404)
                 return null;
@@ -583,16 +457,14 @@ public class HttpOp {
      *            HTTP Client
      * @param httpContext
      *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
      */
     public static void execHttpPost(String url, String contentType, String 
content, String acceptType,
-            HttpResponseHandler handler, HttpClient httpClient, HttpContext 
httpContext, HttpAuthenticator authenticator) {
+            HttpResponseHandler handler, HttpClient httpClient, HttpContext 
httpContext) {
         StringEntity e = null;
         try {
             e = new StringEntity(content, StandardCharsets.UTF_8);
             e.setContentType(contentType);
-            execHttpPost(url, e, acceptType, handler, httpClient, httpContext, 
authenticator);
+            execHttpPost(url, e, acceptType, handler, httpClient, httpContext);
         }
         finally {
             closeEntity(e);
@@ -627,7 +499,7 @@ public class HttpOp {
      * 
      */
     public static void execHttpPost(String url, String contentType, 
InputStream input, long length) {
-        execHttpPost(url, contentType, input, length, null, nullHandler, null, 
null, defaultAuthenticator);
+        execHttpPost(url, contentType, input, length, null, nullHandler, null, 
null);
     }
 
     /**
@@ -652,7 +524,7 @@ public class HttpOp {
      */
     public static void execHttpPost(String url, String contentType, 
InputStream input, long length, String acceptType,
             HttpResponseHandler handler) {
-        execHttpPost(url, contentType, input, length, acceptType, handler, 
null, null, null);
+        execHttpPost(url, contentType, input, length, acceptType, handler, 
null, null);
     }
 
     /**
@@ -678,16 +550,15 @@ public class HttpOp {
      *            HTTP Client
      * @param httpContext
      *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
+     *
      */
     public static void execHttpPost(String url, String contentType, 
InputStream input, long length, String acceptType,
-            HttpResponseHandler handler, HttpClient httpClient, HttpContext 
httpContext, HttpAuthenticator authenticator) {
+            HttpResponseHandler handler, HttpClient httpClient, HttpContext 
httpContext) {
         InputStreamEntity e = new InputStreamEntity(input, length);
         e.setContentType(contentType);
         e.setContentEncoding("UTF-8");
         try {
-            execHttpPost(url, e, acceptType, handler, httpClient, httpContext, 
authenticator);
+            execHttpPost(url, e, acceptType, handler, httpClient, httpContext);
         } finally {
             closeEntity(e);
         }
@@ -732,7 +603,7 @@ public class HttpOp {
      *            Response Handler
      */
     public static void execHttpPost(String url, HttpEntity entity, String 
acceptString, HttpResponseHandler handler) {
-        execHttpPost(url, entity, acceptString, handler, null, null, null);
+        execHttpPost(url, entity, acceptString, handler, null, null);
     }
 
     /**
@@ -751,13 +622,10 @@ public class HttpOp {
      *            HTTP Client
      * @param httpContext
      *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
      */
-    public static void execHttpPost(String url, HttpEntity entity, HttpClient 
httpClient, HttpContext httpContext,
-            HttpAuthenticator authenticator) {
+    public static void execHttpPost(String url, HttpEntity entity, HttpClient 
httpClient, HttpContext httpContext) {
 
-        execHttpPost(url, entity, null, nullHandler, httpClient, httpContext, 
authenticator);
+        execHttpPost(url, entity, null, nullHandler, httpClient, httpContext);
     }
 
     /**
@@ -778,13 +646,11 @@ public class HttpOp {
      *            HTTP Client
      * @param httpContext
      *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
      */
     public static TypedInputStream execHttpPostStream(String url, HttpEntity 
entity, String acceptHeader,
-                                    HttpClient httpClient, HttpContext 
httpContext, HttpAuthenticator authenticator) {
+                                    HttpClient httpClient, HttpContext 
httpContext) {
         CaptureInput handler = new CaptureInput();
-        execHttpPost(url, entity, acceptHeader, handler, httpClient, 
httpContext, authenticator) ;
+        execHttpPost(url, entity, acceptHeader, handler, httpClient, 
httpContext) ;
         return handler.get() ;
     }
 
@@ -808,16 +674,14 @@ public class HttpOp {
      *            HTTP Client
      * @param httpContext
      *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
      */
     public static void execHttpPost(String url, HttpEntity entity, String 
acceptHeader, HttpResponseHandler handler,
-            HttpClient httpClient, HttpContext httpContext, HttpAuthenticator 
authenticator) {
+            HttpClient httpClient, HttpContext httpContext) {
         String requestURI = determineRequestURI(url);
         HttpPost httppost = new HttpPost(requestURI);
         if (entity != null)
             httppost.setEntity(entity);
-        exec(url, httppost, acceptHeader, handler, httpClient, httpContext, 
authenticator);
+        exec(url, httppost, acceptHeader, handler, httpClient, httpContext);
     }
     
     
@@ -847,7 +711,7 @@ public class HttpOp {
      * @param acceptHeader
      */
     public static TypedInputStream execHttpPostFormStream(String url, Params 
params, String acceptHeader) {
-        return execHttpPostFormStream(url, params, acceptHeader, null, null, 
null);
+        return execHttpPostFormStream(url, params, acceptHeader, null, null);
     }
 
     
@@ -902,14 +766,12 @@ public class HttpOp {
      *            HTTP Client
      * @param httpContext
      *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
      */
     public static TypedInputStream execHttpPostFormStream(String url, Params 
params, String acceptHeader, HttpClient httpClient,
-            HttpContext httpContext, HttpAuthenticator authenticator) {
+            HttpContext httpContext) {
         CaptureInput handler = new CaptureInput();
         try {
-            execHttpPostForm(url, params, acceptHeader, handler, httpClient, 
httpContext, authenticator);
+            execHttpPostForm(url, params, acceptHeader, handler, httpClient, 
httpContext);
         } catch (HttpException ex) {
             if (ex.getResponseCode() == HttpSC.NOT_FOUND_404)
                 return null;
@@ -931,7 +793,7 @@ public class HttpOp {
      *            Response handler called to process the response
      */
     public static void execHttpPostForm(String url, Params params, String 
acceptString, HttpResponseHandler handler) {
-        execHttpPostForm(url, params, acceptString, handler, null, null, null);
+        execHttpPostForm(url, params, acceptString, handler, null, null);
     }
 
     /**
@@ -949,17 +811,15 @@ public class HttpOp {
      *            HTTP Client
      * @param httpContext
      *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
      */
     public static void execHttpPostForm(String url, Params params, String 
acceptHeader, HttpResponseHandler handler,
-            HttpClient httpClient, HttpContext httpContext, HttpAuthenticator 
authenticator) {
+            HttpClient httpClient, HttpContext httpContext) {
         if (handler == null)
             throw new IllegalArgumentException("A HttpResponseHandler must be 
provided (e.g. HttpResponseLib.nullhandler)");
         String requestURI = url;
         HttpPost httppost = new HttpPost(requestURI);
         httppost.setEntity(convertFormParams(params));
-        exec(url, httppost, acceptHeader, handler, httpClient, httpContext, 
authenticator);
+        exec(url, httppost, acceptHeader, handler, httpClient, httpContext);
     }
 
     /**
@@ -973,7 +833,7 @@ public class HttpOp {
      *            Content for the PUT
      */
     public static void execHttpPut(String url, String contentType, String 
content) {
-        execHttpPut(url, contentType, content, null, null, 
defaultAuthenticator);
+        execHttpPut(url, contentType, content, null, null);
     }
 
     /**
@@ -989,16 +849,14 @@ public class HttpOp {
      *            HTTP Client
      * @param httpContext
      *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
      */
     public static void execHttpPut(String url, String contentType, String 
content, HttpClient httpClient,
-            HttpContext httpContext, HttpAuthenticator authenticator) {
+            HttpContext httpContext) {
         StringEntity e = null;
         try {
             e = new StringEntity(content, StandardCharsets.UTF_8);
             e.setContentType(contentType);
-            execHttpPut(url, e, httpClient, httpContext, authenticator);
+            execHttpPut(url, e, httpClient, httpContext);
         }
         finally {
             closeEntity(e);
@@ -1018,7 +876,7 @@ public class HttpOp {
      *            Amount of content to PUT
      */
     public static void execHttpPut(String url, String contentType, InputStream 
input, long length) {
-        execHttpPut(url, contentType, input, length, null, null, null);
+        execHttpPut(url, contentType, input, length, null, null);
     }
 
     /**
@@ -1036,16 +894,14 @@ public class HttpOp {
      *            HTTP Client
      * @param httpContext
      *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
      */
     public static void execHttpPut(String url, String contentType, InputStream 
input, long length, HttpClient httpClient,
-            HttpContext httpContext, HttpAuthenticator authenticator) {
+            HttpContext httpContext) {
         InputStreamEntity e = new InputStreamEntity(input, length);
         e.setContentType(contentType);
         e.setContentEncoding("UTF-8");
         try {
-            execHttpPut(url, e, httpClient, httpContext, authenticator);
+            execHttpPut(url, e, httpClient, httpContext);
         } finally {
             closeEntity(e);
         }
@@ -1060,7 +916,7 @@ public class HttpOp {
      *            HTTP Entity to PUT
      */
     public static void execHttpPut(String url, HttpEntity entity) {
-        execHttpPut(url, entity, null, null, null);
+        execHttpPut(url, entity, null, null);
     }
 
     /**
@@ -1074,15 +930,12 @@ public class HttpOp {
      *            HTTP Client
      * @param httpContext
      *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
      */
-    public static void execHttpPut(String url, HttpEntity entity, HttpClient 
httpClient, HttpContext httpContext,
-            HttpAuthenticator authenticator) {
+    public static void execHttpPut(String url, HttpEntity entity, HttpClient 
httpClient, HttpContext httpContext) {
         String requestURI = determineRequestURI(url);
         HttpPut httpput = new HttpPut(requestURI);
         httpput.setEntity(entity);
-        exec(url, httpput, null, nullHandler, httpClient, httpContext, 
authenticator);
+        exec(url, httpput, null, nullHandler, httpClient, httpContext);
     }
 
     /**
@@ -1106,7 +959,7 @@ public class HttpOp {
      *            Response Handler
      */
     public static void execHttpHead(String url, String acceptString, 
HttpResponseHandler handler) {
-        execHttpHead(url, acceptString, handler, null, null, null);
+        execHttpHead(url, acceptString, handler, null, null);
     }
 
     /**
@@ -1122,15 +975,13 @@ public class HttpOp {
      *            HTTP Client
      * @param httpContext
      *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
      */
 
     public static void execHttpHead(String url, String acceptString, 
HttpResponseHandler handler, HttpClient httpClient,
-            HttpContext httpContext, HttpAuthenticator authenticator) {
+            HttpContext httpContext) {
         String requestURI = determineRequestURI(url);
         HttpHead httpHead = new HttpHead(requestURI);
-        exec(url, httpHead, acceptString, handler, httpClient, httpContext, 
authenticator);
+        exec(url, httpHead, acceptString, handler, httpClient, httpContext);
     }
 
     /**
@@ -1152,7 +1003,7 @@ public class HttpOp {
      *            Response Handler
      */
     public static void execHttpDelete(String url, HttpResponseHandler handler) 
{
-        execHttpDelete(url, handler, null, null, null);
+        execHttpDelete(url, handler, null, null);
     }
 
     /**
@@ -1166,34 +1017,22 @@ public class HttpOp {
      *            HTTP Client
      * @param httpContext
      *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
      */
-    public static void execHttpDelete(String url, HttpResponseHandler handler, 
HttpClient httpClient, HttpContext httpContext,
-            HttpAuthenticator authenticator) {
+    public static void execHttpDelete(String url, HttpResponseHandler handler, 
HttpClient httpClient, HttpContext httpContext) {
         HttpUriRequest httpDelete = new HttpDelete(url);
-        exec(url, httpDelete, null, handler, null, httpContext, authenticator);
+        exec(url, httpDelete, null, handler, null, httpContext);
     }
 
     // ---- Perform the operation!
-
-    private static void exec(String url, HttpUriRequest request, String 
acceptHeader, HttpResponseHandler handler,
-                             HttpClient httpClient, HttpContext httpContext, 
HttpAuthenticator authenticator) {
-        // Prepare authentication, if any.
-        httpClient = ensureClient(httpClient, authenticator);
-        httpContext = ensureContext(httpContext);
-        applyAuthentication(asAbstractClient(httpClient), url, httpContext, 
authenticator);
-        exec(url, request, acceptHeader, handler, httpClient, httpContext); 
-    }
-    
     private static void exec(String url, HttpUriRequest request, String 
acceptHeader, HttpResponseHandler handler, HttpClient httpClient, HttpContext 
httpContext) {
+        httpClient = ensureClient(httpClient);
+        httpContext = ensureContext(httpContext);
         try {
             if (handler == null)
                 // This cleans up.
                 handler = nullHandler;
 
             long id = counter.incrementAndGet();
-            String requestURI = determineRequestURI(url);
             String baseURI = determineBaseIRI(url);
             if (log.isDebugEnabled())
                 log.debug(format("[%d] %s %s", id, request.getMethod(), 
request.getURI().toString()));
@@ -1235,38 +1074,20 @@ public class HttpOp {
      * <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. This is used only when no
-     * authentication is required unless the user has indicated they want to 
use
-     * the default client with authentication regardless.
+     * {@link HttpClient} if available.
      * </p>
      * <p>
-     * In all other cases it creates a fresh instance of a
-     * {@link SystemDefaultHttpClient} each time.
+     * In all other cases it creates a fresh instance of a client each time.
      * </p>
      * 
      * @param client
      *            HTTP Client
      * @return HTTP Client
      */
-    private static HttpClient ensureClient(HttpClient client, 
HttpAuthenticator auth) {
-        // Use user provided client if available
-        if (client != null)
-            return client;
-
-        // Use configured default client if no authentication involved or
-        // configured to use it with authentication
-        if (defaultHttpClient != null && (auth == null || 
useDefaultClientWithAuthentication))
-            return defaultHttpClient;
-
-        // Otherwise use a fresh client each time
-        return new SystemDefaultHttpClient();
-    }
-
-    private static AbstractHttpClient asAbstractClient(HttpClient client) {
-        if (AbstractHttpClient.class.isAssignableFrom(client.getClass())) {
-            return (AbstractHttpClient) client;
-        }
-        return null;
+    public static HttpClient ensureClient(HttpClient client) {
+        return client != null ? client
+                : getDefaultHttpClient() != null ? getDefaultHttpClient()
+                        : HttpClients.createSystem();
     }
 
     /**
@@ -1293,48 +1114,6 @@ public class HttpOp {
         }
     }
 
-    /**
-     * Applies authentication to the given client as appropriate
-     * <p>
-     * If a null authenticator is provided this method tries to use the
-     * registered default authenticator which may be set via the
-     * {@link HttpOp#setDefaultAuthenticator(HttpAuthenticator)} method.
-     * </p>
-     * 
-     * @param client
-     *            HTTP Client
-     * @param target
-     *            Target URI
-     * @param context
-     *            HTTP Context
-     * @param authenticator
-     *            HTTP Authenticator
-     */
-    public static void applyAuthentication(AbstractHttpClient client, String 
target, HttpContext context,
-            HttpAuthenticator authenticator) {
-        // Cannot apply to null client
-        if (client == null)
-            return;
-
-        // Fallback to default authenticator if null authenticator provided
-        if (authenticator == null)
-            authenticator = defaultAuthenticator;
-
-        // Authenticator could still be null even if we fell back to default
-        if (authenticator == null)
-            return;
-
-        try {
-            // Apply the authenticator
-            URI uri = new URI(target);
-            authenticator.apply(client, context, uri);
-        } catch (URISyntaxException e) {
-            throw new RiotException("Invalid request URI", e);
-        } catch (NullPointerException e) {
-            throw new RiotException("Null request URI", e);
-        }
-    }
-
     private static HttpEntity convertFormParams(Params params) {
         List<NameValuePair> nvps = new ArrayList<>();
         for (Pair p : params.pairs())

http://git-wip-us.apache.org/repos/asf/jena/blob/2e8fc564/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 153417d..179d730 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
@@ -21,26 +21,20 @@ package org.apache.jena.sparql.engine.http;
 import java.io.InputStream ;
 import java.net.MalformedURLException ;
 import java.net.URL ;
-import java.util.concurrent.TimeUnit ;
+import java.util.Map;
 import java.util.regex.Pattern ;
 
 import org.apache.http.client.HttpClient ;
-import org.apache.http.conn.params.ConnManagerPNames ;
-import org.apache.http.impl.client.AbstractHttpClient ;
-import org.apache.http.impl.client.DecompressingHttpClient ;
-import org.apache.http.impl.client.SystemDefaultHttpClient ;
-import org.apache.http.params.CoreConnectionPNames ;
-import org.apache.http.protocol.BasicHttpContext ;
-import org.apache.http.protocol.HttpContext ;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.protocol.HttpClientContext;
 import org.apache.jena.atlas.web.HttpException ;
 import org.apache.jena.atlas.web.TypedInputStream ;
-import org.apache.jena.atlas.web.auth.HttpAuthenticator ;
-import org.apache.jena.atlas.web.auth.SimpleAuthenticator ;
 import org.apache.jena.query.ARQ ;
 import org.apache.jena.query.QueryExecException ;
 import org.apache.jena.riot.WebContent ;
 import org.apache.jena.riot.web.HttpOp ;
 import org.apache.jena.shared.JenaException ;
+import org.apache.jena.sparql.util.Context;
 import org.slf4j.Logger ;
 import org.slf4j.LoggerFactory ;
 
@@ -51,7 +45,7 @@ import org.slf4j.LoggerFactory ;
  * 
  * If the query string is large, then HTTP POST is used.
  */
-@SuppressWarnings("deprecation")
+
 public class HttpQuery extends Params {
     static final Logger log = 
LoggerFactory.getLogger(HttpQuery.class.getName());
 
@@ -65,7 +59,6 @@ public class HttpQuery extends Params {
     // An object indicate no value associated with parameter name
     final static Object noValue = new Object();
 
-    private HttpAuthenticator authenticator = null;
     private int responseCode = 0;
     private String responseMessage = null;
     private boolean forcePOST = false;
@@ -78,6 +71,8 @@ public class HttpQuery extends Params {
     private HttpClient client;
     private boolean requireClientShutdown = true;
 
+    private HttpClientContext context = new HttpClientContext();
+
     /**
      * Create a execution object for a whole model GET
      * 
@@ -183,25 +178,11 @@ public class HttpQuery extends Params {
     }
 
     /**
-     * Sets basic authentication. It may be preferable to use the
-     * {@link #setAuthenticator(HttpAuthenticator)} method since that provides
-     * more flexibility in the type of authentication supported.
-     * 
-     * @param user
-     *            User name
-     * @param password
-     *            Password
+     * Sets the client to use
+     * @param client Client
      */
-    public void setBasicAuthentication(String user, char[] password) {
-        this.setAuthenticator(new SimpleAuthenticator(user, password));
-    }
-
-    /**
-     * Sets the authenticator to use
-     * @param authenticator Authenticator
-     */
-    public void setAuthenticator(HttpAuthenticator authenticator) {
-        this.authenticator = authenticator;
+    public void setClient(HttpClient client) {
+        this.client = client;
     }
     
     /**
@@ -209,7 +190,16 @@ public class HttpQuery extends Params {
      * @return HTTP Client or null
      */
     public HttpClient getClient() {
-        return this.client;
+        Context arqContext = ARQ.getContext();
+        if (arqContext.isDefined(Service.serviceContext)) {
+            @SuppressWarnings("unchecked")
+            Map<String, Context> context = (Map<String, Context>) 
arqContext.get(Service.serviceContext);
+            if (context.containsKey(serviceURL)) {
+                Context serviceContext = context.get(serviceURL);
+                if (serviceContext.isDefined(Service.queryClient)) return 
serviceContext.get(Service.queryClient);
+            }
+        }
+        return client;
     }
     
     /**
@@ -286,6 +276,10 @@ public class HttpQuery extends Params {
      * @throws QueryExceptionHTTP
      */
     public InputStream exec() throws QueryExceptionHTTP {
+        // Select the appropriate HttpClient to use
+        client = HttpOp.ensureClient(getClient());
+        contextualizeCompressionSettings();
+        contextualizeTimeoutSettings();
         try {
             if (usesPOST())
                 return execPost();
@@ -298,6 +292,19 @@ public class HttpQuery extends Params {
             throw jEx;
         }
     }
+    
+    private void contextualizeCompressionSettings() {
+        final RequestConfig.Builder builder = 
RequestConfig.copy(context.getRequestConfig());
+        builder.setContentCompressionEnabled(allowGZip || allowDeflate);
+        context.setRequestConfig(builder.build());
+    }
+    
+    private void contextualizeTimeoutSettings() {
+        final RequestConfig.Builder builder = 
RequestConfig.copy(context.getRequestConfig());
+        if (connectTimeout > 0) builder.setConnectTimeout(connectTimeout);
+
+        context.setRequestConfig(builder.build());
+    }
 
     private InputStream execGet() throws QueryExceptionHTTP {
         URL target = null;
@@ -314,34 +321,10 @@ public class HttpQuery extends Params {
             throw new QueryExceptionHTTP(0, "Malformed URL: " + malEx);
         }
         log.trace("GET " + target.toExternalForm());
-
         try {
             try {
-                // Select the appropriate HttpClient to use
-                this.selectClient();
-                
-                // Always apply a 10 second timeout to obtaining a connection 
lease from HTTP Client
-                // This prevents a potential lock up
-                
this.client.getParams().setLongParameter(ConnManagerPNames.TIMEOUT, 
TimeUnit.SECONDS.toMillis(10));
-                
-                // If user has specified time outs apply them now
-                if (this.connectTimeout > 0)
-                    
this.client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
 this.connectTimeout);
-                if (this.readTimeout > 0)
-                    
this.client.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 
this.readTimeout);
-                
-                // Enable compression support appropriately
-                HttpContext context = new BasicHttpContext();
-                if (allowGZip || allowDeflate) {
-                    // Apply auth early as the decompressing client we're about
-                    // to add will block this being applied later
-                    HttpOp.applyAuthentication((AbstractHttpClient) client, 
serviceURL, context, authenticator);
-                    client = new DecompressingHttpClient(client);
-                }
-                
                 // Get the actual response stream
-                TypedInputStream stream = 
HttpOp.execHttpGet(target.toString(), contentTypeResult, client, context,
-                        this.authenticator);
+                TypedInputStream stream = 
HttpOp.execHttpGet(target.toString(), contentTypeResult, client, context);
                 if (stream == null)
                     throw new QueryExceptionHTTP(404);
                 return execCommon(stream);
@@ -368,30 +351,8 @@ public class HttpQuery extends Params {
         ARQ.getHttpRequestLogger().trace(target.toExternalForm());
 
         try {
-            // Select the appropriate HttpClient to use
-            this.selectClient();
-                    
-            // Always apply a 10 second timeout to obtaining a connection 
lease from HTTP Client
-            // This prevents a potential lock up
-            
this.client.getParams().setLongParameter(ConnManagerPNames.TIMEOUT, 
TimeUnit.SECONDS.toMillis(10));
-            
-            // If user has specified time outs apply them now
-            if (this.connectTimeout > 0)
-                
this.client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
 this.connectTimeout);
-            if (this.readTimeout > 0)
-                
this.client.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 
this.readTimeout);
-            
-            // Enable compression support appropriately
-            HttpContext context = new BasicHttpContext();
-            if (allowGZip || allowDeflate) {
-                // Apply auth early as the decompressing client we're about
-                // to add will block this being applied later
-                HttpOp.applyAuthentication((AbstractHttpClient) client, 
serviceURL, context, authenticator);
-                this.client = new DecompressingHttpClient(client);
-            }
-
             // Get the actual response stream
-            TypedInputStream stream = 
HttpOp.execHttpPostFormStream(serviceURL, this, contentTypeResult, client, 
context, authenticator);
+            TypedInputStream stream = 
HttpOp.execHttpPostFormStream(serviceURL, this, contentTypeResult, client, 
context);
             if (stream == null)
                 throw new QueryExceptionHTTP(404);
             return execCommon(stream);
@@ -420,19 +381,6 @@ public class HttpQuery extends Params {
                return new QueryExceptionHTTP("Unexpected error making the 
query", httpEx);
         }
     }
-    
-    private void selectClient() {
-        // May use configured default client where appropriate
-        this.client = HttpOp.getDefaultHttpClient();
-        if (this.client == null || (this.authenticator != null && 
!HttpOp.getUseDefaultClientWithAuthentication())) {
-            // If no configured default or authentication is in-use and the 
user has not configured
-            // to use authentication with the default client use a fresh 
SystemDefaultHttpClient instance
-            this.client = new SystemDefaultHttpClient();
-        } else {
-            // When using the configured default client we don't want to shut 
it down at the end of a request
-            this.requireClientShutdown = false;
-        }
-    }
 
     private InputStream execCommon(TypedInputStream stream) throws 
QueryExceptionHTTP {
         // Assume response code must be 200 if we got here

http://git-wip-us.apache.org/repos/asf/jena/blob/2e8fc564/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 b196f83..2d8284d 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
@@ -30,8 +30,6 @@ import org.apache.http.client.HttpClient ;
 import org.apache.jena.atlas.RuntimeIOException;
 import org.apache.jena.atlas.io.IO ;
 import org.apache.jena.atlas.lib.Pair ;
-import org.apache.jena.atlas.web.auth.HttpAuthenticator ;
-import org.apache.jena.atlas.web.auth.SimpleAuthenticator ;
 import org.apache.jena.graph.Triple ;
 import org.apache.jena.query.* ;
 import org.apache.jena.rdf.model.Model ;
@@ -39,7 +37,6 @@ import org.apache.jena.riot.Lang ;
 import org.apache.jena.riot.RDFDataMgr ;
 import org.apache.jena.riot.RDFLanguages ;
 import org.apache.jena.riot.WebContent ;
-import org.apache.jena.riot.web.HttpOp ;
 import org.apache.jena.sparql.ARQException ;
 import org.apache.jena.sparql.core.Quad;
 import org.apache.jena.sparql.engine.ResultSetCheckCondition ;
@@ -72,7 +69,7 @@ public class QueryEngineHTTP implements QueryExecution {
     // Protocol
     private List<String> defaultGraphURIs = new ArrayList<>();
     private List<String> namedGraphURIs = new ArrayList<>();
-    private HttpAuthenticator authenticator;
+    private HttpClient client;
 
     private boolean closed = false;
 
@@ -117,23 +114,23 @@ public class QueryEngineHTTP implements QueryExecution {
         this(serviceURI, query, query.toString());
     }
     
-    public QueryEngineHTTP(String serviceURI, Query query, HttpAuthenticator 
authenticator) {
-        this(serviceURI, query, query.toString(), authenticator);
+    public QueryEngineHTTP(String serviceURI, Query query, HttpClient client) {
+        this(serviceURI, query, query.toString(), client);
     }
 
     public QueryEngineHTTP(String serviceURI, String queryString) {
         this(serviceURI, null, queryString);
     }
     
-    public QueryEngineHTTP(String serviceURI, String queryString, 
HttpAuthenticator authenticator) {
-        this(serviceURI, null, queryString, authenticator);
+    public QueryEngineHTTP(String serviceURI, String queryString, HttpClient 
client) {
+        this(serviceURI, null, queryString, client);
     }
     
     private QueryEngineHTTP(String serviceURI, Query query, String 
queryString) {
         this(serviceURI, query, queryString, null);
     }
 
-    private QueryEngineHTTP(String serviceURI, Query query, String 
queryString, HttpAuthenticator authenticator) {
+    private QueryEngineHTTP(String serviceURI, Query query, String 
queryString, HttpClient client) {
         this.query = query;
         this.queryString = queryString;
         this.service = serviceURI;
@@ -141,13 +138,12 @@ public class QueryEngineHTTP implements QueryExecution {
         this.context = new Context(ARQ.getContext());
 
         // Apply service configuration if relevant
-        QueryEngineHTTP.applyServiceConfig(serviceURI, this);
+        applyServiceConfig(serviceURI, this);
         
-        // Don't want to overwrite credentials we may have picked up from
+        // Don't want to overwrite client config we may have picked up from
         // service context in the parent constructor if the specified
-        // authenticator is null
-        if (authenticator != null)
-            this.setAuthenticator(authenticator);
+        // client is null
+        if (client != null) setClient(client);
     }
 
     /**
@@ -182,16 +178,13 @@ public class QueryEngineHTTP implements QueryExecution {
             
engine.setAllowDeflate(serviceContext.isTrueOrUndef(Service.queryDeflate));
             applyServiceTimeouts(engine, serviceContext);
 
-            // Apply authentication settings
-            String user = serviceContext.getAsString(Service.queryAuthUser);
-            String pwd = serviceContext.getAsString(Service.queryAuthPwd);
+            // Apply context-supplied client settings
+            HttpClient client = serviceContext.get(Service.queryClient);
 
-            if (user != null || pwd != null) {
-                user = user == null ? "" : user;
-                pwd = pwd == null ? "" : pwd;
+            if (client != null) {
                 if (log.isDebugEnabled())
-                    log.debug("Setting basic HTTP authentication for endpoint 
URI {} with username: {} ", serviceURI, user);
-                engine.setBasicAuthentication(user, pwd.toCharArray());
+                    log.debug("Using context-supplied HTTP client for endpoint 
URI {}", serviceURI);
+                engine.setClient(client);
             }
         }
     }
@@ -303,44 +296,24 @@ public class QueryEngineHTTP implements QueryExecution {
     }
 
     /**
-     * Gets whether an authentication mechanism has been provided.
-     * <p>
-     * Even if this returns false authentication may still be used if the
-     * default authenticator applies, this is controlled via the
-     * {@link HttpOp#setDefaultAuthenticator(HttpAuthenticator)} method
-     * </p>
+     * Sets the HTTP client to use, if none is set then the default
+     * client is used.
      * 
-     * @return True if an authenticator has been provided
+     * @param client
+     *            HTTP client
      */
-    public boolean isUsingBasicAuthentication() {
-        return this.authenticator != null;
+    public void setClient(HttpClient client) {
+        this.client = client;
     }
-
-    /**
-     * Set user and password for basic authentication. After the request is 
made
-     * (one of the exec calls), the application can overwrite the password 
array
-     * to remove details of the secret.
-     * <p>
-     * Note that it may be more flexible to
-     * </p>
-     * 
-     * @param user
-     * @param password
-     */
-    public void setBasicAuthentication(String user, char[] password) {
-        this.authenticator = new SimpleAuthenticator(user, password);
-    }
-
+    
     /**
-     * Sets the HTTP authenticator to use, if none is set then the default
-     * authenticator is used. This may be configured via the
-     * {@link HttpOp#setDefaultAuthenticator(HttpAuthenticator)} method.
+     * Get the HTTP client in use, if none is set then null.
      * 
-     * @param authenticator
-     *            HTTP authenticator
+     * @param client
+     *            HTTP client
      */
-    public void setAuthenticator(HttpAuthenticator authenticator) {
-        this.authenticator = authenticator;
+    public HttpClient getClient() {
+        return client;
     }
 
     /** The Content-Type response header received (null before the remote 
operation is attempted). */
@@ -646,7 +619,7 @@ public class QueryEngineHTTP implements QueryExecution {
         if (allowDeflate)
             httpQuery.setAllowDeflate(true);
 
-        httpQuery.setAuthenticator(this.authenticator);
+        httpQuery.setClient(client);
 
         // Apply timeouts
         if (connectTimeout > 0) {

http://git-wip-us.apache.org/repos/asf/jena/blob/2e8fc564/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/Service.java
----------------------------------------------------------------------
diff --git 
a/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/Service.java 
b/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/Service.java
index 162aa0d..081a822 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/Service.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/Service.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.http.client.HttpClient;
 import org.apache.jena.atlas.io.IO;
 import org.apache.jena.query.Query ;
 import org.apache.jena.query.QueryExecException ;
@@ -59,14 +60,9 @@ public class Service {
     public static final Symbol queryGzip = SystemARQ.allocSymbol(base, 
"queryGzip");
 
     /**
-     * Use to set the user id for basic auth.
+     * Use to set the HTTP client for a service.
      */
-    public static final Symbol queryAuthUser = SystemARQ.allocSymbol(base, 
"queryAuthUser");
-
-    /**
-     * Use to set the user password for basic auth.
-     */
-    public static final Symbol queryAuthPwd = SystemARQ.allocSymbol(base, 
"queryAuthPwd");
+    public static final Symbol queryClient = SystemARQ.allocSymbol(base, 
"queryClient");
 
     /**
      * Use this Symbol to allow passing additional service context variables
@@ -234,14 +230,8 @@ public class Service {
         httpQuery.setAllowGZip(context.isTrueOrUndef(queryGzip));
         httpQuery.setAllowDeflate(context.isTrueOrUndef(queryDeflate));
 
-        String user = context.getAsString(queryAuthUser);
-        String pwd = context.getAsString(queryAuthPwd);
-
-        if (user != null || pwd != null) {
-            user = user == null ? "" : user;
-            pwd = pwd == null ? "" : pwd;
-            httpQuery.setBasicAuthentication(user, pwd.toCharArray());
-        }
+        HttpClient client = context.get(queryClient);
+        if (client != null) httpQuery.setClient(client);    
 
         setAnyTimeouts(httpQuery, context);
 

http://git-wip-us.apache.org/repos/asf/jena/blob/2e8fc564/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessRemote.java
----------------------------------------------------------------------
diff --git 
a/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessRemote.java 
b/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessRemote.java
index e05f245..506de60 100644
--- 
a/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessRemote.java
+++ 
b/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessRemote.java
@@ -18,7 +18,7 @@
 
 package org.apache.jena.sparql.modify;
 
-import org.apache.jena.atlas.web.auth.HttpAuthenticator;
+import org.apache.http.client.HttpClient;
 import org.apache.jena.riot.WebContent ;
 import org.apache.jena.riot.web.HttpOp ;
 import org.apache.jena.sparql.ARQException ;
@@ -46,16 +46,15 @@ public class UpdateProcessRemote extends 
UpdateProcessRemoteBase
      * @param request Update request
      * @param endpoint Update endpoint
      * @param context Context
-     * @param authenticator HTTP Authenticator
+     * @param client HTTP client
      */
-    public UpdateProcessRemote(UpdateRequest request, String endpoint, Context 
context, HttpAuthenticator authenticator)
+    public UpdateProcessRemote(UpdateRequest request, String endpoint, Context 
context, HttpClient client)
     {
         this(request, endpoint, context);
-        // Don't want to overwrite credentials we may have picked up from
+        // Don't want to overwrite config we may have picked up from
         // service context in the parent constructor if the specified
-        // authenticator is null
-        if (authenticator != null)
-            this.setAuthenticator(authenticator);
+        // client is null
+        if (client != null) this.setClient(client);
     }
 
     @Override
@@ -76,7 +75,7 @@ public class UpdateProcessRemote extends 
UpdateProcessRemoteBase
         
         // Execution
         String reqStr = this.getUpdateRequest().toString() ;
-        HttpOp.execHttpPost(endpoint, WebContent.contentTypeSPARQLUpdate, 
reqStr, null, getHttpContext(), getAuthenticator()) ;
+        HttpOp.execHttpPost(endpoint, WebContent.contentTypeSPARQLUpdate, 
reqStr, getClient(), getHttpContext()) ;
     }
 }
 

http://git-wip-us.apache.org/repos/asf/jena/blob/2e8fc564/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessRemoteBase.java
----------------------------------------------------------------------
diff --git 
a/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessRemoteBase.java
 
b/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessRemoteBase.java
index a581179..8e18cd1 100644
--- 
a/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessRemoteBase.java
+++ 
b/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessRemoteBase.java
@@ -22,9 +22,8 @@ import java.util.ArrayList ;
 import java.util.List ;
 import java.util.Map ;
 
+import org.apache.http.client.HttpClient;
 import org.apache.http.protocol.HttpContext ;
-import org.apache.jena.atlas.web.auth.HttpAuthenticator ;
-import org.apache.jena.atlas.web.auth.SimpleAuthenticator ;
 import org.apache.jena.riot.web.HttpOp ;
 import org.apache.jena.sparql.core.DatasetGraph ;
 import org.apache.jena.sparql.engine.http.HttpParams ;
@@ -55,7 +54,7 @@ public abstract class UpdateProcessRemoteBase implements 
UpdateProcessor {
     private final UpdateRequest request;
     private final String endpoint;
     private final Context context;
-    private HttpAuthenticator authenticator;
+    private HttpClient client;
     private Params params;
 
     protected List<String> defaultGraphURIs = new ArrayList<>();
@@ -106,17 +105,13 @@ public abstract class UpdateProcessRemoteBase implements 
UpdateProcessor {
             if (log.isDebugEnabled())
                 log.debug("Endpoint URI {} has SERVICE Context: {} ", 
serviceURI, serviceContext);
 
-            // Apply authentication settings
-            String user = serviceContext.getAsString(Service.queryAuthUser);
-            String pwd = serviceContext.getAsString(Service.queryAuthPwd);
+            // Apply client settings
+            HttpClient client = serviceContext.get(Service.queryClient);
 
-            if (user != null || pwd != null) {
-                user = user == null ? "" : user;
-                pwd = pwd == null ? "" : pwd;
+            if (client != null) {
                 if (log.isDebugEnabled())
-                    log.debug("Setting basic HTTP authentication for endpoint 
URI {} with username: {} ", serviceURI, user);
-
-                engine.setAuthentication(user, pwd.toCharArray());
+                    log.debug("Using context-supplied client for endpoint URI 
{}", serviceURI);
+                engine.setClient(client);
             }
         }
     }
@@ -263,56 +258,31 @@ public abstract class UpdateProcessRemoteBase implements 
UpdateProcessor {
     }
 
     /**
-     * Sets authentication credentials for remote updates
+     * Sets the client to use
      * <p>
-     * May be better to use {@link #setAuthenticator(HttpAuthenticator)} as 
that
-     * allows for more complex authentication to be used
+     * Note that you can globally set an client via
+     * {@link HttpOp#setDefaultHttpClient(HttpClient)} to avoid the
+     * need to set client on a per-request basis
      * </p>
      * 
-     * @param username
-     *            User name
-     * @param password
-     *            Password
+     * @param client
+     *            HTTP client
      */
-    public void setAuthentication(String username, char[] password) {
-        this.setAuthenticator(new SimpleAuthenticator(username, password));
+    public void setClient(HttpClient client) {
+        this.client = client;
     }
 
     /**
-     * Sets the authenticator to use
+     * Gets the client that has been set (if any)
      * <p>
-     * Note that you can globally set an authenticator via
-     * {@link HttpOp#setDefaultAuthenticator(HttpAuthenticator)} to avoid the
-     * need to set authentication on a per-request basis
-     * </p>
-     * 
-     * @param authenticator
-     *            HTTP Authenticator
-     */
-    public void setAuthenticator(HttpAuthenticator authenticator) {
-        this.authenticator = authenticator;
-    }
-
-    /**
-     * Gets the authenticator that has been set (if any)
-     * <p>
-     * If no authenticator is used then the default authenticator will be used,
+     * If no client is used then the default client will be used,
      * this can be configured via the
-     * {@link HttpOp#setDefaultAuthenticator(HttpAuthenticator)} method.
+     * {@link HttpOp#setDefaultHttpClient(HttpClient)} method.
      * </p>
      * 
-     * @return HTTP Authenticator if set, null otherwise
-     */
-    public HttpAuthenticator getAuthenticator() {
-        return this.authenticator;
-    }
-
-    /**
-     * Gets whether any authenticator has been set
-     * 
-     * @return True if an authenticator has been set, false otherwise
+     * @return HTTP client if set, null otherwise
      */
-    public boolean isUsingAuthentication() {
-        return this.authenticator != null;
+    public HttpClient getClient() {
+        return this.client;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jena/blob/2e8fc564/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessRemoteForm.java
----------------------------------------------------------------------
diff --git 
a/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessRemoteForm.java
 
b/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessRemoteForm.java
index 77fd27f..b827d14 100644
--- 
a/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessRemoteForm.java
+++ 
b/jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessRemoteForm.java
@@ -18,8 +18,9 @@
 
 package org.apache.jena.sparql.modify;
 
-import org.apache.jena.atlas.web.auth.HttpAuthenticator;
-import org.apache.jena.riot.web.HttpOp;
+import static org.apache.jena.riot.web.HttpOp.execHttpPostForm;
+
+import org.apache.http.client.HttpClient;
 import org.apache.jena.riot.web.HttpResponseLib;
 import org.apache.jena.sparql.ARQException ;
 import org.apache.jena.sparql.engine.http.HttpParams ;
@@ -62,13 +63,12 @@ public class UpdateProcessRemoteForm extends 
UpdateProcessRemoteBase {
      * @param authenticator
      *            HTTP Authenticator
      */
-    public UpdateProcessRemoteForm(UpdateRequest request, String endpoint, 
Context context, HttpAuthenticator authenticator) {
+    public UpdateProcessRemoteForm(UpdateRequest request, String endpoint, 
Context context, HttpClient client) {
         this(request, endpoint, context);
-        // Don't want to overwrite credentials we may have picked up from
+        // Don't want to overwrite config we may have picked up from
         // service context in the parent constructor if the specified
-        // authenticator is null
-        if (authenticator != null)
-            this.setAuthenticator(authenticator);
+        // client is null
+        if (client != null) this.setClient(client);
     }
 
     @Override
@@ -83,7 +83,6 @@ public class UpdateProcessRemoteForm extends 
UpdateProcessRemoteBase {
         String reqStr = this.getUpdateRequest().toString();
         Params ps = new Params(this.getParams());
         ps.addParam(HttpParams.pUpdate, reqStr);
-        HttpOp.execHttpPostForm(this.getEndpoint(), ps, null, 
HttpResponseLib.nullResponse, null, getHttpContext(),
-                getAuthenticator());
+        execHttpPostForm(this.getEndpoint(), ps, null, 
HttpResponseLib.nullResponse, getClient(), getHttpContext());
     }
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/2e8fc564/jena-arq/src/main/java/org/apache/jena/sparql/util/Context.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/util/Context.java 
b/jena-arq/src/main/java/org/apache/jena/sparql/util/Context.java
index 6cb0e30..cfaae9c 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/util/Context.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/util/Context.java
@@ -65,10 +65,11 @@ public class Context {
     }
 
     // -- basic operations
-
+    
     /** Get the object value of a property or null */
-    public Object get(Symbol property) {
-        return context.get(property) ;
+    @SuppressWarnings("unchecked")
+    public <T> T get(Symbol property) {
+        return (T) context.get(property) ;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/jena/blob/2e8fc564/jena-arq/src/main/java/org/apache/jena/update/UpdateExecutionFactory.java
----------------------------------------------------------------------
diff --git 
a/jena-arq/src/main/java/org/apache/jena/update/UpdateExecutionFactory.java 
b/jena-arq/src/main/java/org/apache/jena/update/UpdateExecutionFactory.java
index 38da497..a30ac4b 100644
--- a/jena-arq/src/main/java/org/apache/jena/update/UpdateExecutionFactory.java
+++ b/jena-arq/src/main/java/org/apache/jena/update/UpdateExecutionFactory.java
@@ -18,7 +18,7 @@
 
 package org.apache.jena.update;
 
-import org.apache.jena.atlas.web.auth.HttpAuthenticator ;
+import org.apache.http.client.HttpClient;
 import org.apache.jena.query.ARQ ;
 import org.apache.jena.query.Dataset ;
 import org.apache.jena.query.QuerySolution ;
@@ -290,12 +290,12 @@ public class UpdateExecutionFactory
     /** Create an UpdateProcessor that sends the update to a remote SPARQL 
Update service.
      * @param update Updates
      * @param remoteEndpoint Endpoint URL
-     * @param authenticator HTTP Authenticator
+     * @param client HTTP client
      * @return Remote Update processor
      */
-    public static UpdateProcessor createRemote(Update update, String 
remoteEndpoint, HttpAuthenticator authenticator)
+    public static UpdateProcessor createRemote(Update update, String 
remoteEndpoint, HttpClient client)
     {
-        return createRemote(new UpdateRequest(update), remoteEndpoint, null, 
authenticator) ;
+        return createRemote(new UpdateRequest(update), remoteEndpoint, null, 
client) ;
     }
     
     /** Create an UpdateProcessor that sends the update to a remote SPARQL 
Update service.
@@ -313,12 +313,12 @@ public class UpdateExecutionFactory
      * @param update Updates
      * @param remoteEndpoint Endpoint URL
      * @param context Context
-     * @param authenticator HTTP Authenticator
+     * @param client HTTP client
      * @return Remote Update processor
      */
-    public static UpdateProcessor createRemote(Update update, String 
remoteEndpoint, Context context, HttpAuthenticator authenticator)
+    public static UpdateProcessor createRemote(Update update, String 
remoteEndpoint, Context context, HttpClient client)
     {
-        return createRemote(new UpdateRequest(update), remoteEndpoint, 
context, authenticator) ;
+        return createRemote(new UpdateRequest(update), remoteEndpoint, 
context, client) ;
     }
         
     /** Create an UpdateProcessor that sends the update request to a remote 
SPARQL Update service.
@@ -334,12 +334,12 @@ public class UpdateExecutionFactory
     /** Create an UpdateProcessor that sends the update request to a remote 
SPARQL Update service.
      * @param updateRequest Updates
      * @param remoteEndpoint Endpoint URL
-     * @param authenticator HTTP Authenticator
+     * @param client HTTP client
      * @return Remote Update processor
      */
-    public static UpdateProcessor createRemote(UpdateRequest updateRequest, 
String remoteEndpoint, HttpAuthenticator authenticator)
+    public static UpdateProcessor createRemote(UpdateRequest updateRequest, 
String remoteEndpoint, HttpClient client)
     {
-        return createRemote(updateRequest, remoteEndpoint, null, 
authenticator) ;
+        return createRemote(updateRequest, remoteEndpoint, null, client) ;
     }
 
     /** Create an UpdateProcessor that sends the update request to a remote 
SPARQL Update service.
@@ -357,12 +357,12 @@ public class UpdateExecutionFactory
      * @param updateRequest Updates
      * @param remoteEndpoint Endpoint URL
      * @param context Context
-     * @param authenticator HTTP Authenticator
+     * @param client HTTP client
      * @return Remote Update processor
      */
-    public static UpdateProcessor createRemote(UpdateRequest updateRequest, 
String remoteEndpoint, Context context, HttpAuthenticator authenticator)
+    public static UpdateProcessor createRemote(UpdateRequest updateRequest, 
String remoteEndpoint, Context context, HttpClient client)
     {
-        return new UpdateProcessRemote(updateRequest, remoteEndpoint, context, 
authenticator) ;
+        return new UpdateProcessRemote(updateRequest, remoteEndpoint, context, 
client) ;
     }
     
     /** Create an UpdateProcessor that sends the update request to a remote 
SPARQL Update service using an HTML form
@@ -378,12 +378,12 @@ public class UpdateExecutionFactory
     /** Create an UpdateProcessor that sends the update request to a remote 
SPARQL Update service using an HTML form
      * @param update Updates
      * @param remoteEndpoint Endpoint URL
-     * @param authenticator HTTP Authenticator
+     * @param client HTTP client
      * @return Remote Update processor
      */
-    public static UpdateProcessor createRemoteForm(Update update, String 
remoteEndpoint, HttpAuthenticator authenticator)
+    public static UpdateProcessor createRemoteForm(Update update, String 
remoteEndpoint, HttpClient client)
     {
-        return createRemoteForm(update, remoteEndpoint, null, null) ;
+        return createRemoteForm(update, remoteEndpoint, null, client) ;
     }
     
     /** Create an UpdateProcessor that sends the update request to a remote 
SPARQL Update service using an HTML form
@@ -394,19 +394,19 @@ public class UpdateExecutionFactory
      */
     public static UpdateProcessor createRemoteForm(Update update, String 
remoteEndpoint, Context context)
     {
-        return createRemoteForm(new UpdateRequest(update), remoteEndpoint, 
null, null) ;
+        return createRemoteForm(new UpdateRequest(update), remoteEndpoint, 
context, null) ;
     }
     
     /** Create an UpdateProcessor that sends the update request to a remote 
SPARQL Update service using an HTML form
      * @param update Updates
      * @param remoteEndpoint Endpoint URL
      * @param context Context
-     * @param authenticator HTTP Authenticator
+     * @param client HTTP client
      * @return Remote Update processor
      */
-    public static UpdateProcessor createRemoteForm(Update update, String 
remoteEndpoint, Context context, HttpAuthenticator authenticator)
+    public static UpdateProcessor createRemoteForm(Update update, String 
remoteEndpoint, Context context, HttpClient client)
     {
-        return createRemoteForm(new UpdateRequest(update), remoteEndpoint, 
null, authenticator) ;
+        return createRemoteForm(new UpdateRequest(update), remoteEndpoint, 
null, client) ;
     }
     
     /** Create an UpdateProcessor that sends the update request to a remote 
SPARQL Update service using an HTML form
@@ -422,12 +422,12 @@ public class UpdateExecutionFactory
     /** Create an UpdateProcessor that sends the update request to a remote 
SPARQL Update service using an HTML form
      * @param updateRequest Updates
      * @param remoteEndpoint Endpoint URL
-     * @param authenticator HTTP Authenticator
+     * @param client HTTP client
      * @return Remote Update processor
      */
-    public static UpdateProcessor createRemoteForm(UpdateRequest 
updateRequest, String remoteEndpoint, HttpAuthenticator authenticator)
+    public static UpdateProcessor createRemoteForm(UpdateRequest 
updateRequest, String remoteEndpoint, HttpClient client)
     {
-        return createRemoteForm(updateRequest, remoteEndpoint, null, 
authenticator) ;
+        return createRemoteForm(updateRequest, remoteEndpoint, null, client) ;
     }
     
     /** Create an UpdateProcessor that sends the update request to a remote 
SPARQL Update service using an HTML form
@@ -445,11 +445,11 @@ public class UpdateExecutionFactory
      * @param updateRequest Updates
      * @param remoteEndpoint Endpoint URL
      * @param context Context
-     * @param authenticator HTTP Authenticator
+     * @param client HTTP client
      * @return Remote Update processor
      */
-    public static UpdateProcessor createRemoteForm(UpdateRequest 
updateRequest, String remoteEndpoint, Context context, HttpAuthenticator 
authenticator)
+    public static UpdateProcessor createRemoteForm(UpdateRequest 
updateRequest, String remoteEndpoint, Context context, HttpClient client)
     {
-        return new UpdateProcessRemoteForm(updateRequest, remoteEndpoint, 
context, authenticator) ;
+        return new UpdateProcessRemoteForm(updateRequest, remoteEndpoint, 
context, client) ;
     }
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/2e8fc564/jena-arq/src/main/java/org/apache/jena/web/DatasetGraphAccessorHTTP.java
----------------------------------------------------------------------
diff --git 
a/jena-arq/src/main/java/org/apache/jena/web/DatasetGraphAccessorHTTP.java 
b/jena-arq/src/main/java/org/apache/jena/web/DatasetGraphAccessorHTTP.java
index 80f1232..32afa09 100644
--- a/jena-arq/src/main/java/org/apache/jena/web/DatasetGraphAccessorHTTP.java
+++ b/jena-arq/src/main/java/org/apache/jena/web/DatasetGraphAccessorHTTP.java
@@ -21,14 +21,11 @@ package org.apache.jena.web ;
 import java.io.OutputStream ;
 
 import org.apache.http.HttpEntity ;
-import org.apache.http.client.methods.HttpHead ;
-import org.apache.http.client.methods.HttpUriRequest ;
+import org.apache.http.client.HttpClient;
 import org.apache.http.entity.ContentProducer ;
 import org.apache.http.entity.EntityTemplate ;
 import org.apache.jena.atlas.lib.IRILib ;
 import org.apache.jena.atlas.web.HttpException ;
-import org.apache.jena.atlas.web.auth.HttpAuthenticator ;
-import org.apache.jena.atlas.web.auth.SimpleAuthenticator ;
 import org.apache.jena.graph.Graph ;
 import org.apache.jena.graph.Node ;
 import org.apache.jena.riot.RDFDataMgr ;
@@ -49,7 +46,7 @@ public class DatasetGraphAccessorHTTP implements 
DatasetGraphAccessor {
     private static final RDFFormat           defaultSendLang   = 
RDFFormat.RDFXML_PLAIN ;
 
     private final String                     remote ;
-    private HttpAuthenticator                authenticator ;
+    private HttpClient                client ;
 
     private RDFFormat                        formatPutPost     = 
defaultSendLang ;
 
@@ -78,7 +75,7 @@ public class DatasetGraphAccessorHTTP implements 
DatasetGraphAccessor {
      *            Remote URL
      */
     public DatasetGraphAccessorHTTP(String remote) {
-        this.remote = remote ;
+        this(remote, HttpOp.getDefaultHttpClient());
     }
 
     /**
@@ -86,34 +83,21 @@ public class DatasetGraphAccessorHTTP implements 
DatasetGraphAccessor {
      * 
      * @param remote
      *            Remote URL
-     * @param authenticator
-     *            HTTP Authenticator
+     * @param client
+     *            HTTP Client
      */
-    public DatasetGraphAccessorHTTP(String remote, HttpAuthenticator 
authenticator) {
-        this(remote) ;
-        this.setAuthenticator(authenticator) ;
-    }
-
-    /**
-     * Sets authentication credentials for the remote URL
-     * 
-     * @param username
-     *            User name
-     * @param password
-     *            Password
-     */
-    public void setAuthentication(String username, char[] password) {
-        this.setAuthenticator(new SimpleAuthenticator(username, password)) ;
+    public DatasetGraphAccessorHTTP(String remote, HttpClient client) {
+        this.remote = remote ;
+        this.setClient(client) ;
     }
 
     /**
-     * Sets an authenticator to use for authentication to the remote URL
+     * Sets an HTTP client for use to this dataset
      * 
-     * @param authenticator
-     *            Authenticator
+     * @param client Client
      */
-    public void setAuthenticator(HttpAuthenticator authenticator) {
-        this.authenticator = authenticator ;
+    public void setClient(HttpClient client) {
+        this.client = client ;
     }
 
     @Override
@@ -129,7 +113,7 @@ public class DatasetGraphAccessorHTTP implements 
DatasetGraphAccessor {
     protected Graph doGet(String url) {
         HttpCaptureResponse<Graph> graph = HttpResponseLib.graphHandler() ;
         try {
-            HttpOp.execHttpGet(url, graphAcceptHeader, graph, 
this.authenticator) ;
+            HttpOp.execHttpGet(url, graphAcceptHeader, graph, client, null) ;
         } catch (HttpException ex) {
             if ( ex.getResponseCode() == HttpSC.NOT_FOUND_404 )
                 return null ;
@@ -149,9 +133,8 @@ public class DatasetGraphAccessorHTTP implements 
DatasetGraphAccessor {
     }
 
     protected boolean doHead(String url) {
-        HttpUriRequest httpHead = new HttpHead(url) ;
         try {
-            HttpOp.execHttpHead(url, WebContent.defaultGraphAcceptHeader, 
noResponse, null, null, this.authenticator) ;
+            HttpOp.execHttpHead(url, WebContent.defaultGraphAcceptHeader, 
noResponse, client, null) ;
             return true ;
         } catch (HttpException ex) {
             if ( ex.getResponseCode() == HttpSC.NOT_FOUND_404 )
@@ -172,7 +155,7 @@ public class DatasetGraphAccessorHTTP implements 
DatasetGraphAccessor {
 
     protected void doPut(String url, Graph data) {
         HttpEntity entity = graphToHttpEntity(data) ;
-        HttpOp.execHttpPut(url, entity, null, null, this.authenticator) ;
+        HttpOp.execHttpPut(url, entity, client, null) ;
     }
 
     @Override
@@ -187,7 +170,7 @@ public class DatasetGraphAccessorHTTP implements 
DatasetGraphAccessor {
 
     protected void doDelete(String url) {
         try {
-            HttpOp.execHttpDelete(url, noResponse, null, null, 
this.authenticator) ;
+            HttpOp.execHttpDelete(url, noResponse, client, null) ;
         } catch (HttpException ex) {
             if ( ex.getResponseCode() == HttpSC.NOT_FOUND_404 )
                 return ;
@@ -206,7 +189,7 @@ public class DatasetGraphAccessorHTTP implements 
DatasetGraphAccessor {
 
     protected void doPost(String url, Graph data) {
         HttpEntity entity = graphToHttpEntity(data) ;
-        HttpOp.execHttpPost(url, entity, null, null, this.authenticator) ;
+        HttpOp.execHttpPost(url, entity, client, null) ;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/jena/blob/2e8fc564/jena-arq/src/test/java/org/apache/jena/sparql/engine/http/TestService.java
----------------------------------------------------------------------
diff --git 
a/jena-arq/src/test/java/org/apache/jena/sparql/engine/http/TestService.java 
b/jena-arq/src/test/java/org/apache/jena/sparql/engine/http/TestService.java
index 8bd9588..8ca1294 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/engine/http/TestService.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/engine/http/TestService.java
@@ -22,7 +22,9 @@ import java.net.SocketException ;
 import java.util.HashMap ;
 import java.util.Map ;
 
+import org.apache.http.client.HttpClient;
 import org.apache.http.conn.ConnectTimeoutException ;
+import org.apache.http.impl.client.HttpClients;
 import org.apache.jena.graph.Node ;
 import org.apache.jena.graph.NodeFactory ;
 import org.apache.jena.graph.Triple ;
@@ -154,7 +156,7 @@ public class TestService {
         Assert.assertEquals(-1, engine.getTimeout2());
         Assert.assertTrue(engine.getAllowGZip());
         Assert.assertTrue(engine.getAllowDeflate());
-        Assert.assertFalse(engine.isUsingBasicAuthentication());
+        Assert.assertNull(engine.getClient());
     }
 
     @SuppressWarnings("unchecked")
@@ -172,8 +174,8 @@ public class TestService {
         }
         Context serviceContext = serviceContextMap.get(SERVICE);
         try {
-            serviceContext.put(Service.queryAuthUser, "user");
-            serviceContext.put(Service.queryAuthPwd, "password");
+            HttpClient testClient = HttpClients.custom().build();
+            serviceContext.put(Service.queryClient, testClient);
 
             Query q = QueryFactory.create("ASK { }");
             QueryEngineHTTP engine = 
QueryExecutionFactory.createServiceRequest(SERVICE, q);
@@ -184,11 +186,10 @@ public class TestService {
             Assert.assertEquals(-1, engine.getTimeout2());
             Assert.assertTrue(engine.getAllowGZip());
             Assert.assertTrue(engine.getAllowDeflate());
-            Assert.assertTrue(engine.isUsingBasicAuthentication());
+            Assert.assertEquals(testClient, engine.getClient());
 
         } finally {
-            serviceContext.remove(Service.queryAuthUser);
-            serviceContext.remove(Service.queryAuthPwd);
+            serviceContext.remove(Service.queryClient);
         }
     }
 
@@ -217,7 +218,7 @@ public class TestService {
             Assert.assertEquals(10, engine.getTimeout2());
             Assert.assertTrue(engine.getAllowGZip());
             Assert.assertTrue(engine.getAllowDeflate());
-            Assert.assertFalse(engine.isUsingBasicAuthentication());
+            Assert.assertNull(engine.getClient());
         } finally {
             serviceContext.remove(Service.queryTimeout);
         }
@@ -248,7 +249,7 @@ public class TestService {
             Assert.assertEquals(10, engine.getTimeout2());
             Assert.assertTrue(engine.getAllowGZip());
             Assert.assertTrue(engine.getAllowDeflate());
-            Assert.assertFalse(engine.isUsingBasicAuthentication());
+            Assert.assertNull(engine.getClient());
         } finally {
             serviceContext.remove(Service.queryTimeout);
         }
@@ -280,7 +281,7 @@ public class TestService {
             Assert.assertEquals(-1, engine.getTimeout2());
             Assert.assertFalse(engine.getAllowGZip());
             Assert.assertFalse(engine.getAllowDeflate());
-            Assert.assertFalse(engine.isUsingBasicAuthentication());
+            Assert.assertNull(engine.getClient());
         } finally {
             serviceContext.remove(Service.queryGzip);
             serviceContext.remove(Service.queryDeflate);
@@ -301,7 +302,7 @@ public class TestService {
         Assert.assertNotNull(engine);
 
         // Check that no settings were changed
-        Assert.assertFalse(engine.isUsingAuthentication());
+        Assert.assertNull(engine.getClient());
     }
 
     @SuppressWarnings("unchecked")
@@ -318,19 +319,18 @@ public class TestService {
         }
         Context serviceContext = serviceContextMap.get(SERVICE);
         try {
-            serviceContext.put(Service.queryAuthUser, "user");
-            serviceContext.put(Service.queryAuthPwd, "password");
+            HttpClient testClient = HttpClients.custom().build();
+            serviceContext.put(Service.queryClient, testClient);
 
             UpdateRequest updates = UpdateFactory.create("CREATE GRAPH 
<http://example>");
             UpdateProcessRemoteBase engine = (UpdateProcessRemoteBase) 
UpdateExecutionFactory.createRemote(updates, SERVICE);
             Assert.assertNotNull(engine);
 
-            // Check that auth settings were changed
-            Assert.assertTrue(engine.isUsingAuthentication());
+            // Check that client settings were changed
+            Assert.assertEquals(testClient, engine.getClient());
 
         } finally {
-            serviceContext.remove(Service.queryAuthUser);
-            serviceContext.remove(Service.queryAuthPwd);
+            serviceContext.remove(Service.queryClient);
         }
     }
 }

Reply via email to