Class JoseHttpSigner

java.lang.Object
com.authlete.hms.impl.JoseHttpSigner
All Implemented Interfaces:
HttpSigner

public class JoseHttpSigner extends Object implements HttpSigner
An HttpSigner implementation for JWS algorithms.
See Also:
  • Constructor Details

    • JoseHttpSigner

      public JoseHttpSigner(JWK key)
      A constructor with a key for signing.

      An algorithm needs to be specified by the alg parameter in the JWK.

      Parameters:
      key - A signing key. This must be a private key.
      Throws:
      IllegalArgumentException - The key is null, is not a private key, or does not contain the alg parameter.
    • JoseHttpSigner

      public JoseHttpSigner(JWK key, JWSAlgorithm alg)
      A constructor with a key and algorithm for signing.

      An algorithm needs to be specified by either the alg argument passed to this method or the alg parameter in the JWK. When both means are used, the specified algorithms must be identical.

      Parameters:
      key - A signing key. This must be a private key.
      alg - An algorithm for signing.
      Throws:
      IllegalArgumentException - The key is null, is not a private key, or the alg parameter of the key does not match the algorithm specified by the alg argument. Or, the key does not contain the alg parameter and the alg argument is null.
  • Method Details

    • sign

      public byte[] sign(byte[] signatureBase) throws SignatureException
      Description copied from interface: HttpSigner
      Sign the signature base (= create a signature).
      Specified by:
      sign in interface HttpSigner
      Parameters:
      signatureBase - The signature base to be signed.
      Returns:
      The resulting signature.
      Throws:
      SignatureException - An error occurred during the signing process.
    • getKey

      public JWK getKey()
      Get the key.
      Returns:
      The key.
    • getAlg

      public JWSAlgorithm getAlg()
      Get the algorithm.
      Returns:
      The algorithm.