Class MACProvider

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Set<JWSAlgorithm> SUPPORTED_ALGORITHMS
      The supported JWS algorithms by the MAC provider class.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected MACProvider​(byte[] secret, java.util.Set<JWSAlgorithm> supportedAlgs)
      Creates a new Message Authentication (MAC) provider.
    • Field Detail

      • SUPPORTED_ALGORITHMS

        public static final java.util.Set<JWSAlgorithm> SUPPORTED_ALGORITHMS
        The supported JWS algorithms by the MAC provider class.
    • Constructor Detail

      • MACProvider

        protected MACProvider​(byte[] secret,
                              java.util.Set<JWSAlgorithm> supportedAlgs)
                       throws KeyLengthException
        Creates a new Message Authentication (MAC) provider.
        Parameters:
        secret - The secret. Must be at least 256 bits long and not null.
        supportedAlgs - The supported HMAC algorithms. Must not be null.
        Throws:
        KeyLengthException - If the secret length is shorter than the minimum 256-bit requirement.
    • Method Detail

      • getJCAAlgorithmName

        protected static java.lang.String getJCAAlgorithmName​(JWSAlgorithm alg)
                                                       throws JOSEException
        Gets the matching Java Cryptography Architecture (JCA) algorithm name for the specified HMAC-based JSON Web Algorithm (JWA).
        Parameters:
        alg - The JSON Web Algorithm (JWA). Must be supported and not null.
        Returns:
        The matching JCA algorithm name.
        Throws:
        JOSEException - If the algorithm is not supported.
      • getSecretKey

        public javax.crypto.SecretKey getSecretKey()
        Gets the secret key.
        Returns:
        The secret key.
      • getSecret

        public byte[] getSecret()
        Gets the secret bytes.
        Returns:
        The secret bytes.
      • getSecretString

        public java.lang.String getSecretString()
        Gets the secret as a UTF-8 encoded string.
        Returns:
        The secret as a UTF-8 encoded string.