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 anOAuth2AuthorizedClientServicethat uses aJdbcOperationsforOAuth2AuthorizedClientpersistence.NOTE: This
OAuth2AuthorizedClientServicedepends 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 classJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolderA holder for anOAuth2AuthorizedClientand End-UserAuthentication(Resource Owner).static classJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientParametersMapperThe defaultFunctionthat mapsJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolderto aListofSqlParameterValue.static classJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientRowMapper
-
Field Summary
Fields Modifier and Type Field Description protected java.util.function.Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder,java.util.List<org.springframework.jdbc.core.SqlParameterValue>>authorizedClientParametersMapperprotected org.springframework.jdbc.core.RowMapper<OAuth2AuthorizedClient>authorizedClientRowMapperprotected org.springframework.jdbc.core.JdbcOperationsjdbcOperationsprotected org.springframework.jdbc.support.lob.LobHandlerlobHandler
-
Constructor Summary
Constructors Constructor Description JdbcOAuth2AuthorizedClientService(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends OAuth2AuthorizedClient>
TloadAuthorizedClient(java.lang.String clientRegistrationId, java.lang.String principalName)Returns theOAuth2AuthorizedClientassociated to the provided client registration identifier and End-User'sPrincipalname ornullif not available.voidremoveAuthorizedClient(java.lang.String clientRegistrationId, java.lang.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).voidsetAuthorizedClientParametersMapper(java.util.function.Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder,java.util.List<org.springframework.jdbc.core.SqlParameterValue>> authorizedClientParametersMapper)Sets theFunctionused for mappingJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolderto aListofSqlParameterValue.voidsetAuthorizedClientRowMapper(org.springframework.jdbc.core.RowMapper<OAuth2AuthorizedClient> authorizedClientRowMapper)Sets theRowMapperused for mapping the current row injava.sql.ResultSettoOAuth2AuthorizedClient.
-
-
-
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
-
lobHandler
protected final org.springframework.jdbc.support.lob.LobHandler lobHandler
-
-
Constructor Detail
-
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 Detail
-
loadAuthorizedClient
public <T extends OAuth2AuthorizedClient> T loadAuthorizedClient(java.lang.String clientRegistrationId, java.lang.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
public void saveAuthorizedClient(OAuth2AuthorizedClient authorizedClient, Authentication principal)
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
public void removeAuthorizedClient(java.lang.String clientRegistrationId, java.lang.String principalName)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(java.util.function.Function<JdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolder,java.util.List<org.springframework.jdbc.core.SqlParameterValue>> authorizedClientParametersMapper)
Sets theFunctionused for mappingJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolderto aListofSqlParameterValue. The default isJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientParametersMapper.- Parameters:
authorizedClientParametersMapper- theFunctionused for mappingJdbcOAuth2AuthorizedClientService.OAuth2AuthorizedClientHolderto aListofSqlParameterValue
-
-