Class JdbcClientRegistrationRepository
java.lang.Object
com.irurueta.authserver.authorization.infrastructure.persistence.clients.JdbcClientRegistrationRepository
- All Implemented Interfaces:
ClientRegistrationRepository
@Repository
public class JdbcClientRegistrationRepository
extends Object
implements ClientRegistrationRepository
ClientRegistrationRepository over Spring Authorization Server's RegisteredClientRepository
(the JDBC one), which reads and writes the oauth2_registered_client table. The operations that
repository does not offer (listing, deleting, replacing a secret) run directly on that table. The conversion
between both models belongs to the RegisteredClientMapper.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringSub-query selecting the internal id of a client by its client id.private static final StringStatement deleting the authorizations of a client.private static final StringStatement deleting the consents granted to a client.private final org.springframework.jdbc.core.simple.JdbcClientJDBC client used for the operations the registered client repository lacks.private final RegisteredClientMapperMaps between registrations and registered clients.private final org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepositoryRepository that maps registered clients to rows. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteByClientId(String clientId) Deletes a client.findAll()Finds every registered client.findByClientId(String clientId) Finds a client by its identifier.voidsave(ClientRegistration registration, String encodedSecret) Inserts a client, or replaces the settings of the stored client that has the same identifier.voidupdateSecret(String clientId, String encodedSecret) Replaces the secret of a client.
-
Field Details
-
CLIENT_ROW_ID
Sub-query selecting the internal id of a client by its client id.- See Also:
-
DELETE_AUTHORIZATIONS
Statement deleting the authorizations of a client.- See Also:
-
DELETE_CONSENTS
Statement deleting the consents granted to a client.- See Also:
-
registeredClientRepository
private final org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository registeredClientRepositoryRepository that maps registered clients to rows. -
jdbcClient
private final org.springframework.jdbc.core.simple.JdbcClient jdbcClientJDBC client used for the operations the registered client repository lacks. -
registeredClientMapper
Maps between registrations and registered clients.
-
-
Constructor Details
-
JdbcClientRegistrationRepository
public JdbcClientRegistrationRepository()
-
-
Method Details
-
findByClientId
Description copied from interface:ClientRegistrationRepositoryFinds a client by its identifier.- Specified by:
findByClientIdin interfaceClientRegistrationRepository- Parameters:
clientId- public identifier of the client.- Returns:
- the client, or an empty optional when it is not registered.
-
findAll
Description copied from interface:ClientRegistrationRepositoryFinds every registered client.- Specified by:
findAllin interfaceClientRegistrationRepository- Returns:
- the clients; empty when there are none.
-
save
Description copied from interface:ClientRegistrationRepositoryInserts a client, or replaces the settings of the stored client that has the same identifier.- Specified by:
savein interfaceClientRegistrationRepository- Parameters:
registration- the client.encodedSecret- the encoded client secret, ornullto keep the stored one (a public client has none).
-
deleteByClientId
Deletes a client.The authorizations (with their consumed refresh tokens, by cascade) and the consents granted to the client reference it by its internal id without a foreign key, so they are deleted first, in the same transaction: otherwise loading one of them later fails because its client is gone. The transaction is the caller's: use cases demarcate transactions, never the adapters.
- Specified by:
deleteByClientIdin interfaceClientRegistrationRepository- Parameters:
clientId- public identifier of the client.
-
updateSecret
Description copied from interface:ClientRegistrationRepositoryReplaces the secret of a client.- Specified by:
updateSecretin interfaceClientRegistrationRepository- Parameters:
clientId- public identifier of the client.encodedSecret- the new encoded secret.
-