Package com.atlassian.bamboo.user
Class BambooUserManagerImpl
- java.lang.Object
-
- bucket.user.DefaultUserAccessor
-
- com.atlassian.bamboo.user.BambooUserManagerImpl
-
- All Implemented Interfaces:
bucket.user.UserAccessor
,BambooUserManager
,com.atlassian.user.search.query.EntityQueryParser
,org.acegisecurity.userdetails.UserDetailsService
public class BambooUserManagerImpl extends bucket.user.DefaultUserAccessor implements BambooUserManager
-
-
Field Summary
-
Fields inherited from interface com.atlassian.bamboo.user.BambooUserManager
JABBER_ADDRESS_KEY, USER_NOTIFICATION_PREFERENCE, USER_NOTIFICATION_TRANSPORT_PREFERENCE
-
-
Constructor Summary
Constructors Constructor Description BambooUserManagerImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addMembershipWithConfirmation(com.atlassian.user.Group group, com.atlassian.user.User user)
BambooUser
addUser(String username, String password, boolean enabled, String email, String fullName, String jabberAddress, List<String> groups, @NotNull List<Long> authors)
BambooUser
addUser(String username, String password, String email, String fullName, String jabberAddress, List<String> groups)
Method that extends the standard addUser methods to also add Bamboo specific paramsBambooUser
addUser(String username, String password, String email, String fullName, String jabberAddress, List<String> groups, @NotNull List<Long> authors)
BambooUser
addUser(String username, String password, String email, String fullName, String jabberAddress, List<String> groups, ExtendedAuthor author)
Method that extends the standard addUser methods to also add Bamboo specific paramsvoid
alterPassword(com.atlassian.user.User user, String plainTextPassword)
boolean
canCreateGroups()
Whether creation of new groups is allowed.boolean
canCreateUsers()
Whether creation of new users is allowed.void
cleanupRemovedGroupReferences(@NotNull String groupName)
Cleanup all Bamboo-stored data related to a group that is being deleted or has been deleted.void
cleanupRemovedUserReferences(@NotNull String username)
Cleanup all Bamboo-stored data related to a user that is being deleted or has been deleted.@NotNull PasswordResetToken
createPasswordResetToken(String username)
Request new one-time token for a user.void
deletePasswordResetToken(String username)
Deletes existing user token.BambooUser
findUserWithJabberAddress(@NotNull String jabberAddress)
Searches for user using specified jabberAddress.BambooUser
getBambooUser(@NotNull AccessToken accessToken)
Returns aBambooUser
with filled accessToken@Nullable BambooUser
getBambooUser(@Nullable com.atlassian.user.User user)
Returns aBambooUser
given aUser
@Nullable BambooUser
getBambooUser(String username)
Returns aBambooUser
of the given usernameList<String>
getGroupNamesAsList(com.atlassian.user.User user)
Returns groups for theUser
com.atlassian.user.search.page.Pager<com.atlassian.user.Group>
getGroups()
String
getJiraIssueDefaults(@NotNull com.atlassian.user.User user)
@NotNull List<String>
getMemberNamesAsList(com.atlassian.user.Group group)
@Nullable PasswordResetToken
getPasswordResetToken(String username)
Retrieves existing user token.@Nullable com.atlassian.user.User
getUser(String name)
BambooUser
injectUser(@NotNull BambooUser user)
A variation of addUser which inserts the encryptedPassword instead - used for importingboolean
isDeletable(com.atlassian.user.Group group)
Returns true if the given group can be deleted.boolean
isDeletable(com.atlassian.user.User user)
Is this user deletable? A user may not be deletable because: 1) They are read-only (i.e.boolean
isReadOnly(com.atlassian.user.Group group)
Is this group read only?boolean
isReadOnly(com.atlassian.user.User user)
Is this user read only?boolean
isUserAutocompleteAllowed()
Determines whether or not we are allowed to do autocompletion for users.BambooUser
loadUserByUsername(String username)
Currently should NOT be called during setup/upgrade.protected List<String>
loadUserGroups(com.atlassian.user.User user)
void
onExternalUserRename(@NotNull String oldUserName, @NotNull String newUserName)
void
postConstruct()
void
removeGroup(com.atlassian.user.Group group)
boolean
removeMembership(com.atlassian.user.Group group, com.atlassian.user.User user)
void
removeUser(com.atlassian.user.User user)
void
renameUser(@NotNull String oldUserName, @NotNull String newUserName)
void
saveJiraIssueDefaults(@NotNull com.atlassian.user.User user, @NotNull String jiraIssueDefaults)
Saves default data use in JIRA issue creation dialogvoid
saveNotificationPreferences(String username, String notificationPreference, String notificationTransportPref)
Save just the notification preferences for the given uservoid
saveUser(String username, @Nullable String password, boolean enabled, String email, String fullName, String jabberAddress, String notificationPreference, String notificationTransportPreference, List<String> selectedGroups, @NotNull List<Long> authors)
void
saveUser(String username, String password, String email, String fullName, String jabberAddress, List<String> selectedGroups)
Saves the properties for the given uservoid
saveUser(String username, String password, String email, String fullName, String jabberAddress, List<String> selectedGroups, ExtendedAuthor author)
Saves the properties for the given uservoid
setAccessTokenDao(AccessTokenDao accessTokenDao)
void
setAclAuthorizationStrategy(org.acegisecurity.acls.domain.AclAuthorizationStrategy aclAuthorizationStrategy)
void
setAclService(HibernateMutableAclService aclService)
void
setAuthorDao(AuthorDao authorDao)
void
setAvatarService(AvatarService avatarService)
void
setCacheManager(com.atlassian.cache.CacheManager cacheManager)
void
setCommentDao(CommentDao commentDao)
void
setFeatureManager(FeatureManager featureManager)
void
setFilteredGroupsProvider(FilteredGroupsProvider filteredGroupsProvider)
void
setLabelDao(LabelDao labelDao)
void
setLoginInformationManager(LoginInformationManager loginInformationManager)
void
setMembership(com.atlassian.user.Group group, List<String> members)
Sets a group's members as the passed listvoid
setPropertySetDao(BambooPropertySetDao propertySetDao)
void
setRecoveryModeService(com.atlassian.crowd.manager.recovery.RecoveryModeService recoveryModeService)
void
setRememberMeTokenDao(com.atlassian.seraph.spi.rememberme.RememberMeTokenDao rememberMeTokenDao)
void
setTokenDao(PasswordResetTokenDao tokenDao)
void
setupInitialAdminUser(String username, String password, String email, String fullName)
Setup the initial admin user for the Bamboo instance.static String[]
stringListToArray(Collection<String> strings)
Converts aCollection
of Strings to an array of Stringsstatic <T> Collection<T>
subtractNewList(Collection<T> oldList, Collection<T> newList)
Works likeCollectionUtils.removeAll(Collection, Collection)
only that it's null safe-
Methods inherited from class bucket.user.DefaultUserAccessor
addGroup, addMembership, addMembership, addUser, addUser, authenticate, checkConfiguration, createGroup, createUser, deactivateUser, findGroups, findGroups, findUsers, findUsers, getAuthenticator, getDefaultGroup, getDelegatingRepositories, getEntityQueryParser, getExternallMembers, getGroup, getGroupCreateIfNecessary, getGroupManager, getGroups, getLocalMembers, getMemberNames, getPropertySet, getPropertySetFactory, getRepository, getUserManager, getUserNames, getUsers, getUsersByEmail, getUsersWithConfluenceAccess, hasMembership, hasMembership, isDeactivated, isDeactivated, isLicensedToAddMoreUsers, isUserRemovable, reactivateUser, removeMembership, removeUserFromAllGroups, saveUser, setAtlassianUserConfiguration
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.atlassian.user.search.query.EntityQueryParser
findGroups, findGroups, findUsers
-
Methods inherited from interface bucket.user.UserAccessor
addGroup, addMembership, addMembership, addUser, addUser, authenticate, createGroup, createUser, deactivateUser, findUsers, getDefaultGroup, getDelegatingRepositories, getExternallMembers, getGroup, getGroupCreateIfNecessary, getGroups, getLocalMembers, getMemberNames, getPropertySet, getRepository, getUserNames, getUsers, getUsersByEmail, getUsersWithConfluenceAccess, hasMembership, hasMembership, isDeactivated, isDeactivated, isLicensedToAddMoreUsers, isUserRemovable, reactivateUser, removeMembership, saveUser, setAtlassianUserConfiguration
-
-
-
-
Method Detail
-
postConstruct
@PostConstruct public void postConstruct()
-
getBambooUser
@Nullable public @Nullable BambooUser getBambooUser(String username)
Description copied from interface:BambooUserManager
Returns aBambooUser
of the given username- Specified by:
getBambooUser
in interfaceBambooUserManager
- Returns:
- The matching user, null if does not exist
-
getBambooUser
@Nullable public @Nullable BambooUser getBambooUser(@Nullable @Nullable com.atlassian.user.User user)
Description copied from interface:BambooUserManager
Returns aBambooUser
given aUser
- Specified by:
getBambooUser
in interfaceBambooUserManager
- Returns:
- The wrapped user.
-
getBambooUser
public BambooUser getBambooUser(@NotNull @NotNull AccessToken accessToken)
Description copied from interface:BambooUserManager
Returns aBambooUser
with filled accessToken- Specified by:
getBambooUser
in interfaceBambooUserManager
- Returns:
- The wrapped user with access token
-
getUser
@Nullable public @Nullable com.atlassian.user.User getUser(String name)
- Specified by:
getUser
in interfacebucket.user.UserAccessor
- Overrides:
getUser
in classbucket.user.DefaultUserAccessor
-
addUser
public BambooUser addUser(String username, String password, String email, String fullName, String jabberAddress, List<String> groups)
Description copied from interface:BambooUserManager
Method that extends the standard addUser methods to also add Bamboo specific params- Specified by:
addUser
in interfaceBambooUserManager
groups
- -List
of Strings as the group names. May be null.- Returns:
- the created
BambooUser
object with the created properties
-
addUser
public BambooUser addUser(String username, String password, String email, String fullName, String jabberAddress, List<String> groups, ExtendedAuthor author)
Description copied from interface:BambooUserManager
Method that extends the standard addUser methods to also add Bamboo specific params- Specified by:
addUser
in interfaceBambooUserManager
- Returns:
- the created
BambooUser
object with the created properties
-
addUser
public BambooUser addUser(String username, String password, String email, String fullName, String jabberAddress, List<String> groups, @NotNull @NotNull List<Long> authors)
- Specified by:
addUser
in interfaceBambooUserManager
-
addUser
public BambooUser addUser(String username, String password, boolean enabled, String email, String fullName, String jabberAddress, List<String> groups, @NotNull @NotNull List<Long> authors)
- Specified by:
addUser
in interfaceBambooUserManager
-
renameUser
public void renameUser(@NotNull @NotNull String oldUserName, @NotNull @NotNull String newUserName)
- Specified by:
renameUser
in interfaceBambooUserManager
-
onExternalUserRename
public void onExternalUserRename(@NotNull @NotNull String oldUserName, @NotNull @NotNull String newUserName)
- Specified by:
onExternalUserRename
in interfaceBambooUserManager
-
saveUser
public void saveUser(String username, String password, String email, String fullName, String jabberAddress, List<String> selectedGroups) throws IllegalArgumentException
Description copied from interface:BambooUserManager
Saves the properties for the given user- Specified by:
saveUser
in interfaceBambooUserManager
- Throws:
IllegalArgumentException
- ifusername
does not match a user, or if the password cannot be altered by the local user management facility.
-
saveUser
public void saveUser(String username, String password, String email, String fullName, String jabberAddress, List<String> selectedGroups, ExtendedAuthor author) throws IllegalArgumentException
Description copied from interface:BambooUserManager
Saves the properties for the given user- Specified by:
saveUser
in interfaceBambooUserManager
- Throws:
IllegalArgumentException
- ifusername
does not match a user, or if the password cannot be altered by the local user management facility.
-
saveUser
public void saveUser(String username, @Nullable @Nullable String password, boolean enabled, String email, String fullName, String jabberAddress, String notificationPreference, String notificationTransportPreference, List<String> selectedGroups, @NotNull @NotNull List<Long> authors) throws IllegalArgumentException
- Specified by:
saveUser
in interfaceBambooUserManager
- Throws:
IllegalArgumentException
-
alterPassword
public void alterPassword(com.atlassian.user.User user, String plainTextPassword) throws com.atlassian.user.EntityException
- Specified by:
alterPassword
in interfacebucket.user.UserAccessor
- Overrides:
alterPassword
in classbucket.user.DefaultUserAccessor
- Throws:
com.atlassian.user.EntityException
-
saveNotificationPreferences
public void saveNotificationPreferences(String username, String notificationPreference, String notificationTransportPref)
Description copied from interface:BambooUserManager
Save just the notification preferences for the given user- Specified by:
saveNotificationPreferences
in interfaceBambooUserManager
-
removeUser
public void removeUser(com.atlassian.user.User user)
- Specified by:
removeUser
in interfacebucket.user.UserAccessor
- Overrides:
removeUser
in classbucket.user.DefaultUserAccessor
-
cleanupRemovedUserReferences
public void cleanupRemovedUserReferences(@NotNull @NotNull String username)
Description copied from interface:BambooUserManager
Cleanup all Bamboo-stored data related to a user that is being deleted or has been deleted.- Specified by:
cleanupRemovedUserReferences
in interfaceBambooUserManager
-
removeGroup
public void removeGroup(com.atlassian.user.Group group)
- Specified by:
removeGroup
in interfacebucket.user.UserAccessor
- Overrides:
removeGroup
in classbucket.user.DefaultUserAccessor
-
cleanupRemovedGroupReferences
public void cleanupRemovedGroupReferences(@NotNull @NotNull String groupName)
Description copied from interface:BambooUserManager
Cleanup all Bamboo-stored data related to a group that is being deleted or has been deleted.- Specified by:
cleanupRemovedGroupReferences
in interfaceBambooUserManager
-
getGroupNamesAsList
public List<String> getGroupNamesAsList(com.atlassian.user.User user)
Description copied from interface:BambooUserManager
Returns groups for theUser
- Specified by:
getGroupNamesAsList
in interfaceBambooUserManager
- Parameters:
user
- - Must not be null- Returns:
List
ofString
representing group names.Collections.emptyList()
if none exists
-
setMembership
public void setMembership(com.atlassian.user.Group group, List<String> members)
Description copied from interface:BambooUserManager
Sets a group's members as the passed list- Specified by:
setMembership
in interfaceBambooUserManager
- Parameters:
group
- - The group to modify the user list. Cannot be null.members
- -List
of usernameString
s. Can be null
-
getMemberNamesAsList
@NotNull public @NotNull List<String> getMemberNamesAsList(com.atlassian.user.Group group)
- Specified by:
getMemberNamesAsList
in interfaceBambooUserManager
-
isUserAutocompleteAllowed
public boolean isUserAutocompleteAllowed()
Description copied from interface:BambooUserManager
Determines whether or not we are allowed to do autocompletion for users. Currently this will return false if using LDAP, otherwise true- Specified by:
isUserAutocompleteAllowed
in interfaceBambooUserManager
- Returns:
- true if we are allowed to do automcomplete for users.
-
subtractNewList
public static <T> Collection<T> subtractNewList(Collection<T> oldList, Collection<T> newList)
Works likeCollectionUtils.removeAll(Collection, Collection)
only that it's null safe- Parameters:
oldList
- - can be nullnewList
- - can be null- Returns:
CollectionUtils.removeAll(Collection, Collection)
. Null lists count as empty lists.
-
stringListToArray
public static String[] stringListToArray(Collection<String> strings)
Converts aCollection
of Strings to an array of Strings- Parameters:
strings
- -Collection
ofString
s. May be nukk- Returns:
- Array of strings. Null if input is null or empty
-
injectUser
public BambooUser injectUser(@NotNull @NotNull BambooUser user)
Description copied from interface:BambooUserManager
A variation of addUser which inserts the encryptedPassword instead - used for importing- Specified by:
injectUser
in interfaceBambooUserManager
- Parameters:
user
- user data- Returns:
- the created
BambooUser
object with the created properties
-
isDeletable
public boolean isDeletable(com.atlassian.user.User user)
Description copied from interface:BambooUserManager
Is this user deletable? A user may not be deletable because: 1) They are read-only (i.e. the user is externally sourced) 2) They have comments/labels linked to them- Specified by:
isDeletable
in interfaceBambooUserManager
- Returns:
boolean
whether user deletable
-
isDeletable
public boolean isDeletable(com.atlassian.user.Group group)
Description copied from interface:BambooUserManager
Returns true if the given group can be deleted. Some user directories may be read-only and thus may not permit deleting entities.- Specified by:
isDeletable
in interfaceBambooUserManager
-
isReadOnly
public boolean isReadOnly(com.atlassian.user.User user)
Description copied from interface:BambooUserManager
Is this user read only?- Specified by:
isReadOnly
in interfaceBambooUserManager
-
isReadOnly
public boolean isReadOnly(com.atlassian.user.Group group)
Description copied from interface:BambooUserManager
Is this group read only?- Specified by:
isReadOnly
in interfaceBambooUserManager
-
canCreateUsers
public boolean canCreateUsers()
Description copied from interface:BambooUserManager
Whether creation of new users is allowed. Some user directories may be read-only and thus may not permit adding new entities.- Specified by:
canCreateUsers
in interfaceBambooUserManager
-
canCreateGroups
public boolean canCreateGroups()
Description copied from interface:BambooUserManager
Whether creation of new groups is allowed. Some user directories may be read-only and thus may not permit adding new entities.- Specified by:
canCreateGroups
in interfaceBambooUserManager
-
setupInitialAdminUser
public void setupInitialAdminUser(String username, String password, String email, String fullName)
Description copied from interface:BambooUserManager
Setup the initial admin user for the Bamboo instance.- Specified by:
setupInitialAdminUser
in interfaceBambooUserManager
-
createPasswordResetToken
@NotNull public @NotNull PasswordResetToken createPasswordResetToken(String username)
Description copied from interface:BambooUserManager
Request new one-time token for a user. Replaces the old one if it exists.- Specified by:
createPasswordResetToken
in interfaceBambooUserManager
- Parameters:
username
- user login name- Returns:
- freshly created one-time token
-
getPasswordResetToken
@Nullable public @Nullable PasswordResetToken getPasswordResetToken(String username)
Description copied from interface:BambooUserManager
Retrieves existing user token. Returns null if there is none.- Specified by:
getPasswordResetToken
in interfaceBambooUserManager
- Parameters:
username
- user login name- Returns:
- user token object or null
-
deletePasswordResetToken
public void deletePasswordResetToken(String username)
Description copied from interface:BambooUserManager
Deletes existing user token. Does nothing if there is no token.- Specified by:
deletePasswordResetToken
in interfaceBambooUserManager
- Parameters:
username
- user login name
-
findUserWithJabberAddress
public BambooUser findUserWithJabberAddress(@NotNull @NotNull String jabberAddress)
Description copied from interface:BambooUserManager
Searches for user using specified jabberAddress.- Specified by:
findUserWithJabberAddress
in interfaceBambooUserManager
- Parameters:
jabberAddress
- address to be matched- Returns:
BambooUser
or null if none found
-
loadUserByUsername
public BambooUser loadUserByUsername(String username) throws org.acegisecurity.userdetails.UsernameNotFoundException, org.springframework.dao.DataAccessException
Description copied from interface:BambooUserManager
Currently should NOT be called during setup/upgrade. We need a better way of handling bamboo-users vs bamboo-user for Cloud and Server https://jira.atlassian.com/browse/ROTP-1557- Specified by:
loadUserByUsername
in interfaceBambooUserManager
- Specified by:
loadUserByUsername
in interfaceorg.acegisecurity.userdetails.UserDetailsService
- Throws:
org.acegisecurity.userdetails.UsernameNotFoundException
org.springframework.dao.DataAccessException
-
getJiraIssueDefaults
public String getJiraIssueDefaults(@NotNull @NotNull com.atlassian.user.User user)
- Specified by:
getJiraIssueDefaults
in interfaceBambooUserManager
- Returns:
- json string containing default JIRA server applink id, project id and issue type id
-
saveJiraIssueDefaults
public void saveJiraIssueDefaults(@NotNull @NotNull com.atlassian.user.User user, @NotNull @NotNull String jiraIssueDefaults)
Description copied from interface:BambooUserManager
Saves default data use in JIRA issue creation dialog- Specified by:
saveJiraIssueDefaults
in interfaceBambooUserManager
- Parameters:
user
- userjiraIssueDefaults
- default data formatted as JSON string
-
removeMembership
public boolean removeMembership(com.atlassian.user.Group group, com.atlassian.user.User user)
- Specified by:
removeMembership
in interfacebucket.user.UserAccessor
- Overrides:
removeMembership
in classbucket.user.DefaultUserAccessor
-
addMembershipWithConfirmation
public boolean addMembershipWithConfirmation(com.atlassian.user.Group group, com.atlassian.user.User user)
- Specified by:
addMembershipWithConfirmation
in interfaceBambooUserManager
- Returns:
- true iff operation successful
-
setAuthorDao
public void setAuthorDao(AuthorDao authorDao)
-
setCommentDao
public void setCommentDao(CommentDao commentDao)
-
setLabelDao
public void setLabelDao(LabelDao labelDao)
-
setTokenDao
public void setTokenDao(PasswordResetTokenDao tokenDao)
-
setAclService
public void setAclService(HibernateMutableAclService aclService)
-
setAclAuthorizationStrategy
public void setAclAuthorizationStrategy(org.acegisecurity.acls.domain.AclAuthorizationStrategy aclAuthorizationStrategy)
-
setLoginInformationManager
public void setLoginInformationManager(LoginInformationManager loginInformationManager)
-
setRememberMeTokenDao
public void setRememberMeTokenDao(com.atlassian.seraph.spi.rememberme.RememberMeTokenDao rememberMeTokenDao)
-
setPropertySetDao
public void setPropertySetDao(BambooPropertySetDao propertySetDao)
-
setFilteredGroupsProvider
public void setFilteredGroupsProvider(FilteredGroupsProvider filteredGroupsProvider)
-
setFeatureManager
public void setFeatureManager(FeatureManager featureManager)
-
setRecoveryModeService
public void setRecoveryModeService(com.atlassian.crowd.manager.recovery.RecoveryModeService recoveryModeService)
-
setAccessTokenDao
public void setAccessTokenDao(AccessTokenDao accessTokenDao)
-
setAvatarService
public void setAvatarService(AvatarService avatarService)
-
setCacheManager
public void setCacheManager(com.atlassian.cache.CacheManager cacheManager)
-
getGroups
public com.atlassian.user.search.page.Pager<com.atlassian.user.Group> getGroups()
- Specified by:
getGroups
in interfacebucket.user.UserAccessor
- Overrides:
getGroups
in classbucket.user.DefaultUserAccessor
-
-