11package com .faforever .api .security ;
22
33import com .faforever .api .config .FafApiProperties ;
4+ import lombok .extern .slf4j .Slf4j ;
45import org .springframework .beans .factory .annotation .Qualifier ;
56import org .springframework .security .jwt .Jwt ;
67import org .springframework .security .jwt .JwtHelper ;
2122import java .util .Objects ;
2223
2324@ Component
25+ @ Slf4j
2426public class FafMultiTokenStore implements TokenStore {
2527 private JsonParser objectMapper = JsonParserFactory .create ();
2628
@@ -58,8 +60,10 @@ public OAuth2Authentication readAuthentication(String token) {
5860 Map <String , Object > claims = objectMapper .parseMap (unverifiedJwt .getClaims ());
5961
6062 if (Objects .equals (claims .get ("iss" ), fafApiProperties .getJwt ().getFafHydraIssuer ())) {
63+ log .trace ("Reading authentication for Hydra token" );
6164 return hydraTokenStore .readAuthentication (token );
6265 } else {
66+ log .trace ("Reading authentication for legacy API token" );
6367 return classicTokenStore .readAuthentication (token );
6468 }
6569 }
@@ -72,8 +76,10 @@ public void storeAccessToken(OAuth2AccessToken token, OAuth2Authentication authe
7276 @ Override
7377 public OAuth2AccessToken readAccessToken (String tokenValue ) {
7478 try {
79+ log .trace ("Reading access token for legacy api token" );
7580 return classicTokenStore .readAccessToken (tokenValue );
7681 } catch (Exception e ) {
82+ log .trace ("Reading access token for legacy api token failed. Fallback to reading access token for Hydra token" );
7783 return hydraTokenStore .readAccessToken (tokenValue );
7884 }
7985 }
0 commit comments