Interface IRoleMatcher


  • public interface IRoleMatcher

    Test if the user of this user token currently owns roles.

    Note, that this method does not behave like IUser.getRoles(). A user token can have more roles than the user itself because of substitutions.

    Example:

    ivy.session.has().role("Manager");
    Since:
    9.3
    API:
    This is a public API.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean anyRoles​(IRole... roles)
      Tests if the user of this user token currently owns any the given roles.
      boolean anyRoles​(String... roleNames)
      Tests if the user of this user token currently owns any of the roles given with their names.
      boolean anyRoles​(Collection<IRole> roles)
      Tests if the user of this user token currently owns any of the given roles.
      boolean anyRolesWithNames​(Collection<String> roleNames)
      Tests if the user of this user token currently owns any of the roles given with their names.
      boolean role​(IRole role)
      Tests if the user of this user token currently owns the given role.
      boolean role​(String roleName)
      Tests if the user of this user token currently owns the role with the given name.
      boolean roles​(IRole... roles)
      Tests if the user of this user token currently owns all the given roles.
      boolean roles​(String... roleNames)
      Tests if the user of this user token currently owns the roles with the given names.
      boolean roles​(Collection<IRole> roles)
      Tests if the user of this user token currently owns all the given roles.
      boolean rolesWithNames​(Collection<String> roleNames)
      Tests if the user of this user token currently owns all the roles given with their names.
    • Method Detail

      • role

        boolean role​(String roleName)

        Tests if the user of this user token currently owns the role with the given name.

        Note, that this method does not behave like IUser.getRoles(). A user token can have more roles than the user itself because of substitutions.

        Example:

        ivy.session.has().role("Manager");
        Parameters:
        roleName - the name of the role to test
        Returns:
        true if the user token currently owns the role with the given name
        Since:
        9.3
        See Also:
        role(IRole)
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • role

        boolean role​(IRole role)

        Tests if the user of this user token currently owns the given role.

        Note, that this method does not behave like IUser.getRoles(). A user token can have more roles than the user itself because of substitutions.

        Example:

        
         IRole manager = ivy.session.getSecurityContext().findRole("Manager");
         ivy.session.has().role(manager);
         
        Parameters:
        role - the role to test
        Returns:
        true if the user token currently owns the given role
        Since:
        9.3
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • roles

        boolean roles​(String... roleNames)

        Tests if the user of this user token currently owns the roles with the given names.

        Note, that this method does not behave like IUser.getRoles(). A user token can have more roles than the user itself because of substitutions.

        Returns true if the given roleNames are empty.

        Example:

        ivy.session.has().roles("Manager", "Employee");
        Parameters:
        roleNames - the names of the roles to test
        Returns:
        true if the user token currently owns all the roles with the given names
        Since:
        9.3
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • roles

        boolean roles​(IRole... roles)

        Tests if the user of this user token currently owns all the given roles.

        Note, that this method does not behave like IUser.getRoles(). A user token can have more roles than the user itself because of substitutions.

        Returns true if the given roles are empty.

        Example:

        
         IRole manager = ivy.session.getSecurityContext().findRole("Manager");
         IRole employee = ivy.session.getSecurityContext().findRole("Employee");
         ivy.session.has().roles(manager, employee);
        Parameters:
        roles - the roles to test
        Returns:
        true if the user token currently owns all the given roles
        Since:
        9.3
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • roles

        boolean roles​(Collection<IRole> roles)

        Tests if the user of this user token currently owns all the given roles.

        Note, that this method does not behave like IUser.getRoles(). A user token can have more roles than the user itself because of substitutions.

        Returns true if the given roles are empty.

        Example:

        
         IRole manager = ivy.session.getSecurityContext().findRole("Manager");
         IRole employee = ivy.session.getSecurityContext().findRole("Employee");
         List roles = [manager, employee];
         ivy.session.has().roles(roles);
        Parameters:
        roles - the roles to test
        Returns:
        true if the user token currently owns all the given roles
        Since:
        9.3
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • rolesWithNames

        boolean rolesWithNames​(Collection<String> roleNames)

        Tests if the user of this user token currently owns all the roles given with their names.

        Note, that this method does not behave like IUser.getRoles(). A user token can have more roles than the user itself because of substitutions.

        Returns true if the given role names are empty.

        Example:

        
         IRole manager = ivy.session.getSecurityContext().findRole("Manager");
         IRole employee = ivy.session.getSecurityContext().findRole("Employee");
         List roleNames = ["Manager", "Employee"];
         ivy.session.has().rolesWithNames(roleNames);
        Parameters:
        roleNames - the names of the roles to test
        Returns:
        true if the user token currently owns all the roles given with their names
        Since:
        9.3
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • anyRoles

        boolean anyRoles​(String... roleNames)

        Tests if the user of this user token currently owns any of the roles given with their names.

        Note, that this method does not behave like IUser.getRoles(). A user token can have more roles than the user itself because of substitutions.

        Returns false if the given role names are empty.

        Example:

        ivy.session.has().anyRoles("Manager", "Employee");
        Parameters:
        roleNames - the names of the roles to test
        Returns:
        true if the user token currently owns any of the roles given with their names
        Since:
        9.3
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • anyRoles

        boolean anyRoles​(IRole... roles)

        Tests if the user of this user token currently owns any the given roles.

        Note, that this method does not behave like IUser.getRoles(). A user token can have more roles than the user itself because of substitutions.

        Returns false if the given roles are empty.

        Example:

        
         IRole manager = ivy.session.getSecurityContext().findRole("Manager");
         IRole employee = ivy.session.getSecurityContext().findRole("Employee");
         List roles = [manager, employee];
         ivy.session.has().anyRoles(roles);
        Parameters:
        roles - the roles to test
        Returns:
        true if the user token currently owns any the given roles
        Since:
        9.3
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • anyRoles

        boolean anyRoles​(Collection<IRole> roles)

        Tests if the user of this user token currently owns any of the given roles.

        Note, that this method does not behave like IUser.getRoles(). A user token can have more roles than the user itself because of substitutions.

        Returns false if the given roles are empty.

        Example:

        
         IRole manager = ivy.session.getSecurityContext().findRole("Manager");
         IRole employee = ivy.session.getSecurityContext().findRole("Employee");
         List roles = [manager, employee];
         ivy.session.has().anyRoles(roles);
        Parameters:
        roles - the roles to test
        Returns:
        true if the user token currently owns any of the given roles
        Since:
        9.3
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • anyRolesWithNames

        boolean anyRolesWithNames​(Collection<String> roleNames)

        Tests if the user of this user token currently owns any of the roles given with their names.

        Note, that this method does not behave like IUser.getRoles(). A user token can have more roles than the user itself because of substitutions.

        Returns false if the given role names are empty.

        Example:

        
         IRole manager = ivy.session.getSecurityContext().findRole("Manager");
         IRole employee = ivy.session.getSecurityContext().findRole("Employee");
         List roleNames = ["Manager", "Employee"];
         ivy.session.has().rolesWithNames(roleNames);
        Parameters:
        roleNames - the names of the roles to test
        Returns:
        true if the user token currently owns any of the roles given with their names
        Since:
        9.3
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.