LineSignatureValidator implements SignatureValidator { @Override public boolean validateSignature(@NonNull byte[] content, @NonNull String headerSignature) { final byte[] signature = generateSignature(content); final byte[] decodeHeaderSignature = Base64.getDecoder().decode(headerSignature); return MessageDigest.isEqual(decodeHeaderSignature, signature); } LineSignatureValidator(byte[] channelSecret); @Override boolean validateSignature(@NonNull byte[] content, @NonNull String headerSignature); byte[] generateSignature(@NonNull byte[] content);  }
@Test public void validateSignature() throws Exception { LineSignatureValidator lineSignatureValidator = new LineSignatureValidator( channelSecret.getBytes(StandardCharsets.UTF_8)); String httpRequestBody = "{}"; assertThat(lineSignatureValidator .validateSignature(httpRequestBody.getBytes(StandardCharsets.UTF_8), "3q8QXTAGaey18yL8FWTqdVlbMr6hcuNvM4tefa0o9nA=")) .isTrue(); assertThat(lineSignatureValidator .validateSignature(httpRequestBody.getBytes(StandardCharsets.UTF_8), "596359635963")) .isFalse(); }