Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #361 from admin-ch/release/4.4.x
Browse files Browse the repository at this point in the history
Release/4.4.x
  • Loading branch information
iris-hunkeler authored Jul 25, 2022
2 parents de4f704 + 725c5b2 commit 5f55808
Show file tree
Hide file tree
Showing 46 changed files with 3,048 additions and 1,003 deletions.
2 changes: 1 addition & 1 deletion .run/CCManagementServiceApplication.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
</component>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>ch.admin.bag.covidcertificate</groupId>
<artifactId>cc-management-service</artifactId>
<version>4.3.3</version>
<version>4.4.6</version>
<name>cc-management-service</name>
<description>Service for generating Covid Certificates</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SigningInformationDto> fromEntityList(List<SigningInformation> signingInformationList) {
return signingInformationList.stream().map(one -> fromEntity(one)).collect(Collectors.toList());
return signingInformationList.stream().map(SigningInformationMapper::fromEntity).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@
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
@NoArgsConstructor
@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")
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public interface SigningClient {

boolean verifySignature(VerifySignatureRequestDto verifySignatureRequestDto);

String getKeyIdentifier(String certificateAlias);
String getKeyIdentifier(Integer slotNumber, String certificateAlias);

void cleanKeyIdentifierCache();

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,4 +11,6 @@
public class SigningRequestDto {
private String dataToSign;
private String signingKeyAlias;
@JsonProperty("keyStoreSlot")
private Integer slotNumber;
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -11,4 +12,6 @@ public class VerifySignatureRequestDto {
private final String dataToSign;
private final String signature;
private final String certificateAlias;
@JsonProperty("keyStoreSlot")
private Integer slotNumber;
}
Loading

0 comments on commit 5f55808

Please sign in to comment.