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
Nested ClassesModifier and TypeClassDescriptionstatic final classExposes the content of the "pp2_tlv_ssl" structure present in thePP2_TYPE_SSLTLV header. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byteApplication-Layer Protocol Negotiation (ALPN).static final byteContains the host name value passed by the client, as an UTF8-encoded string.static final byteThe value of the type PP2_TYPE_CRC32C is a 32-bit number storing the CRC32c checksum of the PROXY protocol header.static final byteThe type PP2_TYPE_NETNS defines the value as the US-ASCII string representation of the namespace's name.static final byteThe TLV of this type should be ignored when parsed.static final byteType of the SSL TLV.static final byteThe 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 TypeMethodDescriptionbooleanReturns 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 ornullif 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 ornullif 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.intReturns the version of theheader.inthashCode()booleanReturns whether this proxy header represents aLOCALcommand.booleanisSsl()Returnstrueif the proxied client uses SSL.static ProxyProtocolHeadernewLocalProxyProtocolHeader(int version) Returns a new proxy protocol header with a local command.static ProxyProtocolHeadernewProxyProtocolHeader(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 ProxyProtocolHeadernewProxyProtocolHeader(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) ornullif the address is not anInetSocketAddress.proxyAddress- the proxy address (destination address) ornullif 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) ornullif the address is not anInetSocketAddress.proxyAddress- the proxy address (destination address) ornullif 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 (
1or2).
-
isLocalCommnand
public boolean isLocalCommnand()Returns whether this proxy header represents aLOCALcommand. Effectively, a connection established directly on the behalf of the proxy.- Returns:
trueif the connection has been established on the behalf of the proxy.falseif 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,TCP6orUNKNKOWN)
-
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 ornullif 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
nullif 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 ornullif 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
nullif 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()Returnstrueif the proxied client uses SSL. Alwaysfalsefor proxy protocol V1 as it does not contain SSL information.- Returns:
trueif the proxied client uses SSL. Alwaysfalsefor proxy protocol V1 as it does not contain SSL information.
-