public final class SignatureHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
RAW_SIGNATURE_FORMAT
The device ID will be the prefix.
|
static Charset |
SIGNATURE_CHARSET
The charset used for the raw and hashed signature.
|
| Modifier | Constructor and Description |
|---|---|
protected |
SignatureHelper() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
buildRawSignature(String resourceUri,
long expiryTime)
Builds the raw signature.
|
static byte[] |
decodeDeviceKeyBase64(String deviceKey)
Decodes the deviceKey using Base64.
|
static byte[] |
encodeSignatureBase64(byte[] sig)
Encodes the signature using Base64 and then further
encodes the resulting string using UTF-8 encoding.
|
static String |
encodeSignatureUtf8(byte[] sig)
Encodes the signature using charset UTF-8.
|
static String |
encodeSignatureWebSafe(String sig)
Safely escapes characters in the signature so that they can be
transmitted over the internet.
|
static byte[] |
encryptSignatureHmacSha256(byte[] sig,
byte[] deviceKey)
Encrypts the signature using HMAC-SHA256.
|
public static final String RAW_SIGNATURE_FORMAT
public static final Charset SIGNATURE_CHARSET
public static byte[] buildRawSignature(String resourceUri, long expiryTime)
resourceUri - the resource URI.expiryTime - the signature expiry time, as a UNIX timestamp.public static byte[] decodeDeviceKeyBase64(String deviceKey)
deviceKey - the device key.public static byte[] encryptSignatureHmacSha256(byte[] sig,
byte[] deviceKey)
sig - the unencrypted signature.deviceKey - the Base64-decoded device key.public static byte[] encodeSignatureBase64(byte[] sig)
sig - the HMAC-SHA256 encrypted signature.public static String encodeSignatureUtf8(byte[] sig)
sig - the HMAC-SHA256 encrypted, Base64-encoded signature.public static String encodeSignatureWebSafe(String sig)
sig - the HMAC-SHA256 encrypted, Base64-encoded, UTF-8 encoded
signature.Copyright © 2017. All rights reserved.