public class BasicResponse
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,java.lang.String> |
basicData
The decoded API response
|
protected Config |
config
Configuration object for the API communication
|
protected java.util.Map<java.lang.String,java.lang.String> |
dataNormalized
The decoded API response
in a normal form (all keys converted to lowercase)
|
protected CommunicationFormat |
format
Output format from the API
|
protected java.lang.String |
rawData
The data received from the API in raw form (plain text)
|
protected java.lang.String |
signature
The Base64 encoded signature for the API response
|
Constructor and Description |
---|
BasicResponse(Config config,
java.lang.String rawData,
CommunicationFormat format) |
Modifier and Type | Method and Description |
---|---|
protected void |
decodeRawData()
Decodes the API response into a key => value structure.
|
protected void |
extractSignature()
Extract the Base64 encoded signature from
the decoded and normalized API response.
|
java.util.Map<java.lang.String,java.lang.String> |
getBasicData() |
Config |
getConfig() |
java.util.Map<java.lang.String,java.lang.String> |
getDataNormalized() |
CommunicationFormat |
getFormat() |
java.lang.String |
getRawData() |
protected byte[] |
getSignedData()
Concatenates all response parameters, so they can be used to recreate
the data, which was signed by the API.
|
StatusCode |
getStatusCode()
Returns the API response status code.
|
java.lang.String |
getStatusMessage()
Returns the API response status message.
|
protected void |
normalizeData()
Transforms the decoded response data into a normal form
(all the keys converted to lowercase).
|
void |
processApiResponse()
Decodes and normalizes the API response.
|
protected void |
verifySignature()
Verifies if the signature in the response is valid for the returned data.
|
protected final Config config
protected final java.lang.String rawData
protected final CommunicationFormat format
protected java.lang.String signature
protected java.util.Map<java.lang.String,java.lang.String> basicData
protected java.util.Map<java.lang.String,java.lang.String> dataNormalized
public BasicResponse(Config config, java.lang.String rawData, CommunicationFormat format) throws IPCException
IPCException
public void processApiResponse() throws IPCException
IPCException
- If the API response could not be decoded.
If the response signature could not be verified.public Config getConfig()
public java.lang.String getRawData()
public CommunicationFormat getFormat()
public java.util.Map<java.lang.String,java.lang.String> getBasicData()
public java.util.Map<java.lang.String,java.lang.String> getDataNormalized()
public StatusCode getStatusCode() throws IPCException
IPCException
- If there is no status code in the response data.
If the status code in the response is not
present in the status code definitions.public java.lang.String getStatusMessage()
protected void decodeRawData() throws IPCException
IPCException
- If the response could not be decoded.
If the communication format is not set, or invalid.protected byte[] getSignedData() throws IPCException
IPCException
- if the response data could not be decodedprotected void normalizeData()
protected void extractSignature()
protected void verifySignature() throws IPCException
IPCException
- If the signature in the response is missing or invalid.
If the signed data could not be verified
for being signed with the API private key.