public static void addLoginNameAlias(String ambariUserName, String loginAlias) {
    ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    if (attr != null) {
      LOG.info("Adding login alias '{}' for user name '{}'", loginAlias, ambariUserName);
      attr.setAttribute(loginAlias, ambariUserName, RequestAttributes.SCOPE_SESSION);
      //save Vice Versa Too
      attr.setAttribute(ambariUserName, loginAlias, RequestAttributes.SCOPE_SESSION);
    }
  }
There are cases when users log-in with a login name that is
define in LDAP and which do not correspond to the user name stored
locally in ambari. These external login names act as an alias to
ambari users name. This method stores in the current http session a mapping
of alias user name to local ambari user name to make possible resolving
login alias to ambari user name.
@param ambariUserName ambari user name for which the alias is to be stored in the session
@param loginAlias The Name with which user logged in Ambari UI.
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AuthorizationHelper.java