code: public ModeledUser retrieveUser(AuthenticationProvider authenticationProvider,
              AuthenticatedUser authenticatedUser) throws GuacamoleException {
  
          // If we already queried this user, return that rather than querying again
          if (authenticatedUser instanceof ModeledAuthenticatedUser)
              return ((ModeledAuthenticatedUser) authenticatedUser).getUser();
  
          // Get username
          String username = authenticatedUser.getIdentifier();
  
          // Retrieve corresponding user model, if such a user exists
          UserModel userModel = userMapper.selectOne(username);
          if (userModel == null)
              return null;
  
          // Create corresponding user object, set up cyclic reference
          ModeledUser user = getObjectInstance(null, userModel);
          user.setCurrentUser(new ModeledAuthenticatedUser(authenticatedUser,
                  authenticationProvider, user));
  
          // Return already-authenticated user
          return user;
  
      }
docs: Retrieves the user corresponding to the given AuthenticatedUser from the
  database.
  
  @param authenticationProvider
  The AuthenticationProvider on behalf of which the user is being
  retrieved.
  
  @param authenticatedUser
  The AuthenticatedUser to retrieve the corresponding ModeledUser of.
  
  @return
  The ModeledUser which corresponds to the given AuthenticatedUser, or
  null if no such user exists.
  
  @throws GuacamoleException
  If a ModeledUser object for the user corresponding to the given
  AuthenticatedUser cannot be created.