[java-opensaml] branch master updated: Add support for setting AuthCache into HttpClientContext.

Scott Cantor cantor.2 at osu.edu
Thu Aug 24 18:43:54 EDT 2017


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository java-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=306b881629e39d2a82e052e023662e25b6bde921

The following commit(s) were added to refs/heads/master by this push:
       new  306b881   Add support for setting AuthCache into HttpClientContext.
306b881 is described below

commit 306b881629e39d2a82e052e023662e25b6bde921
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Aug 24 18:43:48 2017 -0400

    Add support for setting AuthCache into HttpClientContext.
---
 .../httpclient/HttpClientSecurityParameters.java   | 27 ++++++++++++++++++++++
 .../httpclient/HttpClientSecuritySupport.java      | 12 +++++++---
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/opensaml-security-api/src/main/java/org/opensaml/security/httpclient/HttpClientSecurityParameters.java b/opensaml-security-api/src/main/java/org/opensaml/security/httpclient/HttpClientSecurityParameters.java
index c31ec37..b8c43fb 100644
--- a/opensaml-security-api/src/main/java/org/opensaml/security/httpclient/HttpClientSecurityParameters.java
+++ b/opensaml-security-api/src/main/java/org/opensaml/security/httpclient/HttpClientSecurityParameters.java
@@ -28,6 +28,7 @@ import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
 
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.AuthCache;
 import org.apache.http.client.CredentialsProvider;
 import org.apache.http.conn.ssl.X509HostnameVerifier;
 import org.apache.http.impl.client.BasicCredentialsProvider;
@@ -42,6 +43,9 @@ public class HttpClientSecurityParameters {
     /** HttpClient credentials provider. */
     @Nullable private CredentialsProvider credentialsProvider;
     
+    /** HttpClient {@link AuthCache} to allow pre-emptive authentication. */
+    @Nullable private AuthCache authCache;
+    
     /** Optional trust engine used in evaluating server TLS credentials. */
     @Nullable private TrustEngine<? super X509Credential> tlsTrustEngine;
     
@@ -79,6 +83,29 @@ public class HttpClientSecurityParameters {
     }
     
     /**
+     * Get an instance of {@link AuthCache} used for authentication by the HttpClient instance.
+     * 
+     * @return the cache, or null
+     * 
+     * @since 3.4.0
+     */
+    @Nullable public AuthCache getAuthCache() {
+        return authCache;
+    }
+    
+    /**
+     * Set an instance of {@link AuthCache} used for authentication by the HttpClient instance.
+     * 
+     * @param cache the auth cache
+     * 
+     * @since 3.4.0
+     */
+    public void setAuthCache(@Nullable final AuthCache cache) {
+        authCache = cache;
+    }
+    
+    
+    /**
      * A convenience method to set a (single) username and password used for BASIC authentication.
      * To disable BASIC authentication pass null for the credentials instance.
      * 
diff --git a/opensaml-security-api/src/main/java/org/opensaml/security/httpclient/HttpClientSecuritySupport.java b/opensaml-security-api/src/main/java/org/opensaml/security/httpclient/HttpClientSecuritySupport.java
index 383f406..b366479 100644
--- a/opensaml-security-api/src/main/java/org/opensaml/security/httpclient/HttpClientSecuritySupport.java
+++ b/opensaml-security-api/src/main/java/org/opensaml/security/httpclient/HttpClientSecuritySupport.java
@@ -136,7 +136,13 @@ public final class HttpClientSecuritySupport {
             }
         }
         
-        setContextValue(context, CONTEXT_KEY_TRUST_ENGINE, 
+        if (securityParameters.getAuthCache() != null) {
+            if (replace || context.getAuthCache() == null) {
+                context.setAuthCache(securityParameters.getAuthCache());
+            }
+        }
+        
+        setContextValue(context, CONTEXT_KEY_TRUST_ENGINE,
                 securityParameters.getTLSTrustEngine(), replace);
         
         setContextValue(context, CONTEXT_KEY_CRITERIA_SET,
@@ -145,10 +151,10 @@ public final class HttpClientSecuritySupport {
         setContextValue(context, CONTEXT_KEY_TLS_PROTOCOLS,
                 securityParameters.getTLSProtocols(), replace);
         
-        setContextValue(context, CONTEXT_KEY_TLS_CIPHER_SUITES, 
+        setContextValue(context, CONTEXT_KEY_TLS_CIPHER_SUITES,
                 securityParameters.getTLSCipherSuites(), replace);
         
-        setContextValue(context, CONTEXT_KEY_HOSTNAME_VERIFIER, 
+        setContextValue(context, CONTEXT_KEY_HOSTNAME_VERIFIER,
                 securityParameters.getHostnameVerifier(), replace);
         
         setContextValue(context, CONTEXT_KEY_CLIENT_TLS_CREDENTIAL,

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list