Class Util
- java.lang.Object
-
- com.cloudinary.Util
-
public class Util extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Map<java.lang.String,java.lang.Object>
buildArchiveParams(java.util.Map options, java.lang.String targetFormat)
protected static java.lang.String
buildCustomHeaders(java.lang.Object headers)
protected static java.lang.String
buildEager(java.util.List<? extends Transformation> transformations)
static java.util.Map<java.lang.String,java.lang.Object>
buildGenerateSpriteParams(java.util.Map options)
static java.util.Map
buildMultiParams(java.util.Map options)
static java.util.Map<java.lang.String,java.lang.Object>
buildUploadParams(java.util.Map options)
static void
clearEmpty(java.util.Map params)
protected static java.lang.String
encodeAccessControl(java.lang.Object accessControl)
protected static java.lang.String
encodeContext(java.lang.Object context)
static byte[]
getUTF8Bytes(java.lang.String string)
Encodes passed string value into a sequence of bytes using the UTF-8 charset.static byte[]
hash(java.lang.String input, SignatureAlgorithm signatureAlgorithm)
Computes hash from input string using specified algorithm.static void
processWriteParameters(java.util.Map<java.lang.String,java.lang.Object> options, java.util.Map<java.lang.String,java.lang.Object> params)
static java.lang.String
produceSignature(java.util.Map<java.lang.String,java.lang.Object> paramsToSign, java.lang.String apiSecret)
Calculates signature, or hashed message authentication code (HMAC) of provided parameters name-value pairs and secret value using default hashing algorithm (SHA1).static java.lang.String
produceSignature(java.util.Map<java.lang.String,java.lang.Object> paramsToSign, java.lang.String apiSecret, SignatureAlgorithm signatureAlgorithm)
Calculates signature, or hashed message authentication code (HMAC) of provided parameters name-value pairs and secret value using specified hashing algorithm.protected static java.lang.String
timestamp()
-
-
-
Method Detail
-
buildUploadParams
public static final java.util.Map<java.lang.String,java.lang.Object> buildUploadParams(java.util.Map options)
-
buildMultiParams
public static java.util.Map buildMultiParams(java.util.Map options)
-
buildGenerateSpriteParams
public static java.util.Map<java.lang.String,java.lang.Object> buildGenerateSpriteParams(java.util.Map options)
-
buildEager
protected static final java.lang.String buildEager(java.util.List<? extends Transformation> transformations)
-
processWriteParameters
public static final void processWriteParameters(java.util.Map<java.lang.String,java.lang.Object> options, java.util.Map<java.lang.String,java.lang.Object> params)
-
encodeAccessControl
protected static java.lang.String encodeAccessControl(java.lang.Object accessControl)
-
encodeContext
protected static java.lang.String encodeContext(java.lang.Object context)
-
buildCustomHeaders
protected static final java.lang.String buildCustomHeaders(java.lang.Object headers)
-
clearEmpty
public static void clearEmpty(java.util.Map params)
-
buildArchiveParams
public static final java.util.Map<java.lang.String,java.lang.Object> buildArchiveParams(java.util.Map options, java.lang.String targetFormat)
-
timestamp
protected static java.lang.String timestamp()
-
getUTF8Bytes
public static byte[] getUTF8Bytes(java.lang.String string)
Encodes passed string value into a sequence of bytes using the UTF-8 charset.- Parameters:
string
- string value to encode- Returns:
- byte array representing passed string value
-
produceSignature
public static java.lang.String produceSignature(java.util.Map<java.lang.String,java.lang.Object> paramsToSign, java.lang.String apiSecret)
Calculates signature, or hashed message authentication code (HMAC) of provided parameters name-value pairs and secret value using default hashing algorithm (SHA1).Argument for hashing function is built by joining sorted parameter name-value pairs into single string in the same fashion as HTTP GET method uses, and concatenating the result with secret value in the end. Method supports arrays/collections as parameter values. In this case, the elements of array/collection are joined into single comma-delimited string prior to inclusion into the result.
- Parameters:
paramsToSign
- parameter name-value pairs list represented as instance ofMap
apiSecret
- secret value- Returns:
- hex-string representation of signature calculated based on provided parameters map and secret
-
produceSignature
public static java.lang.String produceSignature(java.util.Map<java.lang.String,java.lang.Object> paramsToSign, java.lang.String apiSecret, SignatureAlgorithm signatureAlgorithm)
Calculates signature, or hashed message authentication code (HMAC) of provided parameters name-value pairs and secret value using specified hashing algorithm.Argument for hashing function is built by joining sorted parameter name-value pairs into single string in the same fashion as HTTP GET method uses, and concatenating the result with secret value in the end. Method supports arrays/collections as parameter values. In this case, the elements of array/collection are joined into single comma-delimited string prior to inclusion into the result.
- Parameters:
paramsToSign
- parameter name-value pairs list represented as instance ofMap
apiSecret
- secret valuesignatureAlgorithm
- type of hashing algorithm to use for calculation of HMAC- Returns:
- hex-string representation of signature calculated based on provided parameters map and secret
-
hash
public static byte[] hash(java.lang.String input, SignatureAlgorithm signatureAlgorithm)
Computes hash from input string using specified algorithm.- Parameters:
input
- string which to compute hash fromsignatureAlgorithm
- algorithm to use for computing hash- Returns:
- array of bytes of computed hash value
-
-