code: byte[] createSignatureFor(String algorithm, PrivateKey privateKey, byte[] headerBytes, byte[] payloadBytes) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException {
          final Signature s = Signature.getInstance(algorithm);
          s.initSign(privateKey);
          s.update(headerBytes);
          s.update(JWT_PART_SEPARATOR);
          s.update(payloadBytes);
          return s.sign();
      }
docs: Create signature for JWT header and payload using a private key.
  
  @param algorithm algorithm name.
  @param privateKey the private key to use for signing.
  @param headerBytes JWT header.
  @param payloadBytes JWT payload.
  @return the signature bytes.
  @throws NoSuchAlgorithmException if the algorithm is not supported.
  @throws InvalidKeyException if the given key is inappropriate for initializing the specified algorithm.
  @throws SignatureException if this signature object is not initialized properly or if this signature algorithm is unable to process the input data provided.