code: private static String getResourceIpAddress(HttpAcceptSession acceptSession, String parameterName) {
          String resourceIpAddress = null;
          ResourceAddress resourceAddress = null;
          switch (parameterName) {
          case FORWARDED_FOR:
              resourceAddress = acceptSession.getRemoteAddress();
              break;
          case FORWARDED_BY:
              resourceAddress = acceptSession.getLocalAddress();
              break;
          }
          ResourceAddress tcpResourceAddress = resourceAddress.findTransport("tcp");
          if (tcpResourceAddress != null) {
              URI resource = tcpResourceAddress.getResource();
              resourceIpAddress = resource.getHost();
          }
  
          return resourceIpAddress;
      }
docs: Get the IP address of the resource based on the parameter name
  
  @param acceptSession
  @param parameterName can be either 'for' (the IP address of the client/server making the request to this
  service), or 'by' (the IP address of this proxy)
  @return the IP address based on the parameter name received