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:
-
OAuth2AuthorizedClientServiceOAuth2AuthorizedClientJdbcOperationsRowMapper
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA holder for anOAuth2AuthorizedClientand End-UserAuthentication(Resource Owner).static classThe defaultFunctionthat mapsJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolderto aListofSqlParameterValue.static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder,List<org.springframework.jdbc.core.SqlParameterValue>> protected org.springframework.jdbc.core.RowMapper<OAuth2AuthorizedClient>protected final org.springframework.jdbc.core.JdbcOperationsprotected final org.springframework.jdbc.support.lob.LobHandler -
Constructor Summary
ConstructorsConstructorDescriptionJdbcOAuth2AuthorizedClientService(org.springframework.jdbc.core.JdbcOperations jdbcOperations, ClientRegistrationRepository clientRegistrationRepository) Constructs aJdbcOAuth2AuthorizedClientServiceusing the provided parameters.JdbcOAuth2AuthorizedClientService(org.springframework.jdbc.core.JdbcOperations jdbcOperations, ClientRegistrationRepository clientRegistrationRepository, org.springframework.jdbc.support.lob.LobHandler lobHandler) Constructs aJdbcOAuth2AuthorizedClientServiceusing the provided parameters. -
Method Summary
Modifier and TypeMethodDescription<T extends OAuth2AuthorizedClient>
TloadAuthorizedClient(String clientRegistrationId, String principalName) Returns theOAuth2AuthorizedClientassociated to the provided client registration identifier and End-User'sPrincipalname ornullif not available.voidremoveAuthorizedClient(String clientRegistrationId, String principalName) Removes theOAuth2AuthorizedClientassociated to the provided client registration identifier and End-User'sPrincipalname.voidsaveAuthorizedClient(OAuth2AuthorizedClient authorizedClient, Authentication principal) Saves theOAuth2AuthorizedClientassociating it to the provided End-UserAuthentication(Resource Owner).final voidsetAuthorizedClientParametersMapper(Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder, List<org.springframework.jdbc.core.SqlParameterValue>> authorizedClientParametersMapper) Sets theFunctionused for mappingJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolderto aListofSqlParameterValue.final voidsetAuthorizedClientRowMapper(org.springframework.jdbc.core.RowMapper<OAuth2AuthorizedClient> authorizedClientRowMapper) Sets theRowMapperused for mapping the current row injava.sql.ResultSettoOAuth2AuthorizedClient.
-
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 aJdbcOAuth2AuthorizedClientServiceusing 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 aJdbcOAuth2AuthorizedClientServiceusing 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:OAuth2AuthorizedClientServiceReturns theOAuth2AuthorizedClientassociated to the provided client registration identifier and End-User'sPrincipalname ornullif not available.- Specified by:
loadAuthorizedClientin 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
OAuth2AuthorizedClientornullif not available
-
saveAuthorizedClient
Description copied from interface:OAuth2AuthorizedClientServiceSaves theOAuth2AuthorizedClientassociating it to the provided End-UserAuthentication(Resource Owner).- Specified by:
saveAuthorizedClientin interfaceOAuth2AuthorizedClientService- Parameters:
authorizedClient- the authorized clientprincipal- the End-UserAuthentication(Resource Owner)
-
removeAuthorizedClient
Description copied from interface:OAuth2AuthorizedClientServiceRemoves theOAuth2AuthorizedClientassociated to the provided client registration identifier and End-User'sPrincipalname.- Specified by:
removeAuthorizedClientin 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 theRowMapperused for mapping the current row injava.sql.ResultSettoOAuth2AuthorizedClient. The default isJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientRowMapper.- Parameters:
authorizedClientRowMapper- theRowMapperused for mapping the current row injava.sql.ResultSettoOAuth2AuthorizedClient
-
setAuthorizedClientParametersMapper
public final void setAuthorizedClientParametersMapper(Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder, List<org.springframework.jdbc.core.SqlParameterValue>> authorizedClientParametersMapper) Sets theFunctionused for mappingJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolderto aListofSqlParameterValue. The default isJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientParametersMapper.- Parameters:
authorizedClientParametersMapper- theFunctionused for mappingJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolderto aListofSqlParameterValue
-