Skip to content

Commit

Permalink
feat: dsc delta download extension (#169)
Browse files Browse the repository at this point in the history
* added Delta&Pagination in SignerInformationService

* added Delta&Pagination in TrustedPartyService

* added Delta&Pagination in TrustListService

* added Delta&Pagination in TrustListController

* fixed sonar warning

* fixed sonar warning and updated type of ifModifiedSince to String

* fixed sonar warning and updated type of ifModifiedSince to String

* flag SignerInformationEntity for deletion (#166)

* flag SignerInformationEntity for deletion

* add cleanup scheduler for signerInformation

* Update pom.xml

* keep thumbprint for identification

* fix after merge

* add deleted to modified-since response

Co-authored-by: Felix Dittrich <[email protected]>

* unit test

* fixed unit test

* Update src/main/java/eu/europa/ec/dgc/gateway/restapi/controller/TrustListController.java

Co-authored-by: Felix Dittrich <[email protected]>

* Update src/main/java/eu/europa/ec/dgc/gateway/restapi/controller/TrustListController.java

Co-authored-by: Felix Dittrich <[email protected]>

* Update src/main/java/eu/europa/ec/dgc/gateway/restapi/controller/TrustListController.java

Co-authored-by: Felix Dittrich <[email protected]>

* Update src/main/java/eu/europa/ec/dgc/gateway/restapi/controller/TrustListController.java

Co-authored-by: Felix Dittrich <[email protected]>

* Update src/main/java/eu/europa/ec/dgc/gateway/restapi/controller/TrustListController.java

Co-authored-by: Felix Dittrich <[email protected]>

* Update src/main/java/eu/europa/ec/dgc/gateway/restapi/controller/TrustListController.java

Co-authored-by: Felix Dittrich <[email protected]>

* Update src/main/java/eu/europa/ec/dgc/gateway/restapi/controller/TrustListController.java

Co-authored-by: Felix Dittrich <[email protected]>

* Update src/main/java/eu/europa/ec/dgc/gateway/restapi/controller/TrustListController.java

Co-authored-by: Felix Dittrich <[email protected]>

* Update src/main/java/eu/europa/ec/dgc/gateway/restapi/controller/TrustListController.java

Co-authored-by: Felix Dittrich <[email protected]>

* Update src/main/java/eu/europa/ec/dgc/gateway/restapi/controller/TrustListController.java

Co-authored-by: Felix Dittrich <[email protected]>

* Update src/main/java/eu/europa/ec/dgc/gateway/restapi/controller/TrustListController.java

Co-authored-by: Felix Dittrich <[email protected]>

* Update src/main/java/eu/europa/ec/dgc/gateway/restapi/controller/TrustListController.java

Co-authored-by: Felix Dittrich <[email protected]>

* Update src/main/java/eu/europa/ec/dgc/gateway/restapi/controller/TrustListController.java

Co-authored-by: Felix Dittrich <[email protected]>

* fix IfModifiedSince DateTimeFormat advice and unit tests

Co-authored-by: Hong Mu <[email protected]>
Co-authored-by: bergmann-dierk <[email protected]>
Co-authored-by: Felix Dittrich <[email protected]>
Co-authored-by: Dierk Bergmann <[email protected]>
Co-authored-by: Andreas Scheibal <[email protected]>
  • Loading branch information
6 people committed Mar 24, 2022
1 parent eba7dac commit 4893077
Show file tree
Hide file tree
Showing 22 changed files with 1,403 additions and 115 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<owasp.version>6.5.3</owasp.version>
<spring.security.version>5.6.2</spring.security.version>
<lombok.version>1.18.22</lombok.version>
<liquibase.version>4.8.0</liquibase.version>
<liquibase.version>4.9.0</liquibase.version>
<springdoc.version>1.6.6</springdoc.version>
<mapstruct.version>1.4.2.Final</mapstruct.version>
<mockito.version>4.3.1</mockito.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class DgcConfigProperties {

private Revocation revocation = new Revocation();

private SignerInformation signerInformation = new SignerInformation();

@Getter
@Setter
public static class JrcConfig {
Expand Down Expand Up @@ -85,4 +87,10 @@ public static class HeaderFields {
public static class Revocation {
private int deleteThreshold = 14;
}

@Getter
@Setter
public static class SignerInformation {
private int deleteThreshold = 14;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public class SignerInformationEntity {
@Column(name = "created_at", nullable = false)
private ZonedDateTime createdAt = ZonedDateTime.now();

@Column(name = "deleted_at")
private ZonedDateTime deletedAt;

/**
* ISO 3166 Alpha-2 Country Code
* (plus code "EU" for administrative European Union entries).
Expand All @@ -75,7 +78,7 @@ public class SignerInformationEntity {
/**
* Signature of the TrustAnchor.
*/
@Column(name = "signature", nullable = false, length = 6000)
@Column(name = "signature", length = 6000)
String signature;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,75 @@
package eu.europa.ec.dgc.gateway.repository;

import eu.europa.ec.dgc.gateway.entity.SignerInformationEntity;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Optional;
import javax.transaction.Transactional;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface SignerInformationRepository extends JpaRepository<SignerInformationEntity, Long> {

String SELECT_SINCE =
"SELECT s FROM SignerInformationEntity s WHERE s.createdAt >= :since OR s.deletedAt >= :since";
String SELECT_BY_TYPE_SINCE =
"SELECT s FROM SignerInformationEntity s WHERE s.certificateType = :certType AND (s.createdAt >= :since "
+ " OR s.deletedAt >= :since)";
String SELECT_BY_TYPE_AND_COUNTRY_SINCE =
"SELECT s FROM SignerInformationEntity s"
+ " WHERE s.certificateType = :certType AND s.country = :country AND (s.createdAt >= :since"
+ " OR s.deletedAt >= :since)";

Optional<SignerInformationEntity> getFirstByThumbprint(String thumbprint);

Optional<SignerInformationEntity> getFirstByThumbprintStartsWith(String thumbprintStart);

@Transactional
void deleteByThumbprint(String thumbprint);
@Modifying
@Query("DELETE FROM SignerInformationEntity s WHERE s.deletedAt < :threshold")
int deleteDeletedSignerInformationOlderThan(@Param("threshold") ZonedDateTime threshold);

List<SignerInformationEntity> getByCertificateType(SignerInformationEntity.CertificateType type,
Pageable pageable);

List<SignerInformationEntity> getByCertificateType(SignerInformationEntity.CertificateType type);

List<SignerInformationEntity> getByCertificateTypeAndCountry(
SignerInformationEntity.CertificateType type, String countryCode,
Pageable pageable);

List<SignerInformationEntity> getByCertificateTypeAndCountry(
SignerInformationEntity.CertificateType type, String countryCode);

@Query(SELECT_SINCE)
List<SignerInformationEntity> getIsSince(@Param("since")ZonedDateTime since);

@Query(SELECT_SINCE)
List<SignerInformationEntity> getIsSince(@Param("since")ZonedDateTime since, Pageable pageable);

@Query(SELECT_BY_TYPE_SINCE)
List<SignerInformationEntity> getByCertificateTypeIsSince(
@Param("certType")SignerInformationEntity.CertificateType type,
@Param("since")ZonedDateTime since);

@Query(SELECT_BY_TYPE_SINCE)
List<SignerInformationEntity> getByCertificateTypeIsSince(
@Param("certType")SignerInformationEntity.CertificateType type,
@Param("since")ZonedDateTime since, Pageable pageable);

@Query(SELECT_BY_TYPE_AND_COUNTRY_SINCE)
List<SignerInformationEntity> getByCertificateTypeAndCountryIsSince(
@Param("certType")SignerInformationEntity.CertificateType type,
@Param("country")String countryCode,
@Param("since")ZonedDateTime since);

@Query(SELECT_BY_TYPE_AND_COUNTRY_SINCE)
List<SignerInformationEntity> getByCertificateTypeAndCountryIsSince(
@Param("certType")SignerInformationEntity.CertificateType type,
@Param("country")String countryCode,
@Param("since")ZonedDateTime since, Pageable pageable);

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,22 @@
package eu.europa.ec.dgc.gateway.repository;

import eu.europa.ec.dgc.gateway.entity.TrustedPartyEntity;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface TrustedPartyRepository extends JpaRepository<TrustedPartyEntity, Long> {

String SELECT_SINCE = "SELECT t FROM TrustedPartyEntity t WHERE t.createdAt >= :since";
String SELECT_BY_TYPE_SINCE =
"SELECT t FROM TrustedPartyEntity t WHERE t.certificateType = :certType AND t.createdAt >= :since";
String SELECT_BY_TYPE_AND_COUNTRY_SINCE =
"SELECT t FROM TrustedPartyEntity t"
+ " WHERE t.certificateType = :certType AND t.country = :country AND t.createdAt >= :since";

List<TrustedPartyEntity> getByCountryAndCertificateType(String country, TrustedPartyEntity.CertificateType type);

List<TrustedPartyEntity> getByCertificateType(TrustedPartyEntity.CertificateType type);
Expand All @@ -41,4 +50,18 @@ Optional<TrustedPartyEntity> getFirstByThumbprintAndCertificateType(
@Query("SELECT DISTINCT t.country FROM TrustedPartyEntity t")
List<String> getCountryCodeList();

@Query(SELECT_SINCE)
List<TrustedPartyEntity> getIsSince(@Param("since") ZonedDateTime since);

@Query(SELECT_BY_TYPE_SINCE)
List<TrustedPartyEntity> getByCertificateTypeIsSince(
@Param("certType")TrustedPartyEntity.CertificateType type,
@Param("since")ZonedDateTime since);

@Query(SELECT_BY_TYPE_AND_COUNTRY_SINCE)
List<TrustedPartyEntity> getByCountryAndCertificateTypeIsSince(
@Param("country")String countryCode,
@Param("certType")TrustedPartyEntity.CertificateType type,
@Param("since")ZonedDateTime since);

}
Loading

0 comments on commit 4893077

Please sign in to comment.