Package org.alfresco.httpclient
Class HttpClientFactory
java.lang.Object
org.alfresco.httpclient.HttpClientFactory
A factory to create HttpClients and AlfrescoHttpClients based on the setting of the 'secureCommsType' property.
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
An extension of the DefaultHttpParamsFactory that uses a RRW lock pattern rather than full synchronization around the parameter CRUD - to avoid locking on many reads.static enum
Communication type for HttpClient: - NONE is plain http - SECRET is plain http with a shared secret via request header - HTTPS is mTLS with client authentication (certificates are required) -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHttpClientFactory
(HttpClientFactory.SecureCommsType secureCommsType, SSLEncryptionParameters sslEncryptionParameters, KeyResourceLoader keyResourceLoader, KeyStoreParameters keyStoreParameters, MD5EncryptionParameters encryptionParameters, String host, int port, int sslPort, int maxTotalConnections, int maxHostConnections, int socketTimeout) Default constructor for legacy subsystems.HttpClientFactory
(HttpClientFactory.SecureCommsType secureCommsType, SSLEncryptionParameters sslEncryptionParameters, KeyResourceLoader keyResourceLoader, KeyStoreParameters keyStoreParameters, MD5EncryptionParameters encryptionParameters, String sharedSecret, String sharedSecretHeader, String host, int port, int sslPort, int maxTotalConnections, int maxHostConnections, int socketTimeout) Recommended constructor for subsystems supporting Shared Secret communication. -
Method Summary
Modifier and TypeMethodDescriptionprotected RequestHeadersHttpClient
protected RequestHeadersHttpClient
Build HTTP Client using default headersprotected AlfrescoHttpClient
protected AlfrescoHttpClient
protected AlfrescoHttpClient
protected RequestHeadersHttpClient
protected RequestHeadersHttpClient
getDefaultHttpClient
(String httpHost, int httpPort) getHost()
getHttpClient
(String host, int port) protected RequestHeadersHttpClient
protected RequestHeadersHttpClient
getHttpsClient
(String httpsHost, int httpsPort) int
int
protected org.apache.commons.httpclient.HttpClient
getMD5HttpClient
(String host, int port) int
getPort()
getRepoClient
(String host, int port) protected RequestHeadersHttpClient
protected RequestHeadersHttpClient
getSharedSecretHttpClient
(String httpHost, int httpPort) void
init()
boolean
isSSL()
void
setConnectionTimeout
(int connectionTimeout) Attempts to connect to a server will timeout after this period (millis).void
setEncryptionParameters
(MD5EncryptionParameters encryptionParameters) void
void
setKeyResourceLoader
(KeyResourceLoader keyResourceLoader) void
setKeyStoreParameters
(KeyStoreParameters keyStoreParameters) void
setMaxHostConnections
(int maxHostConnections) void
setMaxTotalConnections
(int maxTotalConnections) void
setPort
(int port) void
setSecureCommsType
(String type) void
setSharedSecret
(String sharedSecret) Shared secret used for SECRET communicationvoid
setSharedSecretHeader
(String sharedSecretHeader) HTTP Request header used for SECRET communicationvoid
setSocketTimeout
(Integer socketTimeout) Sets the default socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data.void
setSSLEncryptionParameters
(SSLEncryptionParameters sslEncryptionParameters) void
setSslPort
(int sslPort)
-
Field Details
-
DEFAULT_SHAREDSECRET_HEADER
- See Also:
-
-
Constructor Details
-
HttpClientFactory
public HttpClientFactory() -
HttpClientFactory
public HttpClientFactory(HttpClientFactory.SecureCommsType secureCommsType, SSLEncryptionParameters sslEncryptionParameters, KeyResourceLoader keyResourceLoader, KeyStoreParameters keyStoreParameters, MD5EncryptionParameters encryptionParameters, String host, int port, int sslPort, int maxTotalConnections, int maxHostConnections, int socketTimeout) Default constructor for legacy subsystems. -
HttpClientFactory
public HttpClientFactory(HttpClientFactory.SecureCommsType secureCommsType, SSLEncryptionParameters sslEncryptionParameters, KeyResourceLoader keyResourceLoader, KeyStoreParameters keyStoreParameters, MD5EncryptionParameters encryptionParameters, String sharedSecret, String sharedSecretHeader, String host, int port, int sslPort, int maxTotalConnections, int maxHostConnections, int socketTimeout) Recommended constructor for subsystems supporting Shared Secret communication. This constructor supports Shared Secret ("secret") communication method additionally to the legacy ones: "none" and "https".
-
-
Method Details
-
init
public void init() -
setHost
-
getHost
-
setPort
public void setPort(int port) -
getPort
public int getPort() -
setSslPort
public void setSslPort(int sslPort) -
isSSL
public boolean isSSL() -
setSecureCommsType
-
setSSLEncryptionParameters
-
setKeyStoreParameters
-
setEncryptionParameters
-
setKeyResourceLoader
-
getMaxTotalConnections
public int getMaxTotalConnections()- Returns:
- the maxTotalConnections
-
setMaxTotalConnections
public void setMaxTotalConnections(int maxTotalConnections) - Parameters:
maxTotalConnections
- the maxTotalConnections to set
-
getMaxHostConnections
public int getMaxHostConnections()- Returns:
- the maxHostConnections
-
setMaxHostConnections
public void setMaxHostConnections(int maxHostConnections) - Parameters:
maxHostConnections
- the maxHostConnections to set
-
setSocketTimeout
Sets the default socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data. A timeout value of zero is interpreted as an infinite timeout.- Parameters:
socketTimeout
- Timeout in milliseconds
-
setConnectionTimeout
public void setConnectionTimeout(int connectionTimeout) Attempts to connect to a server will timeout after this period (millis). Default is zero (the timeout is not used).- Parameters:
connectionTimeout
- time in millis.
-
constructHttpClient
-
getHttpsClient
-
getHttpsClient
-
getDefaultHttpClient
-
getDefaultHttpClient
-
getAlfrescoHttpsClient
-
getAlfrescoHttpClient
-
getMD5HttpClient
-
getRepoClient
-
getHttpClient
-
getHttpClient
-