Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 5ee7fc6d authored by Malo Toudic's avatar Malo Toudic
Browse files

Merge branch 'feature/LACPASS-10_display_json' into 'develop'

new ws to retrieve json

See merge request !3
parents 1c41c928 c28b0f9b
No related branches found
No related tags found
2 merge requests!4Develop,!3new ws to retrieve json
package net.ihe.gazelle.app.dccvalidator.application;
import net.ihe.gazelle.modelapi.dcc.v1_3_0.Eudcc;
import net.ihe.gazelle.modelapi.validation.business.InvalidObjectException;
import net.ihe.gazelle.modelapi.validation.business.ValidationOverview;
import net.ihe.gazelle.modelapi.validation.business.ValidationReport;
......@@ -15,8 +16,8 @@ public abstract class AbstractValidator extends Validator {
super(keyword, name, domain);
}
public abstract void validate(byte[] object) throws InvalidObjectException;
public abstract ValidationReport validate(byte[] object, ValidationOverview validationOverview);
public abstract ValidationReport validateWithReport(byte[] object, ValidationOverview validationOverview);
public abstract Eudcc decode(byte[] object) throws InvalidObjectException;
}
......@@ -10,6 +10,7 @@ import net.ihe.gazelle.app.dccvalidator.business.Concept;
import net.ihe.gazelle.app.dccvalidator.business.DCCValueSet;
import net.ihe.gazelle.app.dccvalidator.business.DecodingException;
import net.ihe.gazelle.app.dccvalidator.business.ValidationException;
import net.ihe.gazelle.modelapi.dcc.v1_3_0.Eudcc;
import net.ihe.gazelle.modelapi.validation.business.InvalidObjectException;
import net.ihe.gazelle.modelapi.validation.business.ValidationOverview;
import net.ihe.gazelle.modelapi.validation.business.ValidationReport;
......@@ -30,10 +31,9 @@ public class BasicDCCValidator extends AbstractValidator {
this.dccValueSets = dccValueSets;
}
@Override
public void validate(byte[] object) throws InvalidObjectException {
public Eudcc decode(byte[] object) throws InvalidObjectException {
try {
new CBOREncoderDecoderV130(dccValueSets).decodeAndValidate(
return new CBOREncoderDecoderV130(dccValueSets).decodeAndValidate(
new COSEEncoderDecoder(null, null, trustedCertificates).decodeAndValidate(
new ZLibEncoderDecoder().decodeAndValidate(
new Base45EncoderDecoder().decodeAndValidate(
......@@ -48,7 +48,7 @@ public class BasicDCCValidator extends AbstractValidator {
}
@Override
public ValidationReport validateWithReport(byte[] object, ValidationOverview validationOverview) {
public ValidationReport validate(byte[] object, ValidationOverview validationOverview) {
final ValidationReport validationReport = new ValidationReport(UUID.randomUUID().toString(), validationOverview);
try {
new CBOREncoderDecoderV130(dccValueSets).decodeAndReportValidation(
......
......@@ -51,7 +51,7 @@ public class BasicDCCValidatorTest {
@Test
public void simpleValidationTest() throws InvalidObjectException {
AbstractValidator validator = new BasicDCCValidator(cryptoLoader.getTrustedCertificates(), null);
Assertions.assertDoesNotThrow(() -> validator.validate(testResourceBarcodeDCC.getImageBytes()));
Assertions.assertDoesNotThrow(() -> validator.decode(testResourceBarcodeDCC.getImageBytes()));
}
}
......@@ -53,22 +53,16 @@ public class DCCValidationServiceWS implements ValidationServiceDTO {
@Override
@WebMethod
@WebResult(name = "valid")
public void validate(@WebParam(name = "object") byte[] object, @WebParam(name = "validator") String validatorKeyword)
throws UnkownValidatorException, InvalidObjectException {
try {
validationService.validate(object, validatorKeyword);
} catch (InvalidObjectException e) {
throw new InvalidObjectException(flattenExceptionCauseMessages(e));
}
@WebResult(name = "validationReport")
public ValidationReportDTO validate(@WebParam(name = "object") byte[] object, @WebParam(name = "validator") String validatorKeyword)
throws UnkownValidatorException {
return validationService.validate(object, validatorKeyword);
}
@Override
@WebMethod
@WebResult(name = "validationReport")
public ValidationReportDTO validateWithReport(@WebParam(name = "object") byte[] object, @WebParam(name = "validator") String validatorKeyword)
throws UnkownValidatorException {
return validationService.validateWithReport(object, validatorKeyword);
@WebResult(name = "decode")
public String decode(@WebParam(name = "object") byte[] object, @WebParam(name = "validator") String validatorKeyword ) throws UnkownValidatorException, InvalidObjectException {
return validationService.decode(object, validatorKeyword);
}
private String flattenExceptionCauseMessages(Throwable t) {
......
package net.ihe.gazelle.app.dccvalidatorservice.application;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import net.ihe.gazelle.app.dccvalidator.application.AbstractValidator;
import net.ihe.gazelle.app.dccvalidator.application.BasicDCCValidator;
import net.ihe.gazelle.modelapi.dcc.v1_3_0.Eudcc;
import net.ihe.gazelle.modelapi.validation.business.InvalidObjectException;
import net.ihe.gazelle.modelapi.validation.business.SeverityLevel;
import net.ihe.gazelle.modelapi.validation.business.UnkownValidatorException;
......@@ -45,14 +48,19 @@ public class DigitalCovidCertificateValidationService implements ValidationServi
}
@Override
public void validate(byte[] object, String validatorKeyword) throws UnkownValidatorException, InvalidObjectException {
getValidator(validatorKeyword).validate(object);
public ValidationReportDTO validate(byte[] object, String validatorKeyword) throws UnkownValidatorException {
ValidationReport validationReport = getValidator(validatorKeyword).validate(object, createValidationOverview(validatorKeyword));
return new ValidationReportDTO(validationReport, SeverityLevel.INFO);
}
@Override
public ValidationReportDTO validateWithReport(byte[] object, String validatorKeyword) throws UnkownValidatorException {
ValidationReport validationReport = getValidator(validatorKeyword).validateWithReport(object, createValidationOverview(validatorKeyword));
return new ValidationReportDTO(validationReport, SeverityLevel.INFO);
public String decode(byte[] object, String validatorKeyword) throws UnkownValidatorException, InvalidObjectException {
Eudcc eudcc = getValidator(validatorKeyword).decode(object);
try {
ObjectMapper mapper = new ObjectMapper();
return mapper.writeValueAsString( eudcc );
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
private AbstractValidator getValidator(String validatorKeyword) throws UnkownValidatorException {
......@@ -76,7 +84,7 @@ public class DigitalCovidCertificateValidationService implements ValidationServi
" See the License for the specific language governing permissions and\n" +
" limitations under the License.",
getName(),
"1.1.0-SNAPSHOT",
"1.0.0-SNAPSHOT",
validatorKeyword);
}
}
......@@ -33,7 +33,7 @@ public class DCCValidationserviceTest {
public void validateTest(String testDataName) {
JSONTestDataProvider testDataProvider = new JSONTestDataProvider(testDataName);
validationService = new DigitalCovidCertificateValidationService(testDataProvider, new ValueSetProviderForUT());
Assertions.assertDoesNotThrow(() -> validationService.validate(testDataProvider.getBarcodeImage(), "basic 1.0.0"));
Assertions.assertDoesNotThrow(() -> validationService.decode(testDataProvider.getBarcodeImage(), "basic 1.0.0"));
}
@ParameterizedTest
......@@ -41,12 +41,12 @@ public class DCCValidationserviceTest {
public void validateTestExpired(String testDataName) {
JSONTestDataProvider testDataProvider = new JSONTestDataProvider(testDataName);
validationService = new DigitalCovidCertificateValidationService(testDataProvider, new ValueSetProviderForUT());
Assertions.assertThrows(InvalidObjectException.class, () -> validationService.validate(testDataProvider.getBarcodeImage(), "basic 1.0.0"));
Assertions.assertThrows(InvalidObjectException.class, () -> validationService.decode(testDataProvider.getBarcodeImage(), "basic 1.0.0"));
}
@Test
public void unknownValidatorTest() {
Assertions.assertThrows(UnkownValidatorException.class, () -> validationService.validate(null, "unknown validator"));
Assertions.assertThrows(UnkownValidatorException.class, () -> validationService.decode(null, "unknown validator"));
}
}
......@@ -208,7 +208,7 @@
<dependency>
<groupId>net.ihe.gazelle</groupId>
<artifactId>modelapi.validation-jax-x</artifactId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.ihe.gazelle</groupId>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment