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 Detail

      • getUser

        User getUser​(String username)
        Get a User from a username. Typically called after login to get a User 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 of Roles 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 all Permissions for the logged in user.
        Parameters:
        username - the username for the user whose permissions should be retrieved
        Returns:
        a list of Permission objects
      • getUsers

        List<User> getUsers()
        Get all users in the database.
        Returns:
        a list of User 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 a User 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 a User 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 a Role in the database.
        Parameters:
        role - the Role to modify in the database
        Returns:
        the roles in the database containing the modified role
      • addRole

        List<Role> addRole​(Role newRole)
        Add a Role to the database.
        Parameters:
        newRole - the Role 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 a Permission in the database.
        Parameters:
        permission - the Permission object to modify in the database
        Returns:
        the permissions in the database containing the modified permission
      • addPermission

        List<Permission> addPermission​(Permission newPermission)
        Add a Permission to the database.
        Parameters:
        newPermission - the Permission to add to the database
        Returns:
        the permissions in the database including the new permission
      • addUserRoles

        Map<String,​List<Role>> addUserRoles​(UserRoles userroles)
        Add one or more roles to a user.
        Parameters:
        userroles - contains the User to add Roles and the roles to add
        Returns:
        the all username to role mappings with the new roles in place
      • removeUserRoles

        Map<String,​List<Role>> removeUserRoles​(UserRoles userroles)
        Remove one or more roles from a user
        Parameters:
        userroles - the User to remove Roles from and the roles to remove
        Returns:
        the all username to role mappings with the removed roles gone
      • 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 - the Role to add permissions to and the list of Permissions 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 - the Role to remove permissions from and the list of Permissions to remove from the role
        Returns:
        all rolename to permission mappings in the database, not including the permissions removed in this operation