Signature

Generating a Signature

getSignatureKey

Use the getSignatureKey method to generate a signature

import smile.identity.core.Signature;

/*
 You have two options for generating a signature:
 You can provide a timestamp string or we will generate a signature
 using the current time as the timestamp.
*/

// calling method without providing timestamp
Signature signature = new Signature(partnerId, apiKey);
SignatureKey key = signature.getSignatureKey();
String timestamp = key.getTimestamp();
String signature = key.getSignature();
// you can print the timestamp used in calculating your signature

// providing your own timestamp
Signature signature = new Signature(partnerId, apiKey);
String isoTimestamp = "2023-03-13T13:25:35.984437Z"; // ISO format or use String timestamp = Instant.now().toString();
SignatureKey key = signature.getSignatureKey(isoTimestamp);
String timestamp = key.getTimestamp();
String signature = key.getSignature();

Confirming an Incoming Signature

confirmSignature

Use the confirmSignature method to confirm the signature you receive while interacting with our servers.

Pass in the timestamp that was returned and the signature String. The method will return a boolean value. True for confirmed and False for unconfirmed

import smile.identity.core.Signature;

Signature signature = new Signature(partnerId, apiKey);
boolean signatureConfirmed = signature.confirmSignature(timestamp, "receivedSignatureString");

Last updated