Package jetbrains.buildServer.users.impl
Class BaseUser
- java.lang.Object
-
- jetbrains.buildServer.users.impl.BaseUser
-
- All Implemented Interfaces:
Loggable
,NotificationRulesHolder
,AuthorityHolder
,RolesHolder
,UserEx
,UserRolesInit
,PropertyHolder
,SPropertyHolder
,SUser
,User
- Direct Known Subclasses:
UserImpl
public abstract class BaseUser extends Object implements UserEx, UserRolesInit, AuthorityHolder
Base class delegating authority holder methods to actual authority holder which should be returned by this class inheritors.
-
-
Field Summary
-
Fields inherited from interface jetbrains.buildServer.users.SUser
GUEST_USER_ID, SUPER_USER_ID, UKNOWN_USER_ID
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
addNewRule(String notifierType, NotificationRule rule)
Adds new rule to the rules of specified user for specified notifier type.void
addRole(RoleScope scope, Role role)
Adds role with specified scopevoid
applyOrder(String notifierType, long[] ruleIds)
Sorts the notification rules in the specified order.void
clearPermissions()
String
describe(boolean verbose)
Collection<Long>
findConflictingRules(String notifierType, WatchedBuilds watch)
Searches for rules which intersect with specified watched builds.NotificationRule
findRuleById(long ruleId)
Searches for a rule with specified id.protected Collection<Permission>
getAdditionalGlobalPermissions()
Collection<RolesHolder>
getAllParentHolders()
Returns all parent holders including transitive onesList<NotificationRulesHolder>
getAllParentRulesHolders()
Returns all (direct and inherited) parent notification rules holdersList<UserGroup>
getAllUserGroups()
Returns the list of all user groups that include this user, directly or through intermediate subgroups.protected List<UserGroup>
getAllUserGroupsUnfiltered()
User
getAssociatedUser()
Returns the user object associated with the principal.String
getBlockState(String blockType)
Retrieves state of a block stored for this userPermissions
getGlobalPermissions()
Returns all granted non-project related permissions and all project-related permissions granted globallyList<NotificationRule>
getNotificationRules(String notificatorType)
Returns the notification rules for specified notifier for this holder (user or group).AuthorityHolder
getOriginalAuthorityHolder()
calculates permissions if not cached or recalculates if neededCollection<RolesHolder>
getParentHolders()
Returns direct (non transitive) parent holders.List<NotificationRulesHolder>
getParentRulesHolders()
Returns direct parent notification rules holdersPermissions
getPermissionsGrantedForAllProjects(Collection<String> projectIds)
Returns all permissions granted for all projects from the collection.Permissions
getPermissionsGrantedForAnyOfProjects(Collection<String> projectIds)
Returns union of permissions granted for projects from the collection.Permissions
getPermissionsGrantedForProject(String projectId)
Returns all permissions granted for particular project.Map<String,Permissions>
getProjectsPermissions()
Returns map of project-related permissions that were granted for a particular project.Collection<RoleEntry>
getRoles()
Returns roles with their scopesCollection<Role>
getRolesWithScope(RoleScope scope)
Returns all roles with specified scope.Collection<RoleScope>
getScopes()
Returns all scopes with assigned rolesprotected SecurityContextEx
getSecurityContext()
protected ServerResponsibility
getServerResponsibility()
List<UserGroup>
getUserGroups()
Returns the list of groups which this user belongs to.List<VcsUsernamePropertyKey>
getVcsUsernameProperties()
Returns list of VCS username properties associated with this user.boolean
hasAllPermissionsOf(AuthorityHolder authorityHolder)
Returns true if this authority holder has all permissions of another authority holder.boolean
isPermissionGrantedForAllProjects(Collection<String> projectIds, Permission permission)
Returns true if permission is granted for all projects from the given list.boolean
isPermissionGrantedForAnyOfProjects(Collection<String> projectIds, Permission permission)
Returns true if specified permission is granted for at least one project from the given collectionboolean
isPermissionGrantedForAnyProject(Permission permission)
Returns true if specified permission is granted for at least one projectboolean
isPermissionGrantedForProject(String projectId, Permission permission)
Returns true if permission is granted for a project, i.e.boolean
isPermissionGrantedGlobally(Permission permission)
Returns true if specified permission granted globally (i.e.boolean
isPseudoUser()
static boolean
isPseudoUserId(long userId)
boolean
isSystemAdministratorRoleGranted()
Returns true if this roles holder contains system administrator role granted directly or inherited via parent holders.boolean
isSystemAdministratorRoleGrantedDirectly()
Returns true if this roles holder contains system administrator role granted directly.boolean
isSystemAdministratorRoleInherited()
Returns true if one of the parents (transitively) of this roles holder contains system administrator role.void
removeRole(Role role)
Removes specified role.void
removeRole(RoleScope scope, Role role)
Removes role with specified scopevoid
removeRoles(RoleScope scope)
Removes all of the roles having the specified scope.void
removeRule(long ruleId)
Removes the rule with specified id.void
removeRule(NotificationRule rule)
Removes the rule.void
resetBlocks()
Reset cached blocksvoid
resetRoles()
Causes roles reloading from the database.<T> T
runWithRestrictor(AuthorityHolderRestrictor restrictor, SecurityContextEx.RunAsActionWithResult<T> action)
void
setBlockState(String blockType, String blockState)
Stores collapsable block state for this uservoid
setNotificationRules(String notifierType, List<NotificationRule> rules)
Sets the notification rules for specified notifier.String
toString()
void
updatePermissions()
Recalculates permissions if cached-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jetbrains.buildServer.serverSide.auth.AuthorityHolder
getAllPermissions
-
Methods inherited from interface jetbrains.buildServer.users.PropertyHolder
getBooleanProperty, getProperties, getPropertyValue
-
Methods inherited from interface jetbrains.buildServer.users.SPropertyHolder
deleteProperty, setProperties, setProperty
-
Methods inherited from interface jetbrains.buildServer.users.SUser
deleteUserProperty, getAllModifications, getBuildTypesOrder, getOrderedBuildTypes, getProjectsOrder, getVcsModifications, hideProject, hideProjects, isGuest, isHighlightRelatedDataInUI, setBuildTypesOrder, setLastLoginTimestamp, setPassword, setProjectsOrder, setUserProperties, setUserProperty, setVisibleProjects, updateUserAccount
-
Methods inherited from interface jetbrains.buildServer.users.User
getAllProjects, getDescriptiveName, getEmail, getExtendedName, getId, getLastLoginTimestamp, getName, getRealm, getUsername, getVisibleProjects
-
Methods inherited from interface jetbrains.buildServer.users.impl.UserEx
addVcsUsername, deleteAttribute, getAttribute, getAttributes, getFilteredVisibleBuildTypes, getProjectVisibilityHolder, getVcsUsernames, getVerifiedEmail, hasPassword, init, isConfiguredVisibleProjects, isHasHiddenProjects, resetBuildTypesOrder, resetCachedAttributes, resetCachedProperties, resetCachedVcsUsernames, runWithRestrictor, setAttribute, setCreationInProgress, setDefaultVcsUsernames, setEmailIsVerified, setVcsRootUsernames, setVcsUsernames, setVcsUsernames
-
-
-
-
Method Detail
-
isPermissionGrantedGlobally
public boolean isPermissionGrantedGlobally(@NotNull Permission permission)
Description copied from interface:AuthorityHolder
Returns true if specified permission granted globally (i.e. not associated with any particular object)- Specified by:
isPermissionGrantedGlobally
in interfaceAuthorityHolder
- Parameters:
permission
- permission to check- Returns:
- true or false
-
isPermissionGrantedForProject
public boolean isPermissionGrantedForProject(@NotNull String projectId, @NotNull Permission permission)
Description copied from interface:AuthorityHolder
Returns true if permission is granted for a project, i.e. the result is true if there is a project related permission granted globally or for specified project- Specified by:
isPermissionGrantedForProject
in interfaceAuthorityHolder
- Parameters:
projectId
- project internal idpermission
- permission to check- Returns:
- see above
-
isPermissionGrantedForAllProjects
public boolean isPermissionGrantedForAllProjects(@NotNull Collection<String> projectIds, @NotNull Permission permission)
Description copied from interface:AuthorityHolder
Returns true if permission is granted for all projects from the given list. Returns false if projectIds is empty.- Specified by:
isPermissionGrantedForAllProjects
in interfaceAuthorityHolder
- Parameters:
projectIds
- collection of project idspermission
- permission to check @return see above- See Also:
AuthorityHolder.isPermissionGrantedForProject(java.lang.String, jetbrains.buildServer.serverSide.auth.Permission)
-
isPermissionGrantedForAnyProject
public boolean isPermissionGrantedForAnyProject(@NotNull Permission permission)
Description copied from interface:AuthorityHolder
Returns true if specified permission is granted for at least one project- Specified by:
isPermissionGrantedForAnyProject
in interfaceAuthorityHolder
- Parameters:
permission
- permission to check- Returns:
- see above
-
isPermissionGrantedForAnyOfProjects
public boolean isPermissionGrantedForAnyOfProjects(@NotNull Collection<String> projectIds, @NotNull Permission permission)
Description copied from interface:AuthorityHolder
Returns true if specified permission is granted for at least one project from the given collection- Specified by:
isPermissionGrantedForAnyOfProjects
in interfaceAuthorityHolder
permission
- permission to check- Returns:
- see above
-
getGlobalPermissions
@NotNull public Permissions getGlobalPermissions()
Description copied from interface:AuthorityHolder
Returns all granted non-project related permissions and all project-related permissions granted globally- Specified by:
getGlobalPermissions
in interfaceAuthorityHolder
- Returns:
- see above
-
getProjectsPermissions
@NotNull public Map<String,Permissions> getProjectsPermissions()
Description copied from interface:AuthorityHolder
Returns map of project-related permissions that were granted for a particular project. Project internal id is used as the key.- Specified by:
getProjectsPermissions
in interfaceAuthorityHolder
- Returns:
- map of project permissions
-
getPermissionsGrantedForProject
@NotNull public Permissions getPermissionsGrantedForProject(@NotNull String projectId)
Description copied from interface:AuthorityHolder
Returns all permissions granted for particular project. These include permissions granted specifically for the specified project and granted global project-related permissions (i.e. permissions supporting project associationPermission.isProjectAssociationSupported()
).- Specified by:
getPermissionsGrantedForProject
in interfaceAuthorityHolder
- Parameters:
projectId
- project internal id- Returns:
- all granted permissions for particular project
-
getPermissionsGrantedForAllProjects
@NotNull public Permissions getPermissionsGrantedForAllProjects(@NotNull Collection<String> projectIds)
Description copied from interface:AuthorityHolder
Returns all permissions granted for all projects from the collection. These include permissions granted specifically for the specified projects and granted global project-related permissions (i.e. permissions supporting project associationPermission.isProjectAssociationSupported()
).- Specified by:
getPermissionsGrantedForAllProjects
in interfaceAuthorityHolder
- Parameters:
projectIds
- collection of project internal ids- Returns:
- all granted permissions for all projects
-
getPermissionsGrantedForAnyOfProjects
@NotNull public Permissions getPermissionsGrantedForAnyOfProjects(@NotNull Collection<String> projectIds)
Description copied from interface:AuthorityHolder
Returns union of permissions granted for projects from the collection. These include permissions granted specifically for the specified projects and granted global project-related permissions (i.e. permissions supporting project associationPermission.isProjectAssociationSupported()
).- Specified by:
getPermissionsGrantedForAnyOfProjects
in interfaceAuthorityHolder
- Parameters:
projectIds
- collection of project internal ids- Returns:
- all granted permissions for all projects
-
getAssociatedUser
@Nullable public User getAssociatedUser()
Description copied from interface:AuthorityHolder
Returns the user object associated with the principal.- Specified by:
getAssociatedUser
in interfaceAuthorityHolder
- Returns:
- may be null if the authority holder is not a user.
-
hasAllPermissionsOf
public boolean hasAllPermissionsOf(@NotNull AuthorityHolder authorityHolder)
Description copied from interface:AuthorityHolder
Returns true if this authority holder has all permissions of another authority holder.- Specified by:
hasAllPermissionsOf
in interfaceAuthorityHolder
- Returns:
- see above
-
getRolesWithScope
@NotNull public Collection<Role> getRolesWithScope(@NotNull RoleScope scope)
Description copied from interface:RolesHolder
Returns all roles with specified scope.- Specified by:
getRolesWithScope
in interfaceRolesHolder
- Parameters:
scope
- roles scope- Returns:
- all roles with specified scope.
-
getScopes
public Collection<RoleScope> getScopes()
Description copied from interface:RolesHolder
Returns all scopes with assigned roles- Specified by:
getScopes
in interfaceRolesHolder
- Returns:
- all scopes with assigned roles
-
getRoles
@NotNull public Collection<RoleEntry> getRoles()
Description copied from interface:RolesHolder
Returns roles with their scopes- Specified by:
getRoles
in interfaceRolesHolder
- Returns:
- roles with their scopes
-
resetRoles
public void resetRoles()
Description copied from interface:UserRolesInit
Causes roles reloading from the database.- Specified by:
resetRoles
in interfaceUserRolesInit
-
addRole
public void addRole(@NotNull RoleScope scope, @NotNull Role role) throws UserNotFoundException
Description copied from interface:RolesHolder
Adds role with specified scope- Specified by:
addRole
in interfaceRolesHolder
- Parameters:
scope
- scope of the rolerole
- role- Throws:
UserNotFoundException
-
removeRole
public void removeRole(@NotNull RoleScope scope, @NotNull Role role) throws UserNotFoundException
Description copied from interface:RolesHolder
Removes role with specified scope- Specified by:
removeRole
in interfaceRolesHolder
- Parameters:
scope
- scope of the rolerole
- role- Throws:
UserNotFoundException
-
removeRoles
public void removeRoles(@NotNull RoleScope scope) throws UserNotFoundException
Description copied from interface:RolesHolder
Removes all of the roles having the specified scope.- Specified by:
removeRoles
in interfaceRolesHolder
- Parameters:
scope
- scope of the role- Throws:
UserNotFoundException
-
removeRole
public void removeRole(@NotNull Role role)
Description copied from interface:RolesHolder
Removes specified role. If the role is associated with several scopes all of these roles will be removed.- Specified by:
removeRole
in interfaceRolesHolder
- Parameters:
role
- role to remove
-
isSystemAdministratorRoleGranted
public boolean isSystemAdministratorRoleGranted()
Description copied from interface:RolesHolder
Returns true if this roles holder contains system administrator role granted directly or inherited via parent holders. Same as:isSystemAdministratorRoleGrantedDirectly() || isSystemAdministratorRoleInherited()
- Specified by:
isSystemAdministratorRoleGranted
in interfaceRolesHolder
- Returns:
- see above.
-
isSystemAdministratorRoleGrantedDirectly
public boolean isSystemAdministratorRoleGrantedDirectly()
Description copied from interface:RolesHolder
Returns true if this roles holder contains system administrator role granted directly.- Specified by:
isSystemAdministratorRoleGrantedDirectly
in interfaceRolesHolder
- Returns:
- see above.
-
isSystemAdministratorRoleInherited
public boolean isSystemAdministratorRoleInherited()
Description copied from interface:RolesHolder
Returns true if one of the parents (transitively) of this roles holder contains system administrator role.- Specified by:
isSystemAdministratorRoleInherited
in interfaceRolesHolder
- Returns:
- see above
-
getParentHolders
@NotNull public Collection<RolesHolder> getParentHolders()
Description copied from interface:RolesHolder
Returns direct (non transitive) parent holders.- Specified by:
getParentHolders
in interfaceRolesHolder
- Returns:
- parent holders
-
getAllParentHolders
@NotNull public Collection<RolesHolder> getAllParentHolders()
Description copied from interface:RolesHolder
Returns all parent holders including transitive ones- Specified by:
getAllParentHolders
in interfaceRolesHolder
- Returns:
- all parent holders
-
getOriginalAuthorityHolder
@NotNull public AuthorityHolder getOriginalAuthorityHolder()
calculates permissions if not cached or recalculates if needed- Specified by:
getOriginalAuthorityHolder
in interfaceUserEx
-
updatePermissions
public void updatePermissions()
Recalculates permissions if cached- Specified by:
updatePermissions
in interfaceUserEx
-
clearPermissions
public void clearPermissions()
-
isPseudoUser
public boolean isPseudoUser()
- Specified by:
isPseudoUser
in interfaceUserEx
-
isPseudoUserId
public static boolean isPseudoUserId(long userId)
-
getAdditionalGlobalPermissions
protected Collection<Permission> getAdditionalGlobalPermissions()
-
getSecurityContext
@NotNull protected SecurityContextEx getSecurityContext()
-
getServerResponsibility
@NotNull protected ServerResponsibility getServerResponsibility()
-
setBlockState
public void setBlockState(String blockType, String blockState)
Description copied from interface:SUser
Stores collapsable block state for this user- Specified by:
setBlockState
in interfaceSUser
- Parameters:
blockType
- type of blockblockState
- state
-
getBlockState
@Nullable public String getBlockState(String blockType)
Description copied from interface:SUser
Retrieves state of a block stored for this user- Specified by:
getBlockState
in interfaceSUser
- Parameters:
blockType
- type of block- Returns:
- block state or null
-
resetBlocks
public void resetBlocks()
Description copied from interface:UserEx
Reset cached blocks- Specified by:
resetBlocks
in interfaceUserEx
-
getUserGroups
@NotNull public List<UserGroup> getUserGroups()
Description copied from interface:SUser
Returns the list of groups which this user belongs to. Only groups which contain this user directly are considered. If you need all user groups useSUser.getAllUserGroups()
.No specific order of the groups is guaranteed.
- Specified by:
getUserGroups
in interfaceSUser
- Returns:
- list of groups containing this user
- See Also:
SUser.getAllUserGroups()
-
getAllUserGroups
@NotNull public List<UserGroup> getAllUserGroups()
Description copied from interface:SUser
Returns the list of all user groups that include this user, directly or through intermediate subgroups.No specific order of the groups is guaranteed.
- Specified by:
getAllUserGroups
in interfaceSUser
- Returns:
- list of all groups containing this user
- See Also:
SUser.getUserGroups()
-
getVcsUsernameProperties
@NotNull public List<VcsUsernamePropertyKey> getVcsUsernameProperties()
Description copied from interface:SUser
Returns list of VCS username properties associated with this user. VCS username property defines username of this user in a concrete VCS root or VCS repository type (Subversion, Perforce, etc).- Specified by:
getVcsUsernameProperties
in interfaceSUser
- Returns:
- list of VCS usernames
-
getNotificationRules
@NotNull public List<NotificationRule> getNotificationRules(@NotNull String notificatorType)
Description copied from interface:NotificationRulesHolder
Returns the notification rules for specified notifier for this holder (user or group).- Specified by:
getNotificationRules
in interfaceNotificationRulesHolder
- Parameters:
notificatorType
- type of the notifier- Returns:
- list of notification rules for specified notifier
-
setNotificationRules
public void setNotificationRules(@NotNull String notifierType, @NotNull List<NotificationRule> rules)
Description copied from interface:NotificationRulesHolder
Sets the notification rules for specified notifier.- Specified by:
setNotificationRules
in interfaceNotificationRulesHolder
- Parameters:
notifierType
- type of the notifierrules
- rules to save
-
removeRule
public void removeRule(long ruleId)
Description copied from interface:NotificationRulesHolder
Removes the rule with specified id.- Specified by:
removeRule
in interfaceNotificationRulesHolder
- Parameters:
ruleId
- id of the rule
-
removeRule
public void removeRule(@NotNull NotificationRule rule)
Description copied from interface:NotificationRulesHolder
Removes the rule. ThrowsNotificationRuleChangedException
if notification rule with same id was already changed. Does nothing if notification rule doesn't exist.- Specified by:
removeRule
in interfaceNotificationRulesHolder
- Parameters:
rule
- rule to remove
-
applyOrder
public void applyOrder(@NotNull String notifierType, @NotNull long[] ruleIds)
Description copied from interface:NotificationRulesHolder
Sorts the notification rules in the specified order.- Specified by:
applyOrder
in interfaceNotificationRulesHolder
- Parameters:
notifierType
- type of the notifierruleIds
- ids of the rules in the required order
-
addNewRule
public long addNewRule(@NotNull String notifierType, @NotNull NotificationRule rule) throws DuplicateNotificationRuleException
Description copied from interface:NotificationRulesHolder
Adds new rule to the rules of specified user for specified notifier type.- Specified by:
addNewRule
in interfaceNotificationRulesHolder
- Parameters:
notifierType
- type of the notifierrule
- rule to add- Returns:
- the id of the newly created rule
- Throws:
DuplicateNotificationRuleException
- if similar rule already exists
-
findConflictingRules
public Collection<Long> findConflictingRules(@NotNull String notifierType, @NotNull WatchedBuilds watch)
Description copied from interface:NotificationRulesHolder
Searches for rules which intersect with specified watched builds.- Specified by:
findConflictingRules
in interfaceNotificationRulesHolder
- Parameters:
notifierType
- type of the notifierwatch
- watched builds- Returns:
- list of conflicting rules ids
-
findRuleById
public NotificationRule findRuleById(long ruleId)
Description copied from interface:NotificationRulesHolder
Searches for a rule with specified id.- Specified by:
findRuleById
in interfaceNotificationRulesHolder
- Parameters:
ruleId
- id of the rule- Returns:
- a found rule, or null
-
getParentRulesHolders
@NotNull public List<NotificationRulesHolder> getParentRulesHolders()
Description copied from interface:NotificationRulesHolder
Returns direct parent notification rules holders- Specified by:
getParentRulesHolders
in interfaceNotificationRulesHolder
- Returns:
- direct parent notification rules holders
-
getAllParentRulesHolders
@NotNull public List<NotificationRulesHolder> getAllParentRulesHolders()
Description copied from interface:NotificationRulesHolder
Returns all (direct and inherited) parent notification rules holders- Specified by:
getAllParentRulesHolders
in interfaceNotificationRulesHolder
- Returns:
- all (direct and inherited) parent notification rules holders
-
describe
@NotNull public String describe(boolean verbose)
-
runWithRestrictor
public <T> T runWithRestrictor(@NotNull AuthorityHolderRestrictor restrictor, @NotNull SecurityContextEx.RunAsActionWithResult<T> action)
- Specified by:
runWithRestrictor
in interfaceUserEx
-
-