DocumentHashVerificationRule extends BaseRule { public VerificationErrorCode getErrorCode() { return VerificationErrorCode.GEN_01; }  VerificationResultCode verifySignature(VerificationContext context); VerificationErrorCode getErrorCode();  }
@Test public void testSignatureVerificationWithoutDocumentHashReturnsOkStatus_Ok() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_2017_03_14))); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.OK); Assert.assertNull(result.getErrorCode()); }
@Test public void testSignatureVerificationWithInvalidDocumentHashReturnsOkStatus_Ok() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_2017_03_14), new DataHash(HashAlgorithm.SHA2_256, new byte[32]))); Assert.assertEquals(result.getResultCode(), VerificationResultCode.FAIL); Assert.assertEquals(result.getErrorCode(), VerificationErrorCode.GEN_01); }
@Test public void testSignatureVerificationWithInvalidRfc3161OutputHashReturnsFailStatus_Ok() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(RFC3161_SIGNATURE), new DataHash(HashAlgorithm.SHA2_256, new byte[32]))); Assert.assertEquals(result.getResultCode(), VerificationResultCode.FAIL); Assert.assertEquals(result.getErrorCode(), VerificationErrorCode.GEN_01); }