Class NetStorageUtils
java.lang.Object
org.frankframework.extensions.akamai.NetStorageUtils
General utility functions needed to implement the HTTP SDK. Many of these functions are also
available as standard parts of other libraries, but this package strives to operate without any
external dependencies.
- Author:
- colinb@akamai.com (Colin Bendell)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
An enum of the keyed-hash algorithms supported bycomputeKeyedHash(byte[], String, NetStorageUtils.KeyedHashAlgorithm)
Currently supported hashes include HMAC-MD5; HMAC-SHA1; HMAC-SHA256 The string representation matches the javaMac.getInstance(String)
cononical names. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
computeKeyedHash
(byte[] data, String key, NetStorageUtils.KeyedHashAlgorithm hashType) Computes the HMAC hash of a given byte[].static String
convertMapAsQueryParams
(Map<String, String> data) ConvertMap<String, String>
into aname=value
query params string.
-
Constructor Details
-
NetStorageUtils
public NetStorageUtils()
-
-
Method Details
-
computeKeyedHash
public static byte[] computeKeyedHash(@Nonnull byte[] data, String key, NetStorageUtils.KeyedHashAlgorithm hashType) Computes the HMAC hash of a given byte[]. This is a wrapper over the Mac crypto functions.- Parameters:
data
- byte[] of content to hashkey
- secret key to salt the hashhashType
- determines which algorithm to use. The recommendation is to use HMAC-SHA256- Returns:
- a byte[] presenting the HMAC hash of the source data.
-
convertMapAsQueryParams
ConvertMap<String, String>
into aname=value
query params string. NB: This uses URLEncoding - not URI Encoding for escaping name and values. This shouldn't be an issue for most uses of this function for the Netstorage API, but could impact non-ascii usernames in the future.- Parameters:
data
- a Key-Value map- Returns:
- a query params encoded string in the form of
name=value&name2=value2...
-