@Override
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    if (request instanceof HttpServletRequest) {
      final HttpServletRequest httpServletRequest = (HttpServletRequest) request;
      Matcher userNameMatcher = getUserNameMatcher(httpServletRequest.getRequestURI());

      if (userNameMatcher.find()) {
        String userNameFromUri = URLDecoder.decode(userNameMatcher.group("username"), "UTF-8");
        final String userName = AuthorizationHelper.resolveLoginAliasToUserName(userNameFromUri);

        if (!userNameFromUri.equals(userName)) {
          final String requestUriOverride = String.format("%s%s%s", userNameMatcher.group("pre"), userName, userNameMatcher.group("post"));

          request = new HttpServletRequestWrapper(httpServletRequest) {
            @Override
            public String getRequestURI() {
              return requestUriOverride;
            }
          };

        }
      }
    }

    chain.doFilter(request, response);
  }
The <code>doFilter</code> method of the Filter is called by the
container each time a request/response pair is passed through the
chain due to a client request for a resource at the end of the chain.
The FilterChain passed in to this method allows the Filter to pass
on the request and response to the next entity in the chain.

Verify if this a user related request by checking that the Uri of the request contains
username and resolves the username to actual ambari user name if username
is a login alias.

@param request
@param response
@param chain
ambari-server/src/main/java/org/apache/ambari/server/api/UserNameOverrideFilter.java