public AuthenticatedUser authenticateUser(Credentials credentials)
            throws GuacamoleException {

        // Pull UserData from credentials, if possible
        UserData userData = userDataService.fromCredentials(credentials);
        if (userData == null)
            throw new GuacamoleInvalidCredentialsException("Permission denied.", CredentialsInfo.EMPTY);

        // Update credentials with username provided via JSON for sake of
        // ${GUAC_USERNAME} token
        credentials.setUsername(userData.getUsername());

        // Produce AuthenticatedUser associated with derived UserData
        AuthenticatedUser authenticatedUser = authenticatedUserProvider.get();
        authenticatedUser.init(credentials, userData);
        return authenticatedUser;

    }
Returns an AuthenticatedUser representing the user authenticated by the
given credentials.

@param credentials
    The credentials to use for authentication.

@return
    An AuthenticatedUser representing the user authenticated by the
    given credentials.

@throws GuacamoleException
    If an error occurs while authenticating the user, or if access is
    denied.
extensions/guacamole-auth-json/src/main/java/org/apache/guacamole/auth/json/AuthenticationProviderService.java