Class PermissionsHolder

  • Direct Known Subclasses:
    DerivedPermissionsAwarePermissionsHolder

    public class PermissionsHolder
    extends Object
    Encapsulates permission checking logic. Global permissions are those that are not associated with any project. Project permissions are associated with a project (via project id).
    • Method Detail

      • setPermissions

        public void setPermissions​(@NotNull
                                   Permissions globalPermissions,
                                   @NotNull
                                   Map<String,​Permissions> projectPermissions)
        Sets global and project permissions in the holder
        Parameters:
        globalPermissions - global permissions
        projectPermissions - project permissions map (internal projects id - permissions to set)
      • isPermissionGrantedGlobally

        public boolean isPermissionGrantedGlobally​(@NotNull
                                                   Permission permission)
        Returns true if the specified permission is granted globally, i.e. the permission is granted and cannot be associated with a project (not project related permission) or is granted to all of the projects.
        Parameters:
        permission - permission to check
        Returns:
        true if permission granted globally
      • isPermissionGrantedForProject

        public boolean isPermissionGrantedForProject​(@NotNull
                                                     String projectId,
                                                     @NotNull
                                                     Permission permission)
        Returns true if the specified permission is granted to the project with specified id.
        Parameters:
        projectId - internal id of the project
        permission - permission to check
        Returns:
        see above
      • isPermissionGrantedForAnyProject

        public boolean isPermissionGrantedForAnyProject​(@NotNull
                                                        Permission permission)
        Returns true if the specified permission is granted to at least one project.
        Parameters:
        permission - permission to check
        Returns:
        see above
      • isPermissionGrantedForAnyOfProjects

        public boolean isPermissionGrantedForAnyOfProjects​(Collection<String> projectIds,
                                                           Permission permission)
        Returns true if the specified permission is granted to at least one project from the given collection.
        Parameters:
        permission - permission to check
        Returns:
        see above
      • isPermissionGrantedForAllProjects

        public boolean isPermissionGrantedForAllProjects​(Collection<String> projectIds,
                                                         @NotNull
                                                         Permission permission)
      • getGlobalPermissions

        @NotNull
        public Permissions getGlobalPermissions()
        Returns permissions granted globally
        Returns:
        permissions granted globally
      • getProjectsPermissions

        @NotNull
        public Map<String,​Permissions> getProjectsPermissions()
        Returns permissions granted to projects
        Returns:
        permissions granted to projects
      • getPermissionsGrantedForProject

        @NotNull
        public Permissions getPermissionsGrantedForProject​(@NotNull
                                                           String projectId)
        Returns permissions granted to the specified project
        Parameters:
        projectId - internal id of the project
        Returns:
        see above
      • getPermissionsGrantedForAllProjects

        @NotNull
        public Permissions getPermissionsGrantedForAllProjects​(@NotNull
                                                               Collection<String> projectIds)
        Returns intersection of permissions granted to the specified projects
        Parameters:
        projectIds - internal ids of the projects
        Returns:
        see above
      • getPermissionsGrantedForAnyOfProjects

        @NotNull
        public Permissions getPermissionsGrantedForAnyOfProjects​(@NotNull
                                                                 Collection<String> projectIds)
        Returns union of permissions granted to the specified projects
        Parameters:
        projectIds - internal ids of the projects
        Returns:
        see above