public class HttpClient extends Object
{ "name": "HttpClient", "type": "HttpClient", "config": { "connections": 64, "disableReuseConnection": true, "disableRetries": true, "hostnameVerifier": "ALLOW_ALL", "soTimeout": "10 seconds", "connectionTimeout": "10 seconds", "keystore": { "file": "/path/to/keystore.jks", "password": "changeit" }, "truststore": { "file": "/path/to/keystore.jks", "password": "changeit" }, "keyManager": [ "RefToKeyManager", ... ] "trustManager": [ "RefToTrustManager", ... ] } }
Note: This implementation does not verify hostnames for outgoing SSL connections by default. This is because the gateway will usually access the SSL endpoint using a raw IP address rather than a fully-qualified hostname.
It's possible to override that behavior using the hostnameVerifier attribute (case is not important, but unknown values will produce an error).
Accepted values are:
The deprecated keystore and truststore optional attributes are both supporting the following attributes:
Expression
The new (since OpenIG 3.1) keyManager and trustManager optional attributes are referencing a
list of KeyManager
(and TrustManager
respectively). They support singleton value (use a single
reference) as well as multi-valued references (a list):
"keyManager": "SingleKeyManagerReference", "trustManager": [ "RefOne", "RefTwo" ]
The soTimeout optional attribute specifies a socket timeout (the given amount of time a connection will live before being considered a stalled and automatically destroyed). It defaults to 10 seconds.
The connectionTimeout optional attribute specifies a connection timeout (the given amount of time to wait until the connection is established). It defaults to 10 seconds.
Duration
,
KeyManagerHeaplet
,
TrustManagerHeaplet
Modifier and Type | Class and Description |
---|---|
static class |
HttpClient.Heaplet
Creates and initializes a http client object in a heap environment.
|
Modifier and Type | Field and Description |
---|---|
static Duration |
DEFAULT_CONNECTION_TIMEOUT
Default connection timeout as a
Duration . |
static int |
DEFAULT_CONNECTIONS
Default maximum number of collections through HTTP client.
|
static Duration |
DEFAULT_SO_TIMEOUT
Default socket timeout as a
Duration . |
static boolean |
DISABLE_CONNECTION_REUSE
Reuse of Http connection is disabled by default.
|
static boolean |
DISABLE_RETRIES
Http connection retries are disabled by default.
|
static String |
HTTP_CLIENT_HEAP_KEY
Key to retrieve an
HttpClient instance from the Heap . |
static String |
TEN_SECONDS
Value of the default timeout.
|
Constructor and Description |
---|
HttpClient(TemporaryStorage storage)
Creates a new client handler which will cache at most 64 connections, allow all host names for SSL requests
and has a both a default connection and so timeout.
|
HttpClient(TemporaryStorage storage,
int connections,
KeyManager[] keyManagers,
TrustManager[] trustManagers,
org.forgerock.openig.http.HttpClient.Verifier verifier,
Duration soTimeout,
Duration connectionTimeout)
Creates a new client handler with the specified maximum number of cached connections.
|
Modifier and Type | Method and Description |
---|---|
HttpClient |
disableConnectionReuse()
Disables connection caching.
|
HttpClient |
disableRetries(Logger logger)
Disables automatic retrying of failed requests.
|
void |
execute(Exchange exchange)
Submits the exchange request to the remote server.
|
Response |
execute(Request request)
Submits the request to the remote server.
|
public static final String HTTP_CLIENT_HEAP_KEY
HttpClient
instance from the Heap
.public static final boolean DISABLE_CONNECTION_REUSE
public static final boolean DISABLE_RETRIES
public static final int DEFAULT_CONNECTIONS
public static final String TEN_SECONDS
public static final Duration DEFAULT_SO_TIMEOUT
Duration
.public static final Duration DEFAULT_CONNECTION_TIMEOUT
Duration
.public HttpClient(TemporaryStorage storage) throws GeneralSecurityException
storage
- the TemporaryStorage to useGeneralSecurityException
- if the SSL algorithm is unsupported or if an error occurs during SSL configurationpublic HttpClient(TemporaryStorage storage, int connections, KeyManager[] keyManagers, TrustManager[] trustManagers, org.forgerock.openig.http.HttpClient.Verifier verifier, Duration soTimeout, Duration connectionTimeout) throws GeneralSecurityException
storage
- the TemporaryStorage
to useconnections
- the maximum number of connections to open.keyManagers
- Provides Keys/Certificates in case of SSL/TLS connectionstrustManagers
- Provides TrustManagers in case of SSL/TLS connectionsverifier
- hostname verification strategysoTimeout
- socket timeout durationconnectionTimeout
- connection timeout durationGeneralSecurityException
- if the SSL algorithm is unsupported or if an error occurs during SSL configurationpublic HttpClient disableConnectionReuse()
public HttpClient disableRetries(Logger logger)
logger
- a logger which should be used for logging the reason that a
request failed.public void execute(Exchange exchange) throws IOException
exchange
- The HTTP exchange containing the request to send and where the
response will be placed.IOException
- If an IO error occurred while performing the request.public Response execute(Request request) throws IOException
request
- The HTTP request to send.IOException
- If an IO error occurred while performing the request.Copyright © 2014 ForgeRock AS. All rights reserved.