Class XForwardedForHeader

java.lang.Object
org.forgerock.http.protocol.Header
org.forgerock.http.header.XForwardedForHeader

public final class XForwardedForHeader extends Header
Processes the X-Forwarded-For message header. For more information, see MDN de-facto standard.

This class is not thread-safe.

  • Field Details

  • Constructor Details

    • XForwardedForHeader

      public XForwardedForHeader()
  • Method Details

    • getClientIpAddress

      public String getClientIpAddress()
      Get the IP address of the request's originating client.
      Returns:
      the IP address of the originating client. null if not set.
    • getLastHopIpAddress

      public String getLastHopIpAddress()
      Get the IP address of the request's last hop.
      Returns:
      the IP address of the last caller. null if not set.
    • addIpAddress

      public XForwardedForHeader addIpAddress(String ipAddress)
      Add an address as last hop to the list of addresses.
      Parameters:
      ipAddress - The address to add. Must be not null.
      Returns:
      The header itself in order to chain method calls.
    • getName

      public String getName()
      Description copied from class: Header
      Returns the name of the header, as it would canonically appear within an HTTP message.
      Specified by:
      getName in class Header
      Returns:
      The name of the header, as it would canonically appear within an HTTP message.
    • getValues

      public List<String> getValues()
      Description copied from class: Header
      Returns the header as a list of strings. If the header has no values then it must return an empty list, never null. Each String should represent the value component of the key-value pair that makes up the HTTP header - as such, for some Header implementations each String in this List may contain multiple token-separated values.

      The List returned from this method should not be expected to be mutable. However, some subclasses of Header may choose to implement it as such.

      Specified by:
      getValues in class Header
      Returns:
      The header as a non-null list of string values. Can be an empty list.
    • getIpAddresses

      public List<String> getIpAddresses()
      Get the IP addresses list.

      The first one is the originating client IP address.

      The last one is the direct client IP address.

      Returns:
      the list of addresses the request went through. This list is immutable.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Header
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Header