Class AuthorizationFunctions


  • public class AuthorizationFunctions
    extends Object
    A set of functions for permissions checking that can be called from JSP.
    • Constructor Detail

      • AuthorizationFunctions

        public AuthorizationFunctions​(@NotNull
                                      SecurityContext context)
        Constructor.
        Parameters:
        context - security context
    • Method Detail

      • permissionGrantedGlobally

        public static boolean permissionGrantedGlobally​(@NotNull
                                                        String permissionName)
        Returns true if currently authenticated user has specified permission granted for all projects
        Parameters:
        permissionName - name of the permission Enum.name()
        Returns:
        true if permission is granted and false otherwise
      • permissionGrantedForProject

        public static boolean permissionGrantedForProject​(@NotNull
                                                          SProject project,
                                                          @NotNull
                                                          String permissionName)
        Returns true if currently authenticated user has permission with specified name granted for specified project
        Parameters:
        project - a project
        permissionName - name of the permission Enum.name()
        Returns:
        true if permission is granted and false otherwise
      • permissionGrantedForProjectWithId

        public static boolean permissionGrantedForProjectWithId​(@NotNull
                                                                String projectId,
                                                                @NotNull
                                                                String permissionName)
        Returns true if specified permission granted for the project with specified id
        Parameters:
        projectId - id of the project
        permissionName - name of the permission Enum.name()
        Returns:
        true if permission is granted and false otherwise
      • permissionGrantedForAnyProject

        public static boolean permissionGrantedForAnyProject​(@NotNull
                                                             String permissionName)
        Returns true if currently authenticated user has permission with specified name granted for any project
        Parameters:
        permissionName - name of the permission Enum.name()
        Returns:
        true if permission is granted and false otherwise
      • permissionGrantedForBuildTemplate

        public static boolean permissionGrantedForBuildTemplate​(@NotNull
                                                                BuildTypeTemplate buildTemplate,
                                                                @NotNull
                                                                String permissionName)
        Returns true if currently authenticated user has permission with specified name granted for specified build configuration template
        Parameters:
        buildTemplate - build configuration template
        permissionName - name of the permission Enum.name()
        Returns:
        true if permission is granted and false otherwise
      • permissionGrantedForBuildType

        public static boolean permissionGrantedForBuildType​(@NotNull
                                                            SBuildType buildType,
                                                            @NotNull
                                                            String permissionName)
        Returns true if currently authenticated user has permission with specified name granted for specified build configuration
        Parameters:
        buildType - build configuration
        permissionName - name of the permission Enum.name()
        Returns:
        true if permission is granted and false otherwise
      • permissionGrantedForBuild

        public static boolean permissionGrantedForBuild​(@NotNull
                                                        SBuild build,
                                                        @NotNull
                                                        String permissionName)
        Returns true if currently authenticated user has permission with specified name granted for specified build
        Parameters:
        build - a build
        permissionName - name of the permission Enum.name()
        Returns:
        true if permission is granted and false otherwise
      • permissionGrantedForModification

        public static boolean permissionGrantedForModification​(@NotNull
                                                               SVcsModification modification,
                                                               @NotNull
                                                               String permissionName)
        Returns true if currently authenticated user has permission with specified name granted for specified VCS modification
        Parameters:
        modification - VCS modification
        permissionName - name of the permission Enum.name()
        Returns:
        true if permission is granted and false otherwise
      • hasFileContentAccess

        public static boolean hasFileContentAccess​(@NotNull
                                                   SVcsModification modification)
        Returns true if currently authenticated user has view file content permission granted for specified VCS modification or any of its duplicates
        Parameters:
        modification - VCS modification
        Returns:
        see above
      • adminSpaceAvailable

        public static boolean adminSpaceAvailable()
        Returns true if currently authenticated user has access to the administration space (can see "Administration" tab in the web UI).
        Returns:
        true if currently authenticated user has access to the administration space
      • userManagementAvailable

        public static boolean userManagementAvailable()
        Returns true if user management UI is available to current authority holder
        Returns:
        see above
      • groupManagementAvailable

        public static boolean groupManagementAvailable()
        Returns true if group management UI is available to current authority holder
        Returns:
        true if group management interface is available
      • canEditVcsRoot

        public static boolean canEditVcsRoot​(@NotNull
                                             SVcsRoot vcsRoot)
        Returns true if current authority holder can edit VCS root
        Parameters:
        vcsRoot - vcs root
        Returns:
        see above
      • canRemoveBuild

        public static boolean canRemoveBuild​(@NotNull
                                             SBuild build)
        Returns true if current authority holder can remove build
        Parameters:
        build - build
        Returns:
        see above
      • canEditVcsChange

        public static boolean canEditVcsChange​(@NotNull
                                               SVcsModification modification)
        Returns true if current authority holder can edit vcs modification
        Returns:
        see above
      • canStopBuild

        public static boolean canStopBuild​(@NotNull
                                           SBuild build)
        Returns true if current authority holder can stop build
        Parameters:
        build - build
        Returns:
        see above
      • canCancelBuild

        public static boolean canCancelBuild​(@NotNull
                                             SQueuedBuild queuedBuild)
        Returns true if current authority holder can cancel queued build
        Parameters:
        queuedBuild - queued build
        Returns:
        see above
      • canViewAgentPool

        public static boolean canViewAgentPool​(@NotNull
                                               AgentPool agentPool)
        Returns true if current authority holder can view agents in specified pool
        Parameters:
        agentPool - agent pool
        Returns:
        see above
      • canViewAgentDetailsInPool

        public static boolean canViewAgentDetailsInPool​(@NotNull
                                                        AgentPool agentPool)
        Returns true if current authority holder can view details of agents in specified pool
        Parameters:
        agentPool - agent pool
        Returns:
        see above
      • isSystemAdmin

        public static boolean isSystemAdmin()
        Returns true if current authenticated user is a system admin
        Returns:
        true if current authenticated user is a system admin