47
47
import org .springframework .jdbc .support .lob .LobHandler ;
48
48
import org .springframework .lang .Nullable ;
49
49
import org .springframework .security .jackson2 .SecurityJackson2Modules ;
50
- import org .springframework .security .oauth2 .core .*;
50
+ import org .springframework .security .oauth2 .core .AuthorizationGrantType ;
51
+ import org .springframework .security .oauth2 .core .OAuth2AccessToken ;
52
+ import org .springframework .security .oauth2 .core .OAuth2DeviceCode ;
53
+ import org .springframework .security .oauth2 .core .OAuth2RefreshToken ;
54
+ import org .springframework .security .oauth2 .core .OAuth2Token ;
55
+ import org .springframework .security .oauth2 .core .OAuth2UserCode ;
51
56
import org .springframework .security .oauth2 .core .endpoint .OAuth2ParameterNames ;
52
57
import org .springframework .security .oauth2 .core .oidc .OidcIdToken ;
53
58
import org .springframework .security .oauth2 .core .oidc .endpoint .OidcParameterNames ;
@@ -118,8 +123,8 @@ public class JdbcOAuth2AuthorizationService implements OAuth2AuthorizationServic
118
123
119
124
private static final String PK_FILTER = "id = ?" ;
120
125
private static final String UNKNOWN_TOKEN_TYPE_FILTER = "state = ? OR authorization_code_value = ? OR "
121
- + "access_token_value = ? OR oidc_id_token_value = ? OR refresh_token_value = ? OR "
122
- + "user_code_value = ? OR device_code_value = ?" ;
126
+ + "access_token_value = ? OR oidc_id_token_value = ? OR refresh_token_value = ? OR user_code_value = ? OR "
127
+ + "device_code_value = ?" ;
123
128
124
129
private static final String STATE_FILTER = "state = ?" ;
125
130
private static final String AUTHORIZATION_CODE_FILTER = "authorization_code_value = ?" ;
@@ -272,10 +277,10 @@ public OAuth2Authorization findByToken(String token, @Nullable OAuth2TokenType t
272
277
} else if (OAuth2TokenType .REFRESH_TOKEN .equals (tokenType )) {
273
278
parameters .add (mapToSqlParameter ("refresh_token_value" , token ));
274
279
return findBy (REFRESH_TOKEN_FILTER , parameters );
275
- } else if (OAuth2TokenType .USER_CODE .equals (tokenType )) {
280
+ } else if (OAuth2ParameterNames .USER_CODE .equals (tokenType . getValue () )) {
276
281
parameters .add (mapToSqlParameter ("user_code_value" , token ));
277
282
return findBy (USER_CODE_FILTER , parameters );
278
- } else if (OAuth2TokenType .DEVICE_CODE .equals (tokenType )) {
283
+ } else if (OAuth2ParameterNames .DEVICE_CODE .equals (tokenType . getValue () )) {
279
284
parameters .add (mapToSqlParameter ("device_code_value" , token ));
280
285
return findBy (DEVICE_CODE_FILTER , parameters );
281
286
}
@@ -447,11 +452,7 @@ public OAuth2Authorization mapRow(ResultSet rs, int rowNum) throws SQLException
447
452
String userCodeValue = getLobValue (rs , "user_code_value" );
448
453
if (StringUtils .hasText (userCodeValue )) {
449
454
tokenIssuedAt = rs .getTimestamp ("user_code_issued_at" ).toInstant ();
450
- tokenExpiresAt = null ;
451
- Timestamp userCodeExpiresAt = rs .getTimestamp ("user_code_expires_at" );
452
- if (userCodeExpiresAt != null ) {
453
- tokenExpiresAt = userCodeExpiresAt .toInstant ();
454
- }
455
+ tokenExpiresAt = rs .getTimestamp ("user_code_expires_at" ).toInstant ();
455
456
Map <String , Object > userCodeMetadata = parseMap (getLobValue (rs , "user_code_metadata" ));
456
457
457
458
OAuth2UserCode userCode = new OAuth2UserCode (userCodeValue , tokenIssuedAt , tokenExpiresAt );
@@ -461,11 +462,7 @@ public OAuth2Authorization mapRow(ResultSet rs, int rowNum) throws SQLException
461
462
String deviceCodeValue = getLobValue (rs , "device_code_value" );
462
463
if (StringUtils .hasText (deviceCodeValue )) {
463
464
tokenIssuedAt = rs .getTimestamp ("device_code_issued_at" ).toInstant ();
464
- tokenExpiresAt = null ;
465
- Timestamp deviceCodeExpiresAt = rs .getTimestamp ("device_code_expires_at" );
466
- if (deviceCodeExpiresAt != null ) {
467
- tokenExpiresAt = deviceCodeExpiresAt .toInstant ();
468
- }
465
+ tokenExpiresAt = rs .getTimestamp ("device_code_expires_at" ).toInstant ();
469
466
Map <String , Object > deviceCodeMetadata = parseMap (getLobValue (rs , "device_code_metadata" ));
470
467
471
468
OAuth2DeviceCode deviceCode = new OAuth2DeviceCode (deviceCodeValue , tokenIssuedAt , tokenExpiresAt );
0 commit comments