@Test public void testVerifyPayload() throws FMSException { boolean result = webhooksService.verifyPayload("1234", payload); Assert.assertFalse(result); result = webhooksService.verifyPayload(intuitSignature, payload); Assert.assertTrue(result); }
public boolean verifyPayload(String intuitSignature, String payload) { try { SecretKeySpec secretKey = new SecretKeySpec(getVerifierKey().getBytes("UTF-8"), ALGORITHM); Mac mac = Mac.getInstance(ALGORITHM); mac.init(secretKey); String hash = DatatypeConverter.printBase64Binary(mac.doFinal(payload.getBytes())); return hash.equals(intuitSignature); } catch (NoSuchAlgorithmException e) { LOG.error("NoSuchAlgorithmException while validating payload", e); return false; } catch (UnsupportedEncodingException e) { LOG.error("UnsupportedEncodingException while validating payload", e); return false; } catch (InvalidKeyException e) { LOG.error("InvalidKeyException validating payload", e); return false; } }
WebhooksService { public boolean verifyPayload(String intuitSignature, String payload) { try { SecretKeySpec secretKey = new SecretKeySpec(getVerifierKey().getBytes("UTF-8"), ALGORITHM); Mac mac = Mac.getInstance(ALGORITHM); mac.init(secretKey); String hash = DatatypeConverter.printBase64Binary(mac.doFinal(payload.getBytes())); return hash.equals(intuitSignature); } catch (NoSuchAlgorithmException e) { LOG.error("NoSuchAlgorithmException while validating payload", e); return false; } catch (UnsupportedEncodingException e) { LOG.error("UnsupportedEncodingException while validating payload", e); return false; } catch (InvalidKeyException e) { LOG.error("InvalidKeyException validating payload", e); return false; } } }
WebhooksService { public boolean verifyPayload(String intuitSignature, String payload) { try { SecretKeySpec secretKey = new SecretKeySpec(getVerifierKey().getBytes("UTF-8"), ALGORITHM); Mac mac = Mac.getInstance(ALGORITHM); mac.init(secretKey); String hash = DatatypeConverter.printBase64Binary(mac.doFinal(payload.getBytes())); return hash.equals(intuitSignature); } catch (NoSuchAlgorithmException e) { LOG.error("NoSuchAlgorithmException while validating payload", e); return false; } catch (UnsupportedEncodingException e) { LOG.error("UnsupportedEncodingException while validating payload", e); return false; } catch (InvalidKeyException e) { LOG.error("InvalidKeyException validating payload", e); return false; } }  }
WebhooksService { public boolean verifyPayload(String intuitSignature, String payload) { try { SecretKeySpec secretKey = new SecretKeySpec(getVerifierKey().getBytes("UTF-8"), ALGORITHM); Mac mac = Mac.getInstance(ALGORITHM); mac.init(secretKey); String hash = DatatypeConverter.printBase64Binary(mac.doFinal(payload.getBytes())); return hash.equals(intuitSignature); } catch (NoSuchAlgorithmException e) { LOG.error("NoSuchAlgorithmException while validating payload", e); return false; } catch (UnsupportedEncodingException e) { LOG.error("UnsupportedEncodingException while validating payload", e); return false; } catch (InvalidKeyException e) { LOG.error("InvalidKeyException validating payload", e); return false; } }  boolean verifyPayload(String intuitSignature, String payload); WebhooksEvent getWebhooksEvent(String payload); }
WebhooksService { public boolean verifyPayload(String intuitSignature, String payload) { try { SecretKeySpec secretKey = new SecretKeySpec(getVerifierKey().getBytes("UTF-8"), ALGORITHM); Mac mac = Mac.getInstance(ALGORITHM); mac.init(secretKey); String hash = DatatypeConverter.printBase64Binary(mac.doFinal(payload.getBytes())); return hash.equals(intuitSignature); } catch (NoSuchAlgorithmException e) { LOG.error("NoSuchAlgorithmException while validating payload", e); return false; } catch (UnsupportedEncodingException e) { LOG.error("UnsupportedEncodingException while validating payload", e); return false; } catch (InvalidKeyException e) { LOG.error("InvalidKeyException validating payload", e); return false; } }  boolean verifyPayload(String intuitSignature, String payload); WebhooksEvent getWebhooksEvent(String payload);  }