From 2c101887f2f42fa9d432f237116577d075a2eda2 Mon Sep 17 00:00:00 2001 From: karthik-tarento Date: Mon, 13 Feb 2023 07:21:25 +0530 Subject: [PATCH] Fix for userId validation --- .../sunbird/common/util/AccessTokenValidator.java | 12 +++++++----- .../org/sunbird/common/util/RequestInterceptor.java | 3 --- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/sunbird/common/util/AccessTokenValidator.java b/src/main/java/org/sunbird/common/util/AccessTokenValidator.java index 9fd676960..12c64ea59 100644 --- a/src/main/java/org/sunbird/common/util/AccessTokenValidator.java +++ b/src/main/java/org/sunbird/common/util/AccessTokenValidator.java @@ -14,6 +14,7 @@ public class AccessTokenValidator { private static Logger logger = LoggerFactory.getLogger(AccessTokenValidator.class.getName()); private static ObjectMapper mapper = new ObjectMapper(); + private static PropertiesCache cache = PropertiesCache.getInstance(); private static Map validateToken(String token) throws Exception { try { @@ -64,11 +65,12 @@ public static String verifyUserToken(String token) { return userId; } - private static boolean checkIss(String iss) { - String realmUrl = - KeyCloakConnectionProvider.SSO_URL + "realms/" + KeyCloakConnectionProvider.SSO_REALM; - return (realmUrl.equalsIgnoreCase(iss)); - } + private static boolean checkIss(String iss) { + String realmUrl = cache.getProperty(Constants.SSO_URL) + "realms/" + cache.getProperty(Constants.SSO_REALM); + if (StringUtils.isBlank(realmUrl)) + return false; + return (realmUrl.equalsIgnoreCase(iss)); + } private static boolean isExpired(Integer expiration) { return (Time.currentTime() > expiration); diff --git a/src/main/java/org/sunbird/common/util/RequestInterceptor.java b/src/main/java/org/sunbird/common/util/RequestInterceptor.java index 9445a4176..c098fee6c 100644 --- a/src/main/java/org/sunbird/common/util/RequestInterceptor.java +++ b/src/main/java/org/sunbird/common/util/RequestInterceptor.java @@ -3,12 +3,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.ConcurrentHashMap; - public class RequestInterceptor { private static Logger logger = LoggerFactory.getLogger(RequestInterceptor.class.getName()); - private static ConcurrentHashMap apiHeaderIgnoreMap = new ConcurrentHashMap<>(); private RequestInterceptor() { }