private static UserContext decorate(AuthenticationProvider authProvider,
            UserContext userContext, AuthenticatedUser authenticatedUser,
            Credentials credentials) throws GuacamoleException {

        // Skip the AuthenticationProvider which produced the UserContext
        // being decorated
        if (authProvider != userContext.getAuthenticationProvider()) {

            // Apply layer of wrapping around UserContext
            UserContext decorated = authProvider.decorate(userContext,
                    authenticatedUser, credentials);

            // Do not allow misbehaving extensions to wipe out the
            // UserContext entirely
            if (decorated != null)
                return decorated;

        }

        return userContext;

    }
private static UserContext decorate ( AuthenticationProvider authProvider , UserContext userContext , AuthenticatedUser authenticatedUser , Credentials credentials ) throws GuacamoleException { if ( authProvider != userContext . getAuthenticationProvider ( ) ) { UserContext decorated = authProvider . decorate ( userContext , authenticatedUser , credentials ) ; if ( decorated != null ) return decorated ; } return userContext ; }
Decorates a newly-created UserContext (as would be returned by
getUserContext()), invoking the decorate() function of the given
AuthenticationProvider to apply an additional layer of decoration. If the
AuthenticationProvider originated the given UserContext, this function
has no effect.

@param authProvider
The AuthenticationProvider which should be used to decorate the
given UserContext.

@param userContext
The UserContext to decorate.

@param authenticatedUser
The AuthenticatedUser identifying the user associated with the given
UserContext.

@param credentials
The credentials associated with the request which produced the given
UserContext.

@return
A UserContext instance which has been decorated (wrapped) by the
given AuthenticationProvider, or the original UserContext if the
given AuthenticationProvider originated the UserContext.

@throws GuacamoleException
If the given AuthenticationProvider fails while decorating the
UserContext.