Class AllRequiredFactorsAuthorizationManager<T>
java.lang.Object
org.springframework.security.authorization.AllRequiredFactorsAuthorizationManager<T>
- All Implemented Interfaces:
AuthorizationManager<T>
public final class AllRequiredFactorsAuthorizationManager<T>
extends Object
implements AuthorizationManager<T>
An
AuthorizationManager that determines if the current user is authorized by
evaluating if the Authentication contains a FactorGrantedAuthority that
is not expired for each RequiredFactor.- Since:
- 7.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA builder forAllRequiredFactorsAuthorizationManager. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> AuthorizationManager<T> anyOf(AllRequiredFactorsAuthorizationManager<T>... managers) Creates anAuthorizationManagerthat grants access if at least oneAllRequiredFactorsAuthorizationManagergranted.authorize(Supplier<? extends @Nullable Authentication> authentication, T object) For eachRequiredFactorfinds the firstFactorGrantedAuthority.getAuthority()that matches theRequiredFactor.getAuthority().static <T> AllRequiredFactorsAuthorizationManager.Builder<T> builder()Creates a newAllRequiredFactorsAuthorizationManager.BuildervoidSets theClockto use.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AuthorizationManager
verify
-
Method Details
-
anyOf
@SafeVarargs public static <T> AuthorizationManager<T> anyOf(AllRequiredFactorsAuthorizationManager<T>... managers) Creates anAuthorizationManagerthat grants access if at least oneAllRequiredFactorsAuthorizationManagergranted. When all managers deny, collects the uniqueRequiredFactorErrors from each manager.- Type Parameters:
- Parameters:
managers- theAllRequiredFactorsAuthorizationManagers to use; cannot be empty or contain null elements- Returns:
- the
AuthorizationManagerto use - Since:
- 7.1
- See Also:
-
setClock
-
authorize
public FactorAuthorizationDecision authorize(Supplier<? extends @Nullable Authentication> authentication, T object) For eachRequiredFactorfinds the firstFactorGrantedAuthority.getAuthority()that matches theRequiredFactor.getAuthority(). TheFactorGrantedAuthority.getIssuedAt()must be more recent thanRequiredFactor.getValidDuration()(if non-null).- Specified by:
authorizein interfaceAuthorizationManager<T>- Parameters:
authentication- theSupplierof theAuthenticationto checkobject- the object to check authorization on (not used).- Returns:
- an
FactorAuthorizationDecision
-
builder
Creates a newAllRequiredFactorsAuthorizationManager.Builder- Returns:
-