Class HTTPConduit

  • All Implemented Interfaces:
    PropertyChangeListener, EventListener, org.apache.cxf.configuration.Configurable, org.apache.cxf.transport.Assertor, org.apache.cxf.transport.Conduit, org.apache.cxf.transport.Observable
    Direct Known Subclasses:
    URLConnectionHTTPConduit

    public abstract class HTTPConduit
    extends org.apache.cxf.transport.AbstractConduit
    implements org.apache.cxf.configuration.Configurable, org.apache.cxf.transport.Assertor, PropertyChangeListener
    This Conduit handles the "http" and "https" transport protocols. An instance is governed by policies either explicitly set or by configuration.
    • Field Detail

      • KEY_HTTP_CONNECTION

        public static final String KEY_HTTP_CONNECTION
        This constant is the Message(Map) key for the HttpURLConnection that is used to get the response.
        See Also:
        Constant Field Values
      • SERVICE_NOT_AVAILABLE_ON_HTTP_STATUS_CODES

        public static final String SERVICE_NOT_AVAILABLE_ON_HTTP_STATUS_CODES
        The HTTP status codes as contextual property (comma-separated integers as String) on the outgoing Message which lead to setting org.apache.cxf.transport.service_not_available for all responses with those status codes. This is used e.g. by the org.apache.cxf.clustering.FailoverTargetSelector to determine if it should do the fail-over. Default: 404,429,503 as per DEFAULT_SERVICE_NOT_AVAILABLE_ON_HTTP_STATUS_CODES
        See Also:
        Constant Field Values
      • LOG

        protected static final Logger LOG
        The Logger for this class.
      • KNOWN_HTTP_VERBS_WITH_NO_CONTENT

        protected static final Set<String> KNOWN_HTTP_VERBS_WITH_NO_CONTENT
      • HTTP_VERSION

        protected static final String HTTP_VERSION
      • bus

        protected final org.apache.cxf.Bus bus
        This field holds a reference to the CXF bus associated this conduit.
      • endpointInfo

        protected final org.apache.cxf.service.model.EndpointInfo endpointInfo
        This field is used for two reasons. First it provides the base name for the conduit for Spring configuration. The other is to hold default address information, should it not be supplied in the Message Map, by the Message.ENDPOINT_ADDRESS property.
      • defaultAddress

        protected volatile Address defaultAddress
        This field holds the "default" URI for this particular conduit, which is created on demand.
      • fromEndpointReferenceType

        protected boolean fromEndpointReferenceType
      • clientSidePolicy

        protected HTTPClientPolicy clientSidePolicy
        This field holds the QoS configuration settings for this conduit. This field is injected via spring configuration based on the conduit name.
      • authorizationPolicy

        protected org.apache.cxf.configuration.security.AuthorizationPolicy authorizationPolicy
        This field holds the password authorization configuration. This field is injected via spring configuration based on the conduit name.
      • proxyAuthorizationPolicy

        protected org.apache.cxf.configuration.security.ProxyAuthorizationPolicy proxyAuthorizationPolicy
        This field holds the password authorization configuration for the configured proxy. This field is injected via spring configuration based on the conduit name.
      • tlsClientParameters

        protected org.apache.cxf.configuration.jsse.TLSClientParameters tlsClientParameters
        This field holds the configuration TLS configuration which is programmatically configured.
      • trustDecider

        protected MessageTrustDecider trustDecider
        This field contains the MessageTrustDecider.
      • authSupplier

        protected volatile HttpAuthSupplier authSupplier
        Implements the authentication handling when talking to a server. If it is not set it will be created from the authorizationPolicy.authType
      • proxyAuthSupplier

        protected volatile HttpAuthSupplier proxyAuthSupplier
        Implements the proxy authentication handling. If it is not set it will be created from the proxyAuthorizationPolicy.authType
      • cookies

        protected Cookies cookies
    • Constructor Detail

      • HTTPConduit

        public HTTPConduit​(org.apache.cxf.Bus b,
                           org.apache.cxf.service.model.EndpointInfo ei)
                    throws IOException
        Constructor
        Parameters:
        b - the associated Bus
        ei - the endpoint info of the initiator
        Throws:
        IOException
      • HTTPConduit

        public HTTPConduit​(org.apache.cxf.Bus b,
                           org.apache.cxf.service.model.EndpointInfo ei,
                           org.apache.cxf.ws.addressing.EndpointReferenceType t)
                    throws IOException
        Constructor
        Parameters:
        b - the associated Bus.
        ei - the endpoint info of the initiator.
        t - the endpoint reference of the target.
        Throws:
        IOException
    • Method Detail

      • getLogger

        protected Logger getLogger()
        This method returns the registered Logger for this conduit.
        Specified by:
        getLogger in class org.apache.cxf.transport.AbstractObservable
      • getConduitName

        public final String getConduitName()
        This method returns the name of the conduit, which is based on the endpoint name plus the SC_HTTP_CONDUIT_SUFFIX.
        Returns:
      • finalizeConfig

        public void finalizeConfig()
        This call gets called by the HTTPTransportFactory after it causes an injection of the Spring configuration properties of this Conduit.
      • getCookies

        public Map<String,​Cookie> getCookies()
        Allow access to the cookies that the conduit is maintaining
        Returns:
        the sessionCookies map
      • prepare

        public void prepare​(org.apache.cxf.message.Message message)
                     throws IOException
        Prepare to send an outbound HTTP message over this http conduit to a particular endpoint.

        If the Message.PATH_INFO property is set it gets appended to the Conduit's endpoint URL. If the Message.QUERY_STRING property is set, it gets appended to the resultant URL following a "?".

        If the Message.HTTP_REQUEST_METHOD property is NOT set, the Http request method defaults to "POST".

        If the Message.PROTOCOL_HEADERS is not set on the message, it is initialized to an empty map.

        This call creates the OutputStream for the content of the message. It also assigns the created Http(s)URLConnection to the Message Map.

        Specified by:
        prepare in interface org.apache.cxf.transport.Conduit
        Parameters:
        message - The message to be sent.
        Throws:
        IOException
      • isChunkingSupported

        protected boolean isChunkingSupported​(org.apache.cxf.message.Message message,
                                              String httpMethod)
      • createOutputStream

        protected abstract OutputStream createOutputStream​(org.apache.cxf.message.Message message,
                                                           boolean needToCacheRequest,
                                                           boolean isChunking,
                                                           int chunkThreshold)
                                                    throws IOException
        Throws:
        IOException
      • determineReceiveTimeout

        protected static int determineReceiveTimeout​(org.apache.cxf.message.Message message,
                                                     HTTPClientPolicy csPolicy)
      • determineConnectionTimeout

        protected static int determineConnectionTimeout​(org.apache.cxf.message.Message message,
                                                        HTTPClientPolicy csPolicy)
      • close

        public void close​(org.apache.cxf.message.Message msg)
                   throws IOException
        Specified by:
        close in interface org.apache.cxf.transport.Conduit
        Overrides:
        close in class org.apache.cxf.transport.AbstractConduit
        Throws:
        IOException
      • close

        public void close()
        Close the conduit
        Specified by:
        close in interface org.apache.cxf.transport.Conduit
        Overrides:
        close in class org.apache.cxf.transport.AbstractConduit
      • getAddress

        public String getAddress()
        Returns:
        the default target address
      • setHeadersByAuthorizationPolicy

        protected void setHeadersByAuthorizationPolicy​(org.apache.cxf.message.Message message,
                                                       URI currentURI)
        This call places HTTP Header strings into the headers that are relevant to the Authorization policies that are set on this conduit by configuration.

        An AuthorizationPolicy may also be set on the message. If so, those policies are merged. A user name or password set on the messsage overrides settings in the AuthorizationPolicy is retrieved from the configuration.

        The precedence is as follows: 1. AuthorizationPolicy that is set on the Message, if exists. 2. Authorization from AuthSupplier, if exists. 3. AuthorizationPolicy set/configured for conduit. REVISIT: Since the AuthorizationPolicy is set on the message by class, then how does one override the ProxyAuthorizationPolicy which is the same type?

        Parameters:
        message -
        currentURI -
      • getBeanName

        public String getBeanName()
        This is part of the Configurable interface which retrieves the configuration from spring injection.
        Specified by:
        getBeanName in interface org.apache.cxf.configuration.Configurable
      • getEffectiveAuthPolicy

        public org.apache.cxf.configuration.security.AuthorizationPolicy getEffectiveAuthPolicy​(org.apache.cxf.message.Message message)
        Determines effective auth policy from message, conduit and empty default with priority from first to last
        Parameters:
        message -
        Returns:
        effective AthorizationPolicy
      • getAuthorization

        public org.apache.cxf.configuration.security.AuthorizationPolicy getAuthorization()
        This method gets the Authorization Policy that was configured or explicitly set for this HTTPConduit.
      • setAuthorization

        public void setAuthorization​(org.apache.cxf.configuration.security.AuthorizationPolicy authorization)
        This method is used to set the Authorization Policy for this conduit. Using this method will override any Authorization Policy set in configuration.
      • getClient

        public HTTPClientPolicy getClient​(org.apache.cxf.message.Message message)
      • getClient

        public HTTPClientPolicy getClient()
        This method retrieves the Client Side Policy set/configured for this HTTPConduit.
      • setClient

        public void setClient​(HTTPClientPolicy client)
        This method sets the Client Side Policy for this HTTPConduit. Using this method will override any HTTPClientPolicy set in configuration.
      • getProxyAuthorization

        public org.apache.cxf.configuration.security.ProxyAuthorizationPolicy getProxyAuthorization()
        This method retrieves the Proxy Authorization Policy for a proxy that is set/configured for this HTTPConduit.
      • setProxyAuthorization

        public void setProxyAuthorization​(org.apache.cxf.configuration.security.ProxyAuthorizationPolicy proxyAuthorization)
        This method sets the Proxy Authorization Policy for a specified proxy. Using this method overrides any Authorization Policy for the proxy that is set in the configuration.
      • getTlsClientParameters

        public org.apache.cxf.configuration.jsse.TLSClientParameters getTlsClientParameters()
        This method returns the TLS Client Parameters that is set/configured for this HTTPConduit.
      • setTlsClientParameters

        public void setTlsClientParameters​(org.apache.cxf.configuration.jsse.TLSClientParameters params)
        This method sets the TLS Client Parameters for this HTTPConduit. Using this method overrides any TLS Client Parameters that is configured for this HTTPConduit.
      • getTrustDecider

        public MessageTrustDecider getTrustDecider()
        This method gets the Trust Decider that was set/configured for this HTTPConduit.
        Returns:
        The Message Trust Decider or null.
      • setTrustDecider

        public void setTrustDecider​(MessageTrustDecider decider)
        This method sets the Trust Decider for this HTTP Conduit. Using this method overrides any trust decider configured for this HTTPConduit.
      • getAuthSupplier

        public HttpAuthSupplier getAuthSupplier()
        This method gets the Auth Supplier that was set/configured for this HTTPConduit.
        Returns:
        The Auth Supplier or null.
      • setProxyAuthSupplier

        public void setProxyAuthSupplier​(HttpAuthSupplier proxyAuthSupplier)
      • extractLocation

        protected String extractLocation​(Map<String,​List<String>> headers)
                                  throws MalformedURLException
        This method extracts the value of the "Location" Http Response header.
        Parameters:
        headers - The Http response headers.
        Returns:
        The value of the "Location" header, null if non-existent.
        Throws:
        MalformedURLException
      • logStackTrace

        protected void logStackTrace​(Throwable ex)
      • assertMessage

        public void assertMessage​(org.apache.cxf.message.Message message)
        Specified by:
        assertMessage in interface org.apache.cxf.transport.Assertor
      • canAssert

        public boolean canAssert​(QName type)
        Specified by:
        canAssert in interface org.apache.cxf.transport.Assertor