From 79bc2508f859ff2e930fa4e22f9853588eb79c0b Mon Sep 17 00:00:00 2001 From: Alexander Schwarz Date: Wed, 22 Sep 2021 10:28:06 +0200 Subject: [PATCH 1/2] change status endpoint code to 204 if no subject or service found --- .gitignore | 1 + .../decorator/service/ValidationStatusService.java | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0af2f6d..7ff7c6b 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,4 @@ build/ .settings.xml /bin/ src/main/resources/application-local-cf.yml +src/main/resources/application-localcf.yml diff --git a/src/main/java/eu/europa/ec/dgc/validation/decorator/service/ValidationStatusService.java b/src/main/java/eu/europa/ec/dgc/validation/decorator/service/ValidationStatusService.java index d82b488..32e96e5 100644 --- a/src/main/java/eu/europa/ec/dgc/validation/decorator/service/ValidationStatusService.java +++ b/src/main/java/eu/europa/ec/dgc/validation/decorator/service/ValidationStatusService.java @@ -30,6 +30,7 @@ import eu.europa.ec.dgc.validation.decorator.entity.ValidationServiceIdentityResponse; import eu.europa.ec.dgc.validation.decorator.entity.ValidationServiceIdentityResponse.PublicKeyJwk; import eu.europa.ec.dgc.validation.decorator.entity.ValidationServiceStatusResponse; +import eu.europa.ec.dgc.validation.decorator.exception.DccException; import eu.europa.ec.dgc.validation.decorator.exception.NotFoundException; import eu.europa.ec.dgc.validation.decorator.exception.RepositoryException; import eu.europa.ec.dgc.validation.decorator.exception.UncheckedCertificateException; @@ -80,14 +81,14 @@ public class ValidationStatusService { public ValidationServiceStatusResponse determineStatus(final String subject) { final ServiceTokenContentResponse tokenContent = this.getBackendTokenContent(subject); if (tokenContent.getSubjects() == null || tokenContent.getSubjects().isEmpty()) { - throw new NotFoundException("Subject not found in token"); + throw new DccException("Subject not found in token", HttpStatus.NO_CONTENT.value()); } final SubjectResponse subjectResponse = tokenContent.getSubjects().get(0); final String serviceId = subjectResponse.getServiceIdUsed(); log.debug("Receive service ID (encoded) from booking service '{}'", serviceId); if (serviceId == null || serviceId.isBlank()) { - throw new NotFoundException(String.format("Passenger without service ID '%s'", serviceId)); + throw new DccException(String.format("Subject without service ID '%s'", serviceId), HttpStatus.NO_CONTENT.value()); } final String decodedServiceId = new String(Base64.getUrlDecoder().decode(serviceId), StandardCharsets.UTF_8); From 73b7f818957a560e53370a4c37ccee7bb42325d6 Mon Sep 17 00:00:00 2001 From: Alexander Schwarz Date: Wed, 22 Sep 2021 10:32:00 +0200 Subject: [PATCH 2/2] fix code style --- .../validation/decorator/service/ValidationStatusService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/europa/ec/dgc/validation/decorator/service/ValidationStatusService.java b/src/main/java/eu/europa/ec/dgc/validation/decorator/service/ValidationStatusService.java index 32e96e5..0172dce 100644 --- a/src/main/java/eu/europa/ec/dgc/validation/decorator/service/ValidationStatusService.java +++ b/src/main/java/eu/europa/ec/dgc/validation/decorator/service/ValidationStatusService.java @@ -88,7 +88,8 @@ public ValidationServiceStatusResponse determineStatus(final String subject) { final String serviceId = subjectResponse.getServiceIdUsed(); log.debug("Receive service ID (encoded) from booking service '{}'", serviceId); if (serviceId == null || serviceId.isBlank()) { - throw new DccException(String.format("Subject without service ID '%s'", serviceId), HttpStatus.NO_CONTENT.value()); + throw new DccException(String.format("Subject without service ID '%s'", serviceId), + HttpStatus.NO_CONTENT.value()); } final String decodedServiceId = new String(Base64.getUrlDecoder().decode(serviceId), StandardCharsets.UTF_8);