[java-opensaml COMMIT] /trunk/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/AbstractPipelineHttpSOAPC...
noreply at shibboleth.net
noreply at shibboleth.net
Fri May 22 18:47:52 EDT 2015
Author: putmanb
Date: Fri May 22 18:47:52 2015
New Revision: 4276
URL: http://svn.shibboleth.net/view/java-opensaml?rev=4276&view=rev
Log:
Fix NPE when don't have HttpClient security parameters.
Refactor for cyclomatic complexity.
Add corresponding getter methods for setters, and avoid direct use of class fields.
Modified:
trunk/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/AbstractPipelineHttpSOAPClient.java
Modified: trunk/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/AbstractPipelineHttpSOAPClient.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/AbstractPipelineHttpSOAPClient.java?rev=4276&r1=4275&r2=4276&view=diff
==============================================================================
--- trunk/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/AbstractPipelineHttpSOAPClient.java (original)
+++ trunk/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/AbstractPipelineHttpSOAPClient.java Fri May 22 18:47:52 2015
@@ -121,6 +121,15 @@
super.doDestroy();
}
+
+ /**
+ * Get the client used to make outbound HTTP requests.
+ *
+ * @return the client instance
+ */
+ @Nonnull public HttpClient getHttpClient() {
+ return httpClient;
+ }
/**
* Set the client used to make outbound HTTP requests.
@@ -134,6 +143,15 @@
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
httpClient = Constraint.isNotNull(client, "HttpClient cannot be null");
+ }
+
+ /**
+ * Get the optional trust engine used in evaluating server TLS credentials.
+ *
+ * @return the trust engine instance, or null
+ */
+ @Nullable public TrustEngine<? super X509Credential> getTLSTrustEngine() {
+ return tlsTrustEngine;
}
/**
@@ -156,6 +174,15 @@
}
/**
+ * Get the strategy function which builds the criteria set which is input to the TLS TrustEngine.
+ *
+ * @return the strategy function, or null
+ */
+ @Nullable public Function<InOutOperationContext<?, ?>, CriteriaSet> getTLSCriteriaSetStrategy() {
+ return tlsCriteriaSetStrategy;
+ }
+
+ /**
* Set the strategy function which builds the criteria set which is input to the TLS TrustEngine.
*
* @param function the strategy function, or null
@@ -165,6 +192,15 @@
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
tlsCriteriaSetStrategy = function;
+ }
+
+ /**
+ * Get then instance of {@link CredentialsProvider} used for authentication by the HttpClient instance.
+ *
+ * @return the credentials provider, or null
+ */
+ @Nullable public CredentialsProvider getCredentialsProvider() {
+ return credentialsProvider;
}
/**
@@ -223,10 +259,10 @@
}
BasicCredentialsProvider provider = new BasicCredentialsProvider();
provider.setCredentials(authScope, credentials);
- credentialsProvider = provider;
+ setCredentialsProvider(provider);
} else {
log.debug("Either username or password were null, disabling basic auth");
- credentialsProvider = null;
+ setCredentialsProvider(null);
}
}
@@ -262,7 +298,7 @@
encoder.encode();
// HttpClient execution
- HttpResponse httpResponse = httpClient.execute(httpRequest, httpContext);
+ HttpResponse httpResponse = getHttpClient().execute(httpRequest, httpContext);
checkTLSCredentialTrusted(httpContext, httpRequest);
// Response decoding
@@ -390,50 +426,71 @@
@Nonnull protected HttpClientContext buildHttpContext(@Nonnull final HttpUriRequest request,
@Nonnull final InOutOperationContext operationContext) {
- HttpClientContext context = resolveHttpContext(operationContext);
+ HttpClientContext httpClientContext = resolveHttpContext(operationContext);
HttpClientSecurityParameters securityParameters = operationContext.getOutboundMessageContext()
.getSubcontext(HttpClientSecurityContext.class, true).getSecurityParameters();
CredentialsProvider credProvider = ObjectSupport.firstNonNull(
- securityParameters.getCredentialsProvider(), context.getCredentialsProvider(), credentialsProvider);
+ securityParameters != null ? securityParameters.getCredentialsProvider() : null,
+ httpClientContext.getCredentialsProvider(), getCredentialsProvider());
if (credProvider != null) {
- context.setCredentialsProvider(credProvider);
- }
+ httpClientContext.setCredentialsProvider(credProvider);
+ }
+
+ populateTLSContextParameters(httpClientContext, securityParameters, request, operationContext);
+
+ return httpClientContext;
[... 89 lines stripped ...]
More information about the commits
mailing list