Class DefaultUserLockoutService
- java.lang.Object
-
- com.broadleafcommerce.auth.user.service.DefaultUserLockoutService
-
- All Implemented Interfaces:
UserLockoutService
public class DefaultUserLockoutService extends Object implements UserLockoutService
-
-
Constructor Summary
Constructors Constructor Description DefaultUserLockoutService(UserService<User> userService, UserLoginAttemptService<UserLoginAttempt> userLoginAttemptService, AuthorizedClientService<AuthorizedClient> clientService, AuthorizationServerService<AuthorizationServer> serverService, UserLockoutProperties userLockoutProperties)
-
Method Summary
-
-
-
Constructor Detail
-
DefaultUserLockoutService
public DefaultUserLockoutService(UserService<User> userService, UserLoginAttemptService<UserLoginAttempt> userLoginAttemptService, AuthorizedClientService<AuthorizedClient> clientService, AuthorizationServerService<AuthorizationServer> serverService, UserLockoutProperties userLockoutProperties)
-
-
Method Detail
-
createLoginAttempt
public void createLoginAttempt(User user, String loginAttemptResult)
Description copied from interface:UserLockoutService
Create a user login attempt.- Specified by:
createLoginAttempt
in interfaceUserLockoutService
- Parameters:
user
- The user to create a login attempt forloginAttemptResult
- The login attempt result.
-
createLoginAttempt
public void createLoginAttempt(String username, String loginAttemptResult, String clientId)
Description copied from interface:UserLockoutService
Create a user login attempt- Specified by:
createLoginAttempt
in interfaceUserLockoutService
- Parameters:
username
- The username to create an attempt forloginAttemptResult
- The login attempt resultclientId
- The client ID
-
unlockUser
public User unlockUser(User user)
Description copied from interface:UserLockoutService
Manually unlock a user- Specified by:
unlockUser
in interfaceUserLockoutService
- Parameters:
user
- The user to unlock
-
lockUser
public User lockUser(User user)
Description copied from interface:UserLockoutService
Manually lock a user- Specified by:
lockUser
in interfaceUserLockoutService
- Parameters:
user
- The user to lock
-
unlockUserIfEligible
public Optional<User> unlockUserIfEligible(String username, String clientId)
Description copied from interface:UserLockoutService
If a user is eligbile for unlocking, unlock them.- Specified by:
unlockUserIfEligible
in interfaceUserLockoutService
- Parameters:
username
- The usernameclientId
- The client ID- Returns:
- The user, if they exist
-
canResetPassword
public boolean canResetPassword(User user)
Description copied from interface:UserLockoutService
Return true if this user can reset their password.See
AuthorizationServer.getLockedUserCanResetPassword()
andUserLockoutProperties.isLockedUserCanResetPassword()
- Specified by:
canResetPassword
in interfaceUserLockoutService
- Parameters:
user
- The user to check- Returns:
- true if the user can reset their password, otherwise false.
-
unlockUserOnPasswordResetIfEligible
@Nullable public Boolean unlockUserOnPasswordResetIfEligible(User user)
Description copied from interface:UserLockoutService
After a password reset, unlock the user if they're eligible.See
AuthorizationServer.getResetPasswordUnlocksUser()
andUserLockoutProperties.isResetPasswordUnlocksUser()
- Specified by:
unlockUserOnPasswordResetIfEligible
in interfaceUserLockoutService
- Parameters:
user
- The user to unlock, if eligible- Returns:
- true if the user has been unlocked, false if the user is still locked, or null if no action was taken
-
createLoginAttempt
protected void createLoginAttempt(String username, @Nullable String userId, String loginAttemptResult, String authServerId)
-
userShouldBeUnlocked
protected boolean userShouldBeUnlocked(@Nullable User user, AuthorizationServer server)
-
countLoginAttempts
protected int countLoginAttempts(String username, AuthorizationServer server)
-
getLockoutDuration
@Nullable protected Duration getLockoutDuration(AuthorizationServer server)
-
readAuthServer
protected AuthorizationServer readAuthServer(String authServerId)
-
getLockoutDurationMinutes
@Nullable protected Long getLockoutDurationMinutes(AuthorizationServer server)
-
getLoginFailDecayMinutes
@Nullable protected Long getLoginFailDecayMinutes(AuthorizationServer server)
-
getLoginAttemptsAllowed
protected int getLoginAttemptsAllowed(AuthorizationServer server)
-
throwIfLocked
protected void throwIfLocked(int attempts, String username, AuthorizationServer server, @Nullable User user)
-
isResetPasswordUnlocksUser
protected boolean isResetPasswordUnlocksUser(AuthorizationServer server)
-
isLockedUserCanResetPassword
protected boolean isLockedUserCanResetPassword(AuthorizationServer server)
-
getUserService
protected UserService<User> getUserService()
-
getUserLoginAttemptService
protected UserLoginAttemptService<UserLoginAttempt> getUserLoginAttemptService()
-
getClientService
protected AuthorizedClientService<AuthorizedClient> getClientService()
-
getServerService
protected AuthorizationServerService<AuthorizationServer> getServerService()
-
getUserLockoutProperties
protected UserLockoutProperties getUserLockoutProperties()
-
-