The framework provides a default implementation of this service, o.a.c.viewer.common.model.userprofile.UserProfileUiServiceDefault.
This returns the user profile name based upon whether the real name is available, and whether the user is currently being impersonated.