Class HttpSOAPClient

  • 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

    @ThreadSafe
    public class HttpSOAPClient
    extends net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
    implements SOAPClient
    SOAP client that uses HTTP as the underlying transport and POST as the binding.
    • Field Detail

      • log

        @Nonnull
        private final Logger log
        Class logger.
      • httpClient

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

        @NonnullAfterInit
        private net.shibboleth.utilities.java.support.xml.ParserPool parserPool
        Pool of XML parsers used to parser incoming responses.
      • soapClientContextLookupStrategy

        @Nonnull
        private Function<org.opensaml.messaging.context.MessageContext,​SOAPClientContext> soapClientContextLookupStrategy
        Strategy used to look up the SOAPClientContext associated with the outbound message context.
      • soap11ContextLookupStrategy

        @Nonnull
        private Function<org.opensaml.messaging.context.MessageContext,​SOAP11Context> soap11ContextLookupStrategy
        Strategy used to look up the SOAP11Context associated with the outbound message context.
    • Constructor Detail

      • HttpSOAPClient

        public HttpSOAPClient()
        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
      • 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
      • setParserPool

        public void setParserPool​(@Nonnull
                                  net.shibboleth.utilities.java.support.xml.ParserPool parser)
        Set the pool of XML parsers used to parse incoming responses.
        Parameters:
        parser - parser pool
      • getSOAPClientContextLookupStrategy

        @Nonnull
        public Function<org.opensaml.messaging.context.MessageContext,​SOAPClientContext> getSOAPClientContextLookupStrategy()
        Get the strategy used to look up the SOAPClientContext associated with the outbound message context.
        Returns:
        strategy used to look up the SOAPClientContext associated with the outbound message context
      • setSOAPClientContextLookupStrategy

        public void setSOAPClientContextLookupStrategy​(@Nonnull
                                                       Function<org.opensaml.messaging.context.MessageContext,​SOAPClientContext> strategy)
        Set the strategy used to look up the SOAPClientContext associated with the outbound message context.
        Parameters:
        strategy - strategy used to look up the SOAPClientContext associated with the outbound message context
      • getSOAP11ContextLookupStrategy

        @Nonnull
        public Function<org.opensaml.messaging.context.MessageContext,​SOAP11Context> getSOAP11ContextLookupStrategy()
        Get the strategy used to look up the SOAP11Context associated with the outbound message context.
        Returns:
        strategy used to look up the SOAP11Context associated with the outbound message context
      • setSOAP11ContextLookupStrategy

        public void setSOAP11ContextLookupStrategy​(@Nonnull
                                                   Function<org.opensaml.messaging.context.MessageContext,​SOAP11Context> strategy)
        Set the strategy used to look up the SOAP11Context associated with the outbound message context.
        Parameters:
        strategy - strategy used to look up the SOAP11Context associated with the outbound message context
      • send

        public void send​(@Nonnull @NotEmpty
                         String endpoint,
                         @Nonnull
                         org.opensaml.messaging.context.InOutOperationContext context)
                  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
        context - 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
      • createPostMethod

        protected HttpPost createPostMethod​(@Nonnull @NotEmpty
                                            String endpoint,
                                            @Nullable
                                            HttpSOAPRequestParameters requestParams,
                                            @Nonnull
                                            Envelope message)
                                     throws SOAPClientException
        Create the post method used to send the SOAP request.
        Parameters:
        endpoint - endpoint to which the message is sent
        requestParams - HTTP request parameters
        message - message to be sent
        Returns:
        the post method to be used to send this message
        Throws:
        SOAPClientException - thrown if the message could not be marshalled
      • createRequestEntity

        protected org.apache.http.HttpEntity createRequestEntity​(@Nonnull
                                                                 Envelope message,
                                                                 @Nullable
                                                                 Charset charset)
                                                          throws SOAPClientException
        Create the request entity that makes up the POST message body.
        Parameters:
        message - message to be sent
        charset - character set used for the message
        Returns:
        request entity that makes up the POST message body
        Throws:
        SOAPClientException - thrown if the message could not be marshalled
      • processSuccessfulResponse

        protected void processSuccessfulResponse​(@Nonnull
                                                 org.apache.http.HttpResponse httpResponse,
                                                 @Nonnull
                                                 org.opensaml.messaging.context.InOutOperationContext context)
                                          throws SOAPClientException
        Process a successful, as determined by an HTTP 200 status code, response.
        Parameters:
        httpResponse - the HTTP response
        context - current operation context
        Throws:
        SOAPClientException - thrown if there is a problem reading the response from the HttpPost
      • processFaultResponse

        protected void processFaultResponse​(@Nonnull
                                            org.apache.http.HttpResponse httpResponse,
                                            @Nonnull
                                            org.opensaml.messaging.context.InOutOperationContext context)
                                     throws SOAPClientException,
                                            SOAPFaultException
        Process a SOAP fault, as determined by an HTTP 500 status code, response.
        Parameters:
        httpResponse - the HTTP response
        context - current operation context
        Throws:
        SOAPClientException - thrown if the response can not be read from the HttpPost
        SOAPFaultException - an exception containing the SOAP fault
      • unmarshallResponse

        protected Envelope unmarshallResponse​(@Nonnull
                                              InputStream responseStream)
                                       throws SOAPClientException
        Unmarshall the incoming response from a POST request.
        Parameters:
        responseStream - input stream bearing the response
        Returns:
        the response
        Throws:
        SOAPClientException - thrown if the incoming response can not be unmarshalled into an Envelope
      • evaluateSecurityPolicy

        protected void evaluateSecurityPolicy​(SOAPClientContext messageContext)
                                       throws SOAPClientException
        Evaluates the security policy associated with the given message context. If no policy resolver is registered or no policy is located during the resolution process then no policy is evaluated. Note that neither the inbound or outbound message transport is available.
        Parameters:
        messageContext - current message context
        Throws:
        SOAPClientException - thrown if there is a problem resolving or evaluating a security policy