Package org.forgerock.http.header
Class XForwardedForHeader
- java.lang.Object
-
- org.forgerock.http.protocol.Header
-
- org.forgerock.http.header.XForwardedForHeader
-
public final class XForwardedForHeader extends Header
Processes theX-Forwarded-For
message header. For more information, see MDN de-facto standard.This class is not thread-safe.
-
-
Constructor Summary
Constructors Constructor Description XForwardedForHeader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description XForwardedForHeader
addIpAddress(String ipAddress)
Add an address as last hop to the list of addresses.boolean
equals(Object o)
String
getClientIpAddress()
Get the IP address of the request's originating client.List<String>
getIpAddresses()
Get the IP addresses list.String
getLastHopIpAddress()
Get the IP address of the request's last hop.String
getName()
Returns the name of the header, as it would canonically appear within an HTTP message.List<String>
getValues()
Returns the header as a list of strings.int
hashCode()
-
Methods inherited from class org.forgerock.http.protocol.Header
getFirstValue, toString
-
-
-
-
Field Detail
-
NAME
public static final String NAME
The name of this header.- See Also:
- Constant Field Values
-
-
Method Detail
-
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 notnull
.- 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.
-
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. 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
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.
-
-