Package services.gui

Class UserService


  • @Singleton
    public class UserService
    extends java.lang.Object
    Service class mostly for Users controller. Handles everything around User.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ADMIN_NAME
      Default admin name; the admin user is created during the first initialization of JATOS; don't confuse admin user with the Role ADMIN
      static java.lang.String ADMIN_PASSWORD
      Default admin password; the admin user is created during the first initialization of JATOS; don't confuse admin user with the Role ADMIN
      static java.lang.String ADMIN_USERNAME
      Default admin username; the admin user is created during the first initialization of JATOS; don't confuse admin user with the Role ADMIN
    • Field Detail

      • ADMIN_USERNAME

        public static final java.lang.String ADMIN_USERNAME
        Default admin username; the admin user is created during the first initialization of JATOS; don't confuse admin user with the Role ADMIN
        See Also:
        Constant Field Values
      • ADMIN_PASSWORD

        public static final java.lang.String ADMIN_PASSWORD
        Default admin password; the admin user is created during the first initialization of JATOS; don't confuse admin user with the Role ADMIN
        See Also:
        Constant Field Values
      • ADMIN_NAME

        public static final java.lang.String ADMIN_NAME
        Default admin name; the admin user is created during the first initialization of JATOS; don't confuse admin user with the Role ADMIN
        See Also:
        Constant Field Values
    • Method Detail

      • retrieveUser

        public User retrieveUser​(java.lang.String normalizedUsername)
                          throws NotFoundException
        Retrieves the user with the given username from the DB. Throws an Exception if it doesn't exist.
        Throws:
        NotFoundException
      • bindToUserAndPersist

        public User bindToUserAndPersist​(NewUserProperties props)
        Creates a user, sets password hash and persists them. Creates and persists a JatosWorker for the user.
      • createAndPersistUser

        public void createAndPersistUser​(User user,
                                         java.lang.String password,
                                         boolean adminRole,
                                         User.AuthMethod authMethod)
        Creates a user, sets password hash and persists them. Creates and persists an JatosWorker for the user.
      • updatePassword

        public void updatePassword​(User user,
                                   java.lang.String newPassword)
        Change password and persist user.
      • changeAdminRole

        public java.util.Set<User.Role> changeAdminRole​(java.lang.String normalizedUsername,
                                                        java.lang.Boolean admin)
                                                 throws NotFoundException,
                                                        ForbiddenException
        Adds or removes an ADMIN role of the user with the given username and persists the change. If the parameter admin is true, the ADMIN role will be set, and if it's false, it will be removed. Returns true if the user has the role in the end - or false if he hasn't.
        Throws:
        NotFoundException
        ForbiddenException
      • setLastSignin

        public void setLastSignin​(java.lang.String normalizedUsername)
      • removeUser

        public void removeUser​(User user)
                        throws java.io.IOException
        Removes the User belonging to the given username from the database. It also removes all studies where this user is the last member (which subsequently removes all components, results and the study assets too).
        Throws:
        java.io.IOException
      • setLastSeen

        public void setLastSeen​(User user)
        Sets the time of the last activity of the given user