diff --git a/.run/CCManagementServiceApplication.run.xml b/.run/CCManagementServiceApplication.run.xml
index 86d8635e..400f937e 100644
--- a/.run/CCManagementServiceApplication.run.xml
+++ b/.run/CCManagementServiceApplication.run.xml
@@ -15,4 +15,4 @@
-
\ No newline at end of file
+
diff --git a/pom.xml b/pom.xml
index 3be9c8c4..65b01672 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
ch.admin.bag.covidcertificate
cc-management-service
- 4.3.3
+ 4.4.6
cc-management-service
Service for generating Covid Certificates
diff --git a/src/main/java/ch/admin/bag/covidcertificate/CCManagementServiceApplication.java b/src/main/java/ch/admin/bag/covidcertificate/CCManagementServiceApplication.java
index fd116e46..7405180a 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/CCManagementServiceApplication.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/CCManagementServiceApplication.java
@@ -8,6 +8,7 @@
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.util.StringUtils;
import java.util.Objects;
@@ -19,29 +20,33 @@
@Slf4j
public class CCManagementServiceApplication {
- public static void main(String[] args) {
-
- String filePath= Objects.requireNonNull(Thread.currentThread()
- .getContextClassLoader().getResource("truststore.jks")).getFile();
- System.setProperty("javax.net.ssl.trustStore", filePath);
- System.setProperty("javax.net.ssl.trustStorePassword","changeit");
-
- Environment env = SpringApplication.run(CCManagementServiceApplication.class, args).getEnvironment();
-
- String protocol = "http";
- if (env.getProperty("server.ssl.key-store") != null) {
- protocol = "https";
- }
- log.info("\n----------------------------------------------------------\n\t" +
- "Yeah!!! {} is running! \n\t" +
- "\n" +
- "\tSwaggerUI: \t{}://localhost:{}/swagger-ui.html\n\t" +
- "Profile(s): \t{}" +
- "\n----------------------------------------------------------",
- env.getProperty("spring.application.name"),
- protocol,
- env.getProperty("server.port"),
- env.getActiveProfiles());
-
- }
+ public static void main(String[] args) {
+ Environment env = SpringApplication.run(CCManagementServiceApplication.class, args).getEnvironment();
+
+ String truststorePassword = env.getProperty("cc-management-service.truststore.password");
+ if (StringUtils.hasText(truststorePassword)) {
+ String filePath = Objects.requireNonNull(Thread.currentThread()
+ .getContextClassLoader().getResource("truststore.jks")).getFile();
+ System.setProperty("javax.net.ssl.trustStore", filePath);
+ System.setProperty("javax.net.ssl.trustStorePassword", truststorePassword);
+ log.info("Custom truststore initialized");
+ } else {
+ log.info("No custom truststore initialized");
+ }
+
+ String protocol = "http";
+ if (env.getProperty("server.ssl.key-store") != null) {
+ protocol = "https";
+ }
+ log.info("\n----------------------------------------------------------\n\t" +
+ "Yeah!!! {} is running! \n\t" +
+ "\n" +
+ "\tSwaggerUI: \t{}://localhost:{}/swagger-ui.html\n\t" +
+ "Profile(s): \t{}" +
+ "\n----------------------------------------------------------",
+ env.getProperty("spring.application.name"),
+ protocol,
+ env.getProperty("server.port"),
+ env.getActiveProfiles());
+ }
}
diff --git a/src/main/java/ch/admin/bag/covidcertificate/api/Constants.java b/src/main/java/ch/admin/bag/covidcertificate/api/Constants.java
index eceb6833..d1ecf3b5 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/api/Constants.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/api/Constants.java
@@ -114,7 +114,12 @@ public class Constants {
public static final CreateCertificateError INVALID_DATE_OF_BIRTH_IN_FUTURE = new CreateCertificateError(489, "Invalid dateOfBirth! Date cannot be in the future", HttpStatus.BAD_REQUEST);
public static final CreateCertificateError NO_ANTIBODY_DATA = new CreateCertificateError(490, "No antibody data specified", HttpStatus.BAD_REQUEST);
public static final CreateCertificateError INVALID_ANTIBODY_SAMPLE_DATE_TIME = new CreateCertificateError(491, "Date of sample collection must not be before 16.11.2021", HttpStatus.BAD_REQUEST);
- public static final CreateCertificateError NO_EXCEPTIONAL_INFO = new CreateCertificateError(492, "No exceptional data specified", HttpStatus.BAD_REQUEST);
+ public static final CreateCertificateError NO_EXCEPTIONAL_INFO = new CreateCertificateError(492,
+ "No exceptional data specified",
+ HttpStatus.BAD_REQUEST);
+ public static final CreateCertificateError INVALID_EXCEPTIONAL_VALID_FROM_DATE = new CreateCertificateError(493,
+ "Invalid date for valid from field",
+ HttpStatus.BAD_REQUEST);
public static final CreateCertificateError DATE_CANT_BE_BEFORE = new CreateCertificateError(494, "Date can't be before %s!", HttpStatus.BAD_REQUEST);
public static final CreateCertificateError DATE_CANT_BE_AFTER = new CreateCertificateError(495, "Date can't be after %s!", HttpStatus.BAD_REQUEST);
diff --git a/src/main/java/ch/admin/bag/covidcertificate/api/mapper/SigningInformationMapper.java b/src/main/java/ch/admin/bag/covidcertificate/api/mapper/SigningInformationMapper.java
index 625cd685..6e7138e6 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/api/mapper/SigningInformationMapper.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/api/mapper/SigningInformationMapper.java
@@ -9,17 +9,18 @@
public class SigningInformationMapper {
public static SigningInformationDto fromEntity(SigningInformation signingInformation) {
- return new SigningInformationDto.SigningInformationDtoBuilder()
- .withCertificateType(signingInformation.getCertificateType())
- .withCode(signingInformation.getCode())
- .withAlias(signingInformation.getAlias())
- .withCertificateAlias(signingInformation.getCertificateAlias())
- .withValidFrom(signingInformation.getValidFrom())
- .withValidTo(signingInformation.getValidTo())
+ return SigningInformationDto.builder()
+ .certificateType(signingInformation.getCertificateType())
+ .code(signingInformation.getCode())
+ .alias(signingInformation.getAlias())
+ .certificateAlias(signingInformation.getCertificateAlias())
+ .slotNumber(signingInformation.getSlotNumber())
+ .validFrom(signingInformation.getValidFrom())
+ .validTo(signingInformation.getValidTo())
.build();
}
public static List fromEntityList(List signingInformationList) {
- return signingInformationList.stream().map(one -> fromEntity(one)).collect(Collectors.toList());
+ return signingInformationList.stream().map(SigningInformationMapper::fromEntity).collect(Collectors.toList());
}
}
diff --git a/src/main/java/ch/admin/bag/covidcertificate/api/request/RecoveryRatCertificateCsvBean.java b/src/main/java/ch/admin/bag/covidcertificate/api/request/RecoveryRatCertificateCsvBean.java
index c33b3814..ed67c34c 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/api/request/RecoveryRatCertificateCsvBean.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/api/request/RecoveryRatCertificateCsvBean.java
@@ -7,9 +7,12 @@
import lombok.NoArgsConstructor;
import lombok.ToString;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import static ch.admin.bag.covidcertificate.api.Constants.INVALID_SAMPLE_DATE_TIME;
+import static ch.admin.bag.covidcertificate.api.Constants.SWISS_TIMEZONE;
@Getter
@ToString
@@ -17,6 +20,9 @@
@AllArgsConstructor
public class RecoveryRatCertificateCsvBean extends CertificateCreateCsvBean {
+ public static final String TIME = "T";
+ public static final String ZONED_MARKER = "Z";
+
@CsvBindByName(column = "sampleDateTime")
private String sampleDateTime;
@CsvBindByName(column = "memberStateOfTest")
@@ -26,7 +32,20 @@ public class RecoveryRatCertificateCsvBean extends CertificateCreateCsvBean {
public RecoveryRatCertificateCreateDto mapToCreateDto() {
ZonedDateTime sampleDateTimeParsed;
try {
- sampleDateTimeParsed = ZonedDateTime.parse(this.sampleDateTime);
+ if (this.sampleDateTime.contains(TIME)) {
+ // it contains a time
+ if (this.sampleDateTime.contains(ZONED_MARKER)) {
+ // it is zoned
+ ZonedDateTime zonedDateTime = ZonedDateTime.parse(this.sampleDateTime);
+ sampleDateTimeParsed = zonedDateTime.withZoneSameInstant(SWISS_TIMEZONE);
+ } else {
+ // it is un zoned and we interpret it as SWISS_TIMEZONE
+ sampleDateTimeParsed = LocalDateTime.parse(this.sampleDateTime).atZone(SWISS_TIMEZONE);
+ }
+ } else {
+ // it is without time and we take start of day with SWISS_TIMEZONE
+ sampleDateTimeParsed = LocalDate.parse(sampleDateTime).atStartOfDay(SWISS_TIMEZONE);
+ }
} catch (Exception e) {
throw new CreateCertificateException(INVALID_SAMPLE_DATE_TIME);
}
diff --git a/src/main/java/ch/admin/bag/covidcertificate/client/signing/SigningClient.java b/src/main/java/ch/admin/bag/covidcertificate/client/signing/SigningClient.java
index c0f0b09d..609cdbdb 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/client/signing/SigningClient.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/client/signing/SigningClient.java
@@ -6,7 +6,7 @@ public interface SigningClient {
boolean verifySignature(VerifySignatureRequestDto verifySignatureRequestDto);
- String getKeyIdentifier(String certificateAlias);
+ String getKeyIdentifier(Integer slotNumber, String certificateAlias);
void cleanKeyIdentifierCache();
diff --git a/src/main/java/ch/admin/bag/covidcertificate/client/signing/SigningInformationDto.java b/src/main/java/ch/admin/bag/covidcertificate/client/signing/SigningInformationDto.java
index a262a976..208f7952 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/client/signing/SigningInformationDto.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/client/signing/SigningInformationDto.java
@@ -1,5 +1,7 @@
package ch.admin.bag.covidcertificate.client.signing;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@@ -9,84 +11,17 @@
@Getter
@EqualsAndHashCode
+@AllArgsConstructor
@ToString
+@Builder
public class SigningInformationDto {
- private String certificateType;
- private String code;
- private String alias;
- private String certificateAlias;
- private LocalDate validFrom;
- private LocalDate validTo;
+ private final String certificateType;
+ private final String code;
+ private final String alias;
+ private final String certificateAlias;
+ private final Integer slotNumber;
+ private final LocalDate validFrom;
+ private final LocalDate validTo;
@Setter
private String calculatedKeyIdentifier;
-
- public SigningInformationDto(
- String certificateType,
- String code,
- String alias,
- String certificateAlias,
- LocalDate validFrom,
- LocalDate validTo
- ) {
- this.certificateType = certificateType;
- this.code = code;
- this.alias = alias;
- this.certificateAlias = certificateAlias;
- this.validFrom = validFrom;
- this.validTo = validTo;
- }
-
- public static class SigningInformationDtoBuilder {
-
- private String certificateType;
- private String code;
- private String alias;
- private String certificateAlias;
- private LocalDate validFrom;
- private LocalDate validTo;
-
- public SigningInformationDtoBuilder() {
- super();
- }
-
- public SigningInformationDtoBuilder withCertificateType(String certificateType) {
- this.certificateType = certificateType;
- return this;
- }
-
- public SigningInformationDtoBuilder withCode(String code) {
- this.code = code;
- return this;
- }
-
- public SigningInformationDtoBuilder withAlias(String alias) {
- this.alias = alias;
- return this;
- }
-
- public SigningInformationDtoBuilder withCertificateAlias(String certificateAlias) {
- this.certificateAlias = certificateAlias;
- return this;
- }
-
- public SigningInformationDtoBuilder withValidFrom(LocalDate validFrom) {
- this.validFrom = validFrom;
- return this;
- }
-
- public SigningInformationDtoBuilder withValidTo(LocalDate validTo) {
- this.validTo = validTo;
- return this;
- }
-
- public SigningInformationDto build() {
- return new SigningInformationDto(
- this.certificateType,
- this.code,
- this.alias,
- this.certificateAlias,
- this.validFrom,
- this.validTo);
- }
- }
}
diff --git a/src/main/java/ch/admin/bag/covidcertificate/client/signing/SigningRequestDto.java b/src/main/java/ch/admin/bag/covidcertificate/client/signing/SigningRequestDto.java
index 7ffa86a0..9eb8ff7d 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/client/signing/SigningRequestDto.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/client/signing/SigningRequestDto.java
@@ -1,5 +1,6 @@
package ch.admin.bag.covidcertificate.client.signing;
+import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -10,4 +11,6 @@
public class SigningRequestDto {
private String dataToSign;
private String signingKeyAlias;
+ @JsonProperty("keyStoreSlot")
+ private Integer slotNumber;
}
\ No newline at end of file
diff --git a/src/main/java/ch/admin/bag/covidcertificate/client/signing/VerifySignatureRequestDto.java b/src/main/java/ch/admin/bag/covidcertificate/client/signing/VerifySignatureRequestDto.java
index ccc5c431..79099ff1 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/client/signing/VerifySignatureRequestDto.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/client/signing/VerifySignatureRequestDto.java
@@ -1,5 +1,6 @@
package ch.admin.bag.covidcertificate.client.signing;
+import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -11,4 +12,6 @@ public class VerifySignatureRequestDto {
private final String dataToSign;
private final String signature;
private final String certificateAlias;
+ @JsonProperty("keyStoreSlot")
+ private Integer slotNumber;
}
\ No newline at end of file
diff --git a/src/main/java/ch/admin/bag/covidcertificate/client/signing/internal/DefaultSigningClient.java b/src/main/java/ch/admin/bag/covidcertificate/client/signing/internal/DefaultSigningClient.java
index 587e67fa..eea17ebb 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/client/signing/internal/DefaultSigningClient.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/client/signing/internal/DefaultSigningClient.java
@@ -35,7 +35,7 @@ public class DefaultSigningClient implements SigningClient {
private final RestTemplate restTemplate;
@Value("${cc-signing-service.url}")
- private String url;
+ private String signUrl;
@Value("${cc-signing-service.verify-url}")
private String verifyUrl;
@@ -48,22 +48,30 @@ public DefaultSigningClient(@Qualifier("signingServiceRestTemplate") RestTemplat
}
public byte[] createSignature(byte[] cosePayload, SigningInformationDto signingInformation) {
- var signingRequestDto = new SigningRequestDto(Base64.getEncoder().encodeToString(cosePayload),
- signingInformation.getAlias());
+ var signingRequestDto = new SigningRequestDto(
+ Base64.getEncoder().encodeToString(cosePayload),
+ signingInformation.getAlias(),
+ signingInformation.getSlotNumber()
+ );
long start = System.currentTimeMillis();
- log.info("Call signing service with url {}", url);
+ log.info("Call signing service with url {}", signUrl);
HttpHeaders headers = new HttpHeaders();
headers.put("Content-Type", Collections.singletonList(MediaType.APPLICATION_JSON_VALUE));
try {
- ResponseEntity result = restTemplate.exchange(url, HttpMethod.POST,
+ ResponseEntity result = restTemplate.exchange(
+ signUrl,
+ HttpMethod.POST,
new HttpEntity<>(signingRequestDto, headers),
- byte[].class);
+ byte[].class
+ );
long end = System.currentTimeMillis();
- log.info("Call of signing service finished with result {} within {} ms.", result.getStatusCode(),
+ log.info("Call of signing service url {} finished with result {} within {} ms.",
+ signUrl,
+ result.getStatusCode(),
end - start);
return result.getBody();
} catch (RestClientException e) {
- log.error("Connection with signing service {} could not be established.", url, e);
+ log.error("Connection with signing service {} could not be established.", signUrl, e);
throw e;
}
}
@@ -73,7 +81,12 @@ public boolean verifySignature(VerifySignatureRequestDto verifySignatureRequestD
HttpHeaders headers = new HttpHeaders();
headers.put("Content-Type", Collections.singletonList(MediaType.APPLICATION_JSON_VALUE));
try {
- ResponseEntity result = restTemplate.exchange(verifyUrl, HttpMethod.POST, new HttpEntity<>(verifySignatureRequestDto, headers), boolean.class);
+ ResponseEntity result = restTemplate.exchange(
+ verifyUrl,
+ HttpMethod.POST,
+ new HttpEntity<>(verifySignatureRequestDto, headers),
+ boolean.class
+ );
return result.getBody();
} catch (RestClientException e) {
log.error("Connection with signing service {} could not be established.", verifyUrl, e);
@@ -82,20 +95,26 @@ public boolean verifySignature(VerifySignatureRequestDto verifySignatureRequestD
}
@Cacheable(KEY_IDENTIFIER_CACHE)
- public String getKeyIdentifier(String certificateAlias) {
- var getKeyUrl = buildSigningUrl(kidUrl, certificateAlias);
+ public String getKeyIdentifier(Integer slotNumber, String certificateAlias) {
+ var specificKidUrl = buildKidUrl(this.kidUrl, slotNumber, certificateAlias);
long start = System.currentTimeMillis();
- log.info("Call signing service to retrieve key identifier for certificate {}.", certificateAlias);
+ log.info("Call signing service with url {}", specificKidUrl);
try {
- ResponseEntity result = restTemplate.exchange(getKeyUrl, HttpMethod.GET,
- new HttpEntity<>(new HttpHeaders()), String.class);
+ ResponseEntity result = restTemplate.exchange(
+ specificKidUrl,
+ HttpMethod.GET,
+ new HttpEntity<>(new HttpHeaders()),
+ String.class
+ );
long end = System.currentTimeMillis();
- log.info("Call of signing service finished with result {} within {} ms.", result.getStatusCode(),
+ log.info("Call of signing service url {} finished with result {} within {} ms.",
+ specificKidUrl,
+ result.getStatusCode(),
end - start);
return result.getBody();
} catch (RestClientException e) {
- log.error("Connection with signing service {} could not be established.", url, e);
+ log.error("Connection with signing service {} could not be established.", specificKidUrl, e);
throw e;
}
}
@@ -106,10 +125,10 @@ public void cleanKeyIdentifierCache() {
log.info("Cleaning cache of key identifier");
}
- private String buildSigningUrl(String url, String pathSegment) {
+ private String buildKidUrl(String url, Integer slotNumber, String kid) {
return new DefaultUriBuilderFactory()
.uriString(url)
- .pathSegment(pathSegment)
+ .pathSegment(slotNumber.toString(), kid)
.build().toString();
}
}
diff --git a/src/main/java/ch/admin/bag/covidcertificate/client/signing/internal/MockSigningClient.java b/src/main/java/ch/admin/bag/covidcertificate/client/signing/internal/MockSigningClient.java
index b1ad6053..5b2292f6 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/client/signing/internal/MockSigningClient.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/client/signing/internal/MockSigningClient.java
@@ -30,7 +30,7 @@ public boolean verifySignature(VerifySignatureRequestDto verifySignatureRequestD
}
@SneakyThrows
- public String getKeyIdentifier(String certificateAlias){
+ public String getKeyIdentifier(Integer slotNumber, String certificateAlias){
var outputStream = new ByteArrayOutputStream();
new HexEncoder().encode(UUID.randomUUID().toString().getBytes(), 0, 8, outputStream);
return outputStream.toString();
diff --git a/src/main/java/ch/admin/bag/covidcertificate/config/security/authentication/JeapAuthenticationToken.java b/src/main/java/ch/admin/bag/covidcertificate/config/security/authentication/JeapAuthenticationToken.java
index c385714d..b62c8030 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/config/security/authentication/JeapAuthenticationToken.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/config/security/authentication/JeapAuthenticationToken.java
@@ -1,6 +1,5 @@
package ch.admin.bag.covidcertificate.config.security.authentication;
-import org.apache.commons.lang3.StringUtils;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.oauth2.jwt.Jwt;
@@ -28,8 +27,7 @@ public JeapAuthenticationToken(Jwt jwt, Set userRoles) {
* @return The client id specified in this token.
*/
public String getClientId() {
- String client_id = getToken().getClaimAsString("client_id");
- return StringUtils.isNotBlank(client_id) ? client_id : getToken().getClaimAsString("clientId");
+ return getToken().getClaimAsString("clientId");
}
/**
diff --git a/src/main/java/ch/admin/bag/covidcertificate/domain/SigningInformation.java b/src/main/java/ch/admin/bag/covidcertificate/domain/SigningInformation.java
index 8d59b6b4..58f66f24 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/domain/SigningInformation.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/domain/SigningInformation.java
@@ -29,6 +29,7 @@ public class SigningInformation {
private String code;
private String alias;
private String certificateAlias;
+ private Integer slotNumber;
private LocalDate validFrom;
private LocalDate validTo;
@@ -37,6 +38,7 @@ public SigningInformation(
String code,
String alias,
String certificateAlias,
+ Integer slotNumber,
LocalDate validFrom,
LocalDate validTo) {
@@ -44,6 +46,7 @@ public SigningInformation(
this.code = code;
this.alias = alias;
this.certificateAlias = certificateAlias;
+ this.slotNumber = slotNumber;
this.validFrom = validFrom;
this.validTo = validTo;
}
diff --git a/src/main/java/ch/admin/bag/covidcertificate/service/COSEService.java b/src/main/java/ch/admin/bag/covidcertificate/service/COSEService.java
index 66e71493..5e7be2d6 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/service/COSEService.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/service/COSEService.java
@@ -34,7 +34,10 @@ public byte[] getCOSESign1(byte[] dgcCBOR, SigningInformationDto signingInformat
private byte[] getProtectedHeader(SigningInformationDto signingInformation) {
try {
if (StringUtils.isNotBlank(signingInformation.getCertificateAlias())) {
- var keyIdentifier = signingClient.getKeyIdentifier(signingInformation.getCertificateAlias());
+ var keyIdentifier = signingClient.getKeyIdentifier(
+ signingInformation.getSlotNumber(),
+ signingInformation.getCertificateAlias()
+ );
signingInformation.setCalculatedKeyIdentifier(keyIdentifier);
return cborService.getProtectedHeader(keyIdentifier);
}
diff --git a/src/main/java/ch/admin/bag/covidcertificate/service/CovidCertificateGeneratePdfFromExistingService.java b/src/main/java/ch/admin/bag/covidcertificate/service/CovidCertificateGeneratePdfFromExistingService.java
new file mode 100644
index 00000000..67e82364
--- /dev/null
+++ b/src/main/java/ch/admin/bag/covidcertificate/service/CovidCertificateGeneratePdfFromExistingService.java
@@ -0,0 +1,150 @@
+package ch.admin.bag.covidcertificate.service;
+
+import ch.admin.bag.covidcertificate.api.exception.CreateCertificateException;
+import ch.admin.bag.covidcertificate.api.request.pdfgeneration.AntibodyCertificatePdfGenerateRequestDto;
+import ch.admin.bag.covidcertificate.api.request.pdfgeneration.ExceptionalCertificatePdfGenerateRequestDto;
+import ch.admin.bag.covidcertificate.api.request.pdfgeneration.RecoveryCertificatePdfGenerateRequestDto;
+import ch.admin.bag.covidcertificate.api.request.pdfgeneration.RecoveryRatCertificatePdfGenerateRequestDto;
+import ch.admin.bag.covidcertificate.api.request.pdfgeneration.TestCertificatePdfGenerateRequestDto;
+import ch.admin.bag.covidcertificate.api.request.pdfgeneration.VaccinationCertificatePdfGenerateRequestDto;
+import ch.admin.bag.covidcertificate.api.request.pdfgeneration.VaccinationTouristCertificatePdfGenerateRequestDto;
+import ch.admin.bag.covidcertificate.api.response.CovidCertificateCreateResponseDto;
+import ch.admin.bag.covidcertificate.api.response.CovidCertificateResponseEnvelope;
+import ch.admin.bag.covidcertificate.service.document.PdfCertificateGenerationService;
+import ch.admin.bag.covidcertificate.service.domain.AbstractCertificatePdf;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import se.digg.dgc.encoding.BarcodeException;
+import se.digg.dgc.encoding.impl.DefaultBarcodeCreator;
+
+import java.nio.charset.StandardCharsets;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+
+import static ch.admin.bag.covidcertificate.api.Constants.CREATE_BARCODE_FAILED;
+
+@Service
+@Slf4j
+@RequiredArgsConstructor
+public class CovidCertificateGeneratePdfFromExistingService {
+
+ private final CovidCertificatePdfGenerateRequestDtoMapperService pdfDtoMapperService;
+ private final PdfCertificateGenerationService pdfCertificateGenerationService;
+
+ public CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
+ VaccinationCertificatePdfGenerateRequestDto pdfGenerateRequestDto) {
+
+ var pdfData = pdfDtoMapperService.toVaccinationCertificatePdf(pdfGenerateRequestDto);
+ return generateFromExistingCovidCertificate(pdfData,
+ pdfGenerateRequestDto.getHcert(),
+ pdfGenerateRequestDto.getIssuedAt(),
+ pdfGenerateRequestDto.getDecodedCert()
+ .getVaccinationInfo()
+ .get(0)
+ .getIdentifier());
+ }
+
+ public CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
+ VaccinationTouristCertificatePdfGenerateRequestDto pdfGenerateRequestDto) {
+
+ var pdfData = pdfDtoMapperService
+ .toVaccinationTouristCertificatePdf(pdfGenerateRequestDto);
+ return generateFromExistingCovidCertificate(pdfData,
+ pdfGenerateRequestDto.getHcert(),
+ pdfGenerateRequestDto.getIssuedAt(),
+ pdfGenerateRequestDto.getDecodedCert()
+ .getVaccinationTouristInfo()
+ .get(0)
+ .getIdentifier());
+ }
+
+ public CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
+ TestCertificatePdfGenerateRequestDto pdfGenerateRequestDto) {
+
+ var pdfData = pdfDtoMapperService.toTestCertificatePdf(pdfGenerateRequestDto);
+ return generateFromExistingCovidCertificate(pdfData,
+ pdfGenerateRequestDto.getHcert(),
+ pdfGenerateRequestDto.getIssuedAt(),
+ pdfGenerateRequestDto.getDecodedCert()
+ .getTestInfo()
+ .get(0)
+ .getIdentifier());
+ }
+
+ public CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
+ RecoveryCertificatePdfGenerateRequestDto pdfGenerateRequestDto) {
+
+ var pdfData = pdfDtoMapperService.toRecoveryCertificatePdf(pdfGenerateRequestDto);
+ return generateFromExistingCovidCertificate(pdfData,
+ pdfGenerateRequestDto.getHcert(),
+ pdfGenerateRequestDto.getIssuedAt(),
+ pdfGenerateRequestDto.getDecodedCert()
+ .getRecoveryInfo()
+ .get(0)
+ .getIdentifier());
+ }
+
+ public CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
+ RecoveryRatCertificatePdfGenerateRequestDto pdfGenerateRequestDto) {
+
+ var pdfData = pdfDtoMapperService.toRecoveryRatCertificatePdf(pdfGenerateRequestDto);
+ return generateFromExistingCovidCertificate(pdfData,
+ pdfGenerateRequestDto.getHcert(),
+ pdfGenerateRequestDto.getIssuedAt(),
+ pdfGenerateRequestDto.getDecodedCert()
+ .getTestInfo()
+ .get(0)
+ .getIdentifier());
+ }
+
+ public CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
+ AntibodyCertificatePdfGenerateRequestDto pdfGenerateRequestDto) {
+
+ var pdfData = pdfDtoMapperService.toAntibodyCertificatePdf(pdfGenerateRequestDto);
+ return generateFromExistingCovidCertificate(pdfData,
+ pdfGenerateRequestDto.getHcert(),
+ pdfGenerateRequestDto.getIssuedAt(),
+ pdfGenerateRequestDto.getDecodedCert()
+ .getAntibodyInfo()
+ .get(0)
+ .getIdentifier());
+ }
+
+ public CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
+ ExceptionalCertificatePdfGenerateRequestDto pdfGenerateRequestDto) {
+
+ var pdfData = pdfDtoMapperService.toExceptionalCertificatePdf(pdfGenerateRequestDto);
+ return generateFromExistingCovidCertificate(pdfData,
+ pdfGenerateRequestDto.getHcert(),
+ pdfGenerateRequestDto.getIssuedAt(),
+ pdfGenerateRequestDto.getDecodedCert()
+ .getExceptionalInfo()
+ .get(0)
+ .getIdentifier());
+ }
+
+ private CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
+ AbstractCertificatePdf pdfData,
+ String hcert,
+ long issuedAtMillis,
+ String uvci) {
+
+ try {
+ var issuedAt = getLocalDateTimeFromEpochMillis(issuedAtMillis);
+ var barcode = new DefaultBarcodeCreator().create(hcert, StandardCharsets.US_ASCII);
+ var pdf = pdfCertificateGenerationService.generateCovidCertificate(pdfData, hcert, issuedAt);
+ var responseDto = new CovidCertificateCreateResponseDto(pdf, barcode.getImage(), uvci);
+ return new CovidCertificateResponseEnvelope(responseDto, null);
+ } catch (BarcodeException e) {
+ throw new CreateCertificateException(CREATE_BARCODE_FAILED);
+ }
+ }
+
+ private LocalDateTime getLocalDateTimeFromEpochMillis(long millis) {
+ var instant = Instant.ofEpochMilli(millis);
+ return ZonedDateTime.from(instant.atZone(ZoneId.systemDefault())).toLocalDateTime();
+ }
+}
diff --git a/src/main/java/ch/admin/bag/covidcertificate/service/CovidCertificateGenerationService.java b/src/main/java/ch/admin/bag/covidcertificate/service/CovidCertificateGenerationService.java
index f029de2c..efda079c 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/service/CovidCertificateGenerationService.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/service/CovidCertificateGenerationService.java
@@ -1,7 +1,6 @@
package ch.admin.bag.covidcertificate.service;
import ch.admin.bag.covidcertificate.api.Constants;
-import ch.admin.bag.covidcertificate.api.exception.CreateCertificateException;
import ch.admin.bag.covidcertificate.api.mapper.CertificatePrintRequestDtoMapper;
import ch.admin.bag.covidcertificate.api.request.AntibodyCertificateCreateDto;
import ch.admin.bag.covidcertificate.api.request.CertificateCreateDto;
@@ -11,13 +10,6 @@
import ch.admin.bag.covidcertificate.api.request.TestCertificateCreateDto;
import ch.admin.bag.covidcertificate.api.request.VaccinationCertificateCreateDto;
import ch.admin.bag.covidcertificate.api.request.VaccinationTouristCertificateCreateDto;
-import ch.admin.bag.covidcertificate.api.request.pdfgeneration.AntibodyCertificatePdfGenerateRequestDto;
-import ch.admin.bag.covidcertificate.api.request.pdfgeneration.ExceptionalCertificatePdfGenerateRequestDto;
-import ch.admin.bag.covidcertificate.api.request.pdfgeneration.RecoveryCertificatePdfGenerateRequestDto;
-import ch.admin.bag.covidcertificate.api.request.pdfgeneration.RecoveryRatCertificatePdfGenerateRequestDto;
-import ch.admin.bag.covidcertificate.api.request.pdfgeneration.TestCertificatePdfGenerateRequestDto;
-import ch.admin.bag.covidcertificate.api.request.pdfgeneration.VaccinationCertificatePdfGenerateRequestDto;
-import ch.admin.bag.covidcertificate.api.request.pdfgeneration.VaccinationTouristCertificatePdfGenerateRequestDto;
import ch.admin.bag.covidcertificate.api.response.CovidCertificateCreateResponseDto;
import ch.admin.bag.covidcertificate.api.response.CovidCertificateResponseEnvelope;
import ch.admin.bag.covidcertificate.client.inapp_delivery.InAppDeliveryClient;
@@ -32,147 +24,26 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
-import se.digg.dgc.encoding.BarcodeException;
-import se.digg.dgc.encoding.impl.DefaultBarcodeCreator;
-import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
import java.util.Base64;
-import static ch.admin.bag.covidcertificate.api.Constants.CREATE_BARCODE_FAILED;
-
@Service
@Slf4j
@RequiredArgsConstructor
public class CovidCertificateGenerationService {
+
private final BarcodeService barcodeService;
private final PrintQueueClient printQueueClient;
private final InAppDeliveryClient inAppDeliveryClient;
private final ObjectMapper objectMapper;
private final PdfCertificateGenerationService pdfCertificateGenerationService;
private final CovidCertificateDtoMapperService ccDtoMapperService;
- private final CovidCertificatePdfGenerateRequestDtoMapperService pdfDtoMapperService;
private final CertificatePrintRequestDtoMapper certificatePrintRequestDtoMapper;
private final SigningInformationService signingInformationService;
private final COSETime coseTime;
- public CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
- VaccinationCertificatePdfGenerateRequestDto pdfGenerateRequestDto) {
-
- var pdfData = pdfDtoMapperService.toVaccinationCertificatePdf(pdfGenerateRequestDto);
- return generateFromExistingCovidCertificate(pdfData,
- pdfGenerateRequestDto.getHcert(),
- pdfGenerateRequestDto.getIssuedAt(),
- pdfGenerateRequestDto.getDecodedCert()
- .getVaccinationInfo()
- .get(0)
- .getIdentifier());
- }
-
- public CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
- VaccinationTouristCertificatePdfGenerateRequestDto pdfGenerateRequestDto) {
-
- var pdfData = pdfDtoMapperService
- .toVaccinationTouristCertificatePdf(pdfGenerateRequestDto);
- return generateFromExistingCovidCertificate(pdfData,
- pdfGenerateRequestDto.getHcert(),
- pdfGenerateRequestDto.getIssuedAt(),
- pdfGenerateRequestDto.getDecodedCert()
- .getVaccinationTouristInfo()
- .get(0)
- .getIdentifier());
- }
-
- public CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
- TestCertificatePdfGenerateRequestDto pdfGenerateRequestDto) {
-
- var pdfData = pdfDtoMapperService.toTestCertificatePdf(pdfGenerateRequestDto);
- return generateFromExistingCovidCertificate(pdfData,
- pdfGenerateRequestDto.getHcert(),
- pdfGenerateRequestDto.getIssuedAt(),
- pdfGenerateRequestDto.getDecodedCert()
- .getTestInfo()
- .get(0)
- .getIdentifier());
- }
-
- public CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
- RecoveryCertificatePdfGenerateRequestDto pdfGenerateRequestDto) {
-
- var pdfData = pdfDtoMapperService.toRecoveryCertificatePdf(pdfGenerateRequestDto);
- return generateFromExistingCovidCertificate(pdfData,
- pdfGenerateRequestDto.getHcert(),
- pdfGenerateRequestDto.getIssuedAt(),
- pdfGenerateRequestDto.getDecodedCert()
- .getRecoveryInfo()
- .get(0)
- .getIdentifier());
- }
-
- public CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
- RecoveryRatCertificatePdfGenerateRequestDto pdfGenerateRequestDto) {
-
- var pdfData = pdfDtoMapperService.toRecoveryRatCertificatePdf(pdfGenerateRequestDto);
- return generateFromExistingCovidCertificate(pdfData,
- pdfGenerateRequestDto.getHcert(),
- pdfGenerateRequestDto.getIssuedAt(),
- pdfGenerateRequestDto.getDecodedCert()
- .getTestInfo()
- .get(0)
- .getIdentifier());
- }
-
- public CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
- AntibodyCertificatePdfGenerateRequestDto pdfGenerateRequestDto) {
-
- var pdfData = pdfDtoMapperService.toAntibodyCertificatePdf(pdfGenerateRequestDto);
- return generateFromExistingCovidCertificate(pdfData,
- pdfGenerateRequestDto.getHcert(),
- pdfGenerateRequestDto.getIssuedAt(),
- pdfGenerateRequestDto.getDecodedCert()
- .getAntibodyInfo()
- .get(0)
- .getIdentifier());
- }
-
- public CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
- ExceptionalCertificatePdfGenerateRequestDto pdfGenerateRequestDto) {
-
- var pdfData = pdfDtoMapperService.toExceptionalCertificatePdf(pdfGenerateRequestDto);
- return generateFromExistingCovidCertificate(pdfData,
- pdfGenerateRequestDto.getHcert(),
- pdfGenerateRequestDto.getIssuedAt(),
- pdfGenerateRequestDto.getDecodedCert()
- .getExceptionalInfo()
- .get(0)
- .getIdentifier());
- }
-
- private CovidCertificateResponseEnvelope generateFromExistingCovidCertificate(
- AbstractCertificatePdf pdfData,
- String hcert,
- long issuedAtMillis,
- String uvci) {
-
- try {
- var issuedAt = getLocalDateTimeFromEpochMillis(issuedAtMillis);
- var barcode = new DefaultBarcodeCreator().create(hcert, StandardCharsets.US_ASCII);
- var pdf = pdfCertificateGenerationService.generateCovidCertificate(pdfData, hcert, issuedAt);
- var responseDto = new CovidCertificateCreateResponseDto(pdf, barcode.getImage(), uvci);
- return new CovidCertificateResponseEnvelope(responseDto, null);
- } catch (BarcodeException e) {
- throw new CreateCertificateException(CREATE_BARCODE_FAILED);
- }
- }
-
- private LocalDateTime getLocalDateTimeFromEpochMillis(long millis) {
- var instant = Instant.ofEpochMilli(millis);
- return ZonedDateTime.from(instant.atZone(ZoneId.systemDefault())).toLocalDateTime();
- }
-
public CovidCertificateResponseEnvelope generateCovidCertificate(VaccinationCertificateCreateDto createDto)
throws JsonProcessingException {
@@ -323,8 +194,7 @@ private CovidCertificateResponseEnvelope generateCovidCertificate(
var createError = this.inAppDeliveryClient.deliverToApp(uvci, inAppDeliveryDto); // null if no error
responseDto.setAppDeliveryError(createError);
}
- var envelope = new CovidCertificateResponseEnvelope(responseDto,
- signingInformation.getCalculatedKeyIdentifier());
- return envelope;
+ return new CovidCertificateResponseEnvelope(responseDto,
+ signingInformation.getCalculatedKeyIdentifier());
}
}
diff --git a/src/main/java/ch/admin/bag/covidcertificate/util/DateDeserializer.java b/src/main/java/ch/admin/bag/covidcertificate/util/DateDeserializer.java
index d9080132..393ad43f 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/util/DateDeserializer.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/util/DateDeserializer.java
@@ -1,9 +1,12 @@
package ch.admin.bag.covidcertificate.util;
import ch.admin.bag.covidcertificate.api.exception.CreateCertificateException;
+import ch.admin.bag.covidcertificate.api.request.AntibodyCertificateDataDto;
+import ch.admin.bag.covidcertificate.api.request.ExceptionalCertificateDataDto;
import ch.admin.bag.covidcertificate.api.request.RecoveryCertificateDataDto;
import ch.admin.bag.covidcertificate.api.request.TestCertificateDataDto;
import ch.admin.bag.covidcertificate.api.request.VaccinationCertificateDataDto;
+import ch.admin.bag.covidcertificate.api.request.VaccinationTouristCertificateDataDto;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
@@ -13,13 +16,19 @@
import java.time.LocalDate;
import java.time.format.DateTimeParseException;
-import static ch.admin.bag.covidcertificate.api.Constants.*;
+import static ch.admin.bag.covidcertificate.api.Constants.INVALID_DATE_OF_FIRST_POSITIVE_TEST_RESULT;
+import static ch.admin.bag.covidcertificate.api.Constants.INVALID_EXCEPTIONAL_VALID_FROM_DATE;
+import static ch.admin.bag.covidcertificate.api.Constants.INVALID_SAMPLE_DATE_TIME;
+import static ch.admin.bag.covidcertificate.api.Constants.INVALID_VACCINATION_DATE;
public class DateDeserializer extends JsonDeserializer {
+ static final String vaccinationTouristCertificate = VaccinationTouristCertificateDataDto.class.getSimpleName();
static final String vaccinationCertificate = VaccinationCertificateDataDto.class.getSimpleName();
static final String recoveryCertificate = RecoveryCertificateDataDto.class.getSimpleName();
+ static final String antibodyCertificate = AntibodyCertificateDataDto.class.getSimpleName();
static final String testCertificate = TestCertificateDataDto.class.getSimpleName();
+ static final String exceptionalCertificate = ExceptionalCertificateDataDto.class.getSimpleName();
@Override
public LocalDate deserialize(JsonParser jsonparser, DeserializationContext context) throws IOException {
@@ -29,15 +38,18 @@ public LocalDate deserialize(JsonParser jsonparser, DeserializationContext conte
try {
String dateAsString = jsonparser.getText();
return LocalDate.parse(dateAsString);
- } catch(DateTimeParseException dateTimeParseException) {
+ } catch (DateTimeParseException dateTimeParseException) {
String origin = jsonparser.getParsingContext().getCurrentValue().getClass().getSimpleName();
-
- if (vaccinationCertificate.equals(origin)) {
- throw new CreateCertificateException(INVALID_VACCINATION_DATE);
- } else if(recoveryCertificate.equals(origin)) {
+ if (vaccinationCertificate.equals(origin) ||
+ vaccinationTouristCertificate.equals(origin)) {
+ throw new CreateCertificateException(INVALID_VACCINATION_DATE);
+ } else if (recoveryCertificate.equals(origin) ||
+ antibodyCertificate.equals(origin)) {
throw new CreateCertificateException(INVALID_DATE_OF_FIRST_POSITIVE_TEST_RESULT);
- } else if(testCertificate.equals(origin)) {
+ } else if (testCertificate.equals(origin)) {
throw new CreateCertificateException(INVALID_SAMPLE_DATE_TIME);
+ } else if (exceptionalCertificate.equals(origin)) {
+ throw new CreateCertificateException(INVALID_EXCEPTIONAL_VALID_FROM_DATE);
} else {
throw dateTimeParseException;
}
diff --git a/src/main/java/ch/admin/bag/covidcertificate/util/ZonedDateTimeDeserializer.java b/src/main/java/ch/admin/bag/covidcertificate/util/ZonedDateTimeDeserializer.java
index 40bf83a7..463d0e91 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/util/ZonedDateTimeDeserializer.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/util/ZonedDateTimeDeserializer.java
@@ -1,21 +1,18 @@
package ch.admin.bag.covidcertificate.util;
import ch.admin.bag.covidcertificate.api.exception.CreateCertificateException;
-import ch.admin.bag.covidcertificate.api.request.TestCertificateDataDto;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
-import java.io.IOException;
import java.time.ZonedDateTime;
-import java.time.format.DateTimeParseException;
import static ch.admin.bag.covidcertificate.api.Constants.INVALID_SAMPLE_DATE_TIME;
public class ZonedDateTimeDeserializer extends JsonDeserializer {
@Override
- public ZonedDateTime deserialize(JsonParser jsonparser, DeserializationContext context) throws IOException {
+ public ZonedDateTime deserialize(JsonParser jsonparser, DeserializationContext context) {
try {
return jsonparser.getCodec().readValue(jsonparser, ZonedDateTime.class);
} catch (Exception e) {
diff --git a/src/main/java/ch/admin/bag/covidcertificate/web/controller/CovidCertificatePdfGenerateController.java b/src/main/java/ch/admin/bag/covidcertificate/web/controller/CovidCertificateGeneratePdfFromExistingController.java
similarity index 82%
rename from src/main/java/ch/admin/bag/covidcertificate/web/controller/CovidCertificatePdfGenerateController.java
rename to src/main/java/ch/admin/bag/covidcertificate/web/controller/CovidCertificateGeneratePdfFromExistingController.java
index 8e991bea..d33a0f6d 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/web/controller/CovidCertificatePdfGenerateController.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/web/controller/CovidCertificateGeneratePdfFromExistingController.java
@@ -9,7 +9,7 @@
import ch.admin.bag.covidcertificate.api.request.pdfgeneration.VaccinationTouristCertificatePdfGenerateRequestDto;
import ch.admin.bag.covidcertificate.api.response.CovidCertificateCreateResponseDto;
import ch.admin.bag.covidcertificate.api.response.CovidCertificateResponseEnvelope;
-import ch.admin.bag.covidcertificate.service.CovidCertificateGenerationService;
+import ch.admin.bag.covidcertificate.service.CovidCertificateGeneratePdfFromExistingService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
@@ -23,9 +23,9 @@
@RequestMapping("/api/v1/covidcertificate/fromexisting")
@RequiredArgsConstructor
@Slf4j
-public class CovidCertificatePdfGenerateController {
+public class CovidCertificateGeneratePdfFromExistingController {
- private final CovidCertificateGenerationService covidCertificateGenerationService;
+ private final CovidCertificateGeneratePdfFromExistingService covidCertificateGenerationService;
@PostMapping("/vaccination")
public CovidCertificateCreateResponseDto generateVaccinationPdfFromExistingCertificate(
@@ -34,8 +34,7 @@ public CovidCertificateCreateResponseDto generateVaccinationPdfFromExistingCerti
log.info("Call of create PDF for vaccination certificate");
CovidCertificateResponseEnvelope responseEnvelope = covidCertificateGenerationService
.generateFromExistingCovidCertificate(pdfGenerateRequestDto);
- CovidCertificateCreateResponseDto responseDto = responseEnvelope.getResponseDto();
- return responseDto;
+ return responseEnvelope.getResponseDto();
}
@PostMapping("/vaccination-tourist")
@@ -45,8 +44,7 @@ public CovidCertificateCreateResponseDto generateVaccinationTouristPdfFromExisti
log.info("Call of create PDF for vaccination-tourist certificate");
CovidCertificateResponseEnvelope responseEnvelope = covidCertificateGenerationService
.generateFromExistingCovidCertificate(pdfGenerateRequestDto);
- CovidCertificateCreateResponseDto responseDto = responseEnvelope.getResponseDto();
- return responseDto;
+ return responseEnvelope.getResponseDto();
}
@PostMapping("/test")
@@ -56,8 +54,7 @@ public CovidCertificateCreateResponseDto generateTestPdfFromExistingCertificate(
log.info("Call of create PDF for test certificate");
CovidCertificateResponseEnvelope responseEnvelope = covidCertificateGenerationService
.generateFromExistingCovidCertificate(pdfGenerateRequestDto);
- CovidCertificateCreateResponseDto responseDto = responseEnvelope.getResponseDto();
- return responseDto;
+ return responseEnvelope.getResponseDto();
}
@PostMapping("/recovery")
@@ -67,8 +64,7 @@ public CovidCertificateCreateResponseDto generateRecoveryPdfFromExistingCertific
log.info("Call of create PDF for recovery certificate");
CovidCertificateResponseEnvelope responseEnvelope = covidCertificateGenerationService
.generateFromExistingCovidCertificate(pdfGenerateRequestDto);
- CovidCertificateCreateResponseDto responseDto = responseEnvelope.getResponseDto();
- return responseDto;
+ return responseEnvelope.getResponseDto();
}
@PostMapping("/recovery-rat")
@@ -78,8 +74,7 @@ public CovidCertificateCreateResponseDto generateRecoveryRatPdfFromExistingCerti
log.info("Call of create PDF for recovery-rat certificate");
CovidCertificateResponseEnvelope responseEnvelope = covidCertificateGenerationService
.generateFromExistingCovidCertificate(pdfGenerateRequestDto);
- CovidCertificateCreateResponseDto responseDto = responseEnvelope.getResponseDto();
- return responseDto;
+ return responseEnvelope.getResponseDto();
}
@PostMapping("/antibody")
@@ -89,8 +84,7 @@ public CovidCertificateCreateResponseDto generateAntibodyPdfFromExistingCertific
log.info("Call of create PDF for antibody certificate");
CovidCertificateResponseEnvelope responseEnvelope = covidCertificateGenerationService
.generateFromExistingCovidCertificate(pdfGenerateRequestDto);
- CovidCertificateCreateResponseDto responseDto = responseEnvelope.getResponseDto();
- return responseDto;
+ return responseEnvelope.getResponseDto();
}
@PostMapping("/exceptional")
@@ -100,7 +94,6 @@ public CovidCertificateCreateResponseDto generateExceptionalPdfFromExistingCerti
log.info("Call of create PDF for exceptional certificate");
CovidCertificateResponseEnvelope responseEnvelope = covidCertificateGenerationService
.generateFromExistingCovidCertificate(pdfGenerateRequestDto);
- CovidCertificateCreateResponseDto responseDto = responseEnvelope.getResponseDto();
- return responseDto;
+ return responseEnvelope.getResponseDto();
}
}
diff --git a/src/main/java/ch/admin/bag/covidcertificate/web/controller/ResponseStatusExceptionHandler.java b/src/main/java/ch/admin/bag/covidcertificate/web/controller/ResponseStatusExceptionHandler.java
index fb4db279..f3d0a38d 100644
--- a/src/main/java/ch/admin/bag/covidcertificate/web/controller/ResponseStatusExceptionHandler.java
+++ b/src/main/java/ch/admin/bag/covidcertificate/web/controller/ResponseStatusExceptionHandler.java
@@ -91,13 +91,13 @@ protected ResponseEntity