B
- the builder type parameter.C
- the resulting connection configuration type parameter.public abstract static class ConnectionConfiguration.Builder<B extends ConnectionConfiguration.Builder<B,C>,C extends ConnectionConfiguration> extends Object
This is an abstract class that uses the builder design pattern and the "getThis() trick" to recover the type of the builder in a class hierarchies with a self-referential generic supertype. Otherwise chaining of build instructions from the superclasses followed by build instructions of a sublcass would not be possible, because the superclass build instructions would return the builder of the superclass and not the one of the subclass. You can read more about it a Angelika Langer's Generics FAQ, especially the entry What is the "getThis()" trick?.
Modifier | Constructor and Description |
---|---|
protected |
Builder() |
Modifier and Type | Method and Description |
---|---|
B |
allowEmptyOrNullUsernames()
Allow
null or the empty String as username. |
abstract C |
build() |
protected abstract B |
getThis() |
B |
setCallbackHandler(CallbackHandler callbackHandler)
Sets a CallbackHandler to obtain information, such as the password or
principal information during the SASL authentication.
|
B |
setCustomSSLContext(SSLContext context)
Sets a custom SSLContext for creating SSL sockets.
|
B |
setDebuggerEnabled(boolean debuggerEnabled)
Sets if the new connection about to be establish is going to be debugged.
|
B |
setEnabledSSLCiphers(String[] enabledSSLCiphers)
Set the enabled SSL/TLS ciphers.
|
B |
setEnabledSSLProtocols(String[] enabledSSLProtocols)
Set the enabled SSL/TLS protocols.
|
B |
setHost(String host) |
B |
setHostnameVerifier(HostnameVerifier verifier)
Set the HostnameVerifier used to verify the hostname of SSLSockets used by XMPP connections
created with this ConnectionConfiguration.
|
B |
setKeystorePath(String keystorePath)
Sets the path to the keystore file.
|
B |
setKeystoreType(String keystoreType)
Sets the keystore type.
|
B |
setLegacySessionDisabled(boolean legacySessionDisabled)
Deprecated.
Smack processes the 'optional' element of the session stream feature.
|
B |
setPKCS11Library(String pkcs11Library)
Sets the PKCS11 library file location, needed when the
Keystore type is PKCS11
|
B |
setPort(int port) |
B |
setProxyInfo(ProxyInfo proxyInfo)
Set the information about the Proxy used for the connection.
|
B |
setResource(String resource)
Set the resource to use.
|
B |
setSecurityMode(ConnectionConfiguration.SecurityMode securityMode)
Sets the TLS security mode used when making the connection.
|
B |
setSendPresence(boolean sendPresence)
Sets if an initial available presence will be sent to the server.
|
B |
setServiceName(String serviceName)
Set the service name of this XMPP service (i.e., the XMPP domain).
|
B |
setSocketFactory(SocketFactory socketFactory)
Sets the socket factory used to create new xmppConnection sockets.
|
B |
setUsernameAndPassword(CharSequence username,
String password)
Set the XMPP entities username and password.
|
protected Builder()
public B setUsernameAndPassword(CharSequence username, String password)
The username is usually the localpart of the clients JID. But some SASL mechanisms or services may require a different format (e.g. the full JID) as used authorization identity.
username
- the username or authorization identitypassword
- the password or token used to authenticatepublic B setServiceName(String serviceName)
serviceName
- the service namepublic B setResource(String resource)
If resource
is null
, then the server will automatically create a resource for the
client. Default resource is "Smack".
resource
- the resource to use.public B setCallbackHandler(CallbackHandler callbackHandler)
callbackHandler
- to obtain information, such as the password or
principal information during the SASL authentication.public B setSecurityMode(ConnectionConfiguration.SecurityMode securityMode)
ConnectionConfiguration.SecurityMode.ifpossible
.securityMode
- the security mode.public B setKeystorePath(String keystorePath)
keystorePath
- the path to the keystore file.public B setKeystoreType(String keystoreType)
keystoreType
- the keystore type.public B setPKCS11Library(String pkcs11Library)
pkcs11Library
- the path to the PKCS11 library file.public B setCustomSSLContext(SSLContext context)
For more information on how to create a SSLContext see Java Secure Socket Extension (JSEE) Reference Guide: Creating Your Own X509TrustManager
context
- the custom SSLContext for new sockets.public B setEnabledSSLProtocols(String[] enabledSSLProtocols)
enabledSSLProtocols
- public B setEnabledSSLCiphers(String[] enabledSSLCiphers)
enabledSSLCiphers
- the enabled SSL/TLS cipherspublic B setHostnameVerifier(HostnameVerifier verifier)
verifier
- @Deprecated public B setLegacySessionDisabled(boolean legacySessionDisabled)
Session
will be requested on login if the server supports
it. Although this was mandatory on RFC 3921, RFC 6120/6121 don't even
mention this part of the protocol.
Deprecation notice: This setting is no longer required in most cases because Smack processes the 'optional' element eventually found in the session stream feature. See also Here Lies Extensible Messaging and Presence Protocol (XMPP) Session Establishment
legacySessionDisabled
- if a session has to be requested when logging in.public B setSendPresence(boolean sendPresence)
sendPresence
- true if an initial available presence will be sent while logging in.public B setDebuggerEnabled(boolean debuggerEnabled)
SmackConfiguration.DEBUG
is used.debuggerEnabled
- if the new connection about to be establish is going to be debugged.public B setSocketFactory(SocketFactory socketFactory)
socketFactory
- used to create new sockets.public B setProxyInfo(ProxyInfo proxyInfo)
proxyInfo
- the Proxy information.public B allowEmptyOrNullUsernames()
null
or the empty String as username.
Some SASL mechanisms (e.g. SASL External) may also signal the username (as "authorization identity"), in
which case Smack should not throw an IllegalArgumentException when the username is not set.