jetbrains.buildServer.serverSide.auth
Class AuthUtil

java.lang.Object
  extended by jetbrains.buildServer.serverSide.auth.AuthUtil

public class AuthUtil
extends java.lang.Object


Field Summary
static Permission[] ADMIN_ZONE_PERMISSIONS
           
 
Method Summary
static boolean adminSpaceAvailable(AuthorityHolder authorityHolder)
          Returns true if authority holder has at least one permission allowing him to access administration space
static boolean canViewUserProfile(AuthorityHolder authorityHolder, SUser user)
          Checks whether authority holder can access user profile data (email and properties).
static boolean groupManagementAvailable(AuthorityHolder authorityHolder)
          Returns true if group management interface is available
static boolean hasFileContentAccess(AuthorityHolder authorityHolder, 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
static boolean hasGlobalPermission(AuthorityHolder authorityHolder, Permission permission)
          Returns true if specified authority holder has specified global permission
static boolean hasPermissionToEditVcsRoot(AuthorityHolder authHolder, SVcsRoot vcsRoot)
          Checks whether specified authority holder can edit VCS root
static boolean hasPermissionToManageAgentPoolsWithProject(AuthorityHolder authHolder, java.lang.String projectId)
          Checks whether specified authority holder can manage agent pool-project association for the specified project.
static boolean hasPermissionToManageAgentPoolsWithProjects(AuthorityHolder authHolder, java.util.Collection<java.lang.String> projects)
          Checks whether specified authority holder can manage agent pools the given projects are associated with.
static boolean hasPermissionToManageAllAgentPoolProjectAssociations(AuthorityHolder authHolder)
          Checks whether specified authority holder can manage agent pool-project associations for all pools.
static boolean hasPermissionToManageAllProjects(AuthorityHolder authHolder)
          Checks whether specified authority holder can manage all projects.
static boolean hasPermissionToManageProject(AuthorityHolder authHolder, java.lang.String projectId)
          Checks whether specified authority holder can manage the given project.
static boolean hasPermissionToManageProjects(AuthorityHolder authHolder, java.util.Collection<java.lang.String> projects)
          Checks whether specified authority holder can manage all the given projects.
static boolean hasPermissionToRemoveBuild(AuthorityHolder authorityHolder, BuildPromotion promotion)
          Returns true if authority holder has permissions to remove build associated with specified buildPromotion
static boolean hasPermissionToStartBuild(AuthorityHolder authorityHolder, BuildType buildType, BuildAgent agent)
          Returns true if authority holder has permissions to start build in specified configuration
static boolean hasPermissionToStopBuild(AuthorityHolder authorityHolder, BuildPromotion promotion)
          Returns true if authority holder has permissions to stop build associated with the specified promotion
static boolean hasReadAccessTo(AuthorityHolder authorityHolder, Build build)
          Returns true if authority holder has read access to build project
static boolean hasReadAccessTo(AuthorityHolder authorityHolder, BuildTypeDescriptor buildType)
          Returns true if authority holder has read access to build configuration project
static boolean hasReadAccessTo(AuthorityHolder authorityHolder, java.lang.String projectId)
          Returns true if authority holder has read access to a project with specified id
static boolean hasReadAccessTo(AuthorityHolder authorityHolder, 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)
static boolean hasReadAccessTo(AuthorityHolder authorityHolder, SVcsRoot vcsRoot)
          Returns true if authority holder has read access to the specified VCS root
static boolean isSystemAdmin(AuthorityHolder authHolder)
          Returns whether a specified authHolder is a system admin (has system admin role).
static boolean userManagementAvailable(AuthorityHolder authorityHolder)
          Returns true if user & group management interfaces are available
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADMIN_ZONE_PERMISSIONS

public static final Permission[] ADMIN_ZONE_PERMISSIONS
Method Detail

hasReadAccessTo

public static boolean hasReadAccessTo(@NotNull
                                      AuthorityHolder authorityHolder,
                                      @NotNull
                                      java.lang.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

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
                                      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

hasPermissionToStartBuild

public static boolean hasPermissionToStartBuild(@NotNull
                                                AuthorityHolder authorityHolder,
                                                @NotNull
                                                BuildType buildType,
                                                @Nullable
                                                BuildAgent agent)
Returns true if authority holder has permissions to start build in specified configuration

Parameters:
authorityHolder - authority holder
buildType - build configuration
agent - agent
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
                                                   java.lang.String projectId)
Checks whether specified authority holder can manage the given project.

Parameters:
authHolder - authority holder.
projectId - project identifier.
Returns:
true if he/she can manage the project.
Since:
7.0

hasPermissionToManageProjects

public static boolean hasPermissionToManageProjects(@NotNull
                                                    AuthorityHolder authHolder,
                                                    @NotNull
                                                    java.util.Collection<java.lang.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

hasPermissionToManageAgentPoolsWithProject

public static boolean hasPermissionToManageAgentPoolsWithProject(@NotNull
                                                                 AuthorityHolder authHolder,
                                                                 @NotNull
                                                                 java.lang.String projectId)
Checks whether specified authority holder can manage agent pool-project association for the specified project.

Parameters:
authHolder - authority holder.
projects - identifiers of projects to check.
Returns:
can manage.
Since:
7.0
See Also:
hasPermissionToManageAgentPoolsWithProjects(jetbrains.buildServer.serverSide.auth.AuthorityHolder, java.util.Collection), hasPermissionToManageAllAgentPoolProjectAssociations(jetbrains.buildServer.serverSide.auth.AuthorityHolder)

hasPermissionToManageAgentPoolsWithProjects

public static boolean hasPermissionToManageAgentPoolsWithProjects(@NotNull
                                                                  AuthorityHolder authHolder,
                                                                  @NotNull
                                                                  java.util.Collection<java.lang.String> projects)
Checks whether specified authority holder can manage agent pools the given projects are associated with. Really, it checks that the user has MANAGE_AGENT_POOLS_FOR_PROJECT for each given project or globally, or MANAGE_AGENT_POOLS globally

Parameters:
authHolder - authority holder.
projects - identifiers of projects to check.
Returns:
can manage.
Since:
7.0
See Also:
hasPermissionToManageAgentPoolsWithProject(jetbrains.buildServer.serverSide.auth.AuthorityHolder, java.lang.String), hasPermissionToManageAllAgentPoolProjectAssociations(jetbrains.buildServer.serverSide.auth.AuthorityHolder)

hasPermissionToManageAllAgentPoolProjectAssociations

public static boolean hasPermissionToManageAllAgentPoolProjectAssociations(@NotNull
                                                                           AuthorityHolder authHolder)
Checks whether specified authority holder can manage agent pool-project associations for all pools.

Parameters:
authHolder - authority holder.
projects - identifiers of projects to check.
Returns:
can manage.
Since:
7.0
See Also:
hasPermissionToManageAgentPoolsWithProject(jetbrains.buildServer.serverSide.auth.AuthorityHolder, java.lang.String), hasPermissionToManageAgentPoolsWithProjects(jetbrains.buildServer.serverSide.auth.AuthorityHolder, java.util.Collection)

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

isSystemAdmin

public static boolean isSystemAdmin(@NotNull
                                    AuthorityHolder authHolder)
Returns whether a specified authHolder is a system admin (has system admin role).

Parameters:
authHolder - authority holder
Returns:
true iff the authority holder is a system admin