Class ConnectionHeaders


  • public final class ConnectionHeaders
    extends Object
    Utility class to handle the encoding and decoding of the connection headers. Connections headers are encoded as a flat JSON object with exclusively String values. We use a pure text based format as this information will be used to decide whether to accept a connection with the remote end, thus, until the connection has been accepted we should not trust ObjectInputStream or an equivalent based mechanism for exchange of pre-connection headers. We could use a header format equivalent to that of HTTP headers, the JSON format of mapping two/from a Map with String keys and values has the advantages
    • there is a 1:1 mapping between a Map and a JSON object
    • A JSON object cannot have null keys and neither can a Map
    • A JSON object can have null values and so can a Map
    • A JSON object can only have one value for any key whereas something like the HTTP Header format allows for multiple values on any specific header
    • Tooling such as wireshark can detect JSON formatted data and present it nicely. (We are assuming here that most usage of the headers will be after a TLS connection has been set-up and thus anyone using wireshark to sniff the packets has access to both side's private keys and as such is trusted to actually be peeking into the headers!)
    Since:
    3.0