Class ForwardedHeader

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

public class ForwardedHeader extends Header
A Header representation of the Forwarded HTTP header.

This class is not thread-safe.

See Also:
  • Field Details

  • Constructor Details

    • ForwardedHeader

      public ForwardedHeader()
  • Method Details

    • 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.
    • getLastHop

      public ForwardedHeader.Hop getLastHop()
      Get the last request's hop information (for, by, host and proto) as expressed in the header (ie: contents may not be well formatted).

      This usually is the last encountered proxy details.

      Returns:
      the last hop details (or null if there is no hop listed)
    • getLastHopClientIp

      public String getLastHopClientIp()
      Get the last request's hop IP address. This IP is either IPv4, IPv6 or null if not found.
      Returns:
      the last hop IP address. null if not present or not an IPv4 nor IPv6.
    • getFirstHop

      public ForwardedHeader.Hop getFirstHop()
      Get the first request's hop information (for, by, host and proto) as expressed in the header (ie: contents may not be well formatted).
      Returns:
      the first hop details (or null if there is no hop listed)
    • getOriginatingClientIp

      public String getOriginatingClientIp()
      Get the first request's hop IP address. This IP is either IPv4, IPv6 or null if not found.
      Returns:
      the last hop IP address. null if not present or not an IPv4 nor IPv6.
    • getHops

      public List<ForwardedHeader.Hop> getHops()
      Get the list of request's hops details.

      The first element is the originating client, the last element is the last proxy encountered.

      Returns:
      the list of request's hops details. this list is immutable.
    • addHop

      public ForwardedHeader addHop(ForwardedHeader.Hop hop)
      Add a new hop detail at the end of the list of hops.
      Parameters:
      hop - the detail of the new hop.
      Returns:
      the header itself to be able to chain method calls.
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Header