diff --git a/apps/adresse-service/src/main/java/no/nav/testnav/apps/adresseservice/config/Consumers.java b/apps/adresse-service/src/main/java/no/nav/testnav/apps/adresseservice/config/Consumers.java
new file mode 100644
index 00000000000..b684a79e257
--- /dev/null
+++ b/apps/adresse-service/src/main/java/no/nav/testnav/apps/adresseservice/config/Consumers.java
@@ -0,0 +1,29 @@
+package no.nav.testnav.apps.adresseservice.config;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import no.nav.testnav.libs.securitycore.domain.ServerProperties;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import static lombok.AccessLevel.PACKAGE;
+
+/**
+ * Samler alle placeholders for ulike {@code consumers.*}-konfigurasjon her, dvs. subklasser av {@code ServerProperties}.
+ *
+ * Husk at Spring Boot bruker relaxed binding
+ * mellom configuration properties og field names.
+ *
+ * @see ServerProperties
+ */
+@Configuration
+@ConfigurationProperties(prefix = "consumers")
+@NoArgsConstructor(access = PACKAGE)
+@Getter
+@Setter(PACKAGE)
+public class Consumers {
+
+ private ServerProperties pdlServices;
+
+}
diff --git a/apps/adresse-service/src/main/java/no/nav/testnav/apps/adresseservice/config/credentials/PdlServiceProperties.java b/apps/adresse-service/src/main/java/no/nav/testnav/apps/adresseservice/config/credentials/PdlServiceProperties.java
deleted file mode 100644
index f27e2494679..00000000000
--- a/apps/adresse-service/src/main/java/no/nav/testnav/apps/adresseservice/config/credentials/PdlServiceProperties.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package no.nav.testnav.apps.adresseservice.config.credentials;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-import no.nav.testnav.libs.securitycore.domain.ServerProperties;
-
-@Configuration
-@ConfigurationProperties(prefix = "consumers.pdl-services")
-public class PdlServiceProperties extends ServerProperties {
-}
\ No newline at end of file
diff --git a/apps/adresse-service/src/main/java/no/nav/testnav/apps/adresseservice/consumer/PdlAdresseConsumer.java b/apps/adresse-service/src/main/java/no/nav/testnav/apps/adresseservice/consumer/PdlAdresseConsumer.java
index 49931250099..c70e707f816 100644
--- a/apps/adresse-service/src/main/java/no/nav/testnav/apps/adresseservice/consumer/PdlAdresseConsumer.java
+++ b/apps/adresse-service/src/main/java/no/nav/testnav/apps/adresseservice/consumer/PdlAdresseConsumer.java
@@ -1,6 +1,6 @@
package no.nav.testnav.apps.adresseservice.consumer;
-import no.nav.testnav.apps.adresseservice.config.credentials.PdlServiceProperties;
+import no.nav.testnav.apps.adresseservice.config.Consumers;
import no.nav.testnav.apps.adresseservice.consumer.command.PdlAdresseSoekCommand;
import no.nav.testnav.apps.adresseservice.dto.GraphQLRequest;
import no.nav.testnav.apps.adresseservice.dto.PdlAdresseResponse;
@@ -13,19 +13,21 @@
public class PdlAdresseConsumer {
private final WebClient webClient;
private final TokenExchange tokenExchange;
- private final ServerProperties properties;
+ private final ServerProperties serverProperties;
- public PdlAdresseConsumer(TokenExchange tokenExchange, PdlServiceProperties properties) {
+ public PdlAdresseConsumer(
+ TokenExchange tokenExchange,
+ Consumers consumers) {
this.tokenExchange = tokenExchange;
- this.properties = properties;
+ serverProperties = consumers.getPdlServices();
this.webClient = WebClient
.builder()
- .baseUrl(properties.getUrl())
+ .baseUrl(serverProperties.getUrl())
.build();
}
public PdlAdresseResponse sendAdressesoek(GraphQLRequest adresseQuery) {
- return tokenExchange.exchange(properties)
+ return tokenExchange.exchange(serverProperties)
.flatMap(token -> new PdlAdresseSoekCommand(webClient, adresseQuery, token.getTokenValue()).call())
.block();
}
diff --git a/apps/amelding-service/src/main/java/no/nav/registre/testnav/ameldingservice/config/Consumers.java b/apps/amelding-service/src/main/java/no/nav/registre/testnav/ameldingservice/config/Consumers.java
new file mode 100644
index 00000000000..90798e40fb2
--- /dev/null
+++ b/apps/amelding-service/src/main/java/no/nav/registre/testnav/ameldingservice/config/Consumers.java
@@ -0,0 +1,29 @@
+package no.nav.registre.testnav.ameldingservice.config;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import no.nav.testnav.libs.securitycore.domain.ServerProperties;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import static lombok.AccessLevel.PACKAGE;
+
+/**
+ * Samler alle placeholders for ulike {@code consumers.*}-konfigurasjon her, dvs. subklasser av {@code ServerProperties}.
+ *
+ * Husk at Spring Boot bruker relaxed binding
+ * mellom configuration properties og field names.
+ *
+ * @see ServerProperties
+ */
+@Configuration
+@ConfigurationProperties(prefix = "consumers")
+@NoArgsConstructor(access = PACKAGE)
+@Getter
+@Setter(PACKAGE)
+public class Consumers {
+
+ private ServerProperties oppsummeringsdokumentService;
+
+}
diff --git a/apps/amelding-service/src/main/java/no/nav/registre/testnav/ameldingservice/consumer/OppsummeringsdokumentConsumer.java b/apps/amelding-service/src/main/java/no/nav/registre/testnav/ameldingservice/consumer/OppsummeringsdokumentConsumer.java
index e3ef3513084..f3c83c07043 100644
--- a/apps/amelding-service/src/main/java/no/nav/registre/testnav/ameldingservice/consumer/OppsummeringsdokumentConsumer.java
+++ b/apps/amelding-service/src/main/java/no/nav/registre/testnav/ameldingservice/consumer/OppsummeringsdokumentConsumer.java
@@ -1,7 +1,7 @@
package no.nav.registre.testnav.ameldingservice.consumer;
import com.fasterxml.jackson.databind.ObjectMapper;
-import no.nav.registre.testnav.ameldingservice.credentials.OppsummeringsdokumentServerProperties;
+import no.nav.registre.testnav.ameldingservice.config.Consumers;
import no.nav.testnav.libs.commands.GetOppsummeringsdokumentByIdCommand;
import no.nav.testnav.libs.commands.GetOppsummeringsdokumentCommand;
import no.nav.testnav.libs.commands.SaveOppsummeringsdokumenterCommand;
@@ -25,23 +25,25 @@ public class OppsummeringsdokumentConsumer {
private final ApplicationProperties applicationProperties;
public OppsummeringsdokumentConsumer(
- OppsummeringsdokumentServerProperties properties,
+ Consumers consumers,
ObjectMapper objectMapper,
ApplicationProperties applicationProperties) {
-
this.applicationProperties = applicationProperties;
this.webClient = WebClient
.builder()
- .baseUrl(properties.getUrl())
- .codecs(clientDefaultCodecsConfigurer -> {
- clientDefaultCodecsConfigurer.defaultCodecs().maxInMemorySize(BYTE_COUNT);
- clientDefaultCodecsConfigurer
- .defaultCodecs()
- .jackson2JsonEncoder(new Jackson2JsonEncoder(objectMapper, MediaType.APPLICATION_JSON));
- clientDefaultCodecsConfigurer
- .defaultCodecs()
- .jackson2JsonDecoder(new Jackson2JsonDecoder(objectMapper, MediaType.APPLICATION_JSON));
- })
+ .baseUrl(consumers.getOppsummeringsdokumentService().getUrl())
+ .codecs(
+ clientDefaultCodecsConfigurer -> {
+ clientDefaultCodecsConfigurer
+ .defaultCodecs()
+ .maxInMemorySize(BYTE_COUNT);
+ clientDefaultCodecsConfigurer
+ .defaultCodecs()
+ .jackson2JsonEncoder(new Jackson2JsonEncoder(objectMapper, MediaType.APPLICATION_JSON));
+ clientDefaultCodecsConfigurer
+ .defaultCodecs()
+ .jackson2JsonDecoder(new Jackson2JsonDecoder(objectMapper, MediaType.APPLICATION_JSON));
+ })
.build();
}
diff --git a/apps/amelding-service/src/main/java/no/nav/registre/testnav/ameldingservice/credentials/OppsummeringsdokumentServerProperties.java b/apps/amelding-service/src/main/java/no/nav/registre/testnav/ameldingservice/credentials/OppsummeringsdokumentServerProperties.java
deleted file mode 100644
index 4f4d3426e6b..00000000000
--- a/apps/amelding-service/src/main/java/no/nav/registre/testnav/ameldingservice/credentials/OppsummeringsdokumentServerProperties.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package no.nav.registre.testnav.ameldingservice.credentials;
-
-import lombok.Getter;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-import no.nav.testnav.libs.securitycore.domain.ServerProperties;
-
-
-@Getter
-@Configuration
-@ConfigurationProperties(prefix = "consumers.oppsummeringsdokument-service")
-public class OppsummeringsdokumentServerProperties extends ServerProperties {
-}
diff --git a/apps/amelding-service/src/main/java/no/nav/registre/testnav/ameldingservice/service/AMeldingService.java b/apps/amelding-service/src/main/java/no/nav/registre/testnav/ameldingservice/service/AMeldingService.java
index 2873263cd77..117a241c0fe 100644
--- a/apps/amelding-service/src/main/java/no/nav/registre/testnav/ameldingservice/service/AMeldingService.java
+++ b/apps/amelding-service/src/main/java/no/nav/registre/testnav/ameldingservice/service/AMeldingService.java
@@ -1,8 +1,8 @@
package no.nav.registre.testnav.ameldingservice.service;
import lombok.RequiredArgsConstructor;
+import no.nav.registre.testnav.ameldingservice.config.Consumers;
import no.nav.registre.testnav.ameldingservice.consumer.OppsummeringsdokumentConsumer;
-import no.nav.registre.testnav.ameldingservice.credentials.OppsummeringsdokumentServerProperties;
import no.nav.registre.testnav.ameldingservice.domain.AMelding;
import no.nav.testnav.libs.reactivesecurity.exchange.TokenExchange;
import no.nav.testnav.libs.securitycore.domain.AccessToken;
@@ -13,11 +13,11 @@
@RequiredArgsConstructor
public class AMeldingService {
private final OppsummeringsdokumentConsumer oppsummeringsdokumentConsumer;
- private final OppsummeringsdokumentServerProperties applicationProperties;
+ private final Consumers consumers;
private final TokenExchange tokenExchange;
public Mono save(AMelding aMelding, String miljo) {
- return tokenExchange.exchange(applicationProperties).flatMap(accessToken -> oppsummeringsdokumentConsumer
+ return tokenExchange.exchange(consumers.getOppsummeringsdokumentService()).flatMap(accessToken -> oppsummeringsdokumentConsumer
.get(
aMelding.getOpplysningspliktigOrganisajonsnummer(),
aMelding.getKalendermaaned(),
@@ -29,7 +29,7 @@ public Mono save(AMelding aMelding, String miljo) {
}
public Mono get(String id) {
- Mono accessToken = tokenExchange.exchange(applicationProperties).map(AccessToken::getTokenValue);
+ Mono accessToken = tokenExchange.exchange(consumers.getOppsummeringsdokumentService()).map(AccessToken::getTokenValue);
return oppsummeringsdokumentConsumer.get(id, accessToken).map(AMelding::new);
}
}
diff --git a/apps/arbeidsforhold-service/src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/config/Consumers.java b/apps/arbeidsforhold-service/src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/config/Consumers.java
new file mode 100644
index 00000000000..38f7ef3b5f9
--- /dev/null
+++ b/apps/arbeidsforhold-service/src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/config/Consumers.java
@@ -0,0 +1,29 @@
+package no.nav.registre.testnorge.arbeidsforholdservice.config;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import no.nav.testnav.libs.securitycore.domain.ServerProperties;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import static lombok.AccessLevel.PACKAGE;
+
+/**
+ * Samler alle placeholders for ulike {@code consumers.*}-konfigurasjon her, dvs. subklasser av {@code ServerProperties}.
+ *
+ * Husk at Spring Boot bruker relaxed binding
+ * mellom configuration properties og field names.
+ *
+ * @see ServerProperties
+ */
+@Configuration
+@ConfigurationProperties(prefix = "consumers")
+@NoArgsConstructor(access = PACKAGE)
+@Getter
+@Setter(PACKAGE)
+public class Consumers {
+
+ private ServerProperties testnavAaregProxy;
+
+}
diff --git a/apps/arbeidsforhold-service/src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/config/credentials/AaregServiceProperties.java b/apps/arbeidsforhold-service/src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/config/credentials/AaregServiceProperties.java
deleted file mode 100644
index 6d75d467b89..00000000000
--- a/apps/arbeidsforhold-service/src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/config/credentials/AaregServiceProperties.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package no.nav.registre.testnorge.arbeidsforholdservice.config.credentials;
-
-import no.nav.testnav.libs.securitycore.domain.ServerProperties;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-
-@Configuration
-@ConfigurationProperties(prefix = "consumers.testnav-aareg-proxy")
-public class AaregServiceProperties extends ServerProperties {
-}
\ No newline at end of file
diff --git a/apps/arbeidsforhold-service/src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/consumer/AaregConsumer.java b/apps/arbeidsforhold-service/src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/consumer/AaregConsumer.java
index 9e44ddd8680..a148b946e8e 100644
--- a/apps/arbeidsforhold-service/src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/consumer/AaregConsumer.java
+++ b/apps/arbeidsforhold-service/src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/consumer/AaregConsumer.java
@@ -2,7 +2,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
-import no.nav.registre.testnorge.arbeidsforholdservice.config.credentials.AaregServiceProperties;
+import no.nav.registre.testnorge.arbeidsforholdservice.config.Consumers;
import no.nav.registre.testnorge.arbeidsforholdservice.consumer.command.GetArbeidstakerArbeidsforholdCommand;
import no.nav.registre.testnorge.arbeidsforholdservice.consumer.dto.ArbeidsforholdDTO;
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
@@ -30,21 +30,23 @@ public class AaregConsumer {
private final TokenExchange tokenExchange;
public AaregConsumer(
- AaregServiceProperties serverProperties,
+ Consumers consumers,
TokenExchange tokenExchange,
ObjectMapper objectMapper) {
-
- this.serverProperties = serverProperties;
+ serverProperties = consumers.getTestnavAaregProxy();
this.tokenExchange = tokenExchange;
-
- ExchangeStrategies jacksonStrategy = ExchangeStrategies.builder()
- .codecs(config -> {
- config.defaultCodecs()
- .jackson2JsonEncoder(new Jackson2JsonEncoder(objectMapper, MediaType.APPLICATION_JSON));
- config.defaultCodecs()
- .jackson2JsonDecoder(new Jackson2JsonDecoder(objectMapper, MediaType.APPLICATION_JSON));
- }).build();
-
+ ExchangeStrategies jacksonStrategy = ExchangeStrategies
+ .builder()
+ .codecs(
+ config -> {
+ config
+ .defaultCodecs()
+ .jackson2JsonEncoder(new Jackson2JsonEncoder(objectMapper, MediaType.APPLICATION_JSON));
+ config
+ .defaultCodecs()
+ .jackson2JsonDecoder(new Jackson2JsonDecoder(objectMapper, MediaType.APPLICATION_JSON));
+ })
+ .build();
this.webClient = WebClient
.builder()
.exchangeStrategies(jacksonStrategy)
diff --git a/apps/batch-bestilling-service/src/main/java/no/nav/registre/testnorge/batchbestillingservice/config/Consumers.java b/apps/batch-bestilling-service/src/main/java/no/nav/registre/testnorge/batchbestillingservice/config/Consumers.java
new file mode 100644
index 00000000000..f6a07c0ea2d
--- /dev/null
+++ b/apps/batch-bestilling-service/src/main/java/no/nav/registre/testnorge/batchbestillingservice/config/Consumers.java
@@ -0,0 +1,29 @@
+package no.nav.registre.testnorge.batchbestillingservice.config;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import no.nav.testnav.libs.securitycore.domain.ServerProperties;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import static lombok.AccessLevel.PACKAGE;
+
+/**
+ * Samler alle placeholders for ulike {@code consumers.*}-konfigurasjon her, dvs. subklasser av {@code ServerProperties}.
+ *
+ * Husk at Spring Boot bruker relaxed binding
+ * mellom configuration properties og field names.
+ *
+ * @see ServerProperties
+ */
+@Configuration
+@ConfigurationProperties(prefix = "consumers")
+@NoArgsConstructor(access = PACKAGE)
+@Getter
+@Setter(PACKAGE)
+public class Consumers {
+
+ private ServerProperties dollyBackend;
+
+}
diff --git a/apps/batch-bestilling-service/src/main/java/no/nav/registre/testnorge/batchbestillingservice/consumer/DollyBackendConsumer.java b/apps/batch-bestilling-service/src/main/java/no/nav/registre/testnorge/batchbestillingservice/consumer/DollyBackendConsumer.java
index 5dd3f928c2d..bc542df61cf 100644
--- a/apps/batch-bestilling-service/src/main/java/no/nav/registre/testnorge/batchbestillingservice/consumer/DollyBackendConsumer.java
+++ b/apps/batch-bestilling-service/src/main/java/no/nav/registre/testnorge/batchbestillingservice/consumer/DollyBackendConsumer.java
@@ -3,7 +3,7 @@
import lombok.extern.slf4j.Slf4j;
import no.nav.registre.testnorge.batchbestillingservice.command.GetAktiveBestillingerCommand;
import no.nav.registre.testnorge.batchbestillingservice.command.PostBestillingCommand;
-import no.nav.registre.testnorge.batchbestillingservice.credentials.DollyBackendServiceProperties;
+import no.nav.registre.testnorge.batchbestillingservice.config.Consumers;
import no.nav.registre.testnorge.batchbestillingservice.request.RsDollyBestillingRequest;
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
import no.nav.testnav.libs.standalone.servletsecurity.exchange.TokenExchange;
@@ -21,18 +21,17 @@ public class DollyBackendConsumer {
private final WebClient webClient;
private final TokenExchange tokenService;
- private final ServerProperties serviceProperties;
+ private final ServerProperties serverProperties;
public DollyBackendConsumer(
- DollyBackendServiceProperties properties,
+ Consumers consumers,
TokenExchange tokenService,
WebClient.Builder webClientBuilder
) {
-
- this.serviceProperties = properties;
+ serverProperties = consumers.getDollyBackend();
this.tokenService = tokenService;
this.webClient = webClientBuilder
- .baseUrl(serviceProperties.getUrl())
+ .baseUrl(serverProperties.getUrl())
.build();
}
@@ -41,7 +40,7 @@ public void postDollyBestilling(Long gruppeId, RsDollyBestillingRequest request,
request.setAntall(antall.intValue());
tokenService
- .exchange(serviceProperties)
+ .exchange(serverProperties)
.map(token -> new PostBestillingCommand(webClient, token.getTokenValue(), gruppeId, request).call())
.doOnError(error -> log.error("Bestilling feilet for gruppe {}", gruppeId, error))
.doOnSuccess(response -> log.info("Bestilling med {} identer startet i backend for gruppe {}", antall, gruppeId))
@@ -53,7 +52,7 @@ public List