private AuthenticatedUser authenticateUser ( Credentials credentials ) throws GuacamoleException { GuacamoleCredentialsException authFailure = null ; // Attempt authentication against each AuthenticationProvider for ( AuthenticationProvider authProvider : authProviders ) { // Attempt authentication try { AuthenticatedUser authenticatedUser = authProvider . authenticateUser ( credentials ) ; if ( authenticatedUser != null ) return authenticatedUser ; } // First failure takes priority for now catch ( GuacamoleCredentialsException e ) { if ( authFailure == null ) authFailure = e ; } } // If a specific failure occured, rethrow that if ( authFailure != null ) throw authFailure ; // Otherwise, request standard username/password throw new GuacamoleInvalidCredentialsException ( "Permission Denied." , CredentialsInfo . USERNAME_PASSWORD ) ; }
Attempts authentication against all AuthenticationProviders in order using the provided credentials . The first authentication failure takes priority but remaining AuthenticationProviders are attempted . If any AuthenticationProvider succeeds the resulting AuthenticatedUser is returned and no further AuthenticationProviders are tried .