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 longaddNewRule(String notifierType, NotificationRule rule)Adds new rule to the rules of specified user for specified notifier type.voidaddRole(RoleScope scope, Role role)Adds role with specified scopevoidapplyOrder(String notifierType, long[] ruleIds)Sorts the notification rules in the specified order.voidclearPermissions()Stringdescribe(boolean verbose)Collection<Long>findConflictingRules(String notifierType, WatchedBuilds watch)Searches for rules which intersect with specified watched builds.NotificationRulefindRuleById(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()UsergetAssociatedUser()Returns the user object associated with the principal.StringgetBlockState(String blockType)Retrieves state of a block stored for this userPermissionsgetGlobalPermissions()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).AuthorityHoldergetOriginalAuthorityHolder()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 holdersPermissionsgetPermissionsGrantedForAllProjects(Collection<String> projectIds)Returns all permissions granted for all projects from the collection.PermissionsgetPermissionsGrantedForAnyOfProjects(Collection<String> projectIds)Returns union of permissions granted for projects from the collection.PermissionsgetPermissionsGrantedForProject(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 SecurityContextExgetSecurityContext()protected ServerResponsibilitygetServerResponsibility()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.booleanhasAllPermissionsOf(AuthorityHolder authorityHolder)Returns true if this authority holder has all permissions of another authority holder.booleanisPermissionGrantedForAllProjects(Collection<String> projectIds, Permission permission)Returns true if permission is granted for all projects from the given list.booleanisPermissionGrantedForAnyOfProjects(Collection<String> projectIds, Permission permission)Returns true if specified permission is granted for at least one project from the given collectionbooleanisPermissionGrantedForAnyProject(Permission permission)Returns true if specified permission is granted for at least one projectbooleanisPermissionGrantedForProject(String projectId, Permission permission)Returns true if permission is granted for a project, i.e.booleanisPermissionGrantedGlobally(Permission permission)Returns true if specified permission granted globally (i.e.booleanisPseudoUser()static booleanisPseudoUserId(long userId)booleanisSystemAdministratorRoleGranted()Returns true if this roles holder contains system administrator role granted directly or inherited via parent holders.booleanisSystemAdministratorRoleGrantedDirectly()Returns true if this roles holder contains system administrator role granted directly.booleanisSystemAdministratorRoleInherited()Returns true if one of the parents (transitively) of this roles holder contains system administrator role.voidremoveRole(Role role)Removes specified role.voidremoveRole(RoleScope scope, Role role)Removes role with specified scopevoidremoveRoles(RoleScope scope)Removes all of the roles having the specified scope.voidremoveRule(long ruleId)Removes the rule with specified id.voidremoveRule(NotificationRule rule)Removes the rule.voidresetBlocks()Reset cached blocksvoidresetRoles()Causes roles reloading from the database.<T> TrunWithRestrictor(AuthorityHolderRestrictor restrictor, SecurityContextEx.RunAsActionWithResult<T> action)voidsetBlockState(String blockType, String blockState)Stores collapsable block state for this uservoidsetNotificationRules(String notifierType, List<NotificationRule> rules)Sets the notification rules for specified notifier.StringtoString()voidupdatePermissions()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:AuthorityHolderReturns true if specified permission granted globally (i.e. not associated with any particular object)- Specified by:
isPermissionGrantedGloballyin interfaceAuthorityHolder- Parameters:
permission- permission to check- Returns:
- true or false
-
isPermissionGrantedForProject
public boolean isPermissionGrantedForProject(@NotNull String projectId, @NotNull Permission permission)Description copied from interface:AuthorityHolderReturns 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:
isPermissionGrantedForProjectin 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:AuthorityHolderReturns true if permission is granted for all projects from the given list. Returns false if projectIds is empty.- Specified by:
isPermissionGrantedForAllProjectsin 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:AuthorityHolderReturns true if specified permission is granted for at least one project- Specified by:
isPermissionGrantedForAnyProjectin interfaceAuthorityHolder- Parameters:
permission- permission to check- Returns:
- see above
-
isPermissionGrantedForAnyOfProjects
public boolean isPermissionGrantedForAnyOfProjects(@NotNull Collection<String> projectIds, @NotNull Permission permission)Description copied from interface:AuthorityHolderReturns true if specified permission is granted for at least one project from the given collection- Specified by:
isPermissionGrantedForAnyOfProjectsin interfaceAuthorityHolderpermission- permission to check- Returns:
- see above
-
getGlobalPermissions
@NotNull public Permissions getGlobalPermissions()
Description copied from interface:AuthorityHolderReturns all granted non-project related permissions and all project-related permissions granted globally- Specified by:
getGlobalPermissionsin interfaceAuthorityHolder- Returns:
- see above
-
getProjectsPermissions
@NotNull public Map<String,Permissions> getProjectsPermissions()
Description copied from interface:AuthorityHolderReturns map of project-related permissions that were granted for a particular project. Project internal id is used as the key.- Specified by:
getProjectsPermissionsin interfaceAuthorityHolder- Returns:
- map of project permissions
-
getPermissionsGrantedForProject
@NotNull public Permissions getPermissionsGrantedForProject(@NotNull String projectId)
Description copied from interface:AuthorityHolderReturns 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:
getPermissionsGrantedForProjectin 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:AuthorityHolderReturns 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:
getPermissionsGrantedForAllProjectsin 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:AuthorityHolderReturns 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:
getPermissionsGrantedForAnyOfProjectsin interfaceAuthorityHolder- Parameters:
projectIds- collection of project internal ids- Returns:
- all granted permissions for all projects
-
getAssociatedUser
@Nullable public User getAssociatedUser()
Description copied from interface:AuthorityHolderReturns the user object associated with the principal.- Specified by:
getAssociatedUserin interfaceAuthorityHolder- Returns:
- may be null if the authority holder is not a user.
-
hasAllPermissionsOf
public boolean hasAllPermissionsOf(@NotNull AuthorityHolder authorityHolder)Description copied from interface:AuthorityHolderReturns true if this authority holder has all permissions of another authority holder.- Specified by:
hasAllPermissionsOfin interfaceAuthorityHolder- Returns:
- see above
-
getRolesWithScope
@NotNull public Collection<Role> getRolesWithScope(@NotNull RoleScope scope)
Description copied from interface:RolesHolderReturns all roles with specified scope.- Specified by:
getRolesWithScopein interfaceRolesHolder- Parameters:
scope- roles scope- Returns:
- all roles with specified scope.
-
getScopes
public Collection<RoleScope> getScopes()
Description copied from interface:RolesHolderReturns all scopes with assigned roles- Specified by:
getScopesin interfaceRolesHolder- Returns:
- all scopes with assigned roles
-
getRoles
@NotNull public Collection<RoleEntry> getRoles()
Description copied from interface:RolesHolderReturns roles with their scopes- Specified by:
getRolesin interfaceRolesHolder- Returns:
- roles with their scopes
-
resetRoles
public void resetRoles()
Description copied from interface:UserRolesInitCauses roles reloading from the database.- Specified by:
resetRolesin interfaceUserRolesInit
-
addRole
public void addRole(@NotNull RoleScope scope, @NotNull Role role) throws UserNotFoundExceptionDescription copied from interface:RolesHolderAdds role with specified scope- Specified by:
addRolein interfaceRolesHolder- Parameters:
scope- scope of the rolerole- role- Throws:
UserNotFoundException
-
removeRole
public void removeRole(@NotNull RoleScope scope, @NotNull Role role) throws UserNotFoundExceptionDescription copied from interface:RolesHolderRemoves role with specified scope- Specified by:
removeRolein interfaceRolesHolder- Parameters:
scope- scope of the rolerole- role- Throws:
UserNotFoundException
-
removeRoles
public void removeRoles(@NotNull RoleScope scope) throws UserNotFoundExceptionDescription copied from interface:RolesHolderRemoves all of the roles having the specified scope.- Specified by:
removeRolesin interfaceRolesHolder- Parameters:
scope- scope of the role- Throws:
UserNotFoundException
-
removeRole
public void removeRole(@NotNull Role role)Description copied from interface:RolesHolderRemoves specified role. If the role is associated with several scopes all of these roles will be removed.- Specified by:
removeRolein interfaceRolesHolder- Parameters:
role- role to remove
-
isSystemAdministratorRoleGranted
public boolean isSystemAdministratorRoleGranted()
Description copied from interface:RolesHolderReturns true if this roles holder contains system administrator role granted directly or inherited via parent holders. Same as:isSystemAdministratorRoleGrantedDirectly() || isSystemAdministratorRoleInherited()
- Specified by:
isSystemAdministratorRoleGrantedin interfaceRolesHolder- Returns:
- see above.
-
isSystemAdministratorRoleGrantedDirectly
public boolean isSystemAdministratorRoleGrantedDirectly()
Description copied from interface:RolesHolderReturns true if this roles holder contains system administrator role granted directly.- Specified by:
isSystemAdministratorRoleGrantedDirectlyin interfaceRolesHolder- Returns:
- see above.
-
isSystemAdministratorRoleInherited
public boolean isSystemAdministratorRoleInherited()
Description copied from interface:RolesHolderReturns true if one of the parents (transitively) of this roles holder contains system administrator role.- Specified by:
isSystemAdministratorRoleInheritedin interfaceRolesHolder- Returns:
- see above
-
getParentHolders
@NotNull public Collection<RolesHolder> getParentHolders()
Description copied from interface:RolesHolderReturns direct (non transitive) parent holders.- Specified by:
getParentHoldersin interfaceRolesHolder- Returns:
- parent holders
-
getAllParentHolders
@NotNull public Collection<RolesHolder> getAllParentHolders()
Description copied from interface:RolesHolderReturns all parent holders including transitive ones- Specified by:
getAllParentHoldersin interfaceRolesHolder- Returns:
- all parent holders
-
getOriginalAuthorityHolder
@NotNull public AuthorityHolder getOriginalAuthorityHolder()
calculates permissions if not cached or recalculates if needed- Specified by:
getOriginalAuthorityHolderin interfaceUserEx
-
updatePermissions
public void updatePermissions()
Recalculates permissions if cached- Specified by:
updatePermissionsin interfaceUserEx
-
clearPermissions
public void clearPermissions()
-
isPseudoUser
public boolean isPseudoUser()
- Specified by:
isPseudoUserin 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:SUserStores collapsable block state for this user- Specified by:
setBlockStatein interfaceSUser- Parameters:
blockType- type of blockblockState- state
-
getBlockState
@Nullable public String getBlockState(String blockType)
Description copied from interface:SUserRetrieves state of a block stored for this user- Specified by:
getBlockStatein interfaceSUser- Parameters:
blockType- type of block- Returns:
- block state or null
-
resetBlocks
public void resetBlocks()
Description copied from interface:UserExReset cached blocks- Specified by:
resetBlocksin interfaceUserEx
-
getUserGroups
@NotNull public List<UserGroup> getUserGroups()
Description copied from interface:SUserReturns 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:
getUserGroupsin interfaceSUser- Returns:
- list of groups containing this user
- See Also:
SUser.getAllUserGroups()
-
getAllUserGroups
@NotNull public List<UserGroup> getAllUserGroups()
Description copied from interface:SUserReturns 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:
getAllUserGroupsin interfaceSUser- Returns:
- list of all groups containing this user
- See Also:
SUser.getUserGroups()
-
getVcsUsernameProperties
@NotNull public List<VcsUsernamePropertyKey> getVcsUsernameProperties()
Description copied from interface:SUserReturns 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:
getVcsUsernamePropertiesin interfaceSUser- Returns:
- list of VCS usernames
-
getNotificationRules
@NotNull public List<NotificationRule> getNotificationRules(@NotNull String notificatorType)
Description copied from interface:NotificationRulesHolderReturns the notification rules for specified notifier for this holder (user or group).- Specified by:
getNotificationRulesin 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:NotificationRulesHolderSets the notification rules for specified notifier.- Specified by:
setNotificationRulesin interfaceNotificationRulesHolder- Parameters:
notifierType- type of the notifierrules- rules to save
-
removeRule
public void removeRule(long ruleId)
Description copied from interface:NotificationRulesHolderRemoves the rule with specified id.- Specified by:
removeRulein interfaceNotificationRulesHolder- Parameters:
ruleId- id of the rule
-
removeRule
public void removeRule(@NotNull NotificationRule rule)Description copied from interface:NotificationRulesHolderRemoves the rule. ThrowsNotificationRuleChangedExceptionif notification rule with same id was already changed. Does nothing if notification rule doesn't exist.- Specified by:
removeRulein interfaceNotificationRulesHolder- Parameters:
rule- rule to remove
-
applyOrder
public void applyOrder(@NotNull String notifierType, @NotNull long[] ruleIds)Description copied from interface:NotificationRulesHolderSorts the notification rules in the specified order.- Specified by:
applyOrderin 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 DuplicateNotificationRuleExceptionDescription copied from interface:NotificationRulesHolderAdds new rule to the rules of specified user for specified notifier type.- Specified by:
addNewRulein 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:NotificationRulesHolderSearches for rules which intersect with specified watched builds.- Specified by:
findConflictingRulesin 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:NotificationRulesHolderSearches for a rule with specified id.- Specified by:
findRuleByIdin interfaceNotificationRulesHolder- Parameters:
ruleId- id of the rule- Returns:
- a found rule, or null
-
getParentRulesHolders
@NotNull public List<NotificationRulesHolder> getParentRulesHolders()
Description copied from interface:NotificationRulesHolderReturns direct parent notification rules holders- Specified by:
getParentRulesHoldersin interfaceNotificationRulesHolder- Returns:
- direct parent notification rules holders
-
getAllParentRulesHolders
@NotNull public List<NotificationRulesHolder> getAllParentRulesHolders()
Description copied from interface:NotificationRulesHolderReturns all (direct and inherited) parent notification rules holders- Specified by:
getAllParentRulesHoldersin 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:
runWithRestrictorin interfaceUserEx
-
-