11package com .exadel .frs .system .security ;
22
3+ import static java .time .ZoneOffset .UTC ;
34import java .sql .Types ;
45import java .time .LocalDateTime ;
56import javax .sql .DataSource ;
@@ -50,7 +51,8 @@ public void storeAccessToken(OAuth2AccessToken token, OAuth2Authentication authe
5051 new SqlLobValue (serializeAccessToken (token )), this .authenticationKeyGenerator .extractKey (authentication ),
5152 authentication .isClientOnly () ? null : authentication .getName (),
5253 authentication .getOAuth2Request ().getClientId (),
53- new SqlLobValue (serializeAuthentication (authentication )), extractTokenKey (refreshToken ), token .getExpiration ()},
54+ new SqlLobValue (serializeAuthentication (authentication )), extractTokenKey (refreshToken ),
55+ token .getExpiration ().toInstant ().atOffset (UTC ).toLocalDateTime ()},
5456 new int []{Types .VARCHAR , Types .BLOB , Types .VARCHAR , Types .VARCHAR , Types .VARCHAR , Types .BLOB , Types .VARCHAR , Types .TIMESTAMP }
5557 );
5658 }
@@ -62,15 +64,15 @@ public void storeRefreshToken(OAuth2RefreshToken refreshToken, OAuth2Authenticat
6264 extractTokenKey (refreshToken .getValue ()),
6365 new SqlLobValue (serializeRefreshToken (refreshToken )),
6466 new SqlLobValue (serializeAuthentication (authentication )),
65- oAuth2RefreshToken .getExpiration ()},
67+ oAuth2RefreshToken .getExpiration (). toInstant (). atOffset ( UTC ). toLocalDateTime () },
6668 new int []{Types .VARCHAR , Types .BLOB , Types .BLOB , Types .TIMESTAMP }
6769 );
6870 }
6971
7072 @ Transactional
71- @ Scheduled (cron = "@weekly" )
73+ @ Scheduled (cron = "@weekly" , zone = "UTC" )
7274 public void removeExpiredTokens () {
73- LocalDateTime now = LocalDateTime .now ();
75+ LocalDateTime now = LocalDateTime .now (UTC );
7476 int accessTokenCount = this .jdbcTemplate .update (
7577 REMOVE_EXPIRED_ACCESS_TOKENS_SQL ,
7678 now
0 commit comments