public ModeledAuthenticatedUser retrieveAuthenticatedUser(AuthenticationProvider authenticationProvider,
            Credentials credentials) throws GuacamoleException {

        // Get username and password
        String username = credentials.getUsername();
        String password = credentials.getPassword();

        // Retrieve corresponding user model, if such a user exists
        UserModel userModel = userMapper.selectOne(username,
                getCaseSensitivity());
        if (userModel == null)
            return null;

        // Verify provided password is correct
        byte[] hash = encryptionService.createPasswordHash(password, userModel.getPasswordSalt());
        if (!Arrays.equals(hash, userModel.getPasswordHash()))
            return null;

        // Create corresponding user object, set up cyclic reference
        ModeledUser user = getObjectInstance(null, userModel);
        user.setCurrentUser(new ModeledAuthenticatedUser(authenticationProvider, user, credentials));

        // Return now-authenticated user
        return user.getCurrentUser();

    }
Retrieves the user corresponding to the given credentials from the
database. Note that this function will not enforce any additional
account restrictions, including explicitly disabled accounts,
scheduling, and password expiration. It is the responsibility of the
caller to enforce such restrictions, if desired.

@param authenticationProvider
    The AuthenticationProvider on behalf of which the user is being
    retrieved.

@param credentials
    The credentials to use when locating the user.

@return
    An AuthenticatedUser containing the existing ModeledUser object if
    the credentials given are valid, null otherwise.

@throws GuacamoleException
    If the provided credentials to not conform to expectations.
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/UserService.java