Interface IUserManager

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean createUser​(java.lang.String username, java.lang.String password)
      Create a user with given username and password.
      boolean deleteUser​(java.lang.String username)
      Delete a user.
      User getUser​(java.lang.String username)
      Get a user object.
      boolean grantPrivilegeToUser​(java.lang.String username, PartialPath path, int privilegeId)
      Grant a privilege on a seriesPath to a user.
      boolean grantRoleToUser​(java.lang.String roleName, java.lang.String username)
      Add a role to a user.
      boolean isUserUseWaterMark​(java.lang.String userName)
      Whether data water-mark is enabled for user 'userName'.
      java.util.List<java.lang.String> listAllUsers()
      List all users in the database.
      void replaceAllUsers​(java.util.Map<java.lang.String,​User> users)
      clear all old users info, replace the old users with the new one.
      void reset()
      Re-initialize this object.
      boolean revokePrivilegeFromUser​(java.lang.String username, PartialPath path, int privilegeId)
      Revoke a privilege on seriesPath from a user.
      boolean revokeRoleFromUser​(java.lang.String roleName, java.lang.String username)
      Revoke a role from a user.
      void setUserUseWaterMark​(java.lang.String userName, boolean useWaterMark)
      Enable or disable data water-mark for user 'userName'.
      boolean updateUserPassword​(java.lang.String username, java.lang.String newPassword)
      Modify the password of a user.
    • Method Detail

      • getUser

        User getUser​(java.lang.String username)
              throws AuthException
        Get a user object.
        Parameters:
        username - The name of the user.
        Returns:
        A user object whose name is username or null if such user does not exist.
        Throws:
        AuthException - if an exception is raised when interacting with the lower storage.
      • createUser

        boolean createUser​(java.lang.String username,
                           java.lang.String password)
                    throws AuthException
        Create a user with given username and password. New users will only be granted no privileges.
        Parameters:
        username - is not null or empty
        password - is not null or empty
        Returns:
        True if the user is successfully created, false when the user already exists.
        Throws:
        AuthException - if the given username or password is illegal.
      • deleteUser

        boolean deleteUser​(java.lang.String username)
                    throws AuthException
        Delete a user.
        Parameters:
        username - the username of the user.
        Returns:
        True if the user is successfully deleted, false if the user does not exists.
        Throws:
        AuthException - .
      • grantPrivilegeToUser

        boolean grantPrivilegeToUser​(java.lang.String username,
                                     PartialPath path,
                                     int privilegeId)
                              throws AuthException
        Grant a privilege on a seriesPath to a user.
        Parameters:
        username - The username of the user to which the privilege should be added.
        path - The seriesPath on which the privilege takes effect. If the privilege is a seriesPath-free privilege, this should be "root".
        privilegeId - An integer that represents a privilege.
        Returns:
        True if the permission is successfully added, false if the permission already exists.
        Throws:
        AuthException - If the user does not exist or the privilege or the seriesPath is illegal.
      • revokePrivilegeFromUser

        boolean revokePrivilegeFromUser​(java.lang.String username,
                                        PartialPath path,
                                        int privilegeId)
                                 throws AuthException
        Revoke a privilege on seriesPath from a user.
        Parameters:
        username - The username of the user from which the privilege should be removed.
        path - The seriesPath on which the privilege takes effect. If the privilege is a seriesPath-free privilege, this should be "root".
        privilegeId - An integer that represents a privilege.
        Returns:
        True if the permission is successfully revoked, false if the permission does not exists.
        Throws:
        AuthException - If the user does not exist or the privilege or the seriesPath is illegal.
      • updateUserPassword

        boolean updateUserPassword​(java.lang.String username,
                                   java.lang.String newPassword)
                            throws AuthException
        Modify the password of a user.
        Parameters:
        username - The user whose password is to be modified.
        newPassword - The new password.
        Returns:
        True if the password is successfully modified, false if the new password is illegal.
        Throws:
        AuthException - If the user does not exists.
      • grantRoleToUser

        boolean grantRoleToUser​(java.lang.String roleName,
                                java.lang.String username)
                         throws AuthException
        Add a role to a user.
        Parameters:
        roleName - The name of the role to be added.
        username - The name of the user to which the role is added.
        Returns:
        True if the role is successfully added, false if the role already exists.
        Throws:
        AuthException - If the user does not exist.
      • revokeRoleFromUser

        boolean revokeRoleFromUser​(java.lang.String roleName,
                                   java.lang.String username)
                            throws AuthException
        Revoke a role from a user.
        Parameters:
        roleName - The name of the role to be removed.
        username - The name of the user from which the role is removed.
        Returns:
        True if the role is successfully removed, false if the role does not exist.
        Throws:
        AuthException - If the user does not exist.
      • listAllUsers

        java.util.List<java.lang.String> listAllUsers()
        List all users in the database.
        Returns:
        A list that contains all users'name.
      • isUserUseWaterMark

        boolean isUserUseWaterMark​(java.lang.String userName)
                            throws AuthException
        Whether data water-mark is enabled for user 'userName'.
        Parameters:
        userName -
        Returns:
        Throws:
        AuthException - if the user does not exist
      • setUserUseWaterMark

        void setUserUseWaterMark​(java.lang.String userName,
                                 boolean useWaterMark)
                          throws AuthException
        Enable or disable data water-mark for user 'userName'.
        Parameters:
        userName -
        useWaterMark -
        Throws:
        AuthException - if the user does not exist.
      • replaceAllUsers

        void replaceAllUsers​(java.util.Map<java.lang.String,​User> users)
                      throws AuthException
        clear all old users info, replace the old users with the new one. The caller should guarantee that no other methods of this interface are invoked concurrently when this method is called.
        Parameters:
        users - new users info
        Throws:
        AuthException