Class AbstractPipelineHttpSOAPClient
- All Implemented Interfaces:
Component
,DestructableComponent
,InitializableComponent
,SOAPClient
- Direct Known Subclasses:
PipelineFactoryHttpSOAPClient
@ThreadSafe public abstract class AbstractPipelineHttpSOAPClient extends AbstractInitializableComponent implements SOAPClient
HttpClientMessagePipeline
.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opensaml.soap.client.SOAPClient
SOAPClient.SOAPRequestParameters
-
Field Summary
Fields Modifier and Type Field Description private org.apache.http.client.HttpClient
httpClient
HTTP client used to send requests and receive responses.private HttpClientSecurityParameters
httpClientSecurityParameters
HTTP client security parameters.private org.slf4j.Logger
log
Class logger.private Function<InOutOperationContext,CriteriaSet>
tlsCriteriaSetStrategy
Strategy for building the criteria set which is input to the TLS trust engine. -
Constructor Summary
Constructors Constructor Description AbstractPipelineHttpSOAPClient()
Constructor. -
Method Summary
Modifier and Type Method Description protected org.apache.http.client.protocol.HttpClientContext
buildHttpContext(org.apache.http.client.methods.HttpUriRequest request, InOutOperationContext operationContext)
Build theHttpClientContext
instance to be used by the HttpClient.protected org.apache.http.client.methods.HttpUriRequest
buildHttpRequest(String endpoint, InOutOperationContext operationContext)
Build theHttpUriRequest
instance to be executed by the HttpClient.protected CriteriaSet
buildTLSCriteriaSet(org.apache.http.client.methods.HttpUriRequest request, InOutOperationContext operationContext)
Build the dynamicCriteriaSet
instance to be used for TLS trust evaluation.protected void
doDestroy()
protected void
doInitialize()
org.apache.http.client.HttpClient
getHttpClient()
Get the client used to make outbound HTTP requests.HttpClientSecurityParameters
getHttpClientSecurityParameters()
Get the optional client security parameters.Function<InOutOperationContext,CriteriaSet>
getTLSCriteriaSetStrategy()
Get the strategy function which builds the dynamically-populated criteria set which is input to the TLS TrustEngine, if no static criteria set is supplied either via context or locally-configuredHttpClientSecurityParameters
.protected abstract HttpClientMessagePipeline
newPipeline()
Get a new instance of theHttpClientMessagePipeline
to be processed.protected org.apache.http.client.protocol.HttpClientContext
resolveClientContext(InOutOperationContext operationContext)
Resolve the effectiveHttpClientContext
instance to use for the current request.protected HttpClientSecurityParameters
resolveContextSecurityParameters(InOutOperationContext operationContext)
Resolve theHttpClientSecurityParameters
instance present in the current operation context.protected HttpClientMessagePipeline
resolvePipeline(InOutOperationContext operationContext)
Resolve and return a new instance of theHttpClientMessagePipeline
to be processed.void
send(String endpoint, InOutOperationContext operationContext)
Sends a message and waits for a response.void
setHttpClient(org.apache.http.client.HttpClient client)
Set the client used to make outbound HTTP requests.void
setHttpClientSecurityParameters(HttpClientSecurityParameters params)
Set the optional client security parameters.void
setTLSCriteriaSetStrategy(Function<InOutOperationContext,CriteriaSet> function)
Set the strategy function which builds the dynamically-populated criteria set which is input to the TLS TrustEngine, if no static criteria set is supplied either via context or locally-configuredHttpClientSecurityParameters
.Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, initialize, isDestroyed, isInitialized
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
httpClient
HTTP client used to send requests and receive responses. -
httpClientSecurityParameters
HTTP client security parameters. -
tlsCriteriaSetStrategy
Strategy for building the criteria set which is input to the TLS trust engine.
-
-
Constructor Details
-
AbstractPipelineHttpSOAPClient
public AbstractPipelineHttpSOAPClient()Constructor.
-
-
Method Details
-
doInitialize
- Overrides:
doInitialize
in classAbstractInitializableComponent
- Throws:
ComponentInitializationException
-
doDestroy
protected void doDestroy()- Overrides:
doDestroy
in classAbstractInitializableComponent
-
getHttpClient
@Nonnull public org.apache.http.client.HttpClient getHttpClient()Get the client used to make outbound HTTP requests.- Returns:
- the client instance
-
setHttpClient
public void setHttpClient(@Nonnull org.apache.http.client.HttpClient client)Set the client used to make outbound HTTP requests.This client SHOULD employ a thread-safe
HttpClient
and may be shared with other objects.- Parameters:
client
- client object
-
getHttpClientSecurityParameters
Get the optional client security parameters.- Returns:
- the client security parameters, or null
-
setHttpClientSecurityParameters
Set the optional client security parameters.- Parameters:
params
- the new client security parameters
-
getTLSCriteriaSetStrategy
Get the strategy function which builds the dynamically-populated criteria set which is input to the TLS TrustEngine, if no static criteria set is supplied either via context or locally-configuredHttpClientSecurityParameters
.- Returns:
- the strategy function, or null
-
setTLSCriteriaSetStrategy
public void setTLSCriteriaSetStrategy(@Nullable Function<InOutOperationContext,CriteriaSet> function)Set the strategy function which builds the dynamically-populated criteria set which is input to the TLS TrustEngine, if no static criteria set is supplied either via context or locally-configuredHttpClientSecurityParameters
.- Parameters:
function
- the strategy function, or null
-
send
public void send(@Nonnull @NotEmpty String endpoint, @Nonnull InOutOperationContext operationContext) throws SOAPException, SecurityExceptionSends a message and waits for a response.- Specified by:
send
in interfaceSOAPClient
- Parameters:
endpoint
- the endpoint to which to send the messageoperationContext
- the operation context containing the outbound SOAP message- Throws:
SOAPException
- thrown if there is a problem sending the message or receiving the response or if the response is a SOAP faultSecurityException
- thrown if the response does not meet any security policy associated with the message context
-
resolvePipeline
@Nonnull protected HttpClientMessagePipeline resolvePipeline(@Nonnull InOutOperationContext operationContext) throws SOAPExceptionResolve and return a new instance of theHttpClientMessagePipeline
to be processed.Each call to this (factory) method MUST produce a new instance of the pipeline.
The default behavior is to simply call
newPipeline()
.- Parameters:
operationContext
- the current operation context- Returns:
- a new pipeline instance
- Throws:
SOAPException
- if there is an error obtaining a new pipeline instance
-
newPipeline
Get a new instance of theHttpClientMessagePipeline
to be processed.Each call to this (factory) method MUST produce a new instance of the pipeline.
- Returns:
- the new pipeline instance
- Throws:
SOAPException
- if there is an error obtaining a new pipeline instance
-
buildHttpRequest
@Nonnull protected org.apache.http.client.methods.HttpUriRequest buildHttpRequest(@Nonnull @NotEmpty String endpoint, @Nonnull InOutOperationContext operationContext)Build theHttpUriRequest
instance to be executed by the HttpClient.- Parameters:
endpoint
- the endpoint to which the message will be sentoperationContext
- the current operation context- Returns:
- the HTTP request to be executed
-
buildHttpContext
@Nonnull protected org.apache.http.client.protocol.HttpClientContext buildHttpContext(@Nonnull org.apache.http.client.methods.HttpUriRequest request, @Nonnull InOutOperationContext operationContext)Build theHttpClientContext
instance to be used by the HttpClient.- Parameters:
request
- the HTTP client requestoperationContext
- the current operation context- Returns:
- the client context instance
-
resolveContextSecurityParameters
protected HttpClientSecurityParameters resolveContextSecurityParameters(@Nonnull InOutOperationContext operationContext)Resolve theHttpClientSecurityParameters
instance present in the current operation context.The default implementation returns the outbound subcontext value
HttpClientSecurityContext.getSecurityParameters()
.Note that any values supplied via this instance will override those supplied locally via
setHttpClientSecurityParameters(HttpClientSecurityParameters)
.- Parameters:
operationContext
- the current operation context- Returns:
- the client security parameters resolved from the current operation context, or null
-
resolveClientContext
@Nonnull protected org.apache.http.client.protocol.HttpClientContext resolveClientContext(@Nonnull InOutOperationContext operationContext)Resolve the effectiveHttpClientContext
instance to use for the current request.The default implementation first attempts to resolve the outbound subcontext value
HttpClientRequestContext.getHttpClientContext()
. If no context value is present, a new empty context instance will be returned viaHttpClientContext.create()
.Note that any security-related attributes supplied directly the client context returned here will override the corresponding values supplied via both operation context and locally-configured instances of
HttpClientSecurityParameters
.- Parameters:
operationContext
- the current operation context- Returns:
- the effective client context instance to use
-
buildTLSCriteriaSet
@Nonnull protected CriteriaSet buildTLSCriteriaSet(@Nonnull org.apache.http.client.methods.HttpUriRequest request, @Nonnull InOutOperationContext operationContext)Build the dynamicCriteriaSet
instance to be used for TLS trust evaluation.- Parameters:
request
- the HTTP client requestoperationContext
- the current operation context- Returns:
- the new criteria set instance
-