public interface RestUtils
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AUTH_BASIC |
static java.lang.String |
AUTH_BEARER |
static int |
CONNECT_TIMEOUT_MILLISECONDS |
static java.lang.String |
HEXES |
static int |
HEXES_L |
static java.lang.String |
MEMBER_PASSWORD |
static java.lang.String |
MEMBER_USERID |
static java.util.logging.Logger |
TRACE |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
createBasicAuth(com.google.gson.JsonObject credentials)
Create an encoded Basic auth header for the given credentials.
|
static java.lang.String |
createBasicAuth(java.lang.String userName,
java.lang.String authToken)
Create an encoded Basic auth header for the given userName and authToken
|
static java.lang.String |
createBearerAuth(java.lang.String tokenBase64)
Create an encoded Bearer auth header for the given token.
|
static org.apache.http.client.fluent.Executor |
createExecutor() |
static org.apache.http.client.fluent.Executor |
createExecutor(boolean allowInsecure) |
static org.apache.http.impl.client.CloseableHttpClient |
createHttpClient() |
static org.apache.http.impl.client.CloseableHttpClient |
createHttpClient(boolean allowInsecure) |
static com.google.gson.JsonObject |
getGsonResponse(org.apache.http.client.fluent.Executor executor,
java.lang.String auth,
java.lang.String url)
Gets a JSON response to an HTTP GET call
|
static com.google.gson.JsonObject |
getGsonResponse(org.apache.http.client.fluent.Executor executor,
java.lang.String auth,
java.net.URL url) |
static java.lang.String |
getResponseString(org.apache.http.client.fluent.Executor executor,
java.lang.String auth,
java.lang.String inputString)
Gets a response to an HTTP GET call as a string
|
static com.google.gson.JsonObject |
gsonFromResponse(org.apache.http.HttpResponse response) |
static java.lang.String |
randomHex(int length)
Create a random string of hexadecimal digits of specified length
|
static com.google.gson.JsonObject |
requestGsonResponse(org.apache.http.client.fluent.Executor executor,
org.apache.http.client.fluent.Request request)
Gets a JSON response to an HTTP request call
|
static final java.util.logging.Logger TRACE
static final java.lang.String MEMBER_PASSWORD
static final java.lang.String MEMBER_USERID
static final java.lang.String AUTH_BEARER
static final java.lang.String AUTH_BASIC
static final int CONNECT_TIMEOUT_MILLISECONDS
static final java.lang.String HEXES
static final int HEXES_L
static java.lang.String randomHex(int length)
length
- length of the generated Stringstatic java.lang.String createBasicAuth(com.google.gson.JsonObject credentials)
credentials
- Service credentials.static java.lang.String createBasicAuth(java.lang.String userName, java.lang.String authToken)
userName
- The user name for authenticationauthToken
- The password for authenticationstatic java.lang.String createBearerAuth(java.lang.String tokenBase64)
tokenBase64
- An authentication token, expected to be already
encoded in base64, as it is when returned from the IAM serverstatic org.apache.http.client.fluent.Executor createExecutor()
static org.apache.http.client.fluent.Executor createExecutor(boolean allowInsecure)
static org.apache.http.impl.client.CloseableHttpClient createHttpClient()
static org.apache.http.impl.client.CloseableHttpClient createHttpClient(boolean allowInsecure)
static com.google.gson.JsonObject getGsonResponse(org.apache.http.client.fluent.Executor executor, java.lang.String auth, java.lang.String url) throws java.io.IOException
executor
- HTTP client executor to use for callauth
- Authentication header contents, or nullinputString
- REST call to makejava.io.IOException
static com.google.gson.JsonObject getGsonResponse(org.apache.http.client.fluent.Executor executor, java.lang.String auth, java.net.URL url) throws java.io.IOException
java.io.IOException
static java.lang.String getResponseString(org.apache.http.client.fluent.Executor executor, java.lang.String auth, java.lang.String inputString) throws java.io.IOException
executor
- HTTP client executor to use for callauth
- Authentication header contents, or nullinputString
- REST call to make, i.e. the URIjava.io.IOException
- TODO: unify error handling between this and gsonFromResponse(), and
convert callers that want JSON to getGsonResponse()static com.google.gson.JsonObject requestGsonResponse(org.apache.http.client.fluent.Executor executor, org.apache.http.client.fluent.Request request) throws java.io.IOException
java.io.IOException
static com.google.gson.JsonObject gsonFromResponse(org.apache.http.HttpResponse response) throws java.io.IOException
java.io.IOException