Package org.onebusaway.users.services
Interface UserService
-
- All Known Implementing Classes:
UserServiceImpl
public interface UserServiceService methods for performing operations on user accounts.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description UserIndexaddUserIndexToUser(User user, UserIndexKey key, String credentials)Add aUserIndexwith the specified id and credentials to an existing user, returning the new index.voidcancelDeleteStaleUsers()Cancel the task to delete state users (started withdeleteStaleUsers()) if it is running.voidclearPhoneNumberRegistration(UserIndexKey userIndexKey)Reset a previous call toregisterPhoneNumber(User, String)for the specified userUserIndexcompletePhoneNumberRegistration(UserIndex userIndex, String registrationCode)Complete phone number registration.voiddeleteStaleUsers()Deletes stale users from the system.voiddeleteUser(User user)Delete the specified user.voiddisableAdminRoleForUser(User user, boolean onlyIfOtherAdmins)Remove the admin role for a User.voidenableAdminRoleForUser(User user, boolean onlyIfNoOtherAdmins)Enable the admin role for a User.List<Integer>getAllUserIds()List<Integer>getAllUserIdsInRange(int offset, int limit)UserBeangetAnonymousUser()IntegergetApiKeyCount()List<User>getApiKeys(int start, int maxResults)LonggetMinApiRequestIntervalForKey(String key, boolean forceRefresh)intgetNumberOfAdmins()longgetNumberOfStaleUsers()intgetNumberOfUsers()UserIndexgetOrCreateUserForIndexKey(UserIndexKey key, String credentials, boolean isAnonymous)UserIndexgetOrCreateUserForUsernameAndPassword(String username, String password)UserBeangetUserAsBean(User user)UsergetUserForId(int userId)UserIndexgetUserIndexForId(UserIndexKey key)UserIndexgetUserIndexForUsername(String username)* @return the user index from the username stringList<String>getUserIndexKeyValuesForKeyType(String keyType)UserPropertiesMigrationStatusgetUserPropertiesMigrationStatus()booleanhasPhoneNumberRegistration(UserIndexKey userIndexKey)booleanisAdministrator(User user)Is the specified user an administrator?booleanisAnonymous(User user)Is the specified user anonymous?booleanisDeletingStaleUsers()voidmergeUsers(User sourceUser, User targetUser)Given two user accounts, merge the two users into one.StringregisterPhoneNumber(User user, String phoneNumber)Begin phone number registration for the specified user.voidremoveUserIndexForUser(User user, UserIndexKey key)Remove theUserIndexwith the specified id from the user.voidresetUser(User user)Reset all properties for the specified user to default values.voidsetCredentialsForUserIndex(UserIndex userIndex, String credentials)Update the credentials for the specified user indexvoidsetPasswordForUsernameUserIndex(UserIndex userIndex, String password)Update the password for theUserIndexTypes.USERNAMEuser indexvoidstartUserPropertiesMigration()Start the user property migration task - seeUserPropertiesMigration
-
-
-
Method Detail
-
getNumberOfUsers
int getNumberOfUsers()
- Returns:
- the number of users in the system
-
getAllUserIdsInRange
List<Integer> getAllUserIdsInRange(int offset, int limit)
- Parameters:
offset- index offset into the full user id listlimit- length of subset of the user id list to return- Returns:
- a subset of the list of all user ids in the system
-
getUserForId
User getUserForId(int userId)
- Parameters:
userId- seeUser.getId()- Returns:
- the user with the specifed id, or null if not found
-
getNumberOfAdmins
int getNumberOfAdmins()
- Returns:
- the number of users with the admin role set
-
getUserIndexKeyValuesForKeyType
List<String> getUserIndexKeyValuesForKeyType(String keyType)
- Returns:
- the set of UserIndexKey values having the specified UserIndexKey type
-
getApiKeyCount
Integer getApiKeyCount()
- Returns:
- the number (count) of Users of type=API_KEY
-
getApiKeys
List<User> getApiKeys(int start, int maxResults)
- Returns:
- the list of Users of type=API_KEY for maxResults of users staring with 'start'
-
getUserIndexForId
UserIndex getUserIndexForId(UserIndexKey key)
- Parameters:
key- seeUserIndex.getId()- Returns:
- the user index with the specified key, or null if not found
-
getUserIndexForUsername
UserIndex getUserIndexForUsername(String username)
* @return the user index from the username string
-
getOrCreateUserForIndexKey
UserIndex getOrCreateUserForIndexKey(UserIndexKey key, String credentials, boolean isAnonymous)
- Parameters:
key- seeUserIndex.getId()credentials-UserIndex.getCredentials()isAnonymous- is a newly created user anonymous -User.getRoles()- Returns:
- an existing user index with the specified key if it already exists, or a newly created user index (and underlying user) with the specified properties
-
getOrCreateUserForUsernameAndPassword
UserIndex getOrCreateUserForUsernameAndPassword(String username, String password)
- Parameters:
username-password-- Returns:
- an existing user index with the specified username if it already exists, or a newly created user index (and underlying user) with the specified username and password credentials
-
addUserIndexToUser
UserIndex addUserIndexToUser(User user, UserIndexKey key, String credentials)
Add aUserIndexwith the specified id and credentials to an existing user, returning the new index. If an index with the specified id already exists, it is returned instead.- Parameters:
user- the target userkey- seeUserIndex.getId()credentials- seeUserIndex.getCredentials()- Returns:
- the newly attached user index, or an existing index if already attached
-
removeUserIndexForUser
void removeUserIndexForUser(User user, UserIndexKey key)
Remove theUserIndexwith the specified id from the user.- Parameters:
user-key- seeUserIndex.getId()
-
setCredentialsForUserIndex
void setCredentialsForUserIndex(UserIndex userIndex, String credentials)
Update the credentials for the specified user index- Parameters:
userIndex-credentials-
-
setPasswordForUsernameUserIndex
void setPasswordForUsernameUserIndex(UserIndex userIndex, String password)
Update the password for theUserIndexTypes.USERNAMEuser index- Parameters:
userIndex-password-
-
getUserAsBean
UserBean getUserAsBean(User user)
- Parameters:
user-- Returns:
- the specified user as a user bean object
-
getAnonymousUser
UserBean getAnonymousUser()
- Returns:
- an anonymous default user object
-
deleteUser
void deleteUser(User user)
Delete the specified user. Will delete anyUserIndexobjects pointing to that user as well.- Parameters:
user-
-
resetUser
void resetUser(User user)
Reset all properties for the specified user to default values.- Parameters:
user-
-
isAnonymous
boolean isAnonymous(User user)
Is the specified user anonymous? See the discussion inStandardAuthoritiesService- Parameters:
user-- Returns:
- true if the user is anonymous, otherwise false
-
isAdministrator
boolean isAdministrator(User user)
Is the specified user an administrator? See the discussion inStandardAuthoritiesService- Parameters:
user-- Returns:
- true if the user is an administrator, otherwise false
-
enableAdminRoleForUser
void enableAdminRoleForUser(User user, boolean onlyIfNoOtherAdmins)
Enable the admin role for a User. For admin bootstrapping, we have a check that will only allow you to set an admin role if no other admins exist. This would be useful for marking the very first user in a system as admin.- Parameters:
user- the user to mark as an adminonlyIfNoOtherAdmins- when true, will only add the admin role if no other users are marked as admin
-
disableAdminRoleForUser
void disableAdminRoleForUser(User user, boolean onlyIfOtherAdmins)
Remove the admin role for a User.- Parameters:
user-onlyIfOtherAdmins- when true, will only remove the admin role if at least one other user is marked as admin
-
mergeUsers
void mergeUsers(User sourceUser, User targetUser)
Given two user accounts, merge the two users into one. The source user is deleted while the target user is updated. Properties in the target user take presedence over properties in the source user if there is overlap.- Parameters:
sourceUser- this user will be deletedtargetUser- this user will be updated and kept
-
startUserPropertiesMigration
void startUserPropertiesMigration()
Start the user property migration task - seeUserPropertiesMigration
-
getUserPropertiesMigrationStatus
UserPropertiesMigrationStatus getUserPropertiesMigrationStatus()
- Returns:
- the status for the user properties migration task
-
registerPhoneNumber
String registerPhoneNumber(User user, String phoneNumber)
Begin phone number registration for the specified user. Returns a code that the user must specify in a call tocompletePhoneNumberRegistration(UserIndex, String)to verify that they do in fact own that phone number.- Parameters:
user-phoneNumber-- Returns:
- the code that must be supplied in a subsequent call to
completePhoneNumberRegistration(UserIndex, String)
-
hasPhoneNumberRegistration
boolean hasPhoneNumberRegistration(UserIndexKey userIndexKey)
- Parameters:
userIndexKey-- Returns:
- true if a phone number registration task is pending for the specified user
-
completePhoneNumberRegistration
UserIndex completePhoneNumberRegistration(UserIndex userIndex, String registrationCode)
Complete phone number registration. If the registrationCode matches one returned in a previous call toregisterPhoneNumber(User, String), then registration is completed by creating a newUserIndexwith typeUserIndexTypes.PHONE_NUMBERwith the phone number specified in the previous call to register phone number.- Parameters:
userIndex-registrationCode-- Returns:
- the newly created
UserIndexobject for the phone number user index
-
clearPhoneNumberRegistration
void clearPhoneNumberRegistration(UserIndexKey userIndexKey)
Reset a previous call toregisterPhoneNumber(User, String)for the specified user- Parameters:
userIndexKey-
-
getMinApiRequestIntervalForKey
Long getMinApiRequestIntervalForKey(String key, boolean forceRefresh)
- Parameters:
key- an API keyforceRefresh- guarantees that supplied value has not been cached- Returns:
- the minimum interval between requests in milliseconds for the key, or null for a key with no permission to access the API
-
deleteStaleUsers
void deleteStaleUsers()
Deletes stale users from the system. Stale users have a last access time of more than a month ago.
-
isDeletingStaleUsers
boolean isDeletingStaleUsers()
- Returns:
- true if the task to delete stale users is currently running.
-
cancelDeleteStaleUsers
void cancelDeleteStaleUsers()
Cancel the task to delete state users (started withdeleteStaleUsers()) if it is running.
-
getNumberOfStaleUsers
long getNumberOfStaleUsers()
- Returns:
- the number of user accounts that have not been accessed in the last month
-
-