Class ConnectionConfiguration
- java.lang.Object
-
- org.jivesoftware.smack.ConnectionConfiguration
-
- Direct Known Subclasses:
BOSHConfiguration
,ModularXmppClientToServerConnectionConfiguration
,XMPPTCPConnectionConfiguration
public abstract class ConnectionConfiguration extends Object
The connection configuration used for XMPP client-to-server connections. A well configured XMPP service will typically only require you to provide two parameters: The XMPP address, also known as the JID, of the user and the password. All other configuration parameters could ideally be determined automatically by Smack. Hence it is often enough to callConnectionConfiguration.Builder.setXmppAddressAndPassword(CharSequence, String)
.Technically there are typically at least two parameters required: Some kind of credentials for authentication. And the XMPP service domain. The credentials often consists of a username and password use for the SASL authentication. But there are also other authentication mechanisms, like client side certificates, which do not require a particular username and password.
There are some misconceptions about XMPP client-to-server parameters: The first is that the username used for authentication will be equal to the localpart of the bound XMPP address after authentication. While this is usually true, it is not required. Technically the username used for authentication and the resulting XMPP address are completely independent from each other. The second common misconception steers from the terms "XMPP host" and "XMPP service domain": An XMPP service host is a system which hosts one or multiple XMPP domains. The "XMPP service domain" will be usually the domainpart of the bound JID. This domain is used to verify the remote endpoint, typically using TLS. This third misconception is that the XMPP service domain is required to become the domainpart of the bound JID. Again, while this is very common to be true, it is not strictly required.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConnectionConfiguration.Builder<B extends ConnectionConfiguration.Builder<B,C>,C extends ConnectionConfiguration>
A builder for XMPP connection configurations.static class
ConnectionConfiguration.DnssecMode
Determines the requested DNSSEC security mode.static class
ConnectionConfiguration.SecurityMode
An enumeration for TLS security modes that are available when making a connection to the XMPP server.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
allowNullOrEmptyUsername
protected DnsName
host
protected InetAddress
hostAddress
protected UInt16
port
protected ProxyInfo
proxy
protected DomainBareJid
xmppServiceDomain
The XMPP domain of the XMPP Service.protected DnsName
xmppServiceDomainDnsName
-
Constructor Summary
Constructors Modifier Constructor Description protected
ConnectionConfiguration(ConnectionConfiguration.Builder<?,?> builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description EntityBareJid
getAuthzid()
Returns the optional XMPP address to be requested as the SASL authorization identity.CallbackHandler
getCallbackHandler()
Returns a CallbackHandler to obtain information, such as the password or principal information during the SASL authentication.SmackDebuggerFactory
getDebuggerFactory()
Returns the Smack debugger factory.ConnectionConfiguration.DnssecMode
getDnssecMode()
Set<String>
getEnabledSaslMechanisms()
Return the explicitly enabled SASL mechanisms.String[]
getEnabledSSLCiphers()
Return the enabled SSL/TLS ciphers.String[]
getEnabledSSLProtocols()
Return the enabled SSL/TLS protocols.DnsName
getHost()
InetAddress
getHostAddress()
HostnameVerifier
getHostnameVerifier()
Returns the configured HostnameVerifier of this ConnectionConfiguration or the Smack default HostnameVerifier configured withSmackConfiguration.setDefaultHostnameVerifier(HostnameVerifier)
.Locale
getLanguage()
Returns the stream language to use when connecting to the server.String
getPassword()
Returns the password to use when trying to reconnect to the server.UInt16
getPort()
ProxyInfo
getProxyInfo()
Get the configured proxy information (if any).Resourcepart
getResource()
Returns the resource to use when trying to reconnect to the server.ConnectionConfiguration.SecurityMode
getSecurityMode()
Returns the TLS security mode used when making the connection.DomainBareJid
getServiceName()
Deprecated.usegetXMPPServiceDomain()
instead.SocketFactory
getSocketFactory()
Returns the socket factory used to create new xmppConnection sockets.CharSequence
getUsername()
Returns the username to use when trying to reconnect to the server.String
getXmlLang()
Returns the xml:lang string of the stream language to use when connecting to the server.DomainBareJid
getXMPPServiceDomain()
Returns the XMPP domain used by this configuration.DnsName
getXmppServiceDomainAsDnsNameIfPossible()
Returns the XMPP service domain as DNS name if possible.boolean
isCompressionEnabled()
Returns true if the connection is going to use stream compression.boolean
isEnabledSaslMechanism(String saslMechanism)
Check if the given SASL mechansism is enabled in this connection configuration.boolean
isSendPresence()
Returns true if an available presence should be sent when logging in while reconnecting.
-
-
-
Field Detail
-
xmppServiceDomain
protected final DomainBareJid xmppServiceDomain
The XMPP domain of the XMPP Service. Usually servers use the same service name as the name of the server. However, there are some servers like google where host would be talk.google.com and the serviceName would be gmail.com.
-
xmppServiceDomainDnsName
protected final DnsName xmppServiceDomainDnsName
-
hostAddress
protected final InetAddress hostAddress
-
allowNullOrEmptyUsername
protected final boolean allowNullOrEmptyUsername
-
-
Constructor Detail
-
ConnectionConfiguration
protected ConnectionConfiguration(ConnectionConfiguration.Builder<?,?> builder)
-
-
Method Detail
-
getHostAddress
public InetAddress getHostAddress()
-
getServiceName
@Deprecated public DomainBareJid getServiceName()
Deprecated.usegetXMPPServiceDomain()
instead.Returns the server name of the target server.- Returns:
- the server name of the target server.
-
getXMPPServiceDomain
public DomainBareJid getXMPPServiceDomain()
Returns the XMPP domain used by this configuration.- Returns:
- the XMPP domain.
-
getXmppServiceDomainAsDnsNameIfPossible
public DnsName getXmppServiceDomainAsDnsNameIfPossible()
Returns the XMPP service domain as DNS name if possible. Note that since not every XMPP address domainpart is a valid DNS name, this method may returnnull
.- Returns:
- the XMPP service domain as DNS name or
null
. - Since:
- 4.3.4
-
getSecurityMode
public ConnectionConfiguration.SecurityMode getSecurityMode()
Returns the TLS security mode used when making the connection. By default, the mode isConnectionConfiguration.SecurityMode.ifpossible
.- Returns:
- the security mode.
-
getDnssecMode
public ConnectionConfiguration.DnssecMode getDnssecMode()
-
getEnabledSSLProtocols
public String[] getEnabledSSLProtocols()
Return the enabled SSL/TLS protocols.- Returns:
- the enabled SSL/TLS protocols
-
getEnabledSSLCiphers
public String[] getEnabledSSLCiphers()
Return the enabled SSL/TLS ciphers.- Returns:
- the enabled SSL/TLS ciphers
-
getHostnameVerifier
public HostnameVerifier getHostnameVerifier()
Returns the configured HostnameVerifier of this ConnectionConfiguration or the Smack default HostnameVerifier configured withSmackConfiguration.setDefaultHostnameVerifier(HostnameVerifier)
.- Returns:
- a configured HostnameVerifier or
null
-
getDebuggerFactory
public SmackDebuggerFactory getDebuggerFactory()
Returns the Smack debugger factory.- Returns:
- the Smack debugger factory or
null
-
getCallbackHandler
public CallbackHandler getCallbackHandler()
Returns a CallbackHandler to obtain information, such as the password or principal information during the SASL authentication. A CallbackHandler will be used ONLY if no password was specified during the login while using SASL authentication.- Returns:
- a CallbackHandler to obtain information, such as the password or principal information during the SASL authentication.
-
getSocketFactory
public SocketFactory getSocketFactory()
Returns the socket factory used to create new xmppConnection sockets. This is useful when connecting through SOCKS5 proxies.- Returns:
- socketFactory used to create new sockets.
-
getProxyInfo
public ProxyInfo getProxyInfo()
Get the configured proxy information (if any).- Returns:
- the configured proxy information or
null
.
-
getUsername
public CharSequence getUsername()
Returns the username to use when trying to reconnect to the server.- Returns:
- the username to use when trying to reconnect to the server.
-
getPassword
public String getPassword()
Returns the password to use when trying to reconnect to the server.- Returns:
- the password to use when trying to reconnect to the server.
-
getResource
public Resourcepart getResource()
Returns the resource to use when trying to reconnect to the server.- Returns:
- the resource to use when trying to reconnect to the server.
-
getLanguage
public Locale getLanguage()
Returns the stream language to use when connecting to the server.- Returns:
- the stream language to use when connecting to the server.
-
getXmlLang
public String getXmlLang()
Returns the xml:lang string of the stream language to use when connecting to the server.If the developer sets the language to null, this will also return null, leading to the removal of the xml:lang tag from the stream. If a Locale("") is configured, this will return "", which can be used as an override.
- Returns:
- the stream language to use when connecting to the server.
-
getAuthzid
public EntityBareJid getAuthzid()
Returns the optional XMPP address to be requested as the SASL authorization identity.- Returns:
- the authorization identifier.
- Since:
- 4.2
- See Also:
- RFC 6120 ยง 6.3.8. Authorization Identity
-
isSendPresence
public boolean isSendPresence()
Returns true if an available presence should be sent when logging in while reconnecting.- Returns:
- true if an available presence should be sent when logging in while reconnecting
-
isCompressionEnabled
public boolean isCompressionEnabled()
Returns true if the connection is going to use stream compression. Stream compression will be requested after TLS was established (if TLS was enabled) and only if the server offered stream compression. With stream compression network traffic can be reduced up to 90%. By default compression is disabled.- Returns:
- true if the connection is going to use stream compression.
-
isEnabledSaslMechanism
public boolean isEnabledSaslMechanism(String saslMechanism)
Check if the given SASL mechansism is enabled in this connection configuration.- Parameters:
saslMechanism
- TODO javadoc me please- Returns:
- true if the given SASL mechanism is enabled, false otherwise.
-
getEnabledSaslMechanisms
public Set<String> getEnabledSaslMechanisms()
Return the explicitly enabled SASL mechanisms. May returnnull
if no SASL mechanisms where explicitly enabled, i.e. all SALS mechanisms supported and announced by the service will be considered.- Returns:
- the enabled SASL mechanisms or
null
.
-
-