@Transactional public interface UserService extends OpenmrsService
List<User> users = Context.getUserService().getAllUsers();
Context
Modifier and Type | Method and Description |
---|---|
void |
changeHashedPassword(User user,
String hashedPassword,
String salt)
Changes the current user's password directly.
|
void |
changePassword(String pw,
String pw2)
Changes the current user's password.
|
void |
changePassword(User u,
String pw)
Changes the
user |
void |
changeQuestionAnswer(String pw,
String q,
String a)
Changes the current user's secret question and answer.
|
void |
changeQuestionAnswer(User u,
String question,
String answer)
Changes the passed user's secret question and answer.
|
User |
createUser(User user,
String password)
Deprecated.
replaced by
saveUser(User, String) |
void |
deleteUser(User user)
Deprecated.
use
purgeUser(User) |
List<User> |
findUsers(String name,
List<String> roles,
boolean includeVoided)
Deprecated.
|
List<User> |
findUsers(String givenName,
String familyName,
boolean includeVoided)
Deprecated.
|
String |
generateSystemId()
Get/generate/find the next system id to be doled out.
|
List<Privilege> |
getAllPrivileges()
Returns all privileges currently possible for any User
|
List<Role> |
getAllRoles()
Returns all roles currently possible for any User
|
List<User> |
getAllUsers()
Returns all users in the system
|
List<User> |
getAllUsers(List<Role> roles,
boolean includeVoided)
Deprecated.
|
Integer |
getCountOfUsers(String name,
List<Role> roles,
boolean includeRetired)
Return the number of users with a matching name or system id and have at least one of the
given roles assigned to them
|
List<Role> |
getInheritingRoles(Role role)
Deprecated.
|
Privilege |
getPrivilege(String p)
Returns Privilege in the system with given String privilege
|
Privilege |
getPrivilegeByUuid(String uuid)
Get Privilege by its UUID
|
List<Privilege> |
getPrivileges()
Deprecated.
|
Role |
getRole(String r)
Returns role object with given string role
|
Role |
getRoleByUuid(String uuid)
Get Role by its UUID
|
List<Role> |
getRoles()
Deprecated.
use
getAllRoles() |
User |
getUser(Integer userId)
Get user by internal user identifier.
|
User |
getUserByUsername(String username)
Get user by username (user's login identifier)
|
User |
getUserByUuid(String uuid)
Get user by the given uuid.
|
List<User> |
getUsers()
Deprecated.
use
getAllUsers() |
List<User> |
getUsers(String nameSearch,
List<Role> roles,
boolean includeVoided)
Return a list of users sorted by personName (see
PersonByNameComparator ) if any part
of the search matches first/last/system id and the user has one at least one of the given
roles assigned to them |
List<User> |
getUsers(String name,
List<Role> roles,
boolean includeRetired,
Integer start,
Integer length)
Return a batch of users of a specific size sorted by personName (see
PersonByNameComparator ) if any part of the search matches first/last/system id and
the user has one at least one of the given roles assigned to them. |
List<User> |
getUsersByName(String givenName,
String familyName,
boolean includeVoided)
Search for a list of users by exact first name and last name.
|
List<User> |
getUsersByPerson(Person person,
boolean includeRetired)
Get all user accounts that belong to a given person.
|
List<User> |
getUsersByRole(Role role)
Get users by role granted
|
void |
grantUserRole(User user,
Role role)
Deprecated.
|
boolean |
hasDuplicateUsername(User user)
true/false if username or systemId is already in db in username or system_id columns
|
boolean |
isSecretAnswer(User u,
String answer)
Compares
answer against the user 's secret answer. |
void |
notifyPrivilegeListeners(User user,
String privilege,
boolean hasPrivilege)
Notifies privilege listener beans about any privilege check.
|
void |
purgePrivilege(Privilege privilege)
Completely remove a privilege from the database
|
void |
purgeRole(Role role)
Complete remove a role from the database
|
void |
purgeUser(User user)
Completely remove a location from the database (not reversible).
|
void |
purgeUser(User user,
boolean cascade)
Completely remove a user from the database (not reversible).
|
User |
removeUserProperty(User user,
String key)
Removes the property denoted by
key from the user 's properties. |
User |
retireUser(User user,
String reason)
Deactive a user account so that it can no longer log in.
|
void |
revokeUserRole(User user,
Role role)
Deprecated.
|
Privilege |
savePrivilege(Privilege privilege)
Save the given privilege in the database
|
Role |
saveRole(Role role)
Save the given role in the database
|
User |
saveUser(User user,
String password)
Saves a user to the database.
|
User |
setUserProperty(User user,
String key,
String value)
Adds the
key /value pair to the given user . |
User |
unretireUser(User user)
Clears retired flag for a user.
|
User |
unvoidUser(User user)
Deprecated.
|
void |
updateUser(User user)
Deprecated.
replaced by
saveUser(User, String) |
User |
voidUser(User user,
String reason)
Deprecated.
|
onShutdown, onStartup
@Authorized(value={"Add Users","Edit Users"}) @Logging(ignoredArgumentIndexes=1) User saveUser(User user, String password) throws APIException
user
- password
- APIException
@Deprecated @Authorized(value="Add Users") @Logging(ignoredArgumentIndexes=1) User createUser(User user, String password) throws APIException
saveUser(User, String)
APIException
saveUser(User, String)
@Transactional(readOnly=true) @Authorized(value="View Users") User getUser(Integer userId) throws APIException
userId
- internal identifierAPIException
@Transactional(readOnly=true) @Authorized(value="View Users") User getUserByUuid(String uuid) throws APIException
uuid
- APIException
@Transactional(readOnly=true) @Authorized(value="View Users") User getUserByUsername(String username) throws APIException
username
- user's identifier used for authenticationAPIException
@Transactional(readOnly=true) @Authorized(value="View Users") boolean hasDuplicateUsername(User user) throws APIException
user
- User to compareAPIException
@Transactional(readOnly=true) @Authorized(value="View Users") List<User> getUsersByRole(Role role) throws APIException
role
- Role that the Users must have to be returnedAPIException
@Deprecated @Authorized(value="Edit Users") void updateUser(User user) throws APIException
saveUser(User, String)
user
to the database.user
- APIException
saveUser(User, String)
@Deprecated @Authorized(value="Edit Users") void grantUserRole(User user, Role role) throws APIException
User.addRole(Role)
APIException
@Deprecated @Authorized(value="Edit Users") void revokeUserRole(User user, Role role) throws APIException
User.removeRole(Role)
APIException
@Deprecated @Authorized(value="Edit Users") User voidUser(User user, String reason) throws APIException
retireUser(User, String)
user
- reason
- APIException
@Deprecated @Authorized(value="Edit Users") User unvoidUser(User user) throws APIException
unretireUser(User)
user
- APIException
@Authorized(value="Edit Users") User retireUser(User user, String reason) throws APIException
user
- reason
- APIException
@Authorized(value="Edit Users") User unretireUser(User user) throws APIException
user
- reason
- APIException
@Deprecated @Authorized(value="Delete Users") void deleteUser(User user) throws APIException
purgeUser(User)
APIException
voidUser(User, String)
,
purgeUser(User)
@Authorized(value="Purge Users") void purgeUser(User user) throws APIException
user
- the User to remove from the database.APIException
@Authorized(value="Purge Users") void purgeUser(User user, boolean cascade) throws APIException
Users
should be
voided and not deleted altogether (since many foreign key constraints
depend on users, deleting a user would require deleting all traces, and any historical trail
would be lost). This method only clears user roles and attempts to delete the user record. If
the user has been included in any other parts of the database (through a foreign key), the
attempt to delete the user will violate foreign key constraints and fail.cascade
- true
to delete associated contentAPIException
@Deprecated @Transactional(readOnly=true) List<Privilege> getPrivileges() throws APIException
getAllPrivileges()
APIException
@Transactional(readOnly=true) List<Privilege> getAllPrivileges() throws APIException
APIException
@Deprecated @Transactional(readOnly=true) List<Role> getRoles() throws APIException
getAllRoles()
APIException
@Transactional(readOnly=true) List<Role> getAllRoles() throws APIException
APIException
@Deprecated @Transactional(readOnly=true) List<Role> getInheritingRoles(Role role) throws APIException
Role.getInheritedRoles()
APIException
@Authorized(value="Manage Roles") Role saveRole(Role role) throws APIException
role
- Role to updateAPIException
@Authorized(value="Purge Roles") void purgeRole(Role role) throws APIException
role
- Role to delete from the databaseAPIException
@Authorized(value="Manage Privileges") Privilege savePrivilege(Privilege privilege) throws APIException
privilege
- Privilege to updateAPIException
@Authorized(value="Purge Privileges") void purgePrivilege(Privilege privilege) throws APIException
privilege
- Privilege to deleteAPIException
@Transactional(readOnly=true) Role getRole(String r) throws APIException
APIException
@Transactional(readOnly=true) Role getRoleByUuid(String uuid) throws APIException
uuid
- APIException
@Transactional(readOnly=true) Privilege getPrivilege(String p) throws APIException
APIException
@Transactional(readOnly=true) Privilege getPrivilegeByUuid(String uuid) throws APIException
uuid
- APIException
@Deprecated @Transactional(readOnly=true) @Authorized(value="View Users") List<User> getUsers() throws APIException
getAllUsers()
APIException
@Transactional(readOnly=true) @Authorized(value="View Users") List<User> getAllUsers() throws APIException
APIException
@Authorized(value="Edit User Passwords") @Logging(ignoredArgumentIndexes=1) void changePassword(User u, String pw) throws APIException
user's password
** Restricted to Super User access**
u
- userpw
- new passwordAPIException
@Logging(ignoredArgumentIndexes={0,1}) void changePassword(String pw, String pw2) throws APIException
pw
- current passwordpw2
- new passwordAPIException
@Authorized(value="Edit User Passwords") void changeHashedPassword(User user, String hashedPassword, String salt) throws APIException
user
- the user whose password you want to changehashedPassword
- - the already hashed password to storesalt
- - the salt which should be used with this hashed passwordAPIException
@Authorized(value="Edit User Passwords") @Logging(ignoredArgumentIndexes={1,2}) void changeQuestionAnswer(User u, String question, String answer) throws APIException
u
- User to changequestion
- answer
- APIException
@Logging(ignoreAllArgumentValues=true) void changeQuestionAnswer(String pw, String q, String a) throws APIException
pw
- user's passwordq
- questiona
- answerAPIException
@Transactional(readOnly=true) @Logging(ignoredArgumentIndexes=1) boolean isSecretAnswer(User u, String answer) throws APIException
answer
against the user
's secret answer.u
- useranswer
- APIException
@Transactional(readOnly=true) @Authorized(value="View Users") List<User> getUsers(String nameSearch, List<Role> roles, boolean includeVoided) throws APIException
PersonByNameComparator
) if any part
of the search matches first/last/system id and the user has one at least one of the given
roles
assigned to themnameSearch
- string to compare to the beginning of user's given/middle/family/family2
namesroles
- all the Roles the user must containincludeVoided
- true/false whether to include voided usersAPIException
@Deprecated @Transactional(readOnly=true) @Authorized(value="View Users") List<User> findUsers(String name, List<String> roles, boolean includeVoided) throws APIException
getUsers(String, List, boolean)
APIException
@Deprecated @Transactional(readOnly=true) @Authorized(value="View Users") List<User> findUsers(String givenName, String familyName, boolean includeVoided) throws APIException
getUsersByName(String, String, boolean)
APIException
@Transactional(readOnly=true) @Authorized(value="View Users") List<User> getUsersByName(String givenName, String familyName, boolean includeVoided) throws APIException
givenName
- familyName
- includeVoided
- APIException
@Transactional(readOnly=true) @Authorized(value="View Users") List<User> getUsersByPerson(Person person, boolean includeRetired) throws APIException
person
- includeRetired
- APIException
@Deprecated @Transactional(readOnly=true) @Authorized(value="View Users") List<User> getAllUsers(List<Role> roles, boolean includeVoided) throws APIException
getUsers(String, List, boolean)
APIException
User setUserProperty(User user, String key, String value) throws APIException
key
/value
pair to the given user
.
Implementations of this method should handle privileges
user
- key
- value
- APIException
User removeUserProperty(User user, String key) throws APIException
key
from the user
's properties.
Implementations of this method should handle privilegesuser
- key
- APIException
String generateSystemId()
@Transactional(readOnly=true) @Authorized(value="View Users") List<User> getUsers(String name, List<Role> roles, boolean includeRetired, Integer start, Integer length) throws APIException
PersonByNameComparator
) if any part of the search matches first/last/system id and
the user has one at least one of the given roles
assigned to them. If start and
length are not specified, then all matches are returned, If name is empty or null, then all
all users will be returned taking into consideration the values of start and length
arguments.name
- string to compare to the beginning of user's given/middle/family/family2 namesroles
- all the Roles the user must containincludeRetired
- true/false whether to include voided usersstart
- beginning index for the batchlength
- number of users to return in the batchAPIException
@Transactional(readOnly=true) @Authorized(value="View Users") Integer getCountOfUsers(String name, List<Role> roles, boolean includeRetired)
name
- patient nameroles
- all the Roles the user must containincludeRetired
- Specifies whether voided users should be included@Transactional(readOnly=true) void notifyPrivilegeListeners(User user, String privilege, boolean hasPrivilege)
It is called by UserContext.hasPrivilege(java.lang.String)
.
user
- the authenticated user or null
if not authenticatedprivilege
- the checked privilegehasPrivilege
- true
if the authenticated user has the required privilege or if it is a proxy privilegePrivilegeListener
Copyright © 2018 OpenMRS LLC.. All Rights Reserved.