Class DefaultUserLoginAttemptService<P extends UserLoginAttempt,D extends com.broadleafcommerce.data.tracking.core.mapping.BusinessTypeAware & com.broadleafcommerce.data.tracking.core.mapping.ModelMapperMappable>
- java.lang.Object
-
- com.broadleafcommerce.auth.user.service.DefaultUserLoginAttemptService<P,D>
-
- All Implemented Interfaces:
UserLoginAttemptService<P>
public class DefaultUserLoginAttemptService<P extends UserLoginAttempt,D extends com.broadleafcommerce.data.tracking.core.mapping.BusinessTypeAware & com.broadleafcommerce.data.tracking.core.mapping.ModelMapperMappable> extends Object implements UserLoginAttemptService<P>
-
-
Constructor Summary
Constructors Constructor Description DefaultUserLoginAttemptService(UserLoginAttemptRepository<D> repository, SimplePayloadMapper mapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
countConsideredUserLoginAttempts(String username, String authServerId)
Read the number of failed login attemptsint
countConsideredUserLoginAttempts(String username, String authServerId, Duration age)
Count number of user login attempts for a specific period of time (e.g.P
createUserLoginAttempt(String username, String userId, String loginAttemptResult, String authServerId)
Create a new user login attempt.void
purgeLoginAttempts(Duration loginAttemptAge, String authServerId)
Purges any login attempts older than the specified duration.List<P>
readConsideredUserLoginAttempts(String username, String authServerId, Duration age)
Read user login attempts for a specific period of time (e.g.void
resetLoginAttempts(String username, String authServerId)
Reset user login attempts for a specific username and auth server ID.
-
-
-
Constructor Detail
-
DefaultUserLoginAttemptService
public DefaultUserLoginAttemptService(UserLoginAttemptRepository<D> repository, SimplePayloadMapper mapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Detail
-
countConsideredUserLoginAttempts
public int countConsideredUserLoginAttempts(String username, String authServerId, Duration age)
Description copied from interface:UserLoginAttemptService
Count number of user login attempts for a specific period of time (e.g. for the last 24 hours)- Specified by:
countConsideredUserLoginAttempts
in interfaceUserLoginAttemptService<P extends UserLoginAttempt>
- Parameters:
username
- The username used in the login attemptauthServerId
- The auth server idage
- The period of time- Returns:
- The number of failed login attempts
-
countConsideredUserLoginAttempts
public int countConsideredUserLoginAttempts(String username, String authServerId)
Description copied from interface:UserLoginAttemptService
Read the number of failed login attempts- Specified by:
countConsideredUserLoginAttempts
in interfaceUserLoginAttemptService<P extends UserLoginAttempt>
- Parameters:
username
- The username to read forauthServerId
- The auth server ID- Returns:
- The number of failed login attempts
-
readConsideredUserLoginAttempts
public List<P> readConsideredUserLoginAttempts(String username, String authServerId, Duration age)
Description copied from interface:UserLoginAttemptService
Read user login attempts for a specific period of time (e.g. for the last 24 hours)- Specified by:
readConsideredUserLoginAttempts
in interfaceUserLoginAttemptService<P extends UserLoginAttempt>
- Parameters:
username
- The username used in the login attemptauthServerId
- The auth server idage
- The period of time- Returns:
- The number of failed login attempts
-
createUserLoginAttempt
public P createUserLoginAttempt(String username, @Nullable String userId, String loginAttemptResult, String authServerId)
Description copied from interface:UserLoginAttemptService
Create a new user login attempt.- Specified by:
createUserLoginAttempt
in interfaceUserLoginAttemptService<P extends UserLoginAttempt>
- Parameters:
username
- The usernameuserId
- The user ID. OptionalloginAttemptResult
- The login result. SeeLoginAttemptResult
authServerId
- The auth server id- Returns:
- The newly create user login attempt
-
resetLoginAttempts
@Transactional public void resetLoginAttempts(String username, String authServerId)
Description copied from interface:UserLoginAttemptService
Reset user login attempts for a specific username and auth server ID. This should generally be called on a successful login attempt- Specified by:
resetLoginAttempts
in interfaceUserLoginAttemptService<P extends UserLoginAttempt>
- Parameters:
username
- The username to reset login attempts forauthServerId
- The auth server ID
-
purgeLoginAttempts
@Transactional public void purgeLoginAttempts(Duration loginAttemptAge, @Nullable String authServerId)
Description copied from interface:UserLoginAttemptService
Purges any login attempts older than the specified duration.- Specified by:
purgeLoginAttempts
in interfaceUserLoginAttemptService<P extends UserLoginAttempt>
- Parameters:
loginAttemptAge
- The age of login attempts to purge. Any attempts greater than or equal to this age will be deleted.authServerId
- The auth server ID of login attempts to purge. Optional.
-
-