From 7888c9d8e3328536d5fcfa2ff207a93a1b1a2889 Mon Sep 17 00:00:00 2001 From: lmeinen Date: Thu, 24 Jun 2021 14:08:54 +0200 Subject: [PATCH] Added scheduled call to app token dataservice --- .../ws/config/WSSchedulingConfig.java | 29 +++++++++++++++++++ .../verifier/ws/config/WsBaseConfig.java | 7 +++++ 2 files changed, 36 insertions(+) create mode 100644 ch-covidcertificate-backend-verifier/ch-covidcertificate-backend-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/verifier/ws/config/WSSchedulingConfig.java diff --git a/ch-covidcertificate-backend-verifier/ch-covidcertificate-backend-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/verifier/ws/config/WSSchedulingConfig.java b/ch-covidcertificate-backend-verifier/ch-covidcertificate-backend-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/verifier/ws/config/WSSchedulingConfig.java new file mode 100644 index 00000000..ccdf1cce --- /dev/null +++ b/ch-covidcertificate-backend-verifier/ch-covidcertificate-backend-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/verifier/ws/config/WSSchedulingConfig.java @@ -0,0 +1,29 @@ +package ch.admin.bag.covidcertificate.backend.verifier.ws.config; + +import ch.admin.bag.covidcertificate.backend.verifier.data.AppTokenDataService; +import ch.admin.bag.covidcertificate.backend.verifier.model.AppToken; +import ch.admin.bag.covidcertificate.backend.verifier.ws.config.model.ApiKeyConfig; +import java.util.List; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; + +@Configuration +@EnableScheduling +public class WSSchedulingConfig { + + private final ApiKeyConfig apiKeyConfig; + private final AppTokenDataService appTokenDataService; + + public WSSchedulingConfig( + ApiKeyConfig apiKeyConfig, + AppTokenDataService appTokenDataService) { + this.apiKeyConfig = apiKeyConfig; + this.appTokenDataService = appTokenDataService; + } + + @Scheduled(cron = "${ws.authentication.cron:0 0/5 0 ? * *}") + public void updateAppTokens() { + final var appTokens = appTokenDataService.getAppTokens(); + } +} diff --git a/ch-covidcertificate-backend-verifier/ch-covidcertificate-backend-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/verifier/ws/config/WsBaseConfig.java b/ch-covidcertificate-backend-verifier/ch-covidcertificate-backend-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/verifier/ws/config/WsBaseConfig.java index ab59f856..a223949a 100644 --- a/ch-covidcertificate-backend-verifier/ch-covidcertificate-backend-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/verifier/ws/config/WsBaseConfig.java +++ b/ch-covidcertificate-backend-verifier/ch-covidcertificate-backend-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/verifier/ws/config/WsBaseConfig.java @@ -10,7 +10,9 @@ package ch.admin.bag.covidcertificate.backend.verifier.ws.config; +import ch.admin.bag.covidcertificate.backend.verifier.data.AppTokenDataService; import ch.admin.bag.covidcertificate.backend.verifier.data.VerifierDataService; +import ch.admin.bag.covidcertificate.backend.verifier.data.impl.JdbcAppTokenDataServiceImpl; import ch.admin.bag.covidcertificate.backend.verifier.data.impl.JdbcVerifierDataServiceImpl; import ch.admin.bag.covidcertificate.backend.verifier.ws.controller.KeyController; import ch.admin.bag.covidcertificate.backend.verifier.ws.controller.RevocationListController; @@ -128,6 +130,11 @@ public VerifierDataService verifierDataService(DataSource dataSource) { return new JdbcVerifierDataServiceImpl(dataSource); } + @Bean + public AppTokenDataService appTokenDataService(DataSource dataSource) { + return new JdbcAppTokenDataServiceImpl(dataSource); + } + @Bean public KeyController keyController(VerifierDataService verifierDataService) { return new KeyController(verifierDataService);