Skip to content

Commit

Permalink
feat: remove-tng-dependency
Browse files Browse the repository at this point in the history
feat: TNG dependencies removed
  • Loading branch information
tence authored Oct 5, 2023
2 parents 761a730 + e190481 commit c55cfca
Show file tree
Hide file tree
Showing 25 changed files with 353 additions and 143 deletions.
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,6 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>eu.europa.ec.dgc</groupId>
<artifactId>ddcc-gateway-lib</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@

package tng.trustnetwork.keydistribution.mapper;

import eu.europa.ec.dgc.gateway.connector.model.TrustedIssuer;
import java.util.List;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import tng.trustnetwork.keydistribution.dto.TrustedIssuerDto;
import tng.trustnetwork.keydistribution.entity.TrustedIssuerEntity;
import tng.trustnetwork.keydistribution.model.TrustedIssuer;

@Mapper(componentModel = "spring")
public interface IssuerMapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package tng.trustnetwork.keydistribution.model;

import java.time.ZonedDateTime;

public class TrustListItem {
private String kid;
private ZonedDateTime timestamp;
private String rawData;
private String country;
private String thumbprint;
private String signature;

public TrustListItem() {
}

public String getKid() {
return this.kid;
}

public ZonedDateTime getTimestamp() {
return this.timestamp;
}

public String getRawData() {
return this.rawData;
}

public String getCountry() {
return this.country;
}

public String getThumbprint() {
return this.thumbprint;
}

public String getSignature() {
return this.signature;
}

public void setKid(final String kid) {
this.kid = kid;
}

public void setTimestamp(final ZonedDateTime timestamp) {
this.timestamp = timestamp;
}

public void setRawData(final String rawData) {
this.rawData = rawData;
}

public void setCountry(final String country) {
this.country = country;
}

public void setThumbprint(final String thumbprint) {
this.thumbprint = thumbprint;
}

public void setSignature(final String signature) {
this.signature = signature;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package tng.trustnetwork.keydistribution.model;

import java.time.ZonedDateTime;

public class TrustedIssuer {
private String url;
private UrlType type;
private String country;
private String thumbprint;
private String sslPublicKey;
private String keyStorageType;
private String signature;
private ZonedDateTime timestamp;
private String name;
private String uuid;
private String domain;

public TrustedIssuer() {
}

public String getUrl() {
return this.url;
}

public UrlType getType() {
return this.type;
}

public String getCountry() {
return this.country;
}

public String getThumbprint() {
return this.thumbprint;
}

public String getSslPublicKey() {
return this.sslPublicKey;
}

public String getKeyStorageType() {
return this.keyStorageType;
}

public String getSignature() {
return this.signature;
}

public ZonedDateTime getTimestamp() {
return this.timestamp;
}

public String getName() {
return this.name;
}

public String getUuid() {
return this.uuid;
}

public String getDomain() {
return this.domain;
}

public void setUrl(final String url) {
this.url = url;
}

public void setType(final UrlType type) {
this.type = type;
}

public void setCountry(final String country) {
this.country = country;
}

public void setThumbprint(final String thumbprint) {
this.thumbprint = thumbprint;
}

public void setSslPublicKey(final String sslPublicKey) {
this.sslPublicKey = sslPublicKey;
}

public void setKeyStorageType(final String keyStorageType) {
this.keyStorageType = keyStorageType;
}

public void setSignature(final String signature) {
this.signature = signature;
}

public void setTimestamp(final ZonedDateTime timestamp) {
this.timestamp = timestamp;
}

public void setName(final String name) {
this.name = name;
}

public void setUuid(final String uuid) {
this.uuid = uuid;
}

public void setDomain(final String domain) {
this.domain = domain;
}

public static enum UrlType {
HTTP,
DID;

private UrlType() {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import lombok.AllArgsConstructor;
import lombok.Getter;


@Schema(
name = "DeltaList",
type = "object",
Expand All @@ -13,6 +12,7 @@
+ "\"deleted\":[\"3115adf=\"]\n"
+ "}"
)

@Getter
@AllArgsConstructor
public class CertificatesLookupResponseItemDto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import lombok.Data;
import lombok.NoArgsConstructor;


@Schema(
name = "DeltaList",
type = "object",
Expand All @@ -15,6 +14,7 @@
+ "\"deleted\":[\"3115adf=\"]\n"
+ "}"
)

@Data
@AllArgsConstructor
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
+ "\"details\":\"...\"\n"
+ "}"
)

@Data
@AllArgsConstructor
public class ProblemReportDto {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package tng.trustnetwork.keydistribution.service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Service;
import tng.trustnetwork.keydistribution.model.TrustListItem;
import tng.trustnetwork.keydistribution.model.TrustedIssuer;

@ConditionalOnProperty({"dgc.gateway.connector.enabled"})
@Service
@EnableScheduling
@RequiredArgsConstructor
public class DummyDownloadConnector {

private List<TrustListItem> trustedCertificates = new ArrayList();

private List<TrustedIssuer> trustedIssuers = new ArrayList();

public List<TrustListItem> getTrustedCertificates() {
this.updateIfRequired();
return Collections.unmodifiableList(this.trustedCertificates);
}

public List<TrustedIssuer> getTrustedIssuers() {
this.updateIfRequired();
return Collections.unmodifiableList(this.trustedIssuers);
}

private void updateIfRequired() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@

package tng.trustnetwork.keydistribution.service;

import eu.europa.ec.dgc.gateway.connector.DgcGatewayDownloadConnector;
import eu.europa.ec.dgc.gateway.connector.model.TrustListItem;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import tng.trustnetwork.keydistribution.model.TrustListItem;

/**
* A service to download the signer certificates from the digital green certificate gateway.
Expand All @@ -39,7 +38,8 @@
@Profile("!btp")
public class SignerCertificateDownloadServiceImpl implements SignerCertificateDownloadService {

private final DgcGatewayDownloadConnector dgcGatewayConnector;
DummyDownloadConnector dummyDownloadConnector = new DummyDownloadConnector();

private final SignerInformationService signerInformationService;

@Override
Expand All @@ -49,11 +49,11 @@ public class SignerCertificateDownloadServiceImpl implements SignerCertificateDo
public void downloadCertificates() {
log.info("Certificates download started");

List<TrustListItem> trustedCerts = dgcGatewayConnector.getTrustedCertificates();
// TODO Dummy
List<TrustListItem> trustedCerts = dummyDownloadConnector.getTrustedCertificates();

signerInformationService.updateTrustedCertsList(trustedCerts);

log.info("Certificates download finished");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

package tng.trustnetwork.keydistribution.service;

import eu.europa.ec.dgc.gateway.connector.model.TrustListItem;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -32,6 +31,7 @@
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import tng.trustnetwork.keydistribution.entity.SignerInformationEntity;
import tng.trustnetwork.keydistribution.model.TrustListItem;
import tng.trustnetwork.keydistribution.repository.SignerInformationRepository;
import tng.trustnetwork.keydistribution.restapi.dto.CertificatesLookupResponseItemDto;
import tng.trustnetwork.keydistribution.restapi.dto.DeltaListDto;
Expand All @@ -43,7 +43,6 @@ public class SignerInformationService {

private final SignerInformationRepository signerInformationRepository;


/**
* Method to query the db for a certificate with a resume token.
*
Expand All @@ -58,7 +57,6 @@ public Optional<SignerInformationEntity> getCertificate(Long resumeToken) {
}
}


/**
* Method to query the db for a list of kid from all certificates.
*
Expand All @@ -72,7 +70,6 @@ public List<String> getListOfValidKids() {

}


/**
* Method to synchronise the certificates in the db with the given List of trusted certificates.
*
Expand All @@ -86,15 +83,13 @@ public void updateTrustedCertsList(List<TrustListItem> trustedCerts) {
List<String> alreadyStoredCerts = getListOfValidKids();
List<String> certsToDelete = new ArrayList<>();


if (trustedCertsKids.isEmpty()) {
signerInformationRepository.setAllDeleted();
return;
} else {
signerInformationRepository.setDeletedByKidsNotIn(trustedCertsKids);
}


List<SignerInformationEntity> signerInformationEntities = new ArrayList<>();

for (TrustListItem cert : trustedCerts) {
Expand All @@ -109,7 +104,6 @@ public void updateTrustedCertsList(List<TrustListItem> trustedCerts) {
signerInformationRepository.saveAllAndFlush(signerInformationEntities);
}


private SignerInformationEntity getSingerInformationEntity(TrustListItem cert) {
SignerInformationEntity signerEntity = new SignerInformationEntity();
signerEntity.setKid(cert.getKid());
Expand Down Expand Up @@ -172,5 +166,4 @@ public Map<String, List<CertificatesLookupResponseItemDto>> getCertificatesData(
private CertificatesLookupResponseItemDto map(SignerInformationEntity entity) {
return new CertificatesLookupResponseItemDto(entity.getKid(), entity.getRawData());
}

}
Loading

0 comments on commit c55cfca

Please sign in to comment.