public class BaseClientHelper extends BaseHelper<Client>
Parameter name | Value type | Default value | Description |
---|---|---|---|
proxyHost | String | System property "http.proxyHost" | The host name of the HTTP proxy. |
proxyPort | int | System property "http.proxyPort" | The port of the HTTP proxy. |
tcpNoDelay | boolean | false | Indicate if Nagle's TCP_NODELAY algorithm should be used. | keystorePath | String | ${user.home}/.keystore | SSL keystore path. |
keystorePassword | String | System property "javax.net.ssl.keyStorePassword" | SSL keystore password. |
keystoreType | String | JKS | SSL keystore type |
keyPassword | String | System property "javax.net.ssl.keyStorePassword" | SSL key password. |
certAlgorithm | String | SunX509 | SSL certificate algorithm. |
secureRandomAlgorithm | String | null (see java.security.SecureRandom) | Name of the RNG algorithm. (see java.security.SecureRandom class). |
securityProvider | String | null (see javax.net.ssl.SSLContext) | Java security provider name (see java.security.Provider class). |
sslProtocol | String | TLS | SSL protocol. |
truststoreType | String | System property "javax.net.ssl.trustStoreType" | Trust store type |
truststorePath | String | null | Path to trust store |
truststorePassword | String | System property "javax.net.ssl.trustStorePassword" | Trust store password |
Constructor and Description |
---|
BaseClientHelper(Client connector)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected Connection<Client> |
createConnection(BaseHelper<Client> helper,
Socket socket,
SocketChannel socketChannel)
Creates a connection associated to the given socket.
|
protected SocketFactory |
createSecureSocketFactory()
Creates a properly configured secure socket factory.
|
protected Socket |
createSocket(boolean secure,
InetSocketAddress socketAddress)
Creates the socket that will be used to send the request and get the
response.
|
protected Socket |
createSocket(boolean secure,
String hostDomain,
int hostPort)
Creates the socket that will be used to send the request and get the
response.
|
protected SocketFactory |
createSocketFactory(boolean secure)
Creates a normal or secure socket factory.
|
protected Connection<Client> |
getBestConnection(Request request)
Tries to reuse an existing connection for the given request, or creates a
new one.
|
String |
getCertAlgorithm()
Returns the SSL certificate algorithm.
|
int |
getConnectTimeout()
Returns the connection timeout.
|
String |
getKeyPassword()
Returns the SSL key password.
|
String |
getKeystorePassword()
Returns the SSL keystore password.
|
String |
getKeystorePath()
Returns the SSL keystore path.
|
String |
getKeystoreType()
Returns the SSL keystore type.
|
String |
getProxyHost()
Returns the host name of the HTTP proxy, if specified.
|
int |
getProxyPort()
Returns the port of the HTTP proxy, if specified, 3128 otherwise.
|
SocketFactory |
getRegularSocketFactory()
Returns the regular socket factory.
|
String |
getSecureRandomAlgorithm()
Returns the name of the RNG algorithm.
|
SocketFactory |
getSecureSocketFactory()
Returns the secure socket factory.
|
String |
getSecurityProvider()
Returns the Java security provider name.
|
protected InetSocketAddress |
getSocketAddress(Request request)
Returns an IP socket address representing the target host domain and port
for a given request.
|
SocketFactory |
getSocketFactory(boolean secure)
Returns the socket factory.
|
String |
getSslProtocol()
Returns the SSL keystore type.
|
boolean |
getTcpNoDelay()
Indicates if the protocol will use Nagle's algorithm
|
String |
getTruststorePassword()
Returns the SSL trust store password.
|
String |
getTruststorePath()
Returns the SSL trust store path.
|
String |
getTruststoreType()
Returns the SSL trust store type.
|
void |
handle(Request request,
Response response)
Handles a call.
|
void |
handleInbound(Response response)
Handles an inbound message.
|
void |
handleOutbound(Response response)
Handles an outbound message.
|
boolean |
isProxying()
Indicates if the helper is going through a client proxy or is a server
proxy.
|
void |
setRegularSocketFactory(SocketFactory regularSocketFactory)
Sets the regular socket factory.
|
void |
setSecureSocketFactory(SocketFactory secureSocketFactory)
Sets the secure socket factory.
|
void |
start()
Start callback.
|
void |
stop()
Stop callback.
|
createController, createControllerService, createResponse, createWorkerService, getConnections, getController, getControllerSleepTimeMs, getInboundBufferSize, getInboundMessages, getMaxConnectionsPerHost, getMaxThreads, getMaxTotalConnections, getMinThreads, getOutboundBufferSize, getOutboundMessages, getThreadMaxIdleTimeMs, getWorkerService, handleNextInbound, handleNextOutbound, isClientSide, isControllerDaemon, isPersistingConnections, isPipeliningConnections, isServerSide, isTracing, isWorkerServiceFull
getConnectorService, getContext, getProtocols, update
getAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, setHelped
public BaseClientHelper(Client connector)
connector
- The helped client connector.protected Connection<Client> createConnection(BaseHelper<Client> helper, Socket socket, SocketChannel socketChannel) throws IOException
BaseHelper
createConnection
in class BaseHelper<Client>
helper
- The parent helper.socket
- The underlying BIO socket.socketChannel
- The underlying NIO socket channel.IOException
protected SocketFactory createSecureSocketFactory() throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
protected Socket createSocket(boolean secure, InetSocketAddress socketAddress) throws UnknownHostException, IOException
getBestConnection(Request)
when a new connection is to be created. By default, calls the
createSocket(boolean, String, int)
method.secure
- Indicates if messages will be exchanged confidentially, for
example via a SSL-secured connection.socketAddress
- The holder of a host/port pair.UnknownHostException
IOException
protected Socket createSocket(boolean secure, String hostDomain, int hostPort) throws UnknownHostException, IOException
secure
- Indicates if messages will be exchanged confidentially, for
example via a SSL-secured connection.hostDomain
- The target host domain name.hostPort
- The target host port.UnknownHostException
IOException
protected SocketFactory createSocketFactory(boolean secure)
secure
- Indicates if the sockets should be secured.protected Connection<Client> getBestConnection(Request request) throws UnknownHostException, IOException
request
- The request to handle.UnknownHostException
IOException
public String getCertAlgorithm()
public int getConnectTimeout()
public String getKeyPassword()
public String getKeystorePassword()
public String getKeystorePath()
public String getKeystoreType()
public String getProxyHost()
public int getProxyPort()
public SocketFactory getRegularSocketFactory()
public String getSecureRandomAlgorithm()
public SocketFactory getSecureSocketFactory()
public String getSecurityProvider()
protected InetSocketAddress getSocketAddress(Request request) throws UnknownHostException
getBestConnection(Request)
method.request
- The given requestUnknownHostException
- If the proxy port is invalid or the host unresolved.public SocketFactory getSocketFactory(boolean secure)
secure
- Indicates if a factory for secure sockets is expected.public String getSslProtocol()
public boolean getTcpNoDelay()
Socket.setTcpNoDelay(boolean)
public String getTruststorePassword()
public String getTruststorePath()
public String getTruststoreType()
public void handle(Request request, Response response)
RestletHelper
handle
in class RestletHelper<Client>
request
- The request to handle.response
- The response to update.public void handleInbound(Response response)
BaseHelper
handleInbound
in class BaseHelper<Client>
response
- The response to handle.public void handleOutbound(Response response)
BaseHelper
handleOutbound
in class BaseHelper<Client>
response
- The response to handle.public void setRegularSocketFactory(SocketFactory regularSocketFactory)
regularSocketFactory
- The regular socket factory.public void setSecureSocketFactory(SocketFactory secureSocketFactory)
secureSocketFactory
- The secure socket factory.public void start() throws Exception
RestletHelper
start
in class BaseHelper<Client>
Exception
public void stop() throws Exception
RestletHelper
stop
in class BaseHelper<Client>
Exception
public boolean isProxying()
BaseHelper
isProxying
in class BaseHelper<Client>
Copyright © 2005–2016. All rights reserved.