Package no.priv.bang.osgiservice.users
Interface UserManagementService
-
public interface UserManagementService
This is an OSGi service that encapsulates user management Implementations of this interface will typically be used to manage users, groups and roles for a software application. The structure of this interface is based on what's convenient for the implementation of a REST API: JSON-friendly beans are both arguments and return values, and update operations returns updated state in a form that is convenient for e.g. updating a redux model in a react/redux frontend.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description List<Permission>
addPermission(Permission newPermission)
Add aPermission
to the database.List<Role>
addRole(Role newRole)
Add aRole
to the database.Map<String,List<Permission>>
addRolePermissions(RolePermissions rolepermissions)
Add one or more permissions to a role.List<User>
addUser(UserAndPasswords newUserWithPasswords)
Create a new user in the database.Map<String,List<Role>>
addUserRoles(UserRoles userroles)
Add one or more roles to a user.List<Permission>
getPermissions()
Return the list of roles defined in the database.List<Permission>
getPermissionsForUser(String username)
Typically called after login to get the list of allPermission
s for the logged in user.List<Role>
getRoles()
Return the list of roles defined in the database.List<Role>
getRolesForUser(String username)
Typically called after login to get the list ofRole
s for the logged in userMap<String,List<Permission>>
getRolesPermissions()
Get all role to permission mappings in the database.User
getUser(String username)
Get a User from a username.Map<String,List<Role>>
getUserRoles()
Get allUser.getUsername()
toRole
mappings in the database.List<User>
getUsers()
Get all users in the database.List<Permission>
modifyPermission(Permission permission)
Modify aPermission
in the database.List<Role>
modifyRole(Role role)
Modify aRole
in the database.List<User>
modifyUser(User user)
Update a user in the database.Map<String,List<Permission>>
removeRolePermissions(RolePermissions rolepermissions)
Remove one or more permissions from a role.Map<String,List<Role>>
removeUserRoles(UserRoles userroles)
Remove one or more roles from a userList<User>
updatePassword(UserAndPasswords userAndPasswords)
Change the passwords of a user in the database
-
-
-
Method Detail
-
getUser
User getUser(String username)
Get a User from a username. Typically called after login to get aUser
object for the logged in user- Parameters:
username
- the username for the user that is to be retrieved- Returns:
- a
User
object for the user with the username
-
getRolesForUser
List<Role> getRolesForUser(String username)
Typically called after login to get the list ofRole
s for the logged in user- Parameters:
username
- the username for the user whose roles should be retrieved- Returns:
- a list of
Role
objects
-
getPermissionsForUser
List<Permission> getPermissionsForUser(String username)
Typically called after login to get the list of allPermission
s for the logged in user.- Parameters:
username
- the username for the user whose permissions should be retrieved- Returns:
- a list of
Permission
objects
-
modifyUser
List<User> modifyUser(User user)
Update a user in the database. What can be updated, are the username, the email address and the first- and lastnames of the user.- Parameters:
user
- The user object to update. The id property of this object defines what user to update- Returns:
- The list of users in the database after the update of a user
-
updatePassword
List<User> updatePassword(UserAndPasswords userAndPasswords)
Change the passwords of a user in the database- Parameters:
userAndPasswords
- an object containing aUser
used to identify the user the passwords should be changed for and two copies of the new password- Returns:
- The list of users in the database
-
addUser
List<User> addUser(UserAndPasswords newUserWithPasswords)
Create a new user in the database.- Parameters:
newUserWithPasswords
- an object containing aUser
object and two copies of the new password- Returns:
- The list of users in the database including the newly created user
-
getRoles
List<Role> getRoles()
Return the list of roles defined in the database.- Returns:
- a list of
Role
beans
-
modifyRole
List<Role> modifyRole(Role role)
Modify aRole
in the database.- Parameters:
role
- theRole
to modify in the database- Returns:
- the roles in the database containing the modified role
-
addRole
List<Role> addRole(Role newRole)
Add aRole
to the database.- Parameters:
newRole
- theRole
to add- Returns:
- the roles in the database, including the new role
-
getPermissions
List<Permission> getPermissions()
Return the list of roles defined in the database.- Returns:
- a
Permission
objekts
-
modifyPermission
List<Permission> modifyPermission(Permission permission)
Modify aPermission
in the database.- Parameters:
permission
- thePermission
object to modify in the database- Returns:
- the permissions in the database containing the modified permission
-
addPermission
List<Permission> addPermission(Permission newPermission)
Add aPermission
to the database.- Parameters:
newPermission
- thePermission
to add to the database- Returns:
- the permissions in the database including the new permission
-
getUserRoles
Map<String,List<Role>> getUserRoles()
Get allUser.getUsername()
toRole
mappings in the database.- Returns:
- a
Map
from usernames to lists of roles
-
addUserRoles
Map<String,List<Role>> addUserRoles(UserRoles userroles)
Add one or more roles to a user.
-
removeUserRoles
Map<String,List<Role>> removeUserRoles(UserRoles userroles)
Remove one or more roles from a user
-
getRolesPermissions
Map<String,List<Permission>> getRolesPermissions()
Get all role to permission mappings in the database.- Returns:
- a map from rolenames to list of permissions
-
addRolePermissions
Map<String,List<Permission>> addRolePermissions(RolePermissions rolepermissions)
Add one or more permissions to a role.- Parameters:
rolepermissions
- theRole
to add permissions to and the list ofPermission
s to add to the role- Returns:
- all rolename to permission mappings in the database, including the permissions added in this operation
-
removeRolePermissions
Map<String,List<Permission>> removeRolePermissions(RolePermissions rolepermissions)
Remove one or more permissions from a role.- Parameters:
rolepermissions
- theRole
to remove permissions from and the list ofPermission
s to remove from the role- Returns:
- all rolename to permission mappings in the database, not including the permissions removed in this operation
-
-