public DecoratedUserContext redecorate(DecoratedUserContext decorated,
            UserContext userContext, AuthenticatedUser authenticatedUser,
            Credentials credentials) throws GuacamoleAuthenticationProcessException {

        // If the given DecoratedUserContext contains further decorated layers,
        // redecorate those first
        DecoratedUserContext next = decorated.getDecoratedUserContext();
        if (next != null) {
            return new DecoratedUserContext(decorated,
                    redecorate(next, userContext, authenticatedUser, credentials),
                    authenticatedUser, credentials);
        }

        // If only one layer of decoration is present, simply redecorate that
        // layer
        return new DecoratedUserContext(decorated, userContext,
                authenticatedUser, credentials);

    }
Creates a new DecoratedUserContext, invoking the redecorate() function
of all AuthenticationProviders to reapply decoration. Decoration by each
AuthenticationProvider will occur in the order that the AuthenticationProviders
were loaded. Only AuthenticationProviders which did not originate the given
UserContext will be used.

@param decorated
    The DecoratedUserContext associated with an older version of the
    given UserContext.

@param userContext
    The new version of the UserContext which should be decorated.

@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 new DecoratedUserContext which has been decorated by all
    AuthenticationProviders.

@throws GuacamoleAuthenticationProcessException
    If any AuthenticationProvider fails while decorating the UserContext.
guacamole/src/main/java/org/apache/guacamole/rest/auth/DecorationService.java