public class JdbcOAuth2AuthorizedClientService extends java.lang.Object implements OAuth2AuthorizedClientService
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.
OAuth2AuthorizedClientService
,
OAuth2AuthorizedClient
,
JdbcOperations
,
RowMapper
Modifier and Type | Class and Description |
---|---|
static class |
JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder
A holder for an
OAuth2AuthorizedClient and End-User Authentication
(Resource Owner). |
static class |
JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientParametersMapper
The default
Function that maps JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder to a
List of SqlParameterValue . |
static class |
JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientRowMapper
|
Modifier and Type | Field and 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 and Description |
---|
JdbcOAuth2AuthorizedClientService(org.springframework.jdbc.core.JdbcOperations jdbcOperations,
ClientRegistrationRepository clientRegistrationRepository)
Constructs a
JdbcOAuth2AuthorizedClientService using the provided
parameters. |
Modifier and Type | Method and Description |
---|---|
<T extends OAuth2AuthorizedClient> |
loadAuthorizedClient(java.lang.String clientRegistrationId,
java.lang.String principalName)
Returns the
OAuth2AuthorizedClient associated to the provided client
registration identifier and End-User's Principal name or null if
not available. |
void |
removeAuthorizedClient(java.lang.String clientRegistrationId,
java.lang.String principalName)
Removes the
OAuth2AuthorizedClient associated to the provided client
registration identifier and End-User's Principal name. |
void |
saveAuthorizedClient(OAuth2AuthorizedClient authorizedClient,
Authentication principal)
Saves the
OAuth2AuthorizedClient associating it to the provided End-User
Authentication (Resource Owner). |
void |
setAuthorizedClientParametersMapper(java.util.function.Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder,java.util.List<org.springframework.jdbc.core.SqlParameterValue>> authorizedClientParametersMapper)
Sets the
Function used for mapping JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder to
a List of SqlParameterValue . |
void |
setAuthorizedClientRowMapper(org.springframework.jdbc.core.RowMapper<OAuth2AuthorizedClient> authorizedClientRowMapper)
Sets the
RowMapper used for mapping the current row in
java.sql.ResultSet to OAuth2AuthorizedClient . |
protected final org.springframework.jdbc.core.JdbcOperations jdbcOperations
protected org.springframework.jdbc.core.RowMapper<OAuth2AuthorizedClient> authorizedClientRowMapper
protected java.util.function.Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder,java.util.List<org.springframework.jdbc.core.SqlParameterValue>> authorizedClientParametersMapper
public JdbcOAuth2AuthorizedClientService(org.springframework.jdbc.core.JdbcOperations jdbcOperations, ClientRegistrationRepository clientRegistrationRepository)
JdbcOAuth2AuthorizedClientService
using the provided
parameters.jdbcOperations
- the JDBC operationsclientRegistrationRepository
- the repository of client registrationspublic <T extends OAuth2AuthorizedClient> T loadAuthorizedClient(java.lang.String clientRegistrationId, java.lang.String principalName)
OAuth2AuthorizedClientService
OAuth2AuthorizedClient
associated to the provided client
registration identifier and End-User's Principal
name or null
if
not available.loadAuthorizedClient
in interface OAuth2AuthorizedClientService
T
- a type of OAuth2AuthorizedClientclientRegistrationId
- the identifier for the client's registrationprincipalName
- the name of the End-User Principal
(Resource Owner)OAuth2AuthorizedClient
or null
if not availablepublic void saveAuthorizedClient(OAuth2AuthorizedClient authorizedClient, Authentication principal)
OAuth2AuthorizedClientService
OAuth2AuthorizedClient
associating it to the provided End-User
Authentication
(Resource Owner).saveAuthorizedClient
in interface OAuth2AuthorizedClientService
authorizedClient
- the authorized clientprincipal
- the End-User Authentication
(Resource Owner)public void removeAuthorizedClient(java.lang.String clientRegistrationId, java.lang.String principalName)
OAuth2AuthorizedClientService
OAuth2AuthorizedClient
associated to the provided client
registration identifier and End-User's Principal
name.removeAuthorizedClient
in interface OAuth2AuthorizedClientService
clientRegistrationId
- the identifier for the client's registrationprincipalName
- the name of the End-User Principal
(Resource Owner)public final void setAuthorizedClientRowMapper(org.springframework.jdbc.core.RowMapper<OAuth2AuthorizedClient> authorizedClientRowMapper)
RowMapper
used for mapping the current row in
java.sql.ResultSet
to OAuth2AuthorizedClient
. The default is
JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientRowMapper
.authorizedClientRowMapper
- the RowMapper
used for mapping the current
row in java.sql.ResultSet
to OAuth2AuthorizedClient
public final void setAuthorizedClientParametersMapper(java.util.function.Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder,java.util.List<org.springframework.jdbc.core.SqlParameterValue>> authorizedClientParametersMapper)
Function
used for mapping JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder
to
a List
of SqlParameterValue
. The default is
JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientParametersMapper
.authorizedClientParametersMapper
- the Function
used for mapping
JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder
to a List
of SqlParameterValue