Class ApiResponseSignatureVerifier


  • public class ApiResponseSignatureVerifier
    extends java.lang.Object
    The ApiResponseSignatureVerifier class is responsible for verifying Cloudinary Upload API response signatures.
    • Constructor Summary

      Constructors 
      Constructor Description
      ApiResponseSignatureVerifier​(java.lang.String secretKey)
      Initializes new instance of ApiResponseSignatureVerifier class with a secret key required to perform API response signatures verification.
      ApiResponseSignatureVerifier​(java.lang.String secretKey, SignatureAlgorithm signatureAlgorithm)
      Initializes new instance of ApiResponseSignatureVerifier class with a secret key required to perform API response signatures verification.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean verifySignature​(java.lang.String publicId, java.lang.String version, java.lang.String signature)
      Checks whether particular Cloudinary Upload API response signature matches expected signature.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ApiResponseSignatureVerifier

        public ApiResponseSignatureVerifier​(java.lang.String secretKey)
        Initializes new instance of ApiResponseSignatureVerifier class with a secret key required to perform API response signatures verification.
        Parameters:
        secretKey - shared secret key string which is used to sign and verify authenticity of API responses
      • ApiResponseSignatureVerifier

        public ApiResponseSignatureVerifier​(java.lang.String secretKey,
                                            SignatureAlgorithm signatureAlgorithm)
        Initializes new instance of ApiResponseSignatureVerifier class with a secret key required to perform API response signatures verification.
        Parameters:
        secretKey - shared secret key string which is used to sign and verify authenticity of API responses
        signatureAlgorithm - type of hashing algorithm to use for calculation of HMACs
    • Method Detail

      • verifySignature

        public boolean verifySignature​(java.lang.String publicId,
                                       java.lang.String version,
                                       java.lang.String signature)
        Checks whether particular Cloudinary Upload API response signature matches expected signature. The task is performed by generating signature using same hashing algorithm as used on Cloudinary servers and comparing the result with provided actual signature.
        Parameters:
        publicId - public id of uploaded resource as stated in upload API response
        version - version of uploaded resource as stated in upload API response
        signature - signature of upload API response, usually passed via X-Cld-Signature custom HTTP response header
        Returns:
        true if response signature passed verification procedure