Class AuthUtil


  • public class AuthUtil
    extends Object
    • Field Detail

      • TEAMCITY_AGENTS_PER_PROJECT_USER_ACCESS_ENABLED

        public static final String TEAMCITY_AGENTS_PER_PROJECT_USER_ACCESS_ENABLED
        See Also:
        Constant Field Values
      • ADMIN_ZONE_PERMISSIONS

        public static final Permission[] ADMIN_ZONE_PERMISSIONS
    • Method Detail

      • hasReadAccessTo

        public static boolean hasReadAccessTo​(@NotNull
                                              AuthorityHolder authorityHolder,
                                              @NotNull
                                              String projectId)
        Returns true if authority holder has read access to a project with specified id
        Parameters:
        authorityHolder - authority holder
        projectId - project id
        Returns:
        true if authority holder has read access to project
      • hasReadAccessToAnyOfProjects

        public static boolean hasReadAccessToAnyOfProjects​(@NotNull
                                                           AuthorityHolder authorityHolder,
                                                           @NotNull
                                                           Collection<String> projectIds)
        Returns true if authority holder has read access to a project with specified id
        Parameters:
        authorityHolder - authority holder
        projectIds - project ids
        Returns:
        true if authority holder has read access to project
      • hasReadAccessTo

        public static boolean hasReadAccessTo​(@NotNull
                                              AuthorityHolder authorityHolder,
                                              @NotNull
                                              BuildTypeDescriptor buildType)
        Returns true if authority holder has read access to build configuration project
        Parameters:
        authorityHolder - authority holder
        buildType - build configuration
        Returns:
        true if authority holder has read access to build configuration project
      • hasReadAccessTo

        public static boolean hasReadAccessTo​(@NotNull
                                              AuthorityHolder authorityHolder,
                                              @NotNull
                                              Build build)
        Returns true if authority holder has read access to build project
        Parameters:
        authorityHolder - authority holder
        build - build
        Returns:
        true if authority holder has read access to build project
      • hasReadAccessTo

        public static boolean hasReadAccessTo​(@NotNull
                                              AuthorityHolder authorityHolder,
                                              @NotNull
                                              VcsRootInstance vcsRoot)
        Returns true if authority holder has read access to the specified VCS root
        Parameters:
        authorityHolder - authority holder
        vcsRoot - vcs root
        Returns:
        true if authority holder has read access to the specified VCS root
      • hasReadAccessTo

        public static boolean hasReadAccessTo​(@NotNull
                                              AuthorityHolder authorityHolder,
                                              @NotNull
                                              SVcsRoot vcsRoot)
        Returns true if authority holder has read access to the specified VCS root
        Parameters:
        authorityHolder - authority holder
        vcsRoot - vcs root
        Returns:
        true if authority holder has read access to the specified VCS root
      • hasReadAccessTo

        public static boolean hasReadAccessTo​(@NotNull
                                              AuthorityHolder authorityHolder,
                                              @NotNull
                                              SVcsModification modification)
        Returns true if authority holder has read access to the specified VCS modification (has read access to at least one build configuration where this modification appeared)
        Parameters:
        authorityHolder - authority holder
        modification - VCS modification
        Returns:
        see above
      • hasFileContentAccess

        public static boolean hasFileContentAccess​(@NotNull
                                                   AuthorityHolder authorityHolder,
                                                   @NotNull
                                                   SVcsModification modification)
        Returns true if authority holder has view file content access to any build configuration related to specified modification, or any build configuration related to any duplicate of specified modification
        Parameters:
        authorityHolder - authority holder
        modification - VCS modification
        Returns:
        see above
      • adminSpaceAvailable

        public static boolean adminSpaceAvailable​(@NotNull
                                                  AuthorityHolder authorityHolder)
        Returns true if authority holder has at least one permission allowing him to access administration space
        Parameters:
        authorityHolder - authority holder
        Returns:
        see above
      • hasGlobalPermission

        public static boolean hasGlobalPermission​(@NotNull
                                                  AuthorityHolder authorityHolder,
                                                  @NotNull
                                                  Permission permission)
        Returns true if specified authority holder has specified global permission
        Parameters:
        authorityHolder - authority holder
        permission - permission
        Returns:
        see above
      • hasProjectPermission

        public static boolean hasProjectPermission​(@NotNull
                                                   AuthorityHolder authorityHolder,
                                                   @NotNull
                                                   String projectId,
                                                   @NotNull
                                                   Permission permission)
        Returns true if specified authority holder has specified permission in specified project
        Parameters:
        authorityHolder - authority holder
        projectId - project internal id
        permission - permission
        Returns:
        see above
        Since:
        2017.1
      • hasGlobalOrPoolProjectsPermission

        public static boolean hasGlobalOrPoolProjectsPermission​(@NotNull
                                                                AuthorityHolder authorityHolder,
                                                                @NotNull
                                                                AgentPool agentPool,
                                                                @NotNull
                                                                Permission globalPermission,
                                                                @NotNull
                                                                Permission projectPermission)
        returns true if specified authority holder has specific permission globally or for supplied all projects.
        Parameters:
        authorityHolder - authority holder
        agentPool - agent pool
        globalPermission - global permission
        projectPermission - corresponding project-level permission
        Returns:
        see above
      • hasPermissionToStopBuild

        public static boolean hasPermissionToStopBuild​(@NotNull
                                                       AuthorityHolder authorityHolder,
                                                       @NotNull
                                                       BuildPromotion promotion)
        Returns true if authority holder has permissions to stop build associated with the specified promotion
        Parameters:
        authorityHolder - authority holder
        promotion - promotion associated with build
        Returns:
        see above
      • hasPermissionToRemoveBuild

        public static boolean hasPermissionToRemoveBuild​(@NotNull
                                                         AuthorityHolder authorityHolder,
                                                         @NotNull
                                                         BuildPromotion promotion)
        Returns true if authority holder has permissions to remove build associated with specified buildPromotion
        Parameters:
        authorityHolder - authority holder
        promotion - promotion associated with build
        Returns:
        see above
      • userManagementAvailable

        public static boolean userManagementAvailable​(@NotNull
                                                      AuthorityHolder authorityHolder)
        Returns true if user & group management interfaces are available
        Parameters:
        authorityHolder - authority holder
        Returns:
        see above
      • groupManagementAvailable

        public static boolean groupManagementAvailable​(@NotNull
                                                       AuthorityHolder authorityHolder)
        Returns true if group management interface is available
        Parameters:
        authorityHolder - authority holder
        Returns:
        true if group management interface is available
      • hasPermissionToEditVcsRoot

        public static boolean hasPermissionToEditVcsRoot​(@NotNull
                                                         AuthorityHolder authHolder,
                                                         @NotNull
                                                         SVcsRoot vcsRoot)
        Checks whether specified authority holder can edit VCS root
      • hasPermissionToManageProject

        public static boolean hasPermissionToManageProject​(@NotNull
                                                           AuthorityHolder authHolder,
                                                           @NotNull
                                                           String projectInternalId)
        Checks whether specified authority holder can manage the given project.
        Parameters:
        authHolder - authority holder.
        projectInternalId - project internal id
        Returns:
        true if he/she can manage the project.
        Since:
        7.0
      • hasPermissionToManageProjects

        public static boolean hasPermissionToManageProjects​(@NotNull
                                                            AuthorityHolder authHolder,
                                                            @NotNull
                                                            Collection<String> projects)
        Checks whether specified authority holder can manage all the given projects.
        Parameters:
        authHolder - authority holder.
        projects - identifiers of projects to check.
        Returns:
        true if he/she can manage each project in the collection; false if he/she cannot manage at least one given project; if collection is empty the result is whether he/she can manage all projects in the system.
        Since:
        7.0
      • hasPermissionToViewAgentDetailsAccessibleForProjects

        public static boolean hasPermissionToViewAgentDetailsAccessibleForProjects​(@NotNull
                                                                                   AuthorityHolder authorityHolder,
                                                                                   @NotNull
                                                                                   Collection<String> projectIds)
        Checks whether specified authority holder can view details of agents from pools the given projects are associated with.
        Parameters:
        authorityHolder - authority holder.
        projectIds - identifiers of projects to check.
        Returns:
        can view.
        Since:
        2018.1
      • hasPermissionToViewAgentPool

        public static boolean hasPermissionToViewAgentPool​(@NotNull
                                                           AuthorityHolder authHolder,
                                                           @NotNull
                                                           AgentPool agentPool)
        Checks whether specified authority holder can view agents placed in the given pool.
        Parameters:
        authHolder - authority holder.
        agentPool - pool to check.
        Returns:
        can view agents.
        Since:
        2018.1
      • hasGlobalPermissionToViewAllAgentPools

        public static boolean hasGlobalPermissionToViewAllAgentPools​(@NotNull
                                                                     AuthorityHolder authHolder)
        Returns true if the current authority holder has some global permissions which allow to view all agent pools
        Parameters:
        authHolder - authority holder
        Returns:
        see above
        Since:
        2024.03
      • hasPermissionToViewAgentDetailsInPool

        public static boolean hasPermissionToViewAgentDetailsInPool​(@NotNull
                                                                    AuthorityHolder authorityHolder,
                                                                    @NotNull
                                                                    AgentPool agentPool)
        Checks whether specified authority holder can view details of agent placed in the given pool.
        Parameters:
        authorityHolder - authority holder.
        agentPool - pool to check.
        Returns:
        can view agent details.
        Since:
        2018.1
      • hasPermissionToAuthorizeAgentsInPool

        public static boolean hasPermissionToAuthorizeAgentsInPool​(@NotNull
                                                                   AuthorityHolder authorityHolder,
                                                                   @NotNull
                                                                   AgentPool agentPool)
        Checks whether specified authority holder can authorize or unauthorize agents in the given pool.
        Parameters:
        authorityHolder - authority holder.
        agentPool - pool to check.
        Returns:
        can authorize/unauthorize agents.
        Since:
        2021.2
      • hasPermissionToEnableAgentsInPool

        public static boolean hasPermissionToEnableAgentsInPool​(@NotNull
                                                                AuthorityHolder authorityHolder,
                                                                @NotNull
                                                                AgentPool agentPool)
        Checks whether specified authority holder can enable or disable agents in the given pool.
        Parameters:
        authorityHolder - authority holder.
        agentPool - pool to check.
        Returns:
        can enable/disable agents.
        Since:
        2021.2
      • hasPermissionToManageAllProjects

        public static boolean hasPermissionToManageAllProjects​(@NotNull
                                                               AuthorityHolder authHolder)
        Checks whether specified authority holder can manage all projects.
        Parameters:
        authHolder - authority holder.
        Returns:
        true if he/she can manage all projects.
        Since:
        7.0
      • canViewUserProfile

        public static boolean canViewUserProfile​(@NotNull
                                                 AuthorityHolder authorityHolder,
                                                 @NotNull
                                                 SUser user)
        Checks whether authority holder can access user profile data (email and properties).
        Parameters:
        authorityHolder - authority holder
        user - user
        Returns:
        true if access is allowed
        Since:
        7.0
      • canAdministerAgents

        public static boolean canAdministerAgents​(@NotNull
                                                  AuthorityHolder authorityHolder)
        Returns true if authority holder can administer at least one agent
        Parameters:
        authorityHolder - authority holder
        Returns:
        see above
        Since:
        2017.1
      • canAdministerAgent

        public static boolean canAdministerAgent​(@NotNull
                                                 AuthorityHolder authorityHolder,
                                                 @NotNull
                                                 SBuildAgent agent)
        Returns true if authority holder can administer the specified agent
        Parameters:
        authorityHolder - authority holder
        agent - agent
        Returns:
        see above
        Since:
        2017.1
      • canViewAgentDetails

        public static boolean canViewAgentDetails​(@NotNull
                                                  AuthorityHolder authorityHolder,
                                                  @NotNull
                                                  SBuildAgent agent)