public class ConnectionUtils extends Object
ConnectionUtils is a singleton utility class that provides convenience methods to build request and process response of connections
In case the connection or configuration is null or empty or invalid
ConnectionException is thrown.
| Modifier and Type | Field and Description |
|---|---|
private static ConnectionUtils |
INSTANCE |
private static Logger |
LOGGER |
| Constructor and Description |
|---|
ConnectionUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
buildAuthorizationUrl(AuthorizationCodeConfiguration authorizationCodeConfig)
Returns a Authorization Url that is constructed from the configuration parameter
|
protected boolean |
computeIsValidToken(double tokenTimeTracker)
Returns true if token hasn't expired since issued and false if token
has expired.
|
static List<org.apache.http.NameValuePair> |
getClientCredentials(ConnectionConfiguration connectionConfiguration)
Returns a List of name value pairs consisting of client credentials and
grant type associated to this configuration
|
static ConnectionUtils |
getInstance()
Returns a lazy loaded singleton instance of
ConnectionUtils |
List<org.apache.http.NameValuePair> |
getNameValuePairs(ADPAPIConnection connection)
Returns a List of name value pairs consisting of client credentials, code,
redirect url and grant type associated to this connection
|
private List<org.apache.http.NameValuePair> |
getNameValuePairs(AuthorizationCodeConnection connection)
Returns a List of name value pairs consisting of client credentials, code,
grant type, redirect url associated to this configuration
|
private List<org.apache.http.NameValuePair> |
getNameValuePairs(ClientCredentialsConnection connection)
Returns List
|
static String |
processResponse(org.apache.http.client.methods.CloseableHttpResponse httpResponse) |
static Token |
processTokenResponse(org.apache.http.client.methods.CloseableHttpResponse response)
Returns a simple value object
Token after processing JSON response
obtained as part of the Http Post execution to token server. |
private static ConnectionUtils INSTANCE
private static final Logger LOGGER
public static ConnectionUtils getInstance()
ConnectionUtilspublic static String buildAuthorizationUrl(AuthorizationCodeConfiguration authorizationCodeConfig) throws ConnectionException
authorizationCodeConfig - contains the authorization configuration
attributesConnectionException - throws connection exception if missing
required configurations attributespublic static List<org.apache.http.NameValuePair> getClientCredentials(ConnectionConfiguration connectionConfiguration) throws ConnectionException
connectionConfiguration - type of connection configurationConnectionException - throws exception if configuration is nullpublic List<org.apache.http.NameValuePair> getNameValuePairs(ADPAPIConnection connection) throws ConnectionException
connection - connection typeConnectionException - throws exception if connection is null or invalidpublic static Token processTokenResponse(org.apache.http.client.methods.CloseableHttpResponse response) throws Exception
Token after processing JSON response
obtained as part of the Http Post execution to token server.response - contains JSON response from token serverExceptionpublic static String processResponse(org.apache.http.client.methods.CloseableHttpResponse httpResponse) throws Exception
httpResponse - IOExceptionExceptionprotected boolean computeIsValidToken(double tokenTimeTracker)
tokenTimeTracker - has sum of token issued time and expiration timeprivate List<org.apache.http.NameValuePair> getNameValuePairs(AuthorizationCodeConnection connection) throws ConnectionException
connection - Authorization Code connectionConnectionException - throws exception if connection is nullprivate List<org.apache.http.NameValuePair> getNameValuePairs(ClientCredentialsConnection connection) throws ConnectionException
connection - Client Credentials ConnectionConnectionException - throws exception if connection is nullCopyright © 2016 ADP LLC. All rights reserved.