SUPPORT-8755: Fix

This commit is contained in:
Eduard Tihomirov 2024-12-24 20:26:17 +03:00
parent f86a8afd2f
commit 1a1ca85a63
2 changed files with 11 additions and 4 deletions

View file

@ -20,14 +20,18 @@ public class TokensStore {
} }
public static String getAccessToken(String prnOid) { public static String getAccessToken(String prnOid) {
return accessTokensMap.get(prnOid).getAccessToken();
}
public static boolean validateAccessToken(String prnOid) {
ExpiringToken token = accessTokensMap.get(prnOid); ExpiringToken token = accessTokensMap.get(prnOid);
if (token == null) { if (token == null) {
throw new CredentialsExpiredException("No access token for prnOid: " + prnOid); throw new CredentialsExpiredException("No ESIA access token for prnOid: " + prnOid);
} }
else if (token.isExpired()) { else if (token.isExpired()) {
throw new CredentialsExpiredException("Access token expired for prnOid: " + prnOid); throw new CredentialsExpiredException("ESIA access token expired for prnOid: " + prnOid);
} }
return token.getAccessToken(); return token.getAccessToken() != null;
} }
public static void removeExpiredAccessToken() { public static void removeExpiredAccessToken() {

View file

@ -65,7 +65,10 @@ public class JwtAuthenticationFilter extends AbstractAuthenticationProcessingFil
if (ids.length != 2) { if (ids.length != 2) {
throw new CredentialsExpiredException("Invalid token. User has no ervuId"); throw new CredentialsExpiredException("Invalid token. User has no ervuId");
} }
TokensStore.getAccessToken(token.getUserAccountId()); boolean hasEsiaAccessToken = TokensStore.validateAccessToken(token.getUserAccountId());
if (!hasEsiaAccessToken) {
throw new CredentialsExpiredException("ESIA access token is null");
}
} }
} }
catch (CredentialsExpiredException e) { catch (CredentialsExpiredException e) {