public class NetStorageCMSv35Signer extends Object implements RequestSigner
| Modifier and Type | Class and Description |
|---|---|
static class |
NetStorageCMSv35Signer.NetStorageType
There are multiple types of Net Storage.
|
static class |
NetStorageCMSv35Signer.SignType
Currently only 3 signing hash types are supported.
|
| Constructor and Description |
|---|
NetStorageCMSv35Signer(String method,
URL url,
APIEventBean params)
Primary invocation for an API communication.
|
NetStorageCMSv35Signer(String method,
URL url,
APIEventBean params,
InputStream uploadStream,
long uploadSize)
Primary invocation for an API communication.
|
| Modifier and Type | Method and Description |
|---|---|
Map<String,String> |
computeHeaders(ClientCredential credential)
Assmembles the HTTP Headers necessary for API communication
|
InputStream |
execute(ClientCredential credential) |
InputStream |
execute(HttpURLConnection request,
ClientCredential credential)
Opens the connection to Netstorage, assembles the signing headers and uploads any files.
|
protected String |
getActionHeaderValue()
Computes the value for the the X-Akamai-ACS-Action: header.
|
protected String |
getAuthDataHeaderValue(ClientCredential credential)
Constructs the X-Akamai-ACS-Auth-Data header which contains the signing version, the current time, a random number
and the username that is used to sign the data.
|
protected String |
getAuthSignHeaderValue(String action,
String authData,
ClientCredential credential)
Computes the X-Akamai-ACS-Auth-Sign header for a given Action and Data header values.
|
String |
getMethod() |
APIEventBean |
getParams() |
NetStorageCMSv35Signer.SignType |
getSignVersion() |
long |
getUploadSize() |
InputStream |
getUploadStream() |
URL |
getUrl() |
void |
setMethod(String method) |
void |
setParams(APIEventBean params) |
void |
setSignVersion(NetStorageCMSv35Signer.SignType signVersion) |
void |
setUploadSize(long uploadSize) |
void |
setUploadStream(InputStream uploadStream) |
void |
setUrl(URL url) |
HttpURLConnection |
sign(HttpURLConnection request,
ClientCredential credential)
Signs a request with the client credential.
|
boolean |
validate(HttpURLConnection connection)
Attempt to validate the response and detect common causes of errors.
|
public NetStorageCMSv35Signer(String method, URL url, APIEventBean params)
method - an HTTP verb (GET, POST, PUT)url - the url to interact with (eg: http://example.akamaihd.net/254462 )params - the set of bean parameters to be sent in the API requestpublic NetStorageCMSv35Signer(String method, URL url, APIEventBean params, InputStream uploadStream, long uploadSize)
Generally, we don't expose that there are other sign versions available and assume it will be HMac-SHA256. However, this can be overridden in the setSignVersion() method;
method - an HTTP verb (GET, POST, PUT)url - the url to interact with (eg: http://example.akamaihd.net/254462 )params - the set of bean parameters to be sent in the API requestuploadStream - the inputStream to read the bytes to uploaduploadSize - if available, the total size of the inputStream. Note, that this could be different than the Size parameter in the action linepublic String getMethod()
public void setMethod(String method)
public URL getUrl()
public void setUrl(URL url)
public APIEventBean getParams()
public void setParams(APIEventBean params)
public InputStream getUploadStream()
public void setUploadStream(InputStream uploadStream)
public long getUploadSize()
public void setUploadSize(long uploadSize)
public NetStorageCMSv35Signer.SignType getSignVersion()
public void setSignVersion(NetStorageCMSv35Signer.SignType signVersion)
protected String getActionHeaderValue()
APIEventBeanprotected String getAuthDataHeaderValue(ClientCredential credential)
credential - client credentialsprotected String getAuthSignHeaderValue(String action, String authData, ClientCredential credential)
action - action header values getActionHeaderValue()authData - data header values getAuthDataHeaderValue(ClientCredential credential)credential - user credentialspublic Map<String,String> computeHeaders(ClientCredential credential)
credential - user credentialspublic boolean validate(HttpURLConnection connection) throws NetStorageException, IOException
TODO: catch rate limitting errors. Should delay and retry.
connection - an open url connectionNetStorageException - wrapped exception if it is a recoverable exceptionIOException - shouldn't be called at this point, but could be triggered when interrogating the responsepublic HttpURLConnection sign(HttpURLConnection request, ClientCredential credential) throws RequestSigningException
RequestSignersign in interface RequestSignerrequest - the request to sign.credential - the credential used in the signing.RequestSigningException - signing exceptionpublic InputStream execute(HttpURLConnection request, ClientCredential credential) throws RequestSigningException
execute in interface RequestSignerrequest - an open requestcredential - user credentialsRequestSigningException - if an error occurred during the communicationpublic InputStream execute(ClientCredential credential) throws RequestSigningException
execute in interface RequestSignerRequestSigningExceptionCopyright © 2016. All rights reserved.