private List < DecoratedUserContext > getUserContexts ( GuacamoleSession existingSession , AuthenticatedUser authenticatedUser , Credentials credentials ) throws GuacamoleException { List < DecoratedUserContext > userContexts = new ArrayList < DecoratedUserContext > ( authProviders . size ( ) ) ; // If UserContexts already exist, update them and add to the list if ( existingSession != null ) { // Update all old user contexts List < DecoratedUserContext > oldUserContexts = existingSession . getUserContexts ( ) ; for ( DecoratedUserContext userContext : oldUserContexts ) { UserContext oldUserContext = userContext . getUndecoratedUserContext ( ) ; // Update existing UserContext AuthenticationProvider authProvider = oldUserContext . getAuthenticationProvider ( ) ; UserContext updatedUserContext = authProvider . updateUserContext ( oldUserContext , authenticatedUser , credentials ) ; // Add to available data, if successful if ( updatedUserContext != null ) userContexts . add ( decorationService . redecorate ( userContext , updatedUserContext , authenticatedUser , credentials ) ) ; // If unsuccessful, log that this happened, as it may be a bug else logger . debug ( "AuthenticationProvider \"{}\" retroactively destroyed its UserContext." , authProvider . getClass ( ) . getName ( ) ) ; } } // Otherwise, create new UserContexts from available AuthenticationProviders else { // Get UserContexts from each available AuthenticationProvider for ( AuthenticationProvider authProvider : authProviders ) { // Generate new UserContext UserContext userContext = authProvider . getUserContext ( authenticatedUser ) ; // Add to available data, if successful if ( userContext != null ) userContexts . add ( decorationService . decorate ( userContext , authenticatedUser , credentials ) ) ; } } return userContexts ; }
Returns all UserContexts associated with the given AuthenticatedUser updating existing UserContexts if any . If no UserContexts are yet associated with the given AuthenticatedUser new UserContexts are generated by polling each available AuthenticationProvider .