Class JdbcFederatedIdentityRepository
java.lang.Object
com.irurueta.authserver.authorization.infrastructure.persistence.social.JdbcFederatedIdentityRepository
- All Implemented Interfaces:
FederatedIdentityRepository
@Repository
public class JdbcFederatedIdentityRepository
extends Object
implements FederatedIdentityRepository
FederatedIdentityRepository over the federated_identities table. It joins the transaction of its
caller, in which lockSubject(com.irurueta.authserver.authorization.domain.social.IdentityProvider, java.lang.String) takes a PostgreSQL transaction-level advisory lock on the provider's identity,
so two first sign-ins of the same person are serialized and the unique constraint on (provider, subject) is never
hit (a violation would abort the caller's transaction).-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringColumns selected for every query.private final FederatedIdentityRowMapperMaps a row to an identity.private static final StringQuery returning one link of an account.private static final StringQuery returning the link of a provider's subject.private static final StringQuery returning the links of an account, oldest first.private final org.springframework.jdbc.core.simple.JdbcClientJDBC client used to run the statements.private static final StringStatement taking the advisory lock of an identity, released when the caller's transaction ends.(package private) static final intFirst key of the advisory locks of the identities, which keeps them apart from every other advisory lock.private static final StringStatement inserting a link, or updating the e-mail address and last sign-in of the one with the same id. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongcountByUser(UUID userId) booleanfindByIdAndUser(UUID id, UUID userId) findByProviderAndSubject(IdentityProvider provider, String subject) findByUser(UUID userId) voidlockSubject(IdentityProvider provider, String subject) save(FederatedIdentity identity)
-
Field Details
-
SUBJECT_LOCK_NAMESPACE
static final int SUBJECT_LOCK_NAMESPACEFirst key of the advisory locks of the identities, which keeps them apart from every other advisory lock.- See Also:
-
LOCK_SUBJECT
Statement taking the advisory lock of an identity, released when the caller's transaction ends.- See Also:
-
COLUMNS
Columns selected for every query.- See Also:
-
FIND_BY_SUBJECT
Query returning the link of a provider's subject.- See Also:
-
FIND_BY_USER
Query returning the links of an account, oldest first.- See Also:
-
FIND_BY_ID_AND_USER
Query returning one link of an account.- See Also:
-
UPSERT
Statement inserting a link, or updating the e-mail address and last sign-in of the one with the same id.- See Also:
-
jdbcClient
private final org.springframework.jdbc.core.simple.JdbcClient jdbcClientJDBC client used to run the statements. -
federatedIdentityRowMapper
Maps a row to an identity.
-
-
Constructor Details
-
JdbcFederatedIdentityRepository
public JdbcFederatedIdentityRepository()
-
-
Method Details
-
lockSubject
- Specified by:
lockSubjectin interfaceFederatedIdentityRepository
-
findByProviderAndSubject
public Optional<FederatedIdentity> findByProviderAndSubject(IdentityProvider provider, String subject) - Specified by:
findByProviderAndSubjectin interfaceFederatedIdentityRepository
-
findByUser
- Specified by:
findByUserin interfaceFederatedIdentityRepository
-
findByIdAndUser
- Specified by:
findByIdAndUserin interfaceFederatedIdentityRepository
-
save
- Specified by:
savein interfaceFederatedIdentityRepository
-
delete
- Specified by:
deletein interfaceFederatedIdentityRepository
-
countByUser
- Specified by:
countByUserin interfaceFederatedIdentityRepository
-