/** * Get an encrypted version of a {@link Policy} to use as a signature. * * @param policy * {@link Policy} that needs to be encrypted. * @param encryptionKey * The key to use to encrypt the {@link Policy}. * @return An encrypted version of the {@link Policy} that is also Base64 encoded to make it safe to transmit as a * query parameter. * @throws Exception * Thrown if there is a problem encrypting or encoding the {@link Policy} */ public static String getPolicySignature(Policy policy, String encryptionKey) throws Exception { return SHA256Util.digest(PolicyUtils.toJson(policy).toJSONString(), encryptionKey); } }