Package org.forgerock.http.header
Class ForwardedHeader
- java.lang.Object
-
- org.forgerock.http.protocol.Header
-
- org.forgerock.http.header.ForwardedHeader
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ForwardedHeader.Hop
This class represents a request's hop detail.
-
Constructor Summary
Constructors Constructor Description ForwardedHeader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ForwardedHeader
addHop(ForwardedHeader.Hop hop)
Add a new hop detail at the end of the list of hops.boolean
equals(Object o)
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).List<ForwardedHeader.Hop>
getHops()
Get the list of request's hops details.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).String
getLastHopClientIp()
Get the last request's hop IP address.String
getName()
Returns the name of the header, as it would canonically appear within an HTTP message.String
getOriginatingClientIp()
Get the first request's hop IP address.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 the header in the HTTP message.- See Also:
- Constant Field Values
-
-
Method Detail
-
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.
-
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.
-
-