Class HmacUtil

java.lang.Object
io.hanko.sdk.util.HmacUtil

public class HmacUtil extends Object
Utility class for providing an authorization header to use for making authenticated calls to the Hanko API.
See Also:
Hanko API security
  • Method Details

    • makeAuthorizationHeader

      public static String makeAuthorizationHeader(String apiSecret, String apiKeyId, String method, String path, String content)
      Construct a suitable authorization header for a request to the Hanko API.

      If no apiKeyId is given, the header value consists of the `secret` prefix and the apiSecret as a token value. Otherwise the header value consist of the `hanko` prefix, and a base64 encoded JSON representation including an HMAC signature as the token value.

      Parameters:
      apiSecret - the Hanko API key as a String
      apiKeyId - the Hanko API key ID as a String
      method - the HTTP method name used in the request
      path - the endpoint path for the request as a String
      content - the request body content (if any)
      Returns:
      the complete authorization header as a String
      Throws:
      HankoClientException - if the HMAC could not be calculated