public class StorageBackedAccountLockoutManager extends AbstractIdentifiableInitializableComponent implements AccountLockoutManager
AccountLockoutManager interface that relies on a StorageService
to track lockout state.| Modifier and Type | Class and Description |
|---|---|
static class |
StorageBackedAccountLockoutManager.UsernameIPLockoutKeyStrategy
A function to generate a key for lockout storage.
|
| Modifier and Type | Field and Description |
|---|---|
private com.google.common.base.Function<ProfileRequestContext,Long> |
counterIntervalLookupStrategy
Lookup function for interval after which counter is reset.
|
private boolean |
extendLockoutDuration
Controls whether attempts against locked accounts extend duration.
|
private com.google.common.base.Function<ProfileRequestContext,Long> |
lockoutDurationLookupStrategy
Lookup function for duration of lockout.
|
private com.google.common.base.Function<ProfileRequestContext,String> |
lockoutKeyStrategy
Lookup function to produce account lockout keys.
|
private org.slf4j.Logger |
log
Class logger.
|
private com.google.common.base.Function<ProfileRequestContext,Integer> |
maxAttemptsLookupStrategy
Lookup function for maximum failed attempts within window.
|
private StorageService |
storageService
Backing service.
|
| Constructor and Description |
|---|
StorageBackedAccountLockoutManager()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
check(ProfileRequestContext profileRequestContext) |
boolean |
clear(ProfileRequestContext profileRequestContext) |
protected boolean |
doIncrement(ProfileRequestContext profileRequestContext,
String key,
int retries)
Implement invalid login attempt counter via storage service, retrying as necessary.
|
protected void |
doInitialize() |
boolean |
increment(ProfileRequestContext profileRequestContext) |
void |
setCounterInterval(long window)
Set interval after which counter is reset.
|
void |
setCounterIntervalLookupStrategy(com.google.common.base.Function<ProfileRequestContext,Long> strategy)
Set lookup function for interval after which counter is reset.
|
void |
setExtendLockoutDuration(boolean flag)
Set whether to extend the lockout duration on attempts during lockout.
|
void |
setLockoutDuration(long duration)
Set lockout duration.
|
void |
setLockoutDurationLookupStrategy(com.google.common.base.Function<ProfileRequestContext,Long> strategy)
Set lookup function for lockout duration.
|
void |
setLockoutKeyStrategy(com.google.common.base.Function<ProfileRequestContext,String> strategy)
Set the strategy function to compute the account lockout key.
|
void |
setMaxAttempts(int attempts)
Set the maximum failed attempts within window.
|
void |
setMaxAttemptsLookupStrategy(com.google.common.base.Function<ProfileRequestContext,Integer> strategy)
Set lookup function for maximum failed attempts within window.
|
void |
setStorageService(StorageService storage)
Set the
StorageService back-end to use. |
setIdgetIddestroy, doDestroy, initialize, isDestroyed, isInitializedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetId@Nonnull private org.slf4j.Logger log
@NonnullAfterInit private StorageService storageService
@Nullable private com.google.common.base.Function<ProfileRequestContext,String> lockoutKeyStrategy
@Nonnull private com.google.common.base.Function<ProfileRequestContext,Integer> maxAttemptsLookupStrategy
@Nonnull private com.google.common.base.Function<ProfileRequestContext,Long> counterIntervalLookupStrategy
@Nonnull private com.google.common.base.Function<ProfileRequestContext,Long> lockoutDurationLookupStrategy
private boolean extendLockoutDuration
public StorageBackedAccountLockoutManager()
public void setStorageService(@Nonnull StorageService storage)
StorageService back-end to use.storage - the back-end to usepublic void setLockoutKeyStrategy(@Nonnull com.google.common.base.Function<ProfileRequestContext,String> strategy)
Defaults to a concatenation of the username and client address.
strategy - strategy functionpublic void setMaxAttempts(@Positive int attempts)
Defaults to 5.
attempts - maximum failed attemptspublic void setMaxAttemptsLookupStrategy(@Nonnull com.google.common.base.Function<ProfileRequestContext,Integer> strategy)
The function MUST return a positive value.
strategy - lookup function@Duration public void setCounterInterval(@Duration@Positive long window)
Defaults to 5 minutes.
window - counter windowpublic void setCounterIntervalLookupStrategy(@Nonnull com.google.common.base.Function<ProfileRequestContext,Long> strategy)
The function MUST return a positive value.
strategy - lookup function@Duration public void setLockoutDuration(@Duration@Positive long duration)
Defaults to 5 minutes.
duration - lockout durationpublic void setLockoutDurationLookupStrategy(@Nonnull com.google.common.base.Function<ProfileRequestContext,Long> strategy)
The function MUST return a positive value. Use a large value for permanent lockout.
strategy - lookup functionpublic void setExtendLockoutDuration(boolean flag)
flag - flag to setprotected void doInitialize()
throws ComponentInitializationException
doInitialize in class AbstractIdentifiedInitializableComponentComponentInitializationExceptionpublic boolean check(@Nonnull ProfileRequestContext profileRequestContext)
check in interface AccountLockoutManagerpublic boolean increment(@Nonnull ProfileRequestContext profileRequestContext)
increment in interface AccountLockoutManagerpublic boolean clear(@Nonnull ProfileRequestContext profileRequestContext)
clear in interface AccountLockoutManagerprotected boolean doIncrement(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull@NotEmpty String key, int retries)
profileRequestContext - current profile request contextkey - account lockout keyretries - number of additional retries to allowCopyright © 1999–2018 Shibboleth Consortium. All rights reserved.