Class JdbcUserAccountRepository
java.lang.Object
com.irurueta.authserver.authorization.infrastructure.persistence.password.JdbcUserAccountRepository
- All Implemented Interfaces:
UserAccountRepository
UserAccountRepository reading user accounts from the users, user_authorities and
user_passwords tables.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringQuery returning the authorities of a user by user id.private static final StringQuery returning the user and its encoded password by username.private static final StringQuery returning the user and its encoded password by e-mail address, ignoring case.private static final StringQuery returning the user and its encoded password by id.private final org.springframework.jdbc.core.simple.JdbcClientJDBC client used to run the queries.private static final StringStatement that verifies the e-mail address and enables the account, only while the address is still unverified: a verification link is effective once, so replaying it cannot re-enable an account that was disabled afterwards.private static final StringColumns selected for an account.private static final StringStatement inserting an encoded password, or replacing the stored one.private static final StringStatement inserting a user, or replacing the columns of the user that has the same id.private final UserAccountRowMapperMaps a user row, without its authorities. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanexistsByUsername(String username) Tells whether an account with a username exists.findByEmail(String email) Finds a user account by its e-mail address.Finds a user account by its identifier.findByUsername(String username) Finds a user account by the name the user signs in with.private Optional<UserAccount> Loads one account, with its authorities.booleanmarkEmailVerified(UUID userId) Marks the e-mail address of an account as verified and enables the account, but only while the address is still unverified: the transition happens once, so a replayed verification never re-enables an account that was disabled after its address had been verified.voidsave(UserAccount account) Stores a new account, with its authorities.voidupdatePassword(UUID userId, String encodedPassword) Replaces the encoded password of an account.
-
Field Details
-
SELECT_USER
Columns selected for an account.- See Also:
-
FIND_USER
Query returning the user and its encoded password by username.- See Also:
-
FIND_USER_BY_ID
Query returning the user and its encoded password by id.- See Also:
-
FIND_USER_BY_EMAIL
Query returning the user and its encoded password by e-mail address, ignoring case.- See Also:
-
UPSERT_USER
Statement inserting a user, or replacing the columns of the user that has the same id.- See Also:
-
UPSERT_PASSWORD
Statement inserting an encoded password, or replacing the stored one.- See Also:
-
FIND_AUTHORITIES
Query returning the authorities of a user by user id.- See Also:
-
MARK_EMAIL_VERIFIED
Statement that verifies the e-mail address and enables the account, only while the address is still unverified: a verification link is effective once, so replaying it cannot re-enable an account that was disabled afterwards.- See Also:
-
jdbcClient
private final org.springframework.jdbc.core.simple.JdbcClient jdbcClientJDBC client used to run the queries. -
userAccountRowMapper
Maps a user row, without its authorities.
-
-
Constructor Details
-
JdbcUserAccountRepository
public JdbcUserAccountRepository()
-
-
Method Details
-
findByUsername
Description copied from interface:UserAccountRepositoryFinds a user account by the name the user signs in with.- Specified by:
findByUsernamein interfaceUserAccountRepository- Parameters:
username- name the user signs in with.- Returns:
- the account, or an empty optional when no account has that username.
-
findById
Description copied from interface:UserAccountRepositoryFinds a user account by its identifier.- Specified by:
findByIdin interfaceUserAccountRepository- Parameters:
id- identifier of the account.- Returns:
- the account, or an empty optional when there is none.
-
findByEmail
Description copied from interface:UserAccountRepositoryFinds a user account by its e-mail address.- Specified by:
findByEmailin interfaceUserAccountRepository- Parameters:
email- e-mail address of the user.- Returns:
- the account, or an empty optional when no account has that address.
-
existsByUsername
Description copied from interface:UserAccountRepositoryTells whether an account with a username exists.- Specified by:
existsByUsernamein interfaceUserAccountRepository- Parameters:
username- name the user signs in with.- Returns:
truewhen an account has that username.
-
save
Stores a new account, with its authorities.Several statements: runs in the caller's transaction, which the use case opens (transactions are demarcated by the use cases, never by the adapters).
- Specified by:
savein interfaceUserAccountRepository- Parameters:
account- the account to create.
-
updatePassword
Description copied from interface:UserAccountRepositoryReplaces the encoded password of an account.- Specified by:
updatePasswordin interfaceUserAccountRepository- Parameters:
userId- identifier of the account.encodedPassword- the new encoded password.
-
markEmailVerified
Description copied from interface:UserAccountRepositoryMarks the e-mail address of an account as verified and enables the account, but only while the address is still unverified: the transition happens once, so a replayed verification never re-enables an account that was disabled after its address had been verified.- Specified by:
markEmailVerifiedin interfaceUserAccountRepository- Parameters:
userId- identifier of the account.- Returns:
truewhen the address was unverified and is now verified,falsewhen the account does not exist or its address had already been verified (nothing changes then).
-
findOne
Loads one account, with its authorities.- Parameters:
sql- query selecting the user row by one parameter.value- value of the parameter.- Returns:
- the account, or an empty optional when no row matches.
-