Class JdbcOAuth2AuthorizedClientService
java.lang.Object
org.springframework.security.oauth2.client.JdbcOAuth2AuthorizedClientService
- All Implemented Interfaces:
OAuth2AuthorizedClientService
public class JdbcOAuth2AuthorizedClientService
extends Object
implements OAuth2AuthorizedClientService
A JDBC implementation of an
OAuth2AuthorizedClientService
that uses a
JdbcOperations
for OAuth2AuthorizedClient
persistence.
NOTE: This OAuth2AuthorizedClientService
depends on the table definition
described in
"classpath:org/springframework/security/oauth2/client/oauth2-client-schema.sql" and
therefore MUST be defined in the database schema.
- Since:
- 5.3
- See Also:
-
OAuth2AuthorizedClientService
OAuth2AuthorizedClient
JdbcOperations
RowMapper
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A holder for anOAuth2AuthorizedClient
and End-UserAuthentication
(Resource Owner).static class
The defaultFunction
that mapsJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder
to aList
ofSqlParameterValue
.static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder,
List<org.springframework.jdbc.core.SqlParameterValue>> protected org.springframework.jdbc.core.RowMapper<OAuth2AuthorizedClient>
protected final org.springframework.jdbc.core.JdbcOperations
protected final org.springframework.jdbc.support.lob.LobHandler
-
Constructor Summary
ConstructorDescriptionJdbcOAuth2AuthorizedClientService
(org.springframework.jdbc.core.JdbcOperations jdbcOperations, ClientRegistrationRepository clientRegistrationRepository) Constructs aJdbcOAuth2AuthorizedClientService
using the provided parameters.JdbcOAuth2AuthorizedClientService
(org.springframework.jdbc.core.JdbcOperations jdbcOperations, ClientRegistrationRepository clientRegistrationRepository, org.springframework.jdbc.support.lob.LobHandler lobHandler) Constructs aJdbcOAuth2AuthorizedClientService
using the provided parameters. -
Method Summary
Modifier and TypeMethodDescription<T extends OAuth2AuthorizedClient>
TloadAuthorizedClient
(String clientRegistrationId, String principalName) Returns theOAuth2AuthorizedClient
associated to the provided client registration identifier and End-User'sPrincipal
name ornull
if not available.void
removeAuthorizedClient
(String clientRegistrationId, String principalName) Removes theOAuth2AuthorizedClient
associated to the provided client registration identifier and End-User'sPrincipal
name.void
saveAuthorizedClient
(OAuth2AuthorizedClient authorizedClient, Authentication principal) Saves theOAuth2AuthorizedClient
associating it to the provided End-UserAuthentication
(Resource Owner).final void
setAuthorizedClientParametersMapper
(Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder, List<org.springframework.jdbc.core.SqlParameterValue>> authorizedClientParametersMapper) Sets theFunction
used for mappingJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder
to aList
ofSqlParameterValue
.final void
setAuthorizedClientRowMapper
(org.springframework.jdbc.core.RowMapper<OAuth2AuthorizedClient> authorizedClientRowMapper) Sets theRowMapper
used for mapping the current row injava.sql.ResultSet
toOAuth2AuthorizedClient
.
-
Field Details
-
jdbcOperations
protected final org.springframework.jdbc.core.JdbcOperations jdbcOperations -
authorizedClientRowMapper
-
authorizedClientParametersMapper
protected Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder,List<org.springframework.jdbc.core.SqlParameterValue>> authorizedClientParametersMapper -
lobHandler
protected final org.springframework.jdbc.support.lob.LobHandler lobHandler
-
-
Constructor Details
-
JdbcOAuth2AuthorizedClientService
public JdbcOAuth2AuthorizedClientService(org.springframework.jdbc.core.JdbcOperations jdbcOperations, ClientRegistrationRepository clientRegistrationRepository) Constructs aJdbcOAuth2AuthorizedClientService
using the provided parameters.- Parameters:
jdbcOperations
- the JDBC operationsclientRegistrationRepository
- the repository of client registrations
-
JdbcOAuth2AuthorizedClientService
public JdbcOAuth2AuthorizedClientService(org.springframework.jdbc.core.JdbcOperations jdbcOperations, ClientRegistrationRepository clientRegistrationRepository, org.springframework.jdbc.support.lob.LobHandler lobHandler) Constructs aJdbcOAuth2AuthorizedClientService
using the provided parameters.- Parameters:
jdbcOperations
- the JDBC operationsclientRegistrationRepository
- the repository of client registrationslobHandler
- the handler for large binary fields and large text fields- Since:
- 5.5
-
-
Method Details
-
loadAuthorizedClient
public <T extends OAuth2AuthorizedClient> T loadAuthorizedClient(String clientRegistrationId, String principalName) Description copied from interface:OAuth2AuthorizedClientService
Returns theOAuth2AuthorizedClient
associated to the provided client registration identifier and End-User'sPrincipal
name ornull
if not available.- Specified by:
loadAuthorizedClient
in interfaceOAuth2AuthorizedClientService
- Type Parameters:
T
- a type of OAuth2AuthorizedClient- Parameters:
clientRegistrationId
- the identifier for the client's registrationprincipalName
- the name of the End-UserPrincipal
(Resource Owner)- Returns:
- the
OAuth2AuthorizedClient
ornull
if not available
-
saveAuthorizedClient
Description copied from interface:OAuth2AuthorizedClientService
Saves theOAuth2AuthorizedClient
associating it to the provided End-UserAuthentication
(Resource Owner).- Specified by:
saveAuthorizedClient
in interfaceOAuth2AuthorizedClientService
- Parameters:
authorizedClient
- the authorized clientprincipal
- the End-UserAuthentication
(Resource Owner)
-
removeAuthorizedClient
Description copied from interface:OAuth2AuthorizedClientService
Removes theOAuth2AuthorizedClient
associated to the provided client registration identifier and End-User'sPrincipal
name.- Specified by:
removeAuthorizedClient
in interfaceOAuth2AuthorizedClientService
- Parameters:
clientRegistrationId
- the identifier for the client's registrationprincipalName
- the name of the End-UserPrincipal
(Resource Owner)
-
setAuthorizedClientRowMapper
public final void setAuthorizedClientRowMapper(org.springframework.jdbc.core.RowMapper<OAuth2AuthorizedClient> authorizedClientRowMapper) Sets theRowMapper
used for mapping the current row injava.sql.ResultSet
toOAuth2AuthorizedClient
. The default isJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientRowMapper
.- Parameters:
authorizedClientRowMapper
- theRowMapper
used for mapping the current row injava.sql.ResultSet
toOAuth2AuthorizedClient
-
setAuthorizedClientParametersMapper
public final void setAuthorizedClientParametersMapper(Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder, List<org.springframework.jdbc.core.SqlParameterValue>> authorizedClientParametersMapper) Sets theFunction
used for mappingJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder
to aList
ofSqlParameterValue
. The default isJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientParametersMapper
.- Parameters:
authorizedClientParametersMapper
- theFunction
used for mappingJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder
to aList
ofSqlParameterValue
-