Package net.shibboleth.idp.authn.impl
Class StorageBackedAccountLockoutManager
java.lang.Object
net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
net.shibboleth.idp.authn.impl.StorageBackedAccountLockoutManager
- All Implemented Interfaces:
AccountLockoutManager,Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent
public class StorageBackedAccountLockoutManager
extends AbstractIdentifiableInitializableComponent
implements AccountLockoutManager
Implementation of
AccountLockoutManager interface that relies on a StorageService
to track lockout state.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA function to generate a key for lockout storage. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Function<ProfileRequestContext,Duration> Lookup function for interval after which counter is reset.private booleanControls whether attempts against locked accounts extend duration.private Function<ProfileRequestContext,Duration> Lookup function for duration of lockout.private Function<ProfileRequestContext,String> Lookup function to produce account lockout keys.private org.slf4j.LoggerClass logger.private Function<ProfileRequestContext,Integer> Lookup function for maximum failed attempts within window.private StorageServiceBacking service. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheck(ProfileRequestContext profileRequestContext) Check if the authentication credentials associated with the request are subject to lockout.booleanclear(ProfileRequestContext profileRequestContext) Clear the lockout state for the authentication credentials associated with the request.protected booleandoIncrement(ProfileRequestContext profileRequestContext, String key, int retries) Implement invalid login attempt counter via storage service, retrying as necessary.protected voidbooleanincrement(ProfileRequestContext profileRequestContext) Increment the lockout counter for the authentication credentials associated with the request.voidsetCounterInterval(Duration window) Set interval after which counter is reset.voidSet lookup function for interval after which counter is reset.voidsetExtendLockoutDuration(boolean flag) Set whether to extend the lockout duration on attempts during lockout.voidsetLockoutDuration(Duration duration) Set lockout duration.voidSet lookup function for lockout duration.voidsetLockoutKeyStrategy(Function<ProfileRequestContext, String> strategy) Set the strategy function to compute the account lockout key.voidsetMaxAttempts(int attempts) Set the maximum failed attempts within window.voidSet lookup function for maximum failed attempts within window.voidsetStorageService(StorageService storage) Set theStorageServiceback-end to use.Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
setIdMethods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
getIdMethods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.utilities.java.support.component.IdentifiedComponent
getId
-
Field Details
-
log
@Nonnull private org.slf4j.Logger logClass logger. -
storageService
Backing service. -
lockoutKeyStrategy
Lookup function to produce account lockout keys. -
maxAttemptsLookupStrategy
Lookup function for maximum failed attempts within window. -
counterIntervalLookupStrategy
Lookup function for interval after which counter is reset. -
lockoutDurationLookupStrategy
Lookup function for duration of lockout. -
extendLockoutDuration
private boolean extendLockoutDurationControls whether attempts against locked accounts extend duration.
-
-
Constructor Details
-
StorageBackedAccountLockoutManager
public StorageBackedAccountLockoutManager()Constructor.
-
-
Method Details
-
setStorageService
Set theStorageServiceback-end to use.- Parameters:
storage- the back-end to use
-
setLockoutKeyStrategy
Set the strategy function to compute the account lockout key.Defaults to a concatenation of the username and client address.
- Parameters:
strategy- strategy function
-
setMaxAttempts
Set the maximum failed attempts within window.Defaults to 5.
- Parameters:
attempts- maximum failed attempts
-
setMaxAttemptsLookupStrategy
Set lookup function for maximum failed attempts within window.The function MUST return a positive value.
- Parameters:
strategy- lookup function
-
setCounterInterval
Set interval after which counter is reset.Defaults to 5 minutes.
- Parameters:
window- counter window
-
setCounterIntervalLookupStrategy
public void setCounterIntervalLookupStrategy(@Nonnull Function<ProfileRequestContext, Duration> strategy) Set lookup function for interval after which counter is reset.The function MUST return a positive value.
- Parameters:
strategy- lookup function
-
setLockoutDuration
Set lockout duration.Defaults to 5 minutes.
- Parameters:
duration- lockout duration
-
setLockoutDurationLookupStrategy
public void setLockoutDurationLookupStrategy(@Nonnull Function<ProfileRequestContext, Duration> strategy) Set lookup function for lockout duration.The function MUST return a positive value. Use a large value for permanent lockout.
- Parameters:
strategy- lookup function
-
setExtendLockoutDuration
public void setExtendLockoutDuration(boolean flag) Set whether to extend the lockout duration on attempts during lockout.- Parameters:
flag- flag to set
-
doInitialize
- Overrides:
doInitializein classAbstractIdentifiedInitializableComponent- Throws:
ComponentInitializationException
-
check
Check if the authentication credentials associated with the request are subject to lockout.- Specified by:
checkin interfaceAccountLockoutManager- Parameters:
profileRequestContext- current profile request context- Returns:
- true iff the credentials correspond to a locked account
-
increment
Increment the lockout counter for the authentication credentials associated with the request.- Specified by:
incrementin interfaceAccountLockoutManager- Parameters:
profileRequestContext- current profile request context- Returns:
- true iff the counter was incremented
-
clear
Clear the lockout state for the authentication credentials associated with the request.- Specified by:
clearin interfaceAccountLockoutManager- Parameters:
profileRequestContext- current profile request context- Returns:
- true iff the state was successfully cleared
-
doIncrement
protected boolean doIncrement(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull @NotEmpty String key, int retries) Implement invalid login attempt counter via storage service, retrying as necessary.- Parameters:
profileRequestContext- current profile request contextkey- account lockout keyretries- number of additional retries to allow- Returns:
- true iff successful
-