Package services.gui
Class UserService
- java.lang.Object
-
- services.gui.UserService
-
@Singleton public class UserService extends java.lang.ObjectService class mostly for Users controller. Handles everything around User.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringADMIN_NAMEDefault admin name; the admin user is created during the first initialization of JATOS; don't confuse admin user with the Role ADMINstatic java.lang.StringADMIN_PASSWORDDefault admin password; the admin user is created during the first initialization of JATOS; don't confuse admin user with the Role ADMINstatic java.lang.StringADMIN_USERNAMEDefault admin username; the admin user is created during the first initialization of JATOS; don't confuse admin user with the Role ADMIN
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UserPropertiesbindToProperties(User user)UserbindToUserAndPersist(NewUserProperties props)Creates a user, sets password hash and persists them.java.util.Set<User.Role>changeAdminRole(java.lang.String normalizedUsername, java.lang.Boolean admin)Adds or removes an ADMIN role of the user with the given username and persists the change.java.util.Set<User.Role>changeSuperuserRole(java.lang.String normalizedUsername, boolean superuser)Adds or removes SUPERUSER role of the user with the given username and persists the change.voidcreateAndPersistUser(User user, java.lang.String password, boolean adminRole, User.AuthMethod authMethod)Creates a user, sets password hash and persists them.UserregisterUser(NewUserProperties newUserProperties)voidremoveUser(java.lang.String normalizedUsername)voidremoveUser(User user)Removes the User belonging to the given username from the database.UserretrieveUser(java.lang.String normalizedUsername)Retrieves the user with the given username from the DB.voidsetLastSeen(User user)Sets the time of the last activity of the given uservoidsetLastSignin(java.lang.String normalizedUsername)voidtoggleActive(java.lang.String normalizedUsername, boolean active)voidtoggleActive(User user, boolean active)voidupdatePassword(User user, java.lang.String newPassword)Change password and persist user.voidupdateUser(User user, UserProperties props)
-
-
-
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
-
registerUser
public User registerUser(NewUserProperties newUserProperties) throws ForbiddenException
- Throws:
ForbiddenException
-
bindToUserAndPersist
public User bindToUserAndPersist(NewUserProperties props)
Creates a user, sets password hash and persists them. Creates and persists a JatosWorker for the user.
-
bindToProperties
public UserProperties bindToProperties(User 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.
-
updateUser
public void updateUser(User user, UserProperties props)
-
updatePassword
public void updatePassword(User user, java.lang.String newPassword)
Change password and persist user.
-
toggleActive
public void toggleActive(java.lang.String normalizedUsername, boolean active) throws NotFoundException, ForbiddenException- Throws:
NotFoundExceptionForbiddenException
-
toggleActive
public void toggleActive(User user, boolean active) throws ForbiddenException
- Throws:
ForbiddenException
-
changeSuperuserRole
public java.util.Set<User.Role> changeSuperuserRole(java.lang.String normalizedUsername, boolean superuser) throws NotFoundException, ForbiddenException
Adds or removes SUPERUSER role of the user with the given username and persists the change.- Throws:
NotFoundExceptionForbiddenException
-
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:
NotFoundExceptionForbiddenException
-
setLastSignin
public void setLastSignin(java.lang.String normalizedUsername)
-
removeUser
public void removeUser(java.lang.String normalizedUsername) throws NotFoundException, ForbiddenException, java.io.IOException- Throws:
NotFoundExceptionForbiddenExceptionjava.io.IOException
-
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
-
-