T
- The concrete builder class.public abstract static class ClientConnectionConfiguration.Builder<T extends ClientConnectionConfiguration.Builder<T>>
extends java.lang.Object
An abstract builder class for building immutable configuration objects.
Modifier and Type | Method and Description |
---|---|
abstract ClientConnectionConfiguration |
build()
Builds the connection configuration.
|
T |
channelEncryption(ChannelEncryption channelEncryption)
Sets how the connection is secured via SSL.
|
T |
compressionMethods(CompressionMethod... compressionMethods)
Sets the compression method.
|
T |
connectTimeout(int connectTimeout)
Sets a timeout for the connection establishment.
|
T |
hostname(java.lang.String hostname)
Sets the hostname.
|
T |
hostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)
Sets an optional hostname verifier, used to verify the hostname in the certificate presented by the server.
|
T |
port(int port)
Sets the port.
|
T |
proxy(java.net.Proxy proxy)
Sets the proxy, e.g. if you are behind a HTTP proxy and use a BOSH connection.
|
T |
secure(boolean secure)
Deprecated.
Use
channelEncryption . |
T |
sslContext(javax.net.ssl.SSLContext sslContext)
Sets a custom SSL context, used to secure the connection.
|
public final T hostname(java.lang.String hostname)
Sets the hostname.
hostname
- The hostname.public final T port(int port)
Sets the port.
port
- The port.public final T proxy(java.net.Proxy proxy)
Sets the proxy, e.g. if you are behind a HTTP proxy and use a BOSH connection.
proxy
- The proxy.@Deprecated public final T secure(boolean secure)
channelEncryption
.Sets whether the connection is secured via SSL.
A standard TCP connection starts with a plain socket and negotiates a secure SSL connection during stream negotiation via ‘StartTLS’. Hence, setting secure(true)
means, you start with a plain socket and upgrade it to a secure socket during XMPP negotiation.
Setting secure(false)
means, you start with plain socket and won’t upgrade to a secure socket. However, some servers require that the client secures the connection, in which case an exception is thrown during connecting.
If your server expects the connection to be secured immediately (often on port 5223), you should set a custom SSL socket factory.
See RFC 6120 § 5. STARTTLS Negotiation for further information.
HTTP (BOSH) and WebSocket connections provide TLS outside of the XMPP layer, i.e. it’s not negotiated in XMPP. Setting secure(true)
for these connection methods means the connection connects via https
or wss
respectively.
If you set this to true
, you should also set an SSLContext
. Otherwise SSLContext.getDefault()
is used.
secure
- If the connection is secured via SSL.sslContext(SSLContext)
public final T channelEncryption(ChannelEncryption channelEncryption)
Sets how the connection is secured via SSL.
A standard TCP connection starts with a plain socket and negotiates a secure SSL connection during stream negotiation via ‘StartTLS’. Hence, setting ChannelEncryption.OPTIONAL
means, you start with a plain socket and upgrade it to a secure socket during XMPP negotiation, if possible.
Setting ChannelEncryption.DISABLED
means, you start with plain socket and won’t upgrade to a secure socket. However, some servers require that the client secures the connection, in which case an exception is thrown during connecting.
If your server expects the connection to be secured immediately (often on port 5223), you should use ChannelEncryption.DIRECT
.
See RFC 6120 § 5. STARTTLS Negotiation for further information.
HTTP (BOSH) and WebSocket connections provide TLS outside of the XMPP layer, i.e. it’s not negotiated in XMPP. Setting ChannelEncryption.DIRECT
for these connection methods means the connection connects via https
or wss
respectively. ChannelEncryption.OPTIONAL
and ChannelEncryption.REQUIRED
are not applicable for these connecion methods.
If you set this to true
, you should also set an SSLContext
. Otherwise SSLContext.getDefault()
is used.
channelEncryption
- The channel encryption mode.sslContext(SSLContext)
public final T sslContext(javax.net.ssl.SSLContext sslContext)
Sets a custom SSL context, used to secure the connection. This SSL context only takes effect, when setting secure(true)
.
sslContext
- The SSL context.secure(boolean)
public final T hostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)
Sets an optional hostname verifier, used to verify the hostname in the certificate presented by the server. If no verifier is set, the hostname is verified nonetheless using the default.
hostnameVerifier
- The hostname verifier.public final T connectTimeout(int connectTimeout)
Sets a timeout for the connection establishment.
Connecting to a XMPP server involves multiple steps:
XMPP stream negotiation is configured via XmppSessionConfiguration.Builder.defaultResponseTimeout(java.time.Duration)
connectTimeout
- The timeout in milliseconds.java.lang.IllegalArgumentException
- If the timeout is negative.XmppSession.connect()
public final T compressionMethods(CompressionMethod... compressionMethods)
Sets the compression method.
compressionMethods
- The compression methods.CompressionMethod.ZLIB
,
CompressionMethod.GZIP
,
CompressionMethod.DEFLATE
public abstract ClientConnectionConfiguration build()
Builds the connection configuration.
Copyright © 2014–2019 XMPP.rocks. All rights reserved.