Apache CXF API

org.apache.cxf.transport.http
Class HTTPConduit

java.lang.Object
  extended by org.apache.cxf.transport.AbstractObservable
      extended by org.apache.cxf.transport.AbstractConduit
          extended by org.apache.cxf.transport.http.HTTPConduit
All Implemented Interfaces:
PropertyChangeListener, EventListener, Configurable, Assertor, Conduit, Observable
Direct Known Subclasses:
URLConnectionHTTPConduit

public abstract class HTTPConduit
extends AbstractConduit
implements Configurable, Assertor, PropertyChangeListener

This Conduit handles the "http" and "https" transport protocols. An instance is governed by policies either explicitly set or by configuration.


Nested Class Summary
protected  class HTTPConduit.InterposedMessageObserver
          Used to set appropriate message properties, exchange etc.
protected  class HTTPConduit.WrappedOutputStream
          Wrapper output stream responsible for flushing headers and handling the incoming HTTP-level response (not necessarily the MEP response).
 
Field Summary
protected  AuthorizationPolicy authorizationPolicy
          This field holds the password authorization configuration.
protected  HttpAuthSupplier authSupplier
          Implements the authentication handling when talking to a server.
protected  Bus bus
          This field holds a reference to the CXF bus associated this conduit.
protected  CertConstraints certConstraints
           
protected  HTTPClientPolicy clientSidePolicy
          This field holds the QoS configuration settings for this conduit.
protected  Cookies cookies
           
protected  URI defaultEndpointURI
          This field holds the "default" URI for this particular conduit, which is created on demand.
protected  String defaultEndpointURIString
           
protected  EndpointInfo endpointInfo
          This field is used for two reasons.
protected  boolean fromEndpointReferenceType
           
static String KEY_HTTP_CONNECTION
          This constant is the Message(Map) key for the HttpURLConnection that is used to get the response.
protected static Logger LOG
          The Logger for this class.
protected  ProxyAuthorizationPolicy proxyAuthorizationPolicy
          This field holds the password authorization configuration for the configured proxy.
protected  HttpAuthSupplier proxyAuthSupplier
          Implements the proxy authentication handling.
protected  ProxyFactory proxyFactory
           
protected  TLSClientParameters tlsClientParameters
          This field holds the configuration TLS configuration which is programmatically configured.
protected  MessageTrustDecider trustDecider
          This field contains the MessageTrustDecider.
 
Fields inherited from class org.apache.cxf.transport.AbstractConduit
target
 
Fields inherited from class org.apache.cxf.transport.AbstractObservable
incomingObserver
 
Constructor Summary
HTTPConduit(Bus b, EndpointInfo ei)
          Constructor
HTTPConduit(Bus b, EndpointInfo ei, EndpointReferenceType t)
          Constructor
 
Method Summary
 void assertMessage(Message message)
           
 boolean canAssert(QName type)
           
 void close()
          Close the conduit
 void close(Message msg)
          Close the connections associated with the message
protected abstract  OutputStream createOutputStream(Message message, boolean needToCacheRequest, boolean isChunking, int chunkThreshold)
           
protected static int determineConnectionTimeout(Message message, HTTPClientPolicy csPolicy)
           
protected static int determineReceiveTimeout(Message message, HTTPClientPolicy csPolicy)
           
protected  String extractLocation(Map<String,List<String>> headers)
          This method extracts the value of the "Location" Http Response header.
 void finalizeConfig()
          This call gets called by the HTTPTransportFactory after it causes an injection of the Spring configuration properties of this Conduit.
 String getAddress()
           
 AuthorizationPolicy getAuthorization()
          This method gets the Authorization Policy that was configured or explicitly set for this HTTPConduit.
 HttpAuthSupplier getAuthSupplier()
          This method gets the Auth Supplier that was set/configured for this HTTPConduit.
 String getBeanName()
          This is part of the Configurable interface which retrieves the configuration from spring injection.
 HTTPClientPolicy getClient()
          This method retrieves the Client Side Policy set/configured for this HTTPConduit.
 HTTPClientPolicy getClient(Message message)
           
 String getConduitName()
          This method returns the name of the conduit, which is based on the endpoint name plus the SC_HTTP_CONDUIT_SUFFIX.
 Map<String,Cookie> getCookies()
          Allow access to the cookies that the conduit is maintaining
 AuthorizationPolicy getEffectiveAuthPolicy(Message message)
          Determines effective auth policy from message, conduit and empty default with priority from first to last
protected  Logger getLogger()
          This method returns the registered Logger for this conduit.
 ProxyAuthorizationPolicy getProxyAuthorization()
          This method retrieves the Proxy Authorization Policy for a proxy that is set/configured for this HTTPConduit.
 HttpAuthSupplier getProxyAuthSupplier()
           
 TLSClientParameters getTlsClientParameters()
          This method returns the TLS Client Parameters that is set/configured for this HTTPConduit.
 MessageTrustDecider getTrustDecider()
          This method gets the Trust Decider that was set/configured for this HTTPConduit.
protected  URI getURI()
           
protected  URI getURI(boolean createOnDemand)
           
protected  boolean isChunkingSupported(Message message, String httpMethod)
           
 void prepare(Message message)
          Prepare to send an outbound HTTP message over this http conduit to a particular endpoint.
 void propertyChange(PropertyChangeEvent evt)
           
 void setAuthorization(AuthorizationPolicy authorization)
          This method is used to set the Authorization Policy for this conduit.
 void setAuthSupplier(HttpAuthSupplier supplier)
           
 void setClient(HTTPClientPolicy client)
          This method sets the Client Side Policy for this HTTPConduit.
protected  void setHeadersByAuthorizationPolicy(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.
 void setProxyAuthorization(ProxyAuthorizationPolicy proxyAuthorization)
          This method sets the Proxy Authorization Policy for a specified proxy.
 void setProxyAuthSupplier(HttpAuthSupplier proxyAuthSupplier)
           
 void setTlsClientParameters(TLSClientParameters params)
          This method sets the TLS Client Parameters for this HTTPConduit.
 void setTrustDecider(MessageTrustDecider decider)
          This method sets the Trust Decider for this HTTP Conduit.
protected abstract  void setupConnection(Message message, URI url, HTTPClientPolicy csPolicy)
           
 
Methods inherited from class org.apache.cxf.transport.AbstractConduit
getTarget, toString
 
Methods inherited from class org.apache.cxf.transport.AbstractObservable
activate, deactivate, getMessageObserver, getTargetReference, getTargetReference, setMessageObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.cxf.transport.Observable
getMessageObserver, setMessageObserver
 

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

LOG

protected static final Logger LOG
The Logger for this class.


bus

protected final Bus bus
This field holds a reference to the CXF bus associated this conduit.


endpointInfo

protected final 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.


defaultEndpointURI

protected URI defaultEndpointURI
This field holds the "default" URI for this particular conduit, which is created on demand.


defaultEndpointURIString

protected String defaultEndpointURIString

fromEndpointReferenceType

protected boolean fromEndpointReferenceType

proxyFactory

protected ProxyFactory proxyFactory

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 AuthorizationPolicy authorizationPolicy
This field holds the password authorization configuration. This field is injected via spring configuration based on the conduit name.


proxyAuthorizationPolicy

protected 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 TLSClientParameters tlsClientParameters
This field holds the configuration TLS configuration which is programmatically configured.


trustDecider

protected MessageTrustDecider trustDecider
This field contains the MessageTrustDecider.


authSupplier

protected 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 HttpAuthSupplier proxyAuthSupplier
Implements the proxy authentication handling. If it is not set it will be created from the proxyAuthorizationPolicy.authType


cookies

protected Cookies cookies

certConstraints

protected CertConstraints certConstraints
Constructor Detail

HTTPConduit

public HTTPConduit(Bus b,
                   EndpointInfo ei)
            throws IOException
Constructor

Parameters:
b - the associated Bus
ei - the endpoint info of the initiator
Throws:
IOException

HTTPConduit

public HTTPConduit(Bus b,
                   EndpointInfo ei,
                   EndpointReferenceType t)
            throws IOException
Constructor

Parameters:
b - the associated Bus.
endpoint - 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 AbstractObservable
Returns:
the logger to use

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

setupConnection

protected abstract void setupConnection(Message message,
                                        URI url,
                                        HTTPClientPolicy csPolicy)
                                 throws IOException
Throws:
IOException

prepare

public void prepare(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 Conduit
Parameters:
message - The message to be sent.
Throws:
IOException

isChunkingSupported

protected boolean isChunkingSupported(Message message,
                                      String httpMethod)

createOutputStream

protected abstract OutputStream createOutputStream(Message message,
                                                   boolean needToCacheRequest,
                                                   boolean isChunking,
                                                   int chunkThreshold)
                                            throws IOException
Throws:
IOException

determineReceiveTimeout

protected static int determineReceiveTimeout(Message message,
                                             HTTPClientPolicy csPolicy)

determineConnectionTimeout

protected static int determineConnectionTimeout(Message message,
                                                HTTPClientPolicy csPolicy)

close

public void close(Message msg)
           throws IOException
Description copied from interface: Conduit
Close the connections associated with the message

Specified by:
close in interface Conduit
Overrides:
close in class AbstractConduit
Parameters:
msg - for which content should be closed.
Throws:
IOException

close

public void close()
Close the conduit

Specified by:
close in interface Conduit
Overrides:
close in class AbstractConduit

getAddress

public String getAddress()
Returns:
the default target address

getURI

protected URI getURI()
              throws URISyntaxException
Returns:
the default target URL
Throws:
URISyntaxException

getURI

protected URI getURI(boolean createOnDemand)
              throws URISyntaxException
Parameters:
createOnDemand - create URL on-demand if null
Returns:
the default target URL
Throws:
URISyntaxException

setHeadersByAuthorizationPolicy

protected void setHeadersByAuthorizationPolicy(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 -
headers -

getBeanName

public String getBeanName()
This is part of the Configurable interface which retrieves the configuration from spring injection.

Specified by:
getBeanName in interface Configurable
Returns:
the bean name

getEffectiveAuthPolicy

public AuthorizationPolicy getEffectiveAuthPolicy(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 AuthorizationPolicy getAuthorization()
This method gets the Authorization Policy that was configured or explicitly set for this HTTPConduit.


setAuthorization

public void setAuthorization(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(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 ProxyAuthorizationPolicy getProxyAuthorization()
This method retrieves the Proxy Authorization Policy for a proxy that is set/configured for this HTTPConduit.


setProxyAuthorization

public void setProxyAuthorization(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 TLSClientParameters getTlsClientParameters()
This method returns the TLS Client Parameters that is set/configured for this HTTPConduit.


setTlsClientParameters

public void setTlsClientParameters(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.

setAuthSupplier

public void setAuthSupplier(HttpAuthSupplier supplier)

getProxyAuthSupplier

public HttpAuthSupplier getProxyAuthSupplier()

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

assertMessage

public void assertMessage(Message message)
Specified by:
assertMessage in interface Assertor

canAssert

public boolean canAssert(QName type)
Specified by:
canAssert in interface Assertor

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

Apache CXF API

Apache CXF