From f830c88f13c66047d9c6281a146b57db0cbe4194 Mon Sep 17 00:00:00 2001 From: Todd Young Date: Fri, 13 Dec 2024 11:25:14 -0500 Subject: [PATCH] feat: log error when refreshing token OCD-4777 --- .../scheduler/ChplSchedulerReference.java | 20 +++++++++++-------- .../healthit/chpl/scheduler/JobAspect.java | 2 +- .../chpl/user/cognito/CognitoApiWrapper.java | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/ChplSchedulerReference.java b/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/ChplSchedulerReference.java index c4ce740c11..0633c033d7 100644 --- a/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/ChplSchedulerReference.java +++ b/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/ChplSchedulerReference.java @@ -6,8 +6,6 @@ import org.springframework.scheduling.quartz.SchedulerFactoryBean; import org.springframework.stereotype.Component; -import jakarta.annotation.PostConstruct; - /** * A Spring singleton object object that provides a reference to the Quartz Scheduler. * @author TYoung @@ -16,18 +14,24 @@ @Scope(value = "singleton") @Component public class ChplSchedulerReference { - @Autowired - private SchedulerFactoryBean schedulerFactory; + //@Autowired + //private SchedulerFactoryBean schedulerFactory; private Scheduler scheduler; + @Autowired + public ChplSchedulerReference(SchedulerFactoryBean schedulerFactory) { + this.scheduler = schedulerFactory.getScheduler(); + } + + /** * Initialize the scheduler service */ - @PostConstruct - private void init() { - scheduler = schedulerFactory.getScheduler(); - } + //@PostConstruct + //private void init() { + // scheduler = schedulerFactory.getScheduler(); + //} public Scheduler getScheduler() { return scheduler; diff --git a/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/JobAspect.java b/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/JobAspect.java index 97a1a2f8b7..d09bfda06d 100644 --- a/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/JobAspect.java +++ b/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/JobAspect.java @@ -9,7 +9,7 @@ public class JobAspect { @After("execution(public void org.quartz.Job.execute(..))") - public void logAfter(JoinPoint joinPoint) { + public void afterExecute(JoinPoint joinPoint) { SecurityContextHolder.clearContext(); } diff --git a/chpl/chpl-service/src/main/java/gov/healthit/chpl/user/cognito/CognitoApiWrapper.java b/chpl/chpl-service/src/main/java/gov/healthit/chpl/user/cognito/CognitoApiWrapper.java index 020b6e7a0a..4a86436464 100644 --- a/chpl/chpl-service/src/main/java/gov/healthit/chpl/user/cognito/CognitoApiWrapper.java +++ b/chpl/chpl-service/src/main/java/gov/healthit/chpl/user/cognito/CognitoApiWrapper.java @@ -248,7 +248,7 @@ public CognitoCredentials createUser(CreateUserRequest userRequest) throws UserC public AuthenticationResultType refreshToken(String refreshToken, UUID cognitoId) { Map authParams = new LinkedHashMap(); authParams.put("REFRESH_TOKEN", refreshToken); - authParams.put("SECRET_HASH", calculateSecretHash(cognitoId.toString())); + authParams.put("SECRET_HASH", calculateSecretHash(cognitoId.toString())); AdminInitiateAuthRequest authRequest = AdminInitiateAuthRequest.builder() .authFlow(AuthFlowType.REFRESH_TOKEN_AUTH) @@ -263,7 +263,7 @@ public AuthenticationResultType refreshToken(String refreshToken, UUID cognitoId } catch (Exception e) { //This is cluttering the logs when the SSO flag is on, and the user logs in using CHPL creds //We might want to uncomment it when we move to only using Cognito creds - //LOGGER.error("Error refreshing token", e); + LOGGER.error("Error refreshing token", e); return null; } }