Signature Class
To calculate your signature first import the necessary class:
import smile.identity.core.Signature;
generate_sec_key method
Then call the Signature class as follows:
import smile.identity.core.Signature;try {Signature connection = new Signature(partner_id, api_key);String signatureJsonStr = connection.generate_sec_key(timestamp); // where timestamp is optional// In order to utilise the signature you can then use a json parser and extract the signature} catch (Exception e) {e.printStackTrace();throw e;}
The response will be a stringified json object:
{sec_key: "<the generated sec key>",timestamp: "<timestamp that you passed in or that was generated>"}
confirm_sec_key method
You can also confirm the signature that you receive when you interacting with our servers, simply use the confirm_sec_key method which returns a boolean:
import smile.identity.core.Signature;try {Signature connection = new Signature(partner_id, api_key);String signatureJsonStr = connection.confirm_sec_key(sec_key, timestamp);// If it is valid then use the response, else throw an error} catch (Exception e) {e.printStackTrace();throw e;}