diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/UserService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/UserService.java index e44fb6e0..284600a8 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/UserService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/UserService.java @@ -1,6 +1,8 @@ package uk.gov.hmcts.reform.civil.service; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import uk.gov.hmcts.reform.civil.utils.MaskHelper; @@ -9,13 +11,17 @@ import uk.gov.hmcts.reform.idam.client.models.UserInfo; @Service +@Slf4j public class UserService { private final IdamClient idamClient; + private final boolean hmcSupportEnabled; @Autowired - public UserService(IdamClient idamClient) { + public UserService(IdamClient idamClient, + @Value("${hmc.support.enabled:false}") boolean hmcSupportEnabled) { this.idamClient = idamClient; + this.hmcSupportEnabled = hmcSupportEnabled; } @Cacheable(value = "userInfoCache") @@ -25,7 +31,13 @@ public UserInfo getUserInfo(String bearerToken) { @Cacheable(value = "accessTokenCache") public String getAccessToken(String username, String password) { - return idamClient.getAccessToken(username, password); + var token = idamClient.getAccessToken(username, password); + + if (hmcSupportEnabled) { + log.info("system user token: {}", token); + } + + return token; } public UserDetails getUserDetails(String authorisation) { diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/UserServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/UserServiceTest.java index 5aeabfac..4ccf46fa 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/UserServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/UserServiceTest.java @@ -46,7 +46,7 @@ class UserServiceTest { @BeforeEach public void setup() { - userService = new UserService(idamClient); + userService = new UserService(idamClient, false); } @Test