public abstract class HttpClient extends Object
| Modifier and Type | Field and Description |
|---|---|
protected okhttp3.HttpUrl |
baseUrl |
protected okhttp3.OkHttpClient |
client |
protected static okhttp3.MediaType |
JSON |
protected KeywhizKeyStore |
keywhizKeyStore |
protected static com.fasterxml.jackson.databind.ObjectMapper |
mapper |
| Modifier | Constructor and Description |
|---|---|
protected |
HttpClient(String baseUrl,
KeywhizKeyStore keywhizKeyStore)
Creates an http client.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearCookies()
Clear all cookies from cookie manager.
|
protected okhttp3.OkHttpClient |
createHttpsClient()
Creates a
OkHttpClient to start a TLS connection. |
static com.fasterxml.jackson.databind.ObjectMapper |
createObjectMapper()
Creates and customizes new ObjectMapper for common settings.
|
protected String |
httpDelete(okhttp3.HttpUrl url) |
protected String |
httpGet(okhttp3.HttpUrl url) |
protected String |
httpPost(okhttp3.HttpUrl url,
Object content) |
protected String |
httpPut(okhttp3.HttpUrl url,
Object content) |
abstract boolean |
isClientAuthEnabled()
Check if client auth is enabled (mTLS) instead of session cookie.
|
protected String |
makeCall(okhttp3.Request request) |
protected void |
throwOnCommonError(int status,
String message)
Maps some of the common HTTP errors to the corresponding exceptions.
|
protected static final okhttp3.MediaType JSON
protected static final com.fasterxml.jackson.databind.ObjectMapper mapper
protected final okhttp3.OkHttpClient client
protected final okhttp3.HttpUrl baseUrl
protected final KeywhizKeyStore keywhizKeyStore
protected HttpClient(String baseUrl, KeywhizKeyStore keywhizKeyStore) throws GeneralSecurityException
baseUrl - keywhiz base urlkeywhizKeyStore - keywhiz keystore.GeneralSecurityExceptionpublic static com.fasterxml.jackson.databind.ObjectMapper createObjectMapper()
protected okhttp3.OkHttpClient createHttpsClient()
throws GeneralSecurityException
OkHttpClient to start a TLS connection. The OKHttp logging is enabled if the
debug log is enabled for HttpClient.GeneralSecurityExceptionpublic void clearCookies()
public abstract boolean isClientAuthEnabled()
true if client auth is enabledprotected void throwOnCommonError(int status,
String message)
throws IOException
IOExceptionprotected String makeCall(okhttp3.Request request) throws IOException
IOExceptionprotected String httpGet(okhttp3.HttpUrl url) throws IOException
IOExceptionprotected String httpPost(okhttp3.HttpUrl url, Object content) throws IOException
IOExceptionprotected String httpPut(okhttp3.HttpUrl url, Object content) throws IOException
IOExceptionprotected String httpDelete(okhttp3.HttpUrl url) throws IOException
IOExceptionCopyright © 2018 Walmart, Inc.. All rights reserved.