Package jetbrains.buildServer.users.impl
Class SecuredUserModel
- java.lang.Object
-
- jetbrains.buildServer.users.impl.SecuredUserModel
-
- All Implemented Interfaces:
PropertyUpdater<Long>,RolesUpdate<Long>,UserModel,UserModelEx,UserUpdate,org.springframework.beans.factory.InitializingBean
public class SecuredUserModel extends Object implements UserModelEx, UserUpdate, org.springframework.beans.factory.InitializingBean
Created by Evgeniy.Koshkin.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jetbrains.buildServer.users.UserModelEx
UserModelEx.SORT_BY
-
-
Constructor Summary
Constructors Constructor Description SecuredUserModel(EventDispatcher<UserModelListener> dispatcher, SecurityContextEx securityContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(UserModelListenerEx listener)voidaddListener(UserModelListener listener)Adds listener to the user modelvoidaddRole(Long id, RoleScope roleScope, Role role)Adds a role with specified scope to an entity with specified id.voidafterPropertiesSet()booleanatLeastOneUserAccountRegistered()Returns true if at least one user account exists.voidblockStateChanged(SUser user)voidcheckUserAccountExists(String username)Checks whether a user account with specified username exists.UserExcreatePermissionsRestrictedUser(UserEx delegate, PermissionsHolder permissionsRestrictor)SUsercreateUserAccount(String realm, String username)Creates a new user.SUsercreateUserAccount(NewUserAccount newUserAccount)voiddeleteProperty(Long id, PropertyKey propertyKey)UserExfindUserAccount(String realm, String username)Searches for a user account with specified realm and usernameSUserfindUserAccount(String realm, String username, String password)Searches for a user account with specified realm, username and passwordUserExfindUserById(long userId)Searches for a user by id in the current login domain.SUserfindUserByUsername(String username, AuthPropertyKey usernamePropertyKey)Looks for a TeamCity user with the specified username.List<UserEx>findUsers(SearchOptions searchOptions, UserModelEx.SORT_BY sortOption, boolean ascending)Searches for users with specified keyword in username, name or email.UserSet<SUser>findUsersByAttributeValue(String attributeKey, String attributeValue, boolean caseSensitive)Returns UserSet of users having specified attribute.Collection<SUser>findUsersByIds(Collection<Long> userIds)Searches for users with specified ids, returns collection of existing users only.UserSet<SUser>findUsersByPropertyValue(PropertyKey propertyKey, String propertyValue, boolean caseSensitive)Returns UserSet of users having specified property in the profile.List<SUser>findUsersByVerifiedEmail(String verifiedEmail)UserSet<SUser>getAllUsers()Returns all of the registered usersUserModelExgetDelegate()UserExgetGuestUser()Returns guest userintgetNumberOfRegisteredUsers()Returns number of users currently registered in the system.SUsergetSuperUser()Returns Super userbooleanhasAdministratorAccount()Returns true if there is at least one administrator that can be authenticated by specified login module.booleanisGuestUser(User user)Returns true if the specified user is guestbooleanisSpecialUser(User user)Returns true if user is guest or root.booleanisSuperUser(User user)Returns true if the specified user is Super uservoidnotifyUserChanged(SUser user)voidnotifyUserPermissionsMayHaveChanged(SUser user)voidnotifyUserPropertyChanged(SUser user, PropertyKey propertyKey)voidnotifyUserRolesChanged(SUser user)voidpersistLastLoginTimestamp(long userId, Date timestamp)Note: login timestamp will be persisted with some delay.voidremoveListener(UserModelListener listener)Removes listener from the user modelvoidremoveRole(Long id, Role role)Removes the specified role from the entity with specified id.voidremoveRole(Long id, RoleScope roleScope, Role role)Removes role with specified scope from the entity with specified id.voidremoveRole(Role role)Removes the specified role for all roles holders.voidremoveRoles(Long id, RoleScope roleScope)Removes all roles with specified scope from the entity with specified id.voidremoveUserAccount(long userId)Removes user account from database.voidsetBuildTypesOrder(long userId, String projectId, UserImpl.BuildTypesOrder buildTypesOrder)Sets order of build typesvoidsetDelegate(UserModelImpl delegate)voidsetLicenseKeysManager(LicenseKeysManager licKeysManager)voidsetPassword(long userId, String password)voidsetProjectsOrder(long userId, List<String> projectsOrder)Sets order of the projects.voidsetProjectsVisibility(long userId, Collection<String> projectIds, boolean isVisible)Set visibility state for selected projects.voidsetProperties(Long id, Map<? extends PropertyKey,String> properties)voidsetProperty(Long id, PropertyKey prop, String value)voidsetVisibleProjects(long userId, Collection<String> visibleProjects)Sets projects visible for specified uservoidupdateUserAccount(long userId, String username, String name, String email)Updates user with specified id and sets his/her username and name.
-
-
-
Constructor Detail
-
SecuredUserModel
public SecuredUserModel(@NotNull EventDispatcher<UserModelListener> dispatcher, @NotNull SecurityContextEx securityContext)
-
-
Method Detail
-
setDelegate
public void setDelegate(@NotNull UserModelImpl delegate)
-
getDelegate
@NotNull public UserModelEx getDelegate()
-
findUsers
public List<UserEx> findUsers(SearchOptions searchOptions, @NotNull UserModelEx.SORT_BY sortOption, boolean ascending)
Description copied from interface:UserModelExSearches for users with specified keyword in username, name or email. If keyword is empty, then all users returned.- Specified by:
findUsersin interfaceUserModelEx- Returns:
- unmodifiable collection of users
-
findUsersByVerifiedEmail
@NotNull public List<SUser> findUsersByVerifiedEmail(@NotNull String verifiedEmail)
- Specified by:
findUsersByVerifiedEmailin interfaceUserModelEx
-
createUserAccount
public SUser createUserAccount(String realm, String username) throws DuplicateUserAccountException, MaxNumberOfUserAccountsReachedException, EmptyUsernameException
Description copied from interface:UserModelCreates a new user.- Specified by:
createUserAccountin interfaceUserModel- Parameters:
realm- realm realm is always ignored. Pass null hereusername- username- Returns:
- newly created user
- Throws:
DuplicateUserAccountException- if user with specified username already exists in specified realmMaxNumberOfUserAccountsReachedException- thrown is maximum number of user accounts reachedEmptyUsernameException- if username is an empty string
-
createUserAccount
@NotNull public SUser createUserAccount(@NotNull NewUserAccount newUserAccount) throws DuplicateUserAccountException, MaxNumberOfUserAccountsReachedException
- Specified by:
createUserAccountin interfaceUserModelEx- Throws:
DuplicateUserAccountExceptionMaxNumberOfUserAccountsReachedException
-
findUserById
@Nullable public UserEx findUserById(long userId)
Description copied from interface:UserModelSearches for a user by id in the current login domain. Login domain is defined by currently selected login module.- Specified by:
findUserByIdin interfaceUserModel- Specified by:
findUserByIdin interfaceUserModelEx- Parameters:
userId- id of the user- Returns:
- found user or null
-
findUsersByIds
@NotNull public Collection<SUser> findUsersByIds(@NotNull Collection<Long> userIds)
Description copied from interface:UserModelSearches for users with specified ids, returns collection of existing users only.- Specified by:
findUsersByIdsin interfaceUserModel- Parameters:
userIds- user ids- Returns:
- collection of found users
-
findUserAccount
@Nullable public UserEx findUserAccount(@Nullable String realm, @NotNull String username)
Description copied from interface:UserModelSearches for a user account with specified realm and username- Specified by:
findUserAccountin interfaceUserModel- Specified by:
findUserAccountin interfaceUserModelEx- Parameters:
realm- realm is always ignored. Pass null here.username- username- Returns:
- found user or null
-
findUserAccount
@Nullable public SUser findUserAccount(@Nullable String realm, @NotNull String username, @NotNull String password)
Description copied from interface:UserModelSearches for a user account with specified realm, username and password- Specified by:
findUserAccountin interfaceUserModel- Parameters:
realm- realm is always ignored. Pass null here.username- usernamepassword- user password- Returns:
- found user or null
-
findUsersByPropertyValue
public UserSet<SUser> findUsersByPropertyValue(PropertyKey propertyKey, String propertyValue, boolean caseSensitive)
Description copied from interface:UserModelReturns UserSet of users having specified property in the profile. UserSet collection will be sorted by account name.- Specified by:
findUsersByPropertyValuein interfaceUserModel- Parameters:
propertyKey- property keypropertyValue- property valuecaseSensitive- whether to perform case sensitive search- Returns:
- set of users having the value with specified key in the profile
-
findUsersByAttributeValue
public UserSet<SUser> findUsersByAttributeValue(String attributeKey, String attributeValue, boolean caseSensitive)
Description copied from interface:UserModelExReturns UserSet of users having specified attribute.- Specified by:
findUsersByAttributeValuein interfaceUserModelEx- Parameters:
attributeKey- attribute keyattributeValue- attribute valuecaseSensitive- whether to perform case-sensitive search- Returns:
- set of users having the attribute with specified key and value
-
findUserByUsername
@Nullable public SUser findUserByUsername(@NotNull String username, @NotNull AuthPropertyKey usernamePropertyKey) throws InvalidUsernameException
Description copied from interface:UserModelLooks for a TeamCity user with the specified username. Username is searched as a value of the specified user property and as an account's username itself (property has higher priority).- Specified by:
findUserByUsernamein interfaceUserModel- Parameters:
username- username to searchusernamePropertyKey- user property key to search username as a value of; it is assumed that no more than one user can have the specified username as a value of this property- Returns:
- user with the specified username being the value of the specified user property or, if not found, user with the same TeamCity username as the specified one and empty value of the specified user property or, if not found, null
- Throws:
InvalidUsernameException-- if user with the specified username being the value of the specified user property does not exist and user with the same TeamCity username as the specified one exists and his/her value of the specified user property is not empty
- if several users match the search
-
getAllUsers
public UserSet<SUser> getAllUsers()
Description copied from interface:UserModelReturns all of the registered users- Specified by:
getAllUsersin interfaceUserModel- Returns:
- all of the registered users
-
getNumberOfRegisteredUsers
public int getNumberOfRegisteredUsers()
Description copied from interface:UserModelReturns number of users currently registered in the system.- Specified by:
getNumberOfRegisteredUsersin interfaceUserModel- Returns:
- number of currently registered users
-
hasAdministratorAccount
public boolean hasAdministratorAccount()
Description copied from interface:UserModelReturns true if there is at least one administrator that can be authenticated by specified login module.- Specified by:
hasAdministratorAccountin interfaceUserModel- Returns:
- true if administrator account exists in the system
-
removeUserAccount
public void removeUserAccount(long userId)
Description copied from interface:UserModelRemoves user account from database.- Specified by:
removeUserAccountin interfaceUserModel- Parameters:
userId- id of the user
-
addListener
public void addListener(UserModelListener listener)
Description copied from interface:UserModelAdds listener to the user model- Specified by:
addListenerin interfaceUserModel- Parameters:
listener- listener to add
-
removeListener
public void removeListener(UserModelListener listener)
Description copied from interface:UserModelRemoves listener from the user model- Specified by:
removeListenerin interfaceUserModel- Parameters:
listener- to remove
-
isGuestUser
public boolean isGuestUser(@NotNull User user)Description copied from interface:UserModelReturns true if the specified user is guest- Specified by:
isGuestUserin interfaceUserModel- Parameters:
user- user to check- Returns:
- true if user is guest
-
checkUserAccountExists
public void checkUserAccountExists(String username) throws DuplicateUserAccountException
Description copied from interface:UserModelExChecks whether a user account with specified username exists. If such user found then DuplicateUserAccountException is thrown.- Specified by:
checkUserAccountExistsin interfaceUserModelEx- Throws:
DuplicateUserAccountException
-
atLeastOneUserAccountRegistered
public boolean atLeastOneUserAccountRegistered()
Description copied from interface:UserModelExReturns true if at least one user account exists.- Specified by:
atLeastOneUserAccountRegisteredin interfaceUserModelEx- Returns:
- see above
-
setLicenseKeysManager
public void setLicenseKeysManager(@NotNull LicenseKeysManager licKeysManager)- Specified by:
setLicenseKeysManagerin interfaceUserModelEx
-
createPermissionsRestrictedUser
public UserEx createPermissionsRestrictedUser(@NotNull UserEx delegate, @NotNull PermissionsHolder permissionsRestrictor)
- Specified by:
createPermissionsRestrictedUserin interfaceUserModelEx
-
isSpecialUser
public boolean isSpecialUser(@NotNull User user)Description copied from interface:UserModelExReturns true if user is guest or root.- Specified by:
isSpecialUserin interfaceUserModelEx- Returns:
-
getGuestUser
@NotNull public UserEx getGuestUser()
Description copied from interface:UserModelReturns guest user- Specified by:
getGuestUserin interfaceUserModel- Specified by:
getGuestUserin interfaceUserModelEx- Returns:
- guest user
-
addListener
public void addListener(UserModelListenerEx listener)
- Specified by:
addListenerin interfaceUserModelEx
-
isSuperUser
public boolean isSuperUser(@NotNull User user)Description copied from interface:UserModelReturns true if the specified user is Super user- Specified by:
isSuperUserin interfaceUserModel- Parameters:
user- user to check- Returns:
- true if user is Super user
-
getSuperUser
@NotNull public SUser getSuperUser()
Description copied from interface:UserModelReturns Super user- Specified by:
getSuperUserin interfaceUserModel- Returns:
- Super user
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
setProperties
public void setProperties(@NotNull Long id, @NotNull Map<? extends PropertyKey,String> properties)- Specified by:
setPropertiesin interfacePropertyUpdater<Long>
-
setProperty
public void setProperty(@NotNull Long id, @NotNull PropertyKey prop, String value)- Specified by:
setPropertyin interfacePropertyUpdater<Long>
-
deleteProperty
public void deleteProperty(@NotNull Long id, @NotNull PropertyKey propertyKey)- Specified by:
deletePropertyin interfacePropertyUpdater<Long>
-
addRole
public void addRole(@NotNull Long id, @NotNull RoleScope roleScope, @NotNull Role role)Description copied from interface:RolesUpdateAdds a role with specified scope to an entity with specified id.- Specified by:
addRolein interfaceRolesUpdate<Long>- Parameters:
id- uidroleScope- scope of the rolerole- role
-
removeRole
public void removeRole(@NotNull Long id, @NotNull RoleScope roleScope, @NotNull Role role)Description copied from interface:RolesUpdateRemoves role with specified scope from the entity with specified id.- Specified by:
removeRolein interfaceRolesUpdate<Long>- Parameters:
id- idroleScope- scope of the rolerole- role
-
removeRole
public void removeRole(@NotNull Long id, @NotNull Role role)Description copied from interface:RolesUpdateRemoves the specified role from the entity with specified id. The role is removed from all of the scopes.- Specified by:
removeRolein interfaceRolesUpdate<Long>- Parameters:
id- idrole- role to remove
-
removeRoles
public void removeRoles(@NotNull Long id, @NotNull RoleScope roleScope)Description copied from interface:RolesUpdateRemoves all roles with specified scope from the entity with specified id.- Specified by:
removeRolesin interfaceRolesUpdate<Long>- Parameters:
id- idroleScope- scope of the role
-
removeRole
public void removeRole(@NotNull Role role)Description copied from interface:RolesUpdateRemoves the specified role for all roles holders.- Specified by:
removeRolein interfaceRolesUpdate<Long>- Parameters:
role- role to remove
-
updateUserAccount
public void updateUserAccount(long userId, String username, String name, String email) throws UserNotFoundException, DuplicateUserAccountException, EmptyUsernameExceptionDescription copied from interface:UserUpdateUpdates user with specified id and sets his/her username and name.- Specified by:
updateUserAccountin interfaceUserUpdate- Parameters:
userId- user idusername- usernamename- full name of a user- Throws:
UserNotFoundException- if specified user no longer exists in the modelDuplicateUserAccountException- if a new username name already assigned to another userEmptyUsernameException- if username is an empty string
-
setPassword
public void setPassword(long userId, String password) throws UserNotFoundException- Specified by:
setPasswordin interfaceUserUpdate- Throws:
UserNotFoundException
-
setProjectsOrder
public void setProjectsOrder(long userId, List<String> projectsOrder) throws UserNotFoundExceptionDescription copied from interface:UserUpdateSets order of the projects.- Specified by:
setProjectsOrderin interfaceUserUpdate- Parameters:
userId- id of a userprojectsOrder- identificators of all projects in the order specified by user. The order will be reset to default (system) if null or empty.- Throws:
UserNotFoundException- if specified user no longer exists
-
setVisibleProjects
public void setVisibleProjects(long userId, Collection<String> visibleProjects) throws UserNotFoundExceptionDescription copied from interface:UserUpdateSets projects visible for specified user- Specified by:
setVisibleProjectsin interfaceUserUpdate- Parameters:
userId- id of a uservisibleProjects- collection of identifiers of visible projects- Throws:
UserNotFoundException- if specified user no longer exists
-
setBuildTypesOrder
public void setBuildTypesOrder(long userId, @NotNull String projectId, @Nullable UserImpl.BuildTypesOrder buildTypesOrder) throws UserNotFoundExceptionDescription copied from interface:UserUpdateSets order of build types- Specified by:
setBuildTypesOrderin interfaceUserUpdatebuildTypesOrder- build type internal ids- Throws:
UserNotFoundException
-
setProjectsVisibility
public void setProjectsVisibility(long userId, @NotNull Collection<String> projectIds, boolean isVisible)Description copied from interface:UserUpdateSet visibility state for selected projects. Doesn't affect other projects nor project order.- Specified by:
setProjectsVisibilityin interfaceUserUpdate
-
persistLastLoginTimestamp
public void persistLastLoginTimestamp(long userId, Date timestamp) throws UserNotFoundExceptionDescription copied from interface:UserUpdateNote: login timestamp will be persisted with some delay.- Specified by:
persistLastLoginTimestampin interfaceUserUpdate- Parameters:
userId- user idtimestamp- timestamp- Throws:
UserNotFoundException
-
notifyUserChanged
public void notifyUserChanged(@NotNull SUser user)- Specified by:
notifyUserChangedin interfaceUserUpdate
-
notifyUserPropertyChanged
public void notifyUserPropertyChanged(@NotNull SUser user, @NotNull PropertyKey propertyKey)- Specified by:
notifyUserPropertyChangedin interfaceUserUpdate
-
notifyUserRolesChanged
public void notifyUserRolesChanged(@NotNull SUser user)- Specified by:
notifyUserRolesChangedin interfaceUserUpdate
-
notifyUserPermissionsMayHaveChanged
public void notifyUserPermissionsMayHaveChanged(@NotNull SUser user)- Specified by:
notifyUserPermissionsMayHaveChangedin interfaceUserUpdate
-
blockStateChanged
public void blockStateChanged(@NotNull SUser user)- Specified by:
blockStateChangedin interfaceUserUpdate
-
-