public abstract class BaseSecureServiceClient extends java.lang.Object implements SecureServiceClient
A base class with convenience methods for custom secure invocation clients to Presto mashable information sources. Secure invocation clients handle all aspects of adding authentication to requests, making secure or unsecure connections to mashable information sources and invoking those sources when they require a specific security profile.
This class provides access to a default HTTP connection, proxy server configuration for Presto and a method to easily convert HTTP response headers to a Map that can be included in the Presto response. To create custom secure invocation clients based on this class, you must implement the following methods:
Constructor and Description |
---|
BaseSecureServiceClient() |
Modifier and Type | Method and Description |
---|---|
abstract void |
close()
Closes the connection to the mashable.
|
java.util.Map<java.lang.String,java.lang.String> |
convertHeadersToMap(Header[] headers)
Converts an array of HTTP headers from the mashable response to a Map to allow
them to be forwarded in the Presto response.
|
abstract java.io.InputStream |
getData(java.lang.String requestData,
ServiceInvocationContext invCtx)
Invokes a mashable for this type of security profile for a specific request that Presto has received from clients or from
mashups.
|
HttpClient |
getDefaultHTTPClient()
Returns an instance of Apache's HTTP client to use to invoke mashables.
|
HttpProxyInfo |
getHttpProxySettings()
Returns proxy server configuration information for Presto.
|
abstract java.io.InputStream |
getMetadata(java.lang.String requestData,
ServiceInvocationContext invCtx)
Invokes a mashable for this type of security profile during registration of the mashable in Presto.
|
abstract java.util.Map<java.lang.String,java.lang.String> |
getResponseHeaders()
Returns the HTTP response headers from the mashable response to an invocation.
|
abstract int |
getStatusCode()
Returns the HTTP status code from the mashable response to an invocation.
|
abstract java.lang.String |
getStatusText()
Returns the HTTP status text from the mashable response to an invocation.
|
void |
setupHttpProxy(HttpClient httpClient,
HttpMethod httpMethod)
Uses Presto configuration to configure the HTTP client to use a proxy server for requests
to a mashable information source.
|
public abstract java.io.InputStream getMetadata(java.lang.String requestData, ServiceInvocationContext invCtx) throws SecureServiceClientException
SecureServiceClient
Invokes a mashable for this type of security profile during registration of the mashable in Presto. Invocation during registration is used primarily to verify that the endpoint is valid, a connection can be created and that the mashable can successfully be invoked.
getMetadata
in interface SecureServiceClient
requestData
- The request payload sent to Presto to invoke this mashable.invCtx
- A ServiceInvocationContext object with context information for this invocation. This includes the security profile
for this mashable and other metadata.SecureServiceClientException
public abstract java.io.InputStream getData(java.lang.String requestData, ServiceInvocationContext invCtx) throws SecureServiceClientException
SecureServiceClient
Invokes a mashable for this type of security profile for a specific request that Presto has received from clients or from mashups.
getData
in interface SecureServiceClient
requestData
- The request payload sent to Presto to invoke this mashable.invCtx
- A ServiceInvocationContext object with context information for this invocation. This includes the security profile
for this mashable and other metadata.SecureServiceClientException
public abstract java.util.Map<java.lang.String,java.lang.String> getResponseHeaders()
SecureServiceClient
Returns the HTTP response headers from the mashable response to an invocation. Headers are returned as a Map.
getResponseHeaders
in interface SecureServiceClient
public abstract int getStatusCode()
SecureServiceClient
Returns the HTTP status code from the mashable response to an invocation.
getStatusCode
in interface SecureServiceClient
public abstract java.lang.String getStatusText()
SecureServiceClient
Returns the HTTP status text from the mashable response to an invocation.
getStatusText
in interface SecureServiceClient
public abstract void close()
SecureServiceClient
Closes the connection to the mashable.
close
in interface SecureServiceClient
public void setupHttpProxy(HttpClient httpClient, HttpMethod httpMethod)
httpClient
- The HTTP client to use for invocations.httpMethod
- The HTTP method to use for an invocation.public HttpClient getDefaultHTTPClient()
public HttpProxyInfo getHttpProxySettings()
public java.util.Map<java.lang.String,java.lang.String> convertHeadersToMap(Header[] headers)