Class HTTPConduit
- java.lang.Object
-
- org.apache.cxf.transport.AbstractObservable
-
- org.apache.cxf.transport.AbstractConduit
-
- org.apache.cxf.transport.http.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classHTTPConduit.InterposedMessageObserverUsed to set appropriate message properties, exchange etc.protected classHTTPConduit.WrappedOutputStreamWrapper output stream responsible for flushing headers and handling the incoming HTTP-level response (not necessarily the MEP response).
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.cxf.configuration.security.AuthorizationPolicyauthorizationPolicyThis field holds the password authorization configuration.protected HttpAuthSupplierauthSupplierImplements the authentication handling when talking to a server.protected org.apache.cxf.BusbusThis field holds a reference to the CXF bus associated this conduit.protected CertConstraintscertConstraintsprotected HTTPClientPolicyclientSidePolicyThis field holds the QoS configuration settings for this conduit.protected Cookiescookiesprotected AddressdefaultAddressThis field holds the "default" URI for this particular conduit, which is created on demand.protected org.apache.cxf.service.model.EndpointInfoendpointInfoThis field is used for two reasons.static StringFORCE_HTTP_VERSIONprotected booleanfromEndpointReferenceTypestatic StringHTTP_RESPONSE_MESSAGEprotected static StringHTTP_VERSIONstatic StringKEY_HTTP_CONNECTIONThis constant is the Message(Map) key for the HttpURLConnection that is used to get the response.static StringKEY_HTTP_CONNECTION_ADDRESSprotected static Set<String>KNOWN_HTTP_VERBS_WITH_NO_CONTENTprotected static LoggerLOGThe Logger for this class.static StringNO_IO_EXCEPTIONSstatic StringPROCESS_FAULT_ON_HTTP_400protected org.apache.cxf.configuration.security.ProxyAuthorizationPolicyproxyAuthorizationPolicyThis field holds the password authorization configuration for the configured proxy.protected HttpAuthSupplierproxyAuthSupplierImplements the proxy authentication handling.protected ProxyFactoryproxyFactorystatic StringSERVICE_NOT_AVAILABLE_ON_HTTP_STATUS_CODESThe HTTP status codes as contextual property (comma-separated integers as String) on the outgoingMessagewhich lead to settingorg.apache.cxf.transport.service_not_availablefor all responses with those status codes.static StringSET_HTTP_RESPONSE_MESSAGEprotected org.apache.cxf.configuration.jsse.TLSClientParameterstlsClientParametersThis field holds the configuration TLS configuration which is programmatically configured.protected MessageTrustDecidertrustDeciderThis field contains the MessageTrustDecider.
-
Constructor Summary
Constructors Constructor Description HTTPConduit(org.apache.cxf.Bus b, org.apache.cxf.service.model.EndpointInfo ei)ConstructorHTTPConduit(org.apache.cxf.Bus b, org.apache.cxf.service.model.EndpointInfo ei, org.apache.cxf.ws.addressing.EndpointReferenceType t)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidassertMessage(org.apache.cxf.message.Message message)booleancanAssert(QName type)voidclose()Close the conduitvoidclose(org.apache.cxf.message.Message msg)protected abstract OutputStreamcreateOutputStream(org.apache.cxf.message.Message message, boolean needToCacheRequest, boolean isChunking, int chunkThreshold)protected static intdetermineConnectionTimeout(org.apache.cxf.message.Message message, HTTPClientPolicy csPolicy)protected static intdetermineReceiveTimeout(org.apache.cxf.message.Message message, HTTPClientPolicy csPolicy)protected StringextractLocation(Map<String,List<String>> headers)This method extracts the value of the "Location" Http Response header.voidfinalizeConfig()This call gets called by the HTTPTransportFactory after it causes an injection of the Spring configuration properties of this Conduit.StringgetAddress()org.apache.cxf.configuration.security.AuthorizationPolicygetAuthorization()This method gets the Authorization Policy that was configured or explicitly set for this HTTPConduit.HttpAuthSuppliergetAuthSupplier()This method gets the Auth Supplier that was set/configured for this HTTPConduit.StringgetBeanName()This is part of the Configurable interface which retrieves the configuration from spring injection.HTTPClientPolicygetClient()This method retrieves the Client Side Policy set/configured for this HTTPConduit.HTTPClientPolicygetClient(org.apache.cxf.message.Message message)StringgetConduitName()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 maintainingorg.apache.cxf.configuration.security.AuthorizationPolicygetEffectiveAuthPolicy(org.apache.cxf.message.Message message)Determines effective auth policy from message, conduit and empty default with priority from first to lastprotected LoggergetLogger()This method returns the registered Logger for this conduit.org.apache.cxf.configuration.security.ProxyAuthorizationPolicygetProxyAuthorization()This method retrieves the Proxy Authorization Policy for a proxy that is set/configured for this HTTPConduit.HttpAuthSuppliergetProxyAuthSupplier()org.apache.cxf.configuration.jsse.TLSClientParametersgetTlsClientParameters()This method returns the TLS Client Parameters that is set/configured for this HTTPConduit.MessageTrustDecidergetTrustDecider()This method gets the Trust Decider that was set/configured for this HTTPConduit.protected URIgetURI()protected booleanisChunkingSupported(org.apache.cxf.message.Message message, String httpMethod)protected voidlogStackTrace(Throwable ex)voidprepare(org.apache.cxf.message.Message message)Prepare to send an outbound HTTP message over this http conduit to a particular endpoint.voidpropertyChange(PropertyChangeEvent evt)voidsetAuthorization(org.apache.cxf.configuration.security.AuthorizationPolicy authorization)This method is used to set the Authorization Policy for this conduit.voidsetAuthSupplier(HttpAuthSupplier supplier)voidsetClient(HTTPClientPolicy client)This method sets the Client Side Policy for this HTTPConduit.protected voidsetHeadersByAuthorizationPolicy(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.voidsetProxyAuthorization(org.apache.cxf.configuration.security.ProxyAuthorizationPolicy proxyAuthorization)This method sets the Proxy Authorization Policy for a specified proxy.voidsetProxyAuthSupplier(HttpAuthSupplier proxyAuthSupplier)voidsetTlsClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters params)This method sets the TLS Client Parameters for this HTTPConduit.voidsetTrustDecider(MessageTrustDecider decider)This method sets the Trust Decider for this HTTP Conduit.protected abstract voidsetupConnection(org.apache.cxf.message.Message message, Address address, HTTPClientPolicy csPolicy)-
Methods inherited from class org.apache.cxf.transport.AbstractObservable
activate, deactivate, getMessageObserver, getTargetReference, getTargetReference, 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
-
KEY_HTTP_CONNECTION_ADDRESS
public static final String KEY_HTTP_CONNECTION_ADDRESS
- See Also:
- Constant Field Values
-
SET_HTTP_RESPONSE_MESSAGE
public static final String SET_HTTP_RESPONSE_MESSAGE
- See Also:
- Constant Field Values
-
HTTP_RESPONSE_MESSAGE
public static final String HTTP_RESPONSE_MESSAGE
- See Also:
- Constant Field Values
-
PROCESS_FAULT_ON_HTTP_400
public static final String PROCESS_FAULT_ON_HTTP_400
- See Also:
- Constant Field Values
-
NO_IO_EXCEPTIONS
public static final String NO_IO_EXCEPTIONS
- See Also:
- Constant Field Values
-
FORCE_HTTP_VERSION
public static final String FORCE_HTTP_VERSION
- 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 outgoingMessagewhich lead to settingorg.apache.cxf.transport.service_not_availablefor all responses with those status codes. This is used e.g. by theorg.apache.cxf.clustering.FailoverTargetSelectorto determine if it should do the fail-over. Default:404,429,503as perDEFAULT_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
-
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 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
-
certConstraints
protected CertConstraints certConstraints
-
-
Constructor Detail
-
HTTPConduit
public HTTPConduit(org.apache.cxf.Bus b, org.apache.cxf.service.model.EndpointInfo ei) throws IOExceptionConstructor- Parameters:
b- the associated Busei- 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 IOExceptionConstructor- 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:
getLoggerin classorg.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
-
setupConnection
protected abstract void setupConnection(org.apache.cxf.message.Message message, Address address, HTTPClientPolicy csPolicy) throws IOException- Throws:
IOException
-
prepare
public void prepare(org.apache.cxf.message.Message message) throws IOExceptionPrepare 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:
preparein interfaceorg.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:
closein interfaceorg.apache.cxf.transport.Conduit- Overrides:
closein classorg.apache.cxf.transport.AbstractConduit- Throws:
IOException
-
close
public void close()
Close the conduit- Specified by:
closein interfaceorg.apache.cxf.transport.Conduit- Overrides:
closein classorg.apache.cxf.transport.AbstractConduit
-
getAddress
public String getAddress()
- Returns:
- the default target address
-
getURI
protected URI getURI() throws URISyntaxException
- Returns:
- the default target URL
- Throws:
URISyntaxException
-
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:
getBeanNamein interfaceorg.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.
-
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
-
logStackTrace
protected void logStackTrace(Throwable ex)
-
assertMessage
public void assertMessage(org.apache.cxf.message.Message message)
- Specified by:
assertMessagein interfaceorg.apache.cxf.transport.Assertor
-
canAssert
public boolean canAssert(QName type)
- Specified by:
canAssertin interfaceorg.apache.cxf.transport.Assertor
-
propertyChange
public void propertyChange(PropertyChangeEvent evt)
- Specified by:
propertyChangein interfacePropertyChangeListener
-
-