Class AuthorityAuthorizationManager<T>
java.lang.Object
org.springframework.security.authorization.AuthorityAuthorizationManager<T>
- Type Parameters:
T- the type of object being authorized.
- All Implemented Interfaces:
AuthorizationManager<T>
public final class AuthorityAuthorizationManager<T>
extends Object
implements AuthorizationManager<T>
An
AuthorizationManager that determines if the current user is authorized by
evaluating if the Authentication contains a specified authority.- Since:
- 5.5
-
Method Summary
Modifier and TypeMethodDescriptioncheck(Supplier<Authentication> authentication, T object) Determines if the current user is authorized by evaluating if theAuthenticationcontains a specified authority.static <T> AuthorityAuthorizationManager<T>hasAnyAuthority(String... authorities) Creates an instance ofAuthorityAuthorizationManagerwith the provided authorities.static <T> AuthorityAuthorizationManager<T>hasAnyRole(String... roles) Creates an instance ofAuthorityAuthorizationManagerwith the provided authorities.static <T> AuthorityAuthorizationManager<T>hasAnyRole(String rolePrefix, String[] roles) Creates an instance ofAuthorityAuthorizationManagerwith the provided authorities.static <T> AuthorityAuthorizationManager<T>hasAuthority(String authority) Creates an instance ofAuthorityAuthorizationManagerwith the provided authority.static <T> AuthorityAuthorizationManager<T>Creates an instance ofAuthorityAuthorizationManagerwith the provided authority.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.security.authorization.AuthorizationManager
verify
-
Method Details
-
hasRole
Creates an instance ofAuthorityAuthorizationManagerwith the provided authority.- Type Parameters:
T- the type of object being authorized- Parameters:
role- the authority to check for prefixed with "ROLE_". Role should not start with "ROLE_" since it is automatically prepended already.- Returns:
- the new instance
-
hasAuthority
Creates an instance ofAuthorityAuthorizationManagerwith the provided authority.- Type Parameters:
T- the type of object being authorized- Parameters:
authority- the authority to check for- Returns:
- the new instance
-
hasAnyRole
Creates an instance ofAuthorityAuthorizationManagerwith the provided authorities.- Type Parameters:
T- the type of object being authorized- Parameters:
roles- the authorities to check for prefixed with "ROLE_". Each role should not start with "ROLE_" since it is automatically prepended already.- Returns:
- the new instance
-
hasAnyRole
Creates an instance ofAuthorityAuthorizationManagerwith the provided authorities.- Type Parameters:
T- the type of object being authorized- Parameters:
rolePrefix- the role prefix forrolesroles- the authorities to check for prefixed withrolePrefix- Returns:
- the new instance
-
hasAnyAuthority
Creates an instance ofAuthorityAuthorizationManagerwith the provided authorities.- Type Parameters:
T- the type of object being authorized- Parameters:
authorities- the authorities to check for- Returns:
- the new instance
-
check
Determines if the current user is authorized by evaluating if theAuthenticationcontains a specified authority.- Specified by:
checkin interfaceAuthorizationManager<T>- Parameters:
authentication- theSupplierof theAuthenticationto checkobject- theAuthorityAuthorizationManagerobject to check- Returns:
- an
AuthorizationDecision
-
toString
-