XROADValidationService implements ValidationService { @Override public Reports validateDocument(ValidationDocument validationDocument) { ValidationPolicy policy = signaturePolicyService.getPolicy(validationDocument.getSignaturePolicy()); final InputStream inputStream = new ByteArrayInputStream(Base64.decodeBase64(validationDocument.getDataBase64Encoded())); AsicContainer container; try { container = AsicContainer.read(inputStream); } catch (Exception e) { LOGGER.error("Unable to create AsicContainer from validation document", e); throw new MalformedDocumentException(e); } final AsicContainerVerifier verifier = new AsicContainerVerifier(container); try { verifier.verify(); return new XROADValidationReportBuilder(verifier, validationDocument, policy, reportConfigurationProperties.isReportSignatureEnabled()).build(); } catch (CodedException codedException) { return new XROADValidationReportBuilder(verifier, validationDocument, policy, reportConfigurationProperties.isReportSignatureEnabled(), codedException).build(); } catch (Exception e) { LOGGER.warn("There was an error validating the document", e); throw new ValidationServiceException(getClass().getSimpleName(), e); } }  @Override Reports validateDocument(ValidationDocument validationDocument); @Autowired void setProperties(XROADValidationServiceProperties properties); @Autowired @Qualifier(value = "XROADPolicyService") void setSignaturePolicyService(SignaturePolicyService<ValidationPolicy> signaturePolicyService); @Autowired void setReportConfigurationProperties(ReportConfigurationProperties reportConfigurationProperties);  }
@Test public void validatingInvalidBase64EncodedDocumentResultsInMalformedDocumentException() throws Exception { ValidationDocument doc = new ValidationDocument(); doc.setDataBase64Encoded("ASDASDAFGOAGMRASGMASPÖGLMOP"); expectedException.expect(MalformedDocumentException.class); expectedException.expectMessage(DOCUMENT_MALFORMED_MESSAGE); validationService.validateDocument(doc); }
@Test public void validatingValidBdocTSWithXroadValidatorResultsInMalformedDocumentException() throws Exception { ValidationDocument doc = buildValidationDocument(BDOC_TS_VALID); expectedException.expect(MalformedDocumentException.class); expectedException.expectMessage(DOCUMENT_MALFORMED_MESSAGE); validationService.validateDocument(doc); }
@Test public void validatingValidDDocWithXroadValidatorResultsInMalformedDocumentException() throws Exception { ValidationDocument doc = buildValidationDocument(DDOC_VALID); expectedException.expect(MalformedDocumentException.class); expectedException.expectMessage(DOCUMENT_MALFORMED_MESSAGE); validationService.validateDocument(doc); }
@Test public void validatingValidPdfWithXroadValidatorResultsInMalformedDocumentException() throws Exception { ValidationDocument doc = buildValidationDocument(PDF_VALID); expectedException.expect(MalformedDocumentException.class); expectedException.expectMessage(DOCUMENT_MALFORMED_MESSAGE); validationService.validateDocument(doc); }