Class BuiltInMethods


  • public final class BuiltInMethods
    extends Object
    Built-in methods for expression language evaluation. These methods are bound in default namespace (without a prefix). Name to use in an expression is the name of the method.
    • Method Detail

      • inRole

        public static boolean inRole​(Subject subject,
                                     String role)
        Check if subject has the specified role.
        Parameters:
        subject - subject of a user or a service
        role - role the subject should be in
        Returns:
        true if the subject is in the role
      • inRoles

        public static boolean inRoles​(Subject subject,
                                      String... roles)
        Check if subject has the specified roles (must have all of them). If you need to check that subject is in EITHER of the roles, you should combine this will or operator (e.g. inRole(user, "manager") || inRole(user, "admin"))
        Parameters:
        subject - subject of a user or a service
        roles - roles the subject should be in
        Returns:
        true if the subject is in all the specified roles
      • inScope

        public static boolean inScope​(Subject subject,
                                      String scope)
        Check if subject has the specified scope.
        Parameters:
        subject - subject of a user
        scope - scope the subject should have
        Returns:
        true if the subject has all the specified scopes
      • inScopes

        public static boolean inScopes​(Subject subject,
                                       String... scopes)
        Check if subject has the specified scopes (must have all of them).
        Parameters:
        subject - subject of a user
        scopes - scopes the subject should have
        Returns:
        true if the subject has all the specified scopes