From 30c43c58e75a1e8dcb8b326ce59f6ff81d6663f7 Mon Sep 17 00:00:00 2001 From: DeclanClarkeCGI <142809814+DeclanClarkeCGI@users.noreply.github.com> Date: Tue, 13 Feb 2024 10:57:01 +0000 Subject: [PATCH] Po 64 add basic auth to legacy gateway service (#194) * update schemas, update defendantaccount details service to retrieve notes * Add legacy gateway basic auth * Bumping chart version/ fixing aliases --------- Co-authored-by: hmcts-jenkins-cnp <60659747+hmcts-jenkins-cnp[bot]@users.noreply.github.com> --- charts/opal-fines-service/Chart.yaml | 2 +- .../values.dev.template.yaml | 6 ++++- charts/opal-fines-service/values.yaml | 4 +++ .../config/rest/RestClientConfiguration.java | 25 +++++++++++++++++++ .../legacy/LegacyAccountTransferService.java | 2 +- .../legacy/LegacyBusinessUnitService.java | 2 +- ...LegacyCommittalWarrantProgressService.java | 2 +- .../service/legacy/LegacyCourtService.java | 2 +- .../legacy/LegacyDebtorDetailService.java | 2 +- .../legacy/LegacyDefendantAccountService.java | 6 ++--- .../legacy/LegacyDocumentInstanceService.java | 2 +- .../service/legacy/LegacyDocumentService.java | 2 +- .../legacy/LegacyEnforcementService.java | 2 +- .../service/legacy/LegacyEnforcerService.java | 2 +- .../legacy/LegacyLocalJusticeAreaService.java | 2 +- .../legacy/LegacyMisDebtorService.java | 2 +- .../service/legacy/LegacyNoteService.java | 2 +- .../service/legacy/LegacyPartyService.java | 2 +- .../legacy/LegacyPaymentInService.java | 2 +- .../legacy/LegacyPaymentTermsService.java | 2 +- .../service/legacy/LegacyPrisonService.java | 2 +- .../service/legacy/LegacyTillService.java | 2 +- src/main/resources/application.yaml | 5 +++- 23 files changed, 59 insertions(+), 23 deletions(-) diff --git a/charts/opal-fines-service/Chart.yaml b/charts/opal-fines-service/Chart.yaml index 4897f8802..9e905d017 100644 --- a/charts/opal-fines-service/Chart.yaml +++ b/charts/opal-fines-service/Chart.yaml @@ -3,7 +3,7 @@ appVersion: "1.0" description: A Helm chart for opal-fines-service app name: opal-fines-service home: https://github.com/hmcts/opal-fines-service -version: 0.0.25 +version: 0.0.26 maintainers: - name: HMCTS Opal Team dependencies: diff --git a/charts/opal-fines-service/values.dev.template.yaml b/charts/opal-fines-service/values.dev.template.yaml index 52063ae68..52911c888 100644 --- a/charts/opal-fines-service/values.dev.template.yaml +++ b/charts/opal-fines-service/values.dev.template.yaml @@ -13,6 +13,10 @@ java: alias: AAD_CLIENT_ID - name: AzureADClientSecret alias: AAD_CLIENT_SECRET + - name: OpalLegacyGatewayUsername + alias: OPAL_LEGACY_GATEWAY_USERNAME + - name: OpalLegacyGatewayPassword + alias: OPAL_LEGACY_GATEWAY_PASSWORD environment: OPAL_FINES_DB_HOST: "{{ .Release.Name }}-postgresql" OPAL_FINES_DB_NAME: "{{ .Values.postgresql.auth.database}}" @@ -22,7 +26,7 @@ java: OPAL_FINES_DB_PORT: 5432 RUN_DB_MIGRATION_ON_STARTUP: true OPAL_FRONTEND_URL: https://opal-frontend.staging.platform.hmcts.net - OPAL_LEGACY_GATEWAY_URL: https://opal-legacy-db-stub.staging.platform.hmcts.net + OPAL_LEGACY_GATEWAY_URL: https://opal.clouddev.online/opal TESTING_SUPPORT_ENDPOINTS_ENABLED: true postgresql: enabled: true diff --git a/charts/opal-fines-service/values.yaml b/charts/opal-fines-service/values.yaml index 5ddba12d6..b58566e4e 100644 --- a/charts/opal-fines-service/values.yaml +++ b/charts/opal-fines-service/values.yaml @@ -25,6 +25,10 @@ java: alias: AAD_CLIENT_SECRET - name: OpalTestUserPassword alias: OPAL_TEST_USER_PASSWORD + - name: OpalLegacyGatewayUsername + alias: OPAL_LEGACY_GATEWAY_USERNAME + - name: OpalLegacyGatewayPassword + alias: OPAL_LEGACY_GATEWAY_PASSWORD environment: RUN_DB_MIGRATION_ON_STARTUP: true OPAL_FRONTEND_URL: https://opal-frontend.{{ .Values.global.environment }}.platform.hmcts.net diff --git a/src/main/java/uk/gov/hmcts/opal/config/rest/RestClientConfiguration.java b/src/main/java/uk/gov/hmcts/opal/config/rest/RestClientConfiguration.java index fafdcb105..ae0c841c7 100644 --- a/src/main/java/uk/gov/hmcts/opal/config/rest/RestClientConfiguration.java +++ b/src/main/java/uk/gov/hmcts/opal/config/rest/RestClientConfiguration.java @@ -1,15 +1,40 @@ package uk.gov.hmcts.opal.config.rest; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpHeaders; import org.springframework.web.client.RestClient; +import java.util.Base64; + @Configuration public class RestClientConfiguration { + @Value("${legacy-gateway.username}") + String legacyUsername; + + @Value("${legacy-gateway.password}") + String legacyPassword; + @Bean public RestClient restClient() { return RestClient.create(); } + @Bean RestClient legacyRestClient() { + return RestClient.builder() + .defaultHeader( + HttpHeaders.AUTHORIZATION, + encodeBasic(legacyUsername, + legacyPassword) + ).build(); + } + + private String encodeBasic(String username, String password) { + return "Basic " + Base64 + .getEncoder() + .encodeToString((username + ":" + password).getBytes()); + } + } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyAccountTransferService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyAccountTransferService.java index 3f4de112d..a1d2ba974 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyAccountTransferService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyAccountTransferService.java @@ -17,7 +17,7 @@ public class LegacyAccountTransferService extends LegacyService implements AccountTransferServiceInterface { @Autowired - protected LegacyAccountTransferService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyAccountTransferService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyBusinessUnitService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyBusinessUnitService.java index 3e8997ebf..e4ddadbd9 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyBusinessUnitService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyBusinessUnitService.java @@ -17,7 +17,7 @@ public class LegacyBusinessUnitService extends LegacyService implements BusinessUnitServiceInterface { @Autowired - protected LegacyBusinessUnitService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyBusinessUnitService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyCommittalWarrantProgressService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyCommittalWarrantProgressService.java index f05b623cf..fa56b6bdf 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyCommittalWarrantProgressService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyCommittalWarrantProgressService.java @@ -18,7 +18,7 @@ public class LegacyCommittalWarrantProgressService extends LegacyService implements CommittalWarrantProgressServiceInterface { @Autowired - protected LegacyCommittalWarrantProgressService(@Value("${legacy-gateway-url}") String gatewayUrl, + protected LegacyCommittalWarrantProgressService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyCourtService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyCourtService.java index e9358c4c0..352b7243b 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyCourtService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyCourtService.java @@ -17,7 +17,7 @@ public class LegacyCourtService extends LegacyService implements CourtServiceInterface { @Autowired - protected LegacyCourtService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyCourtService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDebtorDetailService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDebtorDetailService.java index 5af0aea67..b051eb468 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDebtorDetailService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDebtorDetailService.java @@ -17,7 +17,7 @@ public class LegacyDebtorDetailService extends LegacyService implements DebtorDetailServiceInterface { @Autowired - protected LegacyDebtorDetailService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyDebtorDetailService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDefendantAccountService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDefendantAccountService.java index dfedb3867..46a297286 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDefendantAccountService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDefendantAccountService.java @@ -30,9 +30,9 @@ public class LegacyDefendantAccountService extends LegacyService implements Defe public static final String GET_ACCOUNT_DETAILS = "getAccountDetails"; @Autowired - protected LegacyDefendantAccountService(@Value("${legacy-gateway-url}") String gatewayUrl, - RestClient restClient) { - super(gatewayUrl, restClient); + protected LegacyDefendantAccountService(@Value("${legacy-gateway.url}") String gatewayUrl, + RestClient legacyRestClient) { + super(gatewayUrl, legacyRestClient); } @Override diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDocumentInstanceService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDocumentInstanceService.java index 75cd8d900..a35b6c511 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDocumentInstanceService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDocumentInstanceService.java @@ -17,7 +17,7 @@ public class LegacyDocumentInstanceService extends LegacyService implements DocumentInstanceServiceInterface { @Autowired - protected LegacyDocumentInstanceService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyDocumentInstanceService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDocumentService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDocumentService.java index ab4f36ed5..6f1c102fb 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDocumentService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyDocumentService.java @@ -17,7 +17,7 @@ public class LegacyDocumentService extends LegacyService implements DocumentServiceInterface { @Autowired - protected LegacyDocumentService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyDocumentService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyEnforcementService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyEnforcementService.java index 600946c91..b200a4e03 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyEnforcementService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyEnforcementService.java @@ -17,7 +17,7 @@ public class LegacyEnforcementService extends LegacyService implements EnforcementServiceInterface { @Autowired - protected LegacyEnforcementService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyEnforcementService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyEnforcerService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyEnforcerService.java index e6bb338ad..3b20d1a43 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyEnforcerService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyEnforcerService.java @@ -17,7 +17,7 @@ public class LegacyEnforcerService extends LegacyService implements EnforcerServiceInterface { @Autowired - protected LegacyEnforcerService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyEnforcerService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyLocalJusticeAreaService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyLocalJusticeAreaService.java index 5088067ea..158d1dac0 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyLocalJusticeAreaService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyLocalJusticeAreaService.java @@ -17,7 +17,7 @@ public class LegacyLocalJusticeAreaService extends LegacyService implements LocalJusticeAreaServiceInterface { @Autowired - protected LegacyLocalJusticeAreaService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyLocalJusticeAreaService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyMisDebtorService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyMisDebtorService.java index 820a13b56..13548d73d 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyMisDebtorService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyMisDebtorService.java @@ -17,7 +17,7 @@ public class LegacyMisDebtorService extends LegacyService implements MisDebtorServiceInterface { @Autowired - protected LegacyMisDebtorService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyMisDebtorService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyNoteService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyNoteService.java index a97b2991f..a8114f29f 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyNoteService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyNoteService.java @@ -19,7 +19,7 @@ public class LegacyNoteService extends LegacyService implements NoteServiceInter public static final String POST_ACCOUNT_NOTES = "postAccountNotes"; - protected LegacyNoteService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyNoteService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPartyService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPartyService.java index 6e0e22af1..c7ede4ba3 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPartyService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPartyService.java @@ -25,7 +25,7 @@ public class LegacyPartyService extends LegacyService implements PartyServiceInt public static final String POST_PARTY = "postParty"; @Autowired - protected LegacyPartyService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyPartyService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPaymentInService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPaymentInService.java index 660d778ae..9ea216d56 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPaymentInService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPaymentInService.java @@ -17,7 +17,7 @@ public class LegacyPaymentInService extends LegacyService implements PaymentInServiceInterface { @Autowired - protected LegacyPaymentInService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyPaymentInService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPaymentTermsService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPaymentTermsService.java index 37c550dba..5d769ffe2 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPaymentTermsService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPaymentTermsService.java @@ -17,7 +17,7 @@ public class LegacyPaymentTermsService extends LegacyService implements PaymentTermsServiceInterface { @Autowired - protected LegacyPaymentTermsService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyPaymentTermsService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPrisonService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPrisonService.java index afd445da6..97e8f42cf 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPrisonService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyPrisonService.java @@ -17,7 +17,7 @@ public class LegacyPrisonService extends LegacyService implements PrisonServiceInterface { @Autowired - protected LegacyPrisonService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyPrisonService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyTillService.java b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyTillService.java index 6f60b5e96..bc8435109 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyTillService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/legacy/LegacyTillService.java @@ -17,7 +17,7 @@ public class LegacyTillService extends LegacyService implements TillServiceInterface { @Autowired - protected LegacyTillService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) { + protected LegacyTillService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) { super(gatewayUrl, restClient); } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index bdc77588c..6f9a95f06 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -82,7 +82,10 @@ azure: app-mode: opal -legacy-gateway-url: ${OPAL_LEGACY_GATEWAY_URL:http://localhost:4553/opal} +legacy-gateway: + url: ${OPAL_LEGACY_GATEWAY_URL:http://localhost:4553/opal} + username: ${OPAL_LEGACY_GATEWAY_USERNAME:username} + password: ${OPAL_LEGACY_GATEWAY_PASSWORD:password} launchdarkly: sdk-key: ${LAUNCH_DARKLY_SDK_KEY:}