Class AuthorizationFunctions


  • public class AuthorizationFunctions
    extends java.lang.Object
    A set of functions for permissions checking that can be called from JSP.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean adminSpaceAvailable()
      Returns true if currently authenticated user has access to the administration space (can see "Administration" tab in the web UI).
      static boolean canCancelBuild​(SQueuedBuild queuedBuild)
      Returns true if current authority holder can cancel queued build
      static boolean canEditVcsChange​(SVcsModification modification)
      Returns true if current authority holder can edit vcs modification
      static boolean canEditVcsRoot​(SVcsRoot vcsRoot)
      Returns true if current authority holder can edit VCS root
      static boolean canRemoveBuild​(SBuild build)
      Returns true if current authority holder can remove build
      static boolean canStopBuild​(SBuild build)
      Returns true if current authority holder can stop build
      static boolean canViewAgentDetailsInPool​(AgentPool agentPool)
      Returns true if current authority holder can view details of agents in specified pool
      static boolean canViewAgentPool​(AgentPool agentPool)
      Returns true if current authority holder can view agents in specified pool
      static boolean groupManagementAvailable()
      Returns true if group management UI is available to current authority holder
      static boolean hasFileContentAccess​(SVcsModification modification)
      Returns true if currently authenticated user has view file content permission granted for specified VCS modification or any of its duplicates
      static boolean isSystemAdmin()
      Returns true if current authenticated user is a system admin
      static boolean permissionGrantedForAnyProject​(java.lang.String permissionName)
      Returns true if currently authenticated user has permission with specified name granted for any project
      static boolean permissionGrantedForBuild​(SBuild build, java.lang.String permissionName)
      Returns true if currently authenticated user has permission with specified name granted for specified build
      static boolean permissionGrantedForBuildTemplate​(BuildTypeTemplate buildTemplate, java.lang.String permissionName)
      Returns true if currently authenticated user has permission with specified name granted for specified build configuration template
      static boolean permissionGrantedForBuildType​(SBuildType buildType, java.lang.String permissionName)
      Returns true if currently authenticated user has permission with specified name granted for specified build configuration
      static boolean permissionGrantedForModification​(SVcsModification modification, java.lang.String permissionName)
      Returns true if currently authenticated user has permission with specified name granted for specified VCS modification
      static boolean permissionGrantedForProject​(SProject project, java.lang.String permissionName)
      Returns true if currently authenticated user has permission with specified name granted for specified project
      static boolean permissionGrantedForProjectWithId​(java.lang.String projectId, java.lang.String permissionName)
      Returns true if specified permission granted for the project with specified id
      static boolean permissionGrantedGlobally​(java.lang.String permissionName)
      Returns true if currently authenticated user has specified permission granted for all projects
      static boolean userManagementAvailable()
      Returns true if user management UI is available to current authority holder
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AuthorizationFunctions

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

      • permissionGrantedGlobally

        public static boolean permissionGrantedGlobally​(@NotNull
                                                        java.lang.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
                                                          java.lang.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
                                                                java.lang.String projectId,
                                                                @NotNull
                                                                java.lang.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
                                                             java.lang.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
                                                                java.lang.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
                                                            java.lang.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
                                                        java.lang.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
                                                               java.lang.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