CertificateValidatorImpl implements CertificateValidator { public boolean validate(String cert, String signedData, String signature) throws NoSuchAlgorithmException, IOException, Exception { byte[] certBytes = Base64.decode(cert); byte[] signedDataBytes = Base64.decode(signedData); byte[] signatureBytes = Base64.decode(signature); return validate(certBytes, signedDataBytes, signatureBytes); }  boolean validate(String cert, String signedData, String signature); boolean validate(byte[] certBytes, byte[] signedDataBytes,
			byte[] signatureBytes);  }
@Test public void basic() throws NoSuchAlgorithmException, Exception { Tags t = getTags(TestAssertions.getExampleRegAssertions()); CertificateValidatorImpl validator = new CertificateValidatorImpl(); boolean validate = validator.validate ( t.getTags().get(TagsEnum.TAG_ATTESTATION_CERT.id).value, getSignedData(t.getTags().get(TagsEnum.TAG_UAFV1_KRD.id)), t.getTags().get(TagsEnum.TAG_SIGNATURE.id).value); assertTrue(validate); }
@Test public void d() throws NoSuchAlgorithmException, Exception { Tags t = getTags(TestAssertions.getRegAssertionsFromD()); CertificateValidatorImpl validator = new CertificateValidatorImpl(); boolean validate = validator.validate ( t.getTags().get(TagsEnum.TAG_ATTESTATION_CERT.id).value, getSignedData(t.getTags().get(TagsEnum.TAG_UAFV1_KRD.id)), t.getTags().get(TagsEnum.TAG_SIGNATURE.id).value); assertTrue(validate); }
@Test public void sValidateTrue() throws NoSuchAlgorithmException, Exception { Tags t = getTags(TestAssertions.getRegAssertionsFromS()); CertificateValidatorImpl validator = new CertificateValidatorImpl(); boolean validate = validator.validate ( t.getTags().get(TagsEnum.TAG_ATTESTATION_CERT.id).value, getSignedData(t.getTags().get(TagsEnum.TAG_UAFV1_KRD.id)), t.getTags().get(TagsEnum.TAG_SIGNATURE.id).value); assertTrue(validate); }
@Test public void s2ValidateTrue() throws NoSuchAlgorithmException, Exception { Tags t = getTags(TestAssertions.getRegAssertionsFromS2()); CertificateValidatorImpl validator = new CertificateValidatorImpl(); boolean validate = validator.validate ( t.getTags().get(TagsEnum.TAG_ATTESTATION_CERT.id).value, getSignedData(t.getTags().get(TagsEnum.TAG_UAFV1_KRD.id)), t.getTags().get(TagsEnum.TAG_SIGNATURE.id).value); assertTrue(validate); }
@Test public void rsaValidateFalse() throws NoSuchAlgorithmException, Exception { Tags t = getTags(TestAssertions.regRequestAssertionsFromRaon()); CertificateValidatorImpl validator = new CertificateValidatorImpl(); boolean validate = validator.validate ( t.getTags().get(TagsEnum.TAG_ATTESTATION_CERT.id).value, getSignedData(t.getTags().get(TagsEnum.TAG_UAFV1_KRD.id)), t.getTags().get(TagsEnum.TAG_SIGNATURE.id).value); assertTrue(!validate); }