public class ConnectionConfiguration extends Object implements Cloneable
It is also possible to configure if TLS, SASL, and compression are used or not.
Modifier and Type | Class and Description |
---|---|
static class |
ConnectionConfiguration.SecurityMode
An enumeration for TLS security modes that are available when making a connection
to the XMPP server.
|
Modifier and Type | Field and Description |
---|---|
protected List<HostAddress> |
hostAddresses |
protected ProxyInfo |
proxy |
Constructor and Description |
---|
ConnectionConfiguration(String serviceName)
Creates a new ConnectionConfiguration for the specified service name.
|
ConnectionConfiguration(String host,
int port)
Creates a new ConnectionConfiguration for a connection that will connect
to the desired host and port.
|
ConnectionConfiguration(String host,
int port,
ProxyInfo proxy)
Creates a new ConnectionConfiguration for a connection that will connect
to the desired host and port with desired proxy.
|
ConnectionConfiguration(String host,
int port,
String serviceName)
Creates a new ConnectionConfiguration using the specified host, port and
service name.
|
ConnectionConfiguration(String host,
int port,
String serviceName,
ProxyInfo proxy)
Creates a new ConnectionConfiguration using the specified host, port and
service name.
|
ConnectionConfiguration(String serviceName,
ProxyInfo proxy)
Creates a new ConnectionConfiguration for the specified service name
with specified proxy.
|
Modifier and Type | Method and Description |
---|---|
CallbackHandler |
getCallbackHandler()
Returns a CallbackHandler to obtain information, such as the password or
principal information during the SASL authentication.
|
SSLContext |
getCustomSSLContext()
Gets the custom SSLContext previously set with
setCustomSSLContext(SSLContext) for
SSL sockets. |
List<HostAddress> |
getHostAddresses() |
HostnameVerifier |
getHostnameVerifier()
Returns the configured HostnameVerifier of this ConnectionConfiguration or the Smack default
HostnameVerifier configured with
SmackConfiguration.setDefaultHostnameVerifier(HostnameVerifier) . |
String |
getKeystorePath()
Retuns the path to the keystore file.
|
String |
getKeystoreType()
Returns the keystore type, or null if it's not set.
|
String |
getPassword()
Returns the password to use when trying to reconnect to the server.
|
String |
getPKCS11Library()
Returns the PKCS11 library file location, needed when the
Keystore type is PKCS11.
|
String |
getResource()
Returns the resource to use when trying to reconnect to the server.
|
RosterStore |
getRosterStore()
Get the permanent roster store
|
ConnectionConfiguration.SecurityMode |
getSecurityMode()
Returns the TLS security mode used when making the connection.
|
String |
getServiceName()
Returns the server name of the target server.
|
SocketFactory |
getSocketFactory()
Returns the socket factory used to create new xmppConnection sockets.
|
String |
getUsername()
Returns the username to use when trying to reconnect to the server.
|
protected void |
init(String serviceName,
ProxyInfo proxy) |
boolean |
isCompressionEnabled()
Returns true if the connection is going to use stream compression.
|
boolean |
isDebuggerEnabled()
Returns true if the new connection about to be establish is going to be debugged.
|
boolean |
isLegacySessionDisabled()
Returns true if a
Session will be requested on login if the server
supports it. |
boolean |
isReconnectionAllowed()
Returns if the reconnection mechanism is allowed to be used.
|
boolean |
isRosterLoadedAtLogin()
Returns true if the roster will be loaded from the server when logging in.
|
boolean |
isSendPresence()
Returns true if an available presence should be sent when logging in while reconnecting.
|
void |
setCallbackHandler(CallbackHandler callbackHandler)
Sets a CallbackHandler to obtain information, such as the password or
principal information during the SASL authentication.
|
void |
setCompressionEnabled(boolean compressionEnabled)
Sets if the connection is going to use stream compression.
|
void |
setCustomSSLContext(SSLContext context)
Sets a custom SSLContext for creating SSL sockets.
|
void |
setDebuggerEnabled(boolean debuggerEnabled)
Sets if the new connection about to be establish is going to be debugged.
|
void |
setHostnameVerifier(HostnameVerifier verifier)
Set the HostnameVerifier used to verify the hostname of SSLSockets used by XMPP connections
created with this ConnectionConfiguration.
|
void |
setKeystorePath(String keystorePath)
Sets the path to the keystore file.
|
void |
setKeystoreType(String keystoreType)
Sets the keystore type.
|
void |
setLegacySessionDisabled(boolean legacySessionDisabled)
Sets if a
Session will be requested on login if the server supports
it. |
void |
setPKCS11Library(String pkcs11Library)
Sets the PKCS11 library file location, needed when the
Keystore type is PKCS11
|
void |
setReconnectionAllowed(boolean isAllowed)
Sets if the reconnection mechanism is allowed to be used.
|
void |
setRosterLoadedAtLogin(boolean rosterLoadedAtLogin)
Sets if the roster will be loaded from the server when logging in.
|
void |
setRosterStore(RosterStore store)
Set the permanent roster store
|
void |
setSecurityMode(ConnectionConfiguration.SecurityMode securityMode)
Sets the TLS security mode used when making the connection.
|
void |
setSendPresence(boolean sendPresence)
Sets if an initial available presence will be sent to the server.
|
void |
setSocketFactory(SocketFactory socketFactory)
Sets the socket factory used to create new xmppConnection sockets.
|
protected List<HostAddress> hostAddresses
public ConnectionConfiguration(String serviceName)
serviceName
- the name of the service provided by an XMPP server.public ConnectionConfiguration(String serviceName, ProxyInfo proxy)
serviceName
- the name of the service provided by an XMPP server.proxy
- the proxy through which XMPP is to be connectedpublic ConnectionConfiguration(String host, int port, String serviceName)
ConnectionConfiguration(String)
constructor. For example, say that an XMPP server is running at localhost
in an internal network on port 5222 but is configured to think that it's
"example.com" for testing purposes. This constructor is necessary to connect
to the server in that case since a DNS SRV lookup for example.com would not
point to the local testing server.host
- the host where the XMPP server is running.port
- the port where the XMPP is listening.serviceName
- the name of the service provided by an XMPP server.public ConnectionConfiguration(String host, int port, String serviceName, ProxyInfo proxy)
ConnectionConfiguration(String)
constructor. For example, say that an XMPP server is running at localhost
in an internal network on port 5222 but is configured to think that it's
"example.com" for testing purposes. This constructor is necessary to connect
to the server in that case since a DNS SRV lookup for example.com would not
point to the local testing server.host
- the host where the XMPP server is running.port
- the port where the XMPP is listening.serviceName
- the name of the service provided by an XMPP server.proxy
- the proxy through which XMPP is to be connectedpublic ConnectionConfiguration(String host, int port)
host
- the host where the XMPP server is running.port
- the port where the XMPP is listening.public ConnectionConfiguration(String host, int port, ProxyInfo proxy)
host
- the host where the XMPP server is running.port
- the port where the XMPP is listening.proxy
- the proxy through which XMPP is to be connectedpublic String getServiceName()
public ConnectionConfiguration.SecurityMode getSecurityMode()
ConnectionConfiguration.SecurityMode.enabled
.public void setSecurityMode(ConnectionConfiguration.SecurityMode securityMode)
ConnectionConfiguration.SecurityMode.enabled
.securityMode
- the security mode.public String getKeystorePath()
public void setKeystorePath(String keystorePath)
keystorePath
- the path to the keystore file.public String getKeystoreType()
public void setKeystoreType(String keystoreType)
keystoreType
- the keystore type.public String getPKCS11Library()
public void setPKCS11Library(String pkcs11Library)
pkcs11Library
- the path to the PKCS11 library filepublic SSLContext getCustomSSLContext()
setCustomSSLContext(SSLContext)
for
SSL sockets. This is null by default.public void 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 socketspublic void setHostnameVerifier(HostnameVerifier verifier)
verifier
- public HostnameVerifier getHostnameVerifier()
SmackConfiguration.setDefaultHostnameVerifier(HostnameVerifier)
.null
public boolean isCompressionEnabled()
public void setCompressionEnabled(boolean compressionEnabled)
compressionEnabled
- if the connection is going to use stream compression.public boolean isDebuggerEnabled()
SmackConfiguration.DEBUG_ENABLED
is used.public void setDebuggerEnabled(boolean debuggerEnabled)
SmackConfiguration.DEBUG_ENABLED
is used.debuggerEnabled
- if the new connection about to be establish is going to be debugged.public void setReconnectionAllowed(boolean isAllowed)
isAllowed
- if the reconnection mechanism should be enabled for this connection.public boolean isReconnectionAllowed()
setReconnectionAllowed(boolean)
.public void setSocketFactory(SocketFactory socketFactory)
socketFactory
- used to create new sockets.public void setSendPresence(boolean sendPresence)
sendPresence
- true if an initial available presence will be sent while logging in.public boolean isRosterLoadedAtLogin()
public void setRosterLoadedAtLogin(boolean rosterLoadedAtLogin)
rosterLoadedAtLogin
- if the roster will be loaded from the server when logging in.public boolean isLegacySessionDisabled()
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.public void 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.legacySessionDisabled
- if a session has to be requested when logging in.public CallbackHandler getCallbackHandler()
public void setCallbackHandler(CallbackHandler callbackHandler)
callbackHandler
- to obtain information, such as the password or
principal information during the SASL authentication.public SocketFactory getSocketFactory()
public List<HostAddress> getHostAddresses()
public void setRosterStore(RosterStore store)
public RosterStore getRosterStore()
public String getUsername()
public String getPassword()
public String getResource()
public boolean isSendPresence()