Package org.forgerock.opendj.io.rx
Class ProxyProtocolHeader
java.lang.Object
org.forgerock.opendj.io.rx.ProxyProtocolHeader
This class defines the proxy protocol header as it is described in
the proxy protocol documentation.
If the proxy protocol is enabled on DS and the proxy ip address is allowed, this header will be parsed at the
beginning of the LDAP connections to extract the original IP address and the SSL information, if present, of the
proxied client application.
Both versions of the proxy protocol (version 1 and version 2) are supported.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Exposes the content of the "pp2_tlv_ssl" structure present in thePP2_TYPE_SSL
TLV header. -
Field Summary
Modifier and TypeFieldDescriptionstatic final byte
Application-Layer Protocol Negotiation (ALPN).static final byte
Contains the host name value passed by the client, as an UTF8-encoded string.static final byte
The value of the type PP2_TYPE_CRC32C is a 32-bit number storing the CRC32c checksum of the PROXY protocol header.static final byte
The type PP2_TYPE_NETNS defines the value as the US-ASCII string representation of the namespace's name.static final byte
The TLV of this type should be ignored when parsed.static final byte
Type of the SSL TLV.static final byte
The value of the type PP2_TYPE_UNIQUE_ID is an opaque byte sequence of up to 128 bytes generated by the upstream proxy that uniquely identifies the connection. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the proxy's address.Returns the transport protocol used by the client to communicate with the proxy.Returns the proxied client's address.Returns the SSL cipher used by the proxied client ornull
if the proxied client did not use a secure connection or in case of proxy protocol V1 as it does not contain SSL information.Returns the information about the SSL protocol that the client might be using on the connection.Returns the SSL version used by the proxied client ornull
if the proxied client did not use a secure connection or in case of proxy protocol V1 as it does not contain SSL information.getTlvs()
Returns Additional information contained in the header as part of the Type-Length-Value.int
Returns the version of theheader
.int
hashCode()
boolean
Returns whether this proxy header represents aLOCAL
command.boolean
isSsl()
Returnstrue
if the proxied client uses SSL.static ProxyProtocolHeader
newLocalProxyProtocolHeader
(int version) Returns a new proxy protocol header with a local command.static ProxyProtocolHeader
newProxyProtocolHeader
(int version, InetSocketAddress clientAddress, InetSocketAddress proxyAddress) Returns a new proxy protocol header with a proxy command: the connection is relayed on behalf of a client.static ProxyProtocolHeader
newProxyProtocolHeader
(int version, InetSocketAddress clientAddress, InetSocketAddress proxyAddress, ProxyProtocolHeader.SslTlv sslTlv) Returns a new proxy protocol header with a proxy command: the connection is relayed on behalf of a client.
-
Field Details
-
PP2_TYPE_ALPN
public static final byte PP2_TYPE_ALPNApplication-Layer Protocol Negotiation (ALPN). It is a byte sequence defining the upper layer protocol in use over the connection. The most common use case will be to pass the exact copy of the ALPN extension of the Transport Layer Security (TLS) protocol as defined by RFC7301.- See Also:
-
PP2_TYPE_AUTHORITY
public static final byte PP2_TYPE_AUTHORITYContains the host name value passed by the client, as an UTF8-encoded string. In case of TLS being used on the client connection, this is the exact copy of the "server_name" extension as defined by RFC3546 [10], section 3.1, often referred to as "SNI". There are probably other situations where an authority can be mentioned on a connection without TLS being involved at all.- See Also:
-
PP2_TYPE_CRC32C
public static final byte PP2_TYPE_CRC32CThe value of the type PP2_TYPE_CRC32C is a 32-bit number storing the CRC32c checksum of the PROXY protocol header.- See Also:
-
PP2_TYPE_NOOP
public static final byte PP2_TYPE_NOOPThe TLV of this type should be ignored when parsed. The value is zero or more bytes. Can be used for data padding or alignment. Note that it can be used to align only by 3 or more bytes because a TLV can not be smaller than that.- See Also:
-
PP2_TYPE_UNIQUE_ID
public static final byte PP2_TYPE_UNIQUE_IDThe value of the type PP2_TYPE_UNIQUE_ID is an opaque byte sequence of up to 128 bytes generated by the upstream proxy that uniquely identifies the connection.- See Also:
-
PP2_TYPE_SSL
public static final byte PP2_TYPE_SSLType of the SSL TLV.- See Also:
-
PP2_TYPE_NETNS
public static final byte PP2_TYPE_NETNSThe type PP2_TYPE_NETNS defines the value as the US-ASCII string representation of the namespace's name.- See Also:
-
-
Method Details
-
newLocalProxyProtocolHeader
Returns a new proxy protocol header with a local command.- Parameters:
version
- the proxy protocol version. Valid values are 1 and 2.- Returns:
- a new proxy protocol header with a local command.
- Throws:
IllegalArgumentException
- if the version in invalid.
-
newProxyProtocolHeader
public static ProxyProtocolHeader newProxyProtocolHeader(int version, InetSocketAddress clientAddress, InetSocketAddress proxyAddress) throws IllegalArgumentException Returns a new proxy protocol header with a proxy command: the connection is relayed on behalf of a client.- Parameters:
version
- the proxy protocol version. Valid values are 1 and 2.clientAddress
- the effective client address (source address) ornull
if the address is not anInetSocketAddress
.proxyAddress
- the proxy address (destination address) ornull
if the address is not anInetSocketAddress
.- Returns:
- a new proxy protocol header with a proxy command.
- Throws:
IllegalArgumentException
- if the version in invalid.
-
newProxyProtocolHeader
public static ProxyProtocolHeader newProxyProtocolHeader(int version, InetSocketAddress clientAddress, InetSocketAddress proxyAddress, ProxyProtocolHeader.SslTlv sslTlv) throws IllegalArgumentException Returns a new proxy protocol header with a proxy command: the connection is relayed on behalf of a client.- Parameters:
version
- the proxy protocol version. Valid values are 1 and 2.clientAddress
- the effective client address (source address) ornull
if the address is not anInetSocketAddress
.proxyAddress
- the proxy address (destination address) ornull
if the address is not anInetSocketAddress
.sslTlv
- information describing if and how the client connected using SSL.- Returns:
- a new proxy protocol header with a proxy command.
- Throws:
IllegalArgumentException
- if the version is invalid.
-
getVersion
public int getVersion()Returns the version of theheader
.- Returns:
- The version (
1
or2
).
-
isLocalCommnand
public boolean isLocalCommnand()Returns whether this proxy header represents aLOCAL
command. Effectively, a connection established directly on the behalf of the proxy.- Returns:
true
if the connection has been established on the behalf of the proxy.false
if the connection has been established on the behalf of a client.
-
getProtocol
Returns the transport protocol used by the client to communicate with the proxy.- Returns:
- The transport protocol (
TCP4
,TCP6
orUNKNKOWN
)
-
getSourceAddress
Returns the proxied client's address.- Returns:
- the proxied client's address.
-
getDestinationAddress
Returns the proxy's address.- Returns:
- the proxy's address.
-
equals
-
hashCode
public int hashCode() -
getTlvs
Returns Additional information contained in the header as part of the Type-Length-Value.- Returns:
- The TLVs.
-
getSslTlv
Returns the information about the SSL protocol that the client might be using on the connection.- Returns:
- The SSL information.
-
getSslCipher
Returns the SSL cipher used by the proxied client ornull
if the proxied client did not use a secure connection or in case of proxy protocol V1 as it does not contain SSL information.- Returns:
- the SSL cipher used by the proxied client or
null
if the proxied client did not use a secure connection or in case of proxy protocol V1 as it does not contain SSL information.
-
getSslVersion
Returns the SSL version used by the proxied client ornull
if the proxied client did not use a secure connection or in case of proxy protocol V1 as it does not contain SSL information.- Returns:
- the SSL version used by the proxied client or
null
if the proxied client did not use a secure connection or in case of proxy protocol V1 as it does not contain SSL information.
-
isSsl
public boolean isSsl()Returnstrue
if the proxied client uses SSL. Alwaysfalse
for proxy protocol V1 as it does not contain SSL information.- Returns:
true
if the proxied client uses SSL. Alwaysfalse
for proxy protocol V1 as it does not contain SSL information.
-