Class UserManager

java.lang.Object
de.dlr.proseo.usermgr.rest.UserManager

@Component @Transactional(isolation=REPEATABLE_READ) public class UserManager extends Object
Service methods required to manage user accounts.
Author:
Dr. Thomas Bassler
  • Field Details

    • userRepository

      @Autowired UserRepository userRepository
      Repository for User objects
  • Constructor Details

    • UserManager

      public UserManager()
  • Method Details

    • toModelUser

      static User toModelUser(RestUser restUser) throws IllegalArgumentException
      Convert a user from REST format to the prosEO data model format (including directly assigned authorities)
      Parameters:
      restUser - the REST user to convert
      Returns:
      the converted model user
      Throws:
      IllegalArgumentException - if an invalid authority value was given
    • toRestUser

      static RestUser toRestUser(User modelUser)
      Convert a user from prosEO data model format to REST format (including directly assigned authorities)
      Parameters:
      modelUser - the model user to convert
      Returns:
      the converted REST user
    • createUser

      public RestUser createUser(RestUser restUser) throws IllegalArgumentException
      Create a user (optionally with direct authorities)
      Parameters:
      restUser - a Json representation of the new user
      Returns:
      a Json representation of the user after creation (with ACL security identity ID)
      Throws:
      IllegalArgumentException - if any of the input data was invalid
    • getUsers

      public List<RestUser> getUsers(String mission, Integer recordFrom, Integer recordTo) throws jakarta.persistence.NoResultException, org.springframework.web.client.HttpClientErrorException
      Get users by mission
      Parameters:
      mission - the mission code
      recordFrom - first record of filtered and ordered result to return
      recordTo - last record of filtered and ordered result to return
      Returns:
      a list of Json objects representing the users authorized for the given mission
      Throws:
      jakarta.persistence.NoResultException - if no user is found for the given mission
      org.springframework.web.client.HttpClientErrorException - if the result list exceeds a configured maximum
    • getUserByName

      public RestUser getUserByName(String username) throws IllegalArgumentException, jakarta.persistence.NoResultException
      Get a user by name
      Parameters:
      username - the user name
      Returns:
      a Json object corresponding to the user found
      Throws:
      IllegalArgumentException - if no user name was given
      jakarta.persistence.NoResultException - if no user with the given name exists
    • deleteUserByName

      public void deleteUserByName(String username) throws jakarta.persistence.EntityNotFoundException, RuntimeException
      Delete a user by user name
      Parameters:
      username - the name of the user to delete
      Throws:
      jakarta.persistence.EntityNotFoundException - if the user to delete does not exist in the database
      RuntimeException - if the deletion was not performed as expected
    • modifyUser

      public RestUser modifyUser(String username, RestUser restUser) throws jakarta.persistence.EntityNotFoundException, IllegalArgumentException, UserManager.NotModifiedException
      Update a user by user name If the password is changed, the password expiration date will be updated according to the password expiration period configured. Note: This method cannot detect, whether a password was actually changed, because due to the BCrypt algorithm used the same password may yield different salted hashes with each encryption run. It is in the responsibility of the calling component to make sure that the password was indeed altered (and that it conforms to any applicable password policy).
      Parameters:
      username - the name of the user to update
      restUser - a Json object containing the modified (and unmodified) attributes
      Returns:
      a response containing a Json object corresponding to the user after modification
      Throws:
      jakarta.persistence.EntityNotFoundException - if no user with the given user name exists
      IllegalArgumentException - if any of the input data was invalid
      UserManager.NotModifiedException - if the user data was not modified (input data same as database data)
    • countUsers

      public String countUsers(String mission)
      Count the users matching the specified mission, if any
      Parameters:
      mission - the mission code
      Returns:
      the number of users found as string