Class AuthorityAuthorizationManager<T>

  • Type Parameters:
    T - the type of object being authorized.
    All Implemented Interfaces:
    AuthorizationManager<T>

    public final class AuthorityAuthorizationManager<T>
    extends java.lang.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 Detail

      • hasRole

        public static <T> AuthorityAuthorizationManager<T> hasRole​(java.lang.String role)
        Creates an instance of AuthorityAuthorizationManager with the provided authority.
        Type Parameters:
        T - the type of object being authorized
        Parameters:
        role - the authority to check for prefixed with "ROLE_"
        Returns:
        the new instance
      • hasAuthority

        public static <T> AuthorityAuthorizationManager<T> hasAuthority​(java.lang.String authority)
        Creates an instance of AuthorityAuthorizationManager with the provided authority.
        Type Parameters:
        T - the type of object being authorized
        Parameters:
        authority - the authority to check for
        Returns:
        the new instance
      • hasAnyRole

        public static <T> AuthorityAuthorizationManager<T> hasAnyRole​(java.lang.String... roles)
        Creates an instance of AuthorityAuthorizationManager with the provided authorities.
        Type Parameters:
        T - the type of object being authorized
        Parameters:
        roles - the authorities to check for prefixed with "ROLE_"
        Returns:
        the new instance
      • hasAnyRole

        public static <T> AuthorityAuthorizationManager<T> hasAnyRole​(java.lang.String rolePrefix,
                                                                      java.lang.String[] roles)
        Creates an instance of AuthorityAuthorizationManager with the provided authorities.
        Type Parameters:
        T - the type of object being authorized
        Parameters:
        rolePrefix - the role prefix for roles
        roles - the authorities to check for prefixed with rolePrefix
        Returns:
        the new instance
      • hasAnyAuthority

        public static <T> AuthorityAuthorizationManager<T> hasAnyAuthority​(java.lang.String... authorities)
        Creates an instance of AuthorityAuthorizationManager with the provided authorities.
        Type Parameters:
        T - the type of object being authorized
        Parameters:
        authorities - the authorities to check for
        Returns:
        the new instance
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object