Package org.forgerock.http.header
Class XForwardedForHeader
java.lang.Object
org.forgerock.http.protocol.Header
org.forgerock.http.header.XForwardedForHeader
Processes the
X-Forwarded-For
message header. For more information, see MDN de-facto standard.
This class is not thread-safe.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddIpAddress
(String ipAddress) Add an address as last hop to the list of addresses.boolean
Get the IP address of the request's originating client.Get the IP addresses list.Get the IP address of the request's last hop.getName()
Returns the name of the header, as it would canonically appear within an HTTP message.Returns the header as a list of strings.int
hashCode()
Methods inherited from class org.forgerock.http.protocol.Header
getFirstValue, toString
-
Field Details
-
NAME
The name of this header.- See Also:
-
-
Constructor Details
-
XForwardedForHeader
public XForwardedForHeader()
-
-
Method Details
-
getClientIpAddress
Get the IP address of the request's originating client.- Returns:
- the IP address of the originating client.
null
if not set.
-
getLastHopIpAddress
Get the IP address of the request's last hop.- Returns:
- the IP address of the last caller.
null
if not set.
-
addIpAddress
Add an address as last hop to the list of addresses.- Parameters:
ipAddress
- The address to add. Must be notnull
.- Returns:
- The header itself in order to chain method calls.
-
getName
Description copied from class:Header
Returns the name of the header, as it would canonically appear within an HTTP message. -
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. EachString
should represent the value component of the key-value pair that makes up the HTTP header - as such, for someHeader
implementations each String in thisList
may contain multiple token-separated values.The
List
returned from this method should not be expected to be mutable. However, some subclasses ofHeader
may choose to implement it as such. -
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
-
hashCode
public int hashCode()
-