Class AbstractPipelineHttpSOAPClient

  • All Implemented Interfaces:
    net.shibboleth.utilities.java.support.component.Component, net.shibboleth.utilities.java.support.component.DestructableComponent, net.shibboleth.utilities.java.support.component.InitializableComponent, SOAPClient
    Direct Known Subclasses:
    PipelineFactoryHttpSOAPClient

    @ThreadSafe
    public abstract class AbstractPipelineHttpSOAPClient
    extends net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
    implements SOAPClient
    SOAP client that is based on HttpClientMessagePipeline.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private HttpClient httpClient
      HTTP client used to send requests and receive responses.
      private org.opensaml.security.httpclient.HttpClientSecurityParameters httpClientSecurityParameters
      HTTP client security parameters.
      private Logger log
      Class logger.
      private Function<org.opensaml.messaging.context.InOutOperationContext,​net.shibboleth.utilities.java.support.resolver.CriteriaSet> tlsCriteriaSetStrategy
      Strategy for building the criteria set which is input to the TLS trust engine.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected HttpClientContext buildHttpContext​(HttpUriRequest request, org.opensaml.messaging.context.InOutOperationContext operationContext)
      Build the HttpClientContext instance to be used by the HttpClient.
      protected HttpUriRequest buildHttpRequest​(String endpoint, org.opensaml.messaging.context.InOutOperationContext operationContext)
      Build the HttpUriRequest instance to be executed by the HttpClient.
      protected net.shibboleth.utilities.java.support.resolver.CriteriaSet buildTLSCriteriaSet​(HttpUriRequest request, org.opensaml.messaging.context.InOutOperationContext operationContext)
      Build the dynamic CriteriaSet instance to be used for TLS trust evaluation.
      protected void doDestroy()
      protected void doInitialize()
      HttpClient getHttpClient()
      Get the client used to make outbound HTTP requests.
      org.opensaml.security.httpclient.HttpClientSecurityParameters getHttpClientSecurityParameters()
      Get the optional client security parameters.
      Function<org.opensaml.messaging.context.InOutOperationContext,​net.shibboleth.utilities.java.support.resolver.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-configured HttpClientSecurityParameters.
      protected abstract org.opensaml.messaging.pipeline.httpclient.HttpClientMessagePipeline newPipeline()
      Get a new instance of the HttpClientMessagePipeline to be processed.
      protected HttpClientContext resolveClientContext​(org.opensaml.messaging.context.InOutOperationContext operationContext)
      Resolve the effective HttpClientContext instance to use for the current request.
      protected org.opensaml.security.httpclient.HttpClientSecurityParameters resolveContextSecurityParameters​(org.opensaml.messaging.context.InOutOperationContext operationContext)
      Resolve the HttpClientSecurityParameters instance present in the current operation context.
      protected org.opensaml.messaging.pipeline.httpclient.HttpClientMessagePipeline resolvePipeline​(org.opensaml.messaging.context.InOutOperationContext operationContext)
      Resolve and return a new instance of the HttpClientMessagePipeline to be processed.
      void send​(String endpoint, org.opensaml.messaging.context.InOutOperationContext operationContext)
      Sends a message and waits for a response.
      void setHttpClient​(HttpClient client)
      Set the client used to make outbound HTTP requests.
      void setHttpClientSecurityParameters​(org.opensaml.security.httpclient.HttpClientSecurityParameters params)
      Set the optional client security parameters.
      void setTLSCriteriaSetStrategy​(Function<org.opensaml.messaging.context.InOutOperationContext,​net.shibboleth.utilities.java.support.resolver.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-configured HttpClientSecurityParameters.
      • Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent

        destroy, initialize, isDestroyed, isInitialized
    • Field Detail

      • log

        @Nonnull
        private final Logger log
        Class logger.
      • httpClient

        @NonnullAfterInit
        private HttpClient httpClient
        HTTP client used to send requests and receive responses.
      • httpClientSecurityParameters

        @Nullable
        private org.opensaml.security.httpclient.HttpClientSecurityParameters httpClientSecurityParameters
        HTTP client security parameters.
      • tlsCriteriaSetStrategy

        @Nullable
        private Function<org.opensaml.messaging.context.InOutOperationContext,​net.shibboleth.utilities.java.support.resolver.CriteriaSet> tlsCriteriaSetStrategy
        Strategy for building the criteria set which is input to the TLS trust engine.
    • Constructor Detail

      • AbstractPipelineHttpSOAPClient

        public AbstractPipelineHttpSOAPClient()
        Constructor.
    • Method Detail

      • doInitialize

        protected void doInitialize()
                             throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
        Overrides:
        doInitialize in class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
        Throws:
        net.shibboleth.utilities.java.support.component.ComponentInitializationException
      • doDestroy

        protected void doDestroy()
        Overrides:
        doDestroy in class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
      • getHttpClient

        @Nonnull
        public HttpClient getHttpClient()
        Get the client used to make outbound HTTP requests.
        Returns:
        the client instance
      • setHttpClient

        public void setHttpClient​(@Nonnull
                                  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

        @Nullable
        public org.opensaml.security.httpclient.HttpClientSecurityParameters getHttpClientSecurityParameters()
        Get the optional client security parameters.
        Returns:
        the client security parameters, or null
      • setHttpClientSecurityParameters

        public void setHttpClientSecurityParameters​(@Nullable
                                                    org.opensaml.security.httpclient.HttpClientSecurityParameters params)
        Set the optional client security parameters.
        Parameters:
        params - the new client security parameters
      • getTLSCriteriaSetStrategy

        @Nullable
        public Function<org.opensaml.messaging.context.InOutOperationContext,​net.shibboleth.utilities.java.support.resolver.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-configured HttpClientSecurityParameters.
        Returns:
        the strategy function, or null
      • setTLSCriteriaSetStrategy

        public void setTLSCriteriaSetStrategy​(@Nullable
                                              Function<org.opensaml.messaging.context.InOutOperationContext,​net.shibboleth.utilities.java.support.resolver.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-configured HttpClientSecurityParameters.
        Parameters:
        function - the strategy function, or null
      • send

        public void send​(@Nonnull @NotEmpty
                         String endpoint,
                         @Nonnull
                         org.opensaml.messaging.context.InOutOperationContext operationContext)
                  throws SOAPException,
                         org.opensaml.security.SecurityException
        Sends a message and waits for a response.
        Specified by:
        send in interface SOAPClient
        Parameters:
        endpoint - the endpoint to which to send the message
        operationContext - 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 fault
        org.opensaml.security.SecurityException - thrown if the response does not meet any security policy associated with the message context
      • resolvePipeline

        @Nonnull
        protected org.opensaml.messaging.pipeline.httpclient.HttpClientMessagePipeline resolvePipeline​(@Nonnull
                                                                                                       org.opensaml.messaging.context.InOutOperationContext operationContext)
                                                                                                throws SOAPException
        Resolve and return a new instance of the HttpClientMessagePipeline 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

        @Nonnull
        protected abstract org.opensaml.messaging.pipeline.httpclient.HttpClientMessagePipeline newPipeline()
                                                                                                     throws SOAPException
        Get a new instance of the HttpClientMessagePipeline 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 HttpUriRequest buildHttpRequest​(@Nonnull @NotEmpty
                                                  String endpoint,
                                                  @Nonnull
                                                  org.opensaml.messaging.context.InOutOperationContext operationContext)
        Build the HttpUriRequest instance to be executed by the HttpClient.
        Parameters:
        endpoint - the endpoint to which the message will be sent
        operationContext - the current operation context
        Returns:
        the HTTP request to be executed
      • buildHttpContext

        @Nonnull
        protected HttpClientContext buildHttpContext​(@Nonnull
                                                     HttpUriRequest request,
                                                     @Nonnull
                                                     org.opensaml.messaging.context.InOutOperationContext operationContext)
        Build the HttpClientContext instance to be used by the HttpClient.
        Parameters:
        request - the HTTP client request
        operationContext - the current operation context
        Returns:
        the client context instance
      • resolveContextSecurityParameters

        protected org.opensaml.security.httpclient.HttpClientSecurityParameters resolveContextSecurityParameters​(@Nonnull
                                                                                                                 org.opensaml.messaging.context.InOutOperationContext operationContext)
        Resolve the HttpClientSecurityParameters 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 HttpClientContext resolveClientContext​(@Nonnull
                                                         org.opensaml.messaging.context.InOutOperationContext operationContext)
        Resolve the effective HttpClientContext 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 via HttpClientContext.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 net.shibboleth.utilities.java.support.resolver.CriteriaSet buildTLSCriteriaSet​(@Nonnull
                                                                                                 HttpUriRequest request,
                                                                                                 @Nonnull
                                                                                                 org.opensaml.messaging.context.InOutOperationContext operationContext)
        Build the dynamic CriteriaSet instance to be used for TLS trust evaluation.
        Parameters:
        request - the HTTP client request
        operationContext - the current operation context
        Returns:
        the new criteria set instance