Class JdbcOAuth2AuthorizedClientService
- java.lang.Object
-
- org.springframework.security.oauth2.client.JdbcOAuth2AuthorizedClientService
-
- All Implemented Interfaces:
OAuth2AuthorizedClientService
public class JdbcOAuth2AuthorizedClientService extends java.lang.Object implements OAuth2AuthorizedClientService
A JDBC implementation of anOAuth2AuthorizedClientService
that uses aJdbcOperations
forOAuth2AuthorizedClient
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
Nested Classes Modifier and Type Class Description static class
JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder
A holder for anOAuth2AuthorizedClient
and End-UserAuthentication
(Resource Owner).static class
JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientParametersMapper
The defaultFunction
that mapsJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder
to aList
ofSqlParameterValue
.static class
JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientRowMapper
-
Field Summary
Fields Modifier and Type Field Description protected java.util.function.Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder,java.util.List<org.springframework.jdbc.core.SqlParameterValue>>
authorizedClientParametersMapper
protected org.springframework.jdbc.core.RowMapper<OAuth2AuthorizedClient>
authorizedClientRowMapper
protected org.springframework.jdbc.core.JdbcOperations
jdbcOperations
-
Constructor Summary
Constructors Constructor Description JdbcOAuth2AuthorizedClientService(org.springframework.jdbc.core.JdbcOperations jdbcOperations, ClientRegistrationRepository clientRegistrationRepository)
Constructs aJdbcOAuth2AuthorizedClientService
using the provided parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends OAuth2AuthorizedClient>
TloadAuthorizedClient(java.lang.String clientRegistrationId, java.lang.String principalName)
Returns theOAuth2AuthorizedClient
associated to the provided client registration identifier and End-User'sPrincipal
name ornull
if not available.void
removeAuthorizedClient(java.lang.String clientRegistrationId, java.lang.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).void
setAuthorizedClientParametersMapper(java.util.function.Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder,java.util.List<org.springframework.jdbc.core.SqlParameterValue>> authorizedClientParametersMapper)
Sets theFunction
used for mappingJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder
to aList
ofSqlParameterValue
.void
setAuthorizedClientRowMapper(org.springframework.jdbc.core.RowMapper<OAuth2AuthorizedClient> authorizedClientRowMapper)
Sets theRowMapper
used for mapping the current row injava.sql.ResultSet
toOAuth2AuthorizedClient
.
-
-
-
Field Detail
-
jdbcOperations
protected final org.springframework.jdbc.core.JdbcOperations jdbcOperations
-
authorizedClientRowMapper
protected org.springframework.jdbc.core.RowMapper<OAuth2AuthorizedClient> authorizedClientRowMapper
-
authorizedClientParametersMapper
protected java.util.function.Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder,java.util.List<org.springframework.jdbc.core.SqlParameterValue>> authorizedClientParametersMapper
-
-
Constructor Detail
-
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
-
-
Method Detail
-
loadAuthorizedClient
public <T extends OAuth2AuthorizedClient> T loadAuthorizedClient(java.lang.String clientRegistrationId, java.lang.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
public void saveAuthorizedClient(OAuth2AuthorizedClient authorizedClient, Authentication principal)
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
public void removeAuthorizedClient(java.lang.String clientRegistrationId, java.lang.String principalName)
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(java.util.function.Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder,java.util.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
-
-