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 java.lang.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 subclass 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 |
addEnabledSaslMechanism(java.util.Collection<java.lang.String> saslMechanisms)
Enable the given SASL mechanisms.
|
B |
addEnabledSaslMechanism(java.lang.String saslMechanism)
Add the given mechanism to the enabled ones.
|
B |
allowEmptyOrNullUsernames()
Allow
null or the empty String as username. |
abstract C |
build() |
B |
enableDefaultDebugger() |
static javax.net.ssl.KeyManager[] |
getKeyManagersFrom(java.lang.String keystoreType,
java.lang.String keystorePath,
javax.security.auth.callback.CallbackHandler callbackHandler,
java.lang.String pkcs11Library) |
protected abstract B |
getThis() |
B |
performSaslAnonymousAuthentication()
Perform anonymous authentication using SASL ANONYMOUS.
|
B |
performSaslExternalAuthentication(javax.net.ssl.SSLContext sslContext)
Perform authentication using SASL EXTERNAL.
|
B |
setAuthzid(org.jxmpp.jid.EntityBareJid authzid)
Set the XMPP address to be used as authorization identity.
|
B |
setCallbackHandler(javax.security.auth.callback.CallbackHandler callbackHandler)
Deprecated.
set a callback-handler aware
KeyManager via setKeyManager(KeyManager) or
setKeyManagers(KeyManager[]), created by
getKeyManagersFrom(String, String, CallbackHandler, String), instead. |
B |
setCompressionEnabled(boolean compressionEnabled)
Sets if the connection is going to use compression (default false).
|
B |
setCustomSSLContext(javax.net.ssl.SSLContext context)
Deprecated.
use
setSslContextFactory(SslContextFactory) instead}. |
B |
setCustomX509TrustManager(javax.net.ssl.X509TrustManager x509TrustManager) |
B |
setDebuggerFactory(SmackDebuggerFactory debuggerFactory)
Set the Smack debugger factory used to construct Smack debuggers.
|
B |
setDnssecMode(ConnectionConfiguration.DnssecMode dnssecMode) |
B |
setEnabledSSLCiphers(java.lang.String[] enabledSSLCiphers)
Set the enabled SSL/TLS ciphers.
|
B |
setEnabledSSLProtocols(java.lang.String[] enabledSSLProtocols)
Set the enabled SSL/TLS protocols.
|
B |
setHost(java.lang.CharSequence host)
Set the name of the host providing the XMPP service.
|
B |
setHost(org.minidns.dnsname.DnsName host)
Set the name of the host providing the XMPP service.
|
B |
setHostAddress(java.net.InetAddress address)
Set the Internet address of the host providing the XMPP service.
|
B |
setHostAddressByNameOrIp(java.lang.CharSequence fqdnOrIp)
Deprecated.
use
setHost(CharSequence) instead. |
B |
setHostnameVerifier(javax.net.ssl.HostnameVerifier verifier)
Set the HostnameVerifier used to verify the hostname of SSLSockets used by XMPP connections
created with this ConnectionConfiguration.
|
B |
setKeyManager(javax.net.ssl.KeyManager keyManager)
Set the
KeyManagers to initialize the SSLContext used by Smack to establish the XMPP connection. |
B |
setKeyManagers(javax.net.ssl.KeyManager[] keyManagers)
Set the
KeyManagers to initialize the SSLContext used by Smack to establish the XMPP connection. |
B |
setKeystorePath(java.lang.String keystorePath)
Deprecated.
set a keystore-path aware
KeyManager via setKeyManager(KeyManager) or
setKeyManagers(KeyManager[]), created by
getKeyManagersFrom(String, String, CallbackHandler, String), instead. |
B |
setKeystoreType(java.lang.String keystoreType)
Deprecated.
set a key-type aware
KeyManager via setKeyManager(KeyManager) or
setKeyManagers(KeyManager[]), created by
getKeyManagersFrom(String, String, CallbackHandler, String), instead. |
B |
setLanguage(java.util.Locale language)
Set the stream language.
|
B |
setPKCS11Library(java.lang.String pkcs11Library)
Deprecated.
set a PKCS11-library aware
KeyManager via setKeyManager(KeyManager) or
setKeyManagers(KeyManager[]), created by
getKeyManagersFrom(String, String, CallbackHandler, String), instead. |
B |
setPort(int port) |
B |
setPort(UInt16 port) |
B |
setProxyInfo(ProxyInfo proxyInfo)
Set the information about the Proxy used for the connection.
|
B |
setResource(java.lang.CharSequence resource)
Set the resource we are requesting from the server.
|
B |
setResource(org.jxmpp.jid.parts.Resourcepart resource)
Set the resource we are requesting from the server.
|
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(org.jxmpp.jid.DomainBareJid serviceName)
Deprecated.
use
setXmppDomain(DomainBareJid) instead. |
B |
setSocketFactory(javax.net.SocketFactory socketFactory)
Sets the socket factory used to create new xmppConnection sockets.
|
B |
setSslContextFactory(SslContextFactory sslContextFactory)
Sets a custom SSLContext for creating SSL sockets.
|
B |
setSslContextSecureRandom(java.security.SecureRandom secureRandom)
Set the
SecureRandom used to initialize the SSLContext used by Smack to establish the XMPP
connection. |
B |
setStanzaIdSourceFactory(StanzaIdSourceFactory stanzaIdSourceFactory)
Set the factory for stanza ID sources to use.
|
B |
setUsernameAndPassword(java.lang.CharSequence username,
java.lang.String password)
Set the XMPP entities username and password.
|
B |
setXmppAddressAndPassword(java.lang.CharSequence jid,
java.lang.String password)
Convenience method to configure the username, password and XMPP service domain.
|
B |
setXmppAddressAndPassword(org.jxmpp.jid.EntityBareJid jid,
java.lang.String password)
Convenience method to configure the username, password and XMPP service domain.
|
B |
setXmppDomain(org.jxmpp.jid.DomainBareJid xmppDomain)
Set the XMPP domain.
|
B |
setXmppDomain(java.lang.String xmppServiceDomain)
Set the XMPP domain.
|
public B setXmppAddressAndPassword(java.lang.CharSequence jid, java.lang.String password) throws org.jxmpp.stringprep.XmppStringprepException
jid - the XMPP address of the user.password - the password of the user.org.jxmpp.stringprep.XmppStringprepException - in case the XMPP address is not valid.setXmppAddressAndPassword(EntityBareJid, String)public B setXmppAddressAndPassword(org.jxmpp.jid.EntityBareJid jid, java.lang.String password)
Please note that this does and can not configure the client XMPP address. XMPP services are not required to assign bound JIDs where the localpart matches the username and the domainpart matches the verified domainpart. Although most services will follow that pattern.
jid - TODO javadoc me pleasepassword - TODO javadoc me pleasepublic B setUsernameAndPassword(java.lang.CharSequence username, java.lang.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 authenticate@Deprecated public B setServiceName(org.jxmpp.jid.DomainBareJid serviceName)
setXmppDomain(DomainBareJid) instead.serviceName - the service namepublic B setXmppDomain(org.jxmpp.jid.DomainBareJid xmppDomain)
xmppDomain - the XMPP domain.public B setXmppDomain(java.lang.String xmppServiceDomain) throws org.jxmpp.stringprep.XmppStringprepException
xmppServiceDomain - the XMPP domain.org.jxmpp.stringprep.XmppStringprepException - if the given string is not a domain bare JID.public B setResource(org.jxmpp.jid.parts.Resourcepart resource)
If resource is null, the default, then the server will automatically create a
resource for the client. Note that XMPP clients only suggest this resource to the server. XMPP servers are
allowed to ignore the client suggested resource and instead assign a completely different
resource (see RFC 6120 § 7.7.1).
resource - the resource to use.public B setLanguage(java.util.Locale language)
language - the language to use.public B setResource(java.lang.CharSequence resource) throws org.jxmpp.stringprep.XmppStringprepException
resource - the non-null CharSequence to use a resource.org.jxmpp.stringprep.XmppStringprepException - if the CharSequence is not a valid resourcepart.setResource(Resourcepart)public B setHostAddress(java.net.InetAddress address)
setHost(CharSequence).address - the Internet address of the host providing the XMPP service.public B setHost(java.lang.CharSequence host)
host - the DNS name of the host providing the XMPP service.public B setHost(org.minidns.dnsname.DnsName host)
setHostAddress(InetAddress) if you want to explicitly set the Internet address of
the host providing the XMPP service.host - the DNS name of the host providing the XMPP service.@Deprecated public B setHostAddressByNameOrIp(java.lang.CharSequence fqdnOrIp)
setHost(CharSequence) instead.fqdnOrIp - a CharSequence either representing the FQDN or the IP of the host.setHost(DnsName),
setHostAddress(InetAddress)public B setPort(int port)
@Deprecated public B setCallbackHandler(javax.security.auth.callback.CallbackHandler callbackHandler)
KeyManager via setKeyManager(KeyManager) or
setKeyManagers(KeyManager[]), created by
getKeyManagersFrom(String, String, CallbackHandler, String), instead.callbackHandler - to obtain information, such as the password or
principal information during the SASL authentication.public B setDnssecMode(ConnectionConfiguration.DnssecMode dnssecMode)
public B setCustomX509TrustManager(javax.net.ssl.X509TrustManager x509TrustManager)
public B setSecurityMode(ConnectionConfiguration.SecurityMode securityMode)
ConnectionConfiguration.SecurityMode.required.securityMode - the security mode.public B setKeyManagers(javax.net.ssl.KeyManager[] keyManagers)
KeyManagers to initialize the SSLContext used by Smack to establish the XMPP connection.keyManagers - an array of KeyManagers to initialize the SSLContext with.public B setKeyManager(javax.net.ssl.KeyManager keyManager)
KeyManagers to initialize the SSLContext used by Smack to establish the XMPP connection.keyManager - the KeyManagers to initialize the SSLContext with.setKeyManagers(KeyManager[])public B setSslContextSecureRandom(java.security.SecureRandom secureRandom)
SecureRandom used to initialize the SSLContext used by Smack to establish the XMPP
connection. Note that you usually do not need (nor want) to set this. Because if the SecureRandom is
not explicitly set, Smack will initialize the SSLContext with null as
SecureRandom argument. And all sane SSLContext implementations will then select a safe secure
random source by default.secureRandom - the SecureRandom to initialize the SSLContext with.@Deprecated public B setKeystorePath(java.lang.String keystorePath)
KeyManager via setKeyManager(KeyManager) or
setKeyManagers(KeyManager[]), created by
getKeyManagersFrom(String, String, CallbackHandler, String), instead.keystorePath - the path to the keystore file.@Deprecated public B setKeystoreType(java.lang.String keystoreType)
KeyManager via setKeyManager(KeyManager) or
setKeyManagers(KeyManager[]), created by
getKeyManagersFrom(String, String, CallbackHandler, String), instead.keystoreType - the keystore type.@Deprecated public B setPKCS11Library(java.lang.String pkcs11Library)
KeyManager via setKeyManager(KeyManager) or
setKeyManagers(KeyManager[]), created by
getKeyManagersFrom(String, String, CallbackHandler, String), instead.pkcs11Library - the path to the PKCS11 library file.@Deprecated public B setCustomSSLContext(javax.net.ssl.SSLContext context)
setSslContextFactory(SslContextFactory) instead}.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 setSslContextFactory(SslContextFactory sslContextFactory)
For more information on how to create a SSLContext see Java Secure Socket Extension (JSEE) Reference Guide: Creating Your Own X509TrustManager
sslContextFactory - the custom SSLContext for new sockets.public B setEnabledSSLProtocols(java.lang.String[] enabledSSLProtocols)
enabledSSLProtocols - TODO javadoc me pleasepublic B setEnabledSSLCiphers(java.lang.String[] enabledSSLCiphers)
enabledSSLCiphers - the enabled SSL/TLS cipherspublic B setHostnameVerifier(javax.net.ssl.HostnameVerifier verifier)
verifier - TODO javadoc me pleasepublic B setSendPresence(boolean sendPresence)
false value.sendPresence - true if an initial available presence will be sent while logging in.public B enableDefaultDebugger()
public B setDebuggerFactory(SmackDebuggerFactory debuggerFactory)
debuggerFactory - the Smack debugger factory.public B setSocketFactory(javax.net.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.public B performSaslAnonymousAuthentication()
addEnabledSaslMechanism(String) with "ANONYMOUS" as argument.public B performSaslExternalAuthentication(javax.net.ssl.SSLContext sslContext)
addEnabledSaslMechanism(String) with "EXTERNAL" as
argument. It also calls allowEmptyOrNullUsernames() and setSecurityMode(ConnectionConfiguration.SecurityMode) to
ConnectionConfiguration.SecurityMode.required.sslContext - custom SSLContext to be used.public B addEnabledSaslMechanism(java.lang.String saslMechanism)
addEnabledSaslMechanism(Collection) for a discussion about enabled SASL mechanisms.saslMechanism - the name of the mechanism to enable.public B addEnabledSaslMechanism(java.util.Collection<java.lang.String> saslMechanisms)
saslMechanisms - a collection of names of mechanisms to enable.public B setAuthzid(org.jxmpp.jid.EntityBareJid authzid)
In XMPP, authorization identities are bare jids. In general, callers should allow the server to select the authorization identifier automatically, and not call this. Note that setting the authzid does not set the XMPP service domain, which should typically match. Calling this will also SASL CRAM, since this mechanism does not support authzid.
authzid - The BareJid to be requested as the authorization identifier.public B setCompressionEnabled(boolean compressionEnabled)
compressionEnabled - if the connection is going to use compression on the HTTP level.public B setStanzaIdSourceFactory(StanzaIdSourceFactory stanzaIdSourceFactory)
stanzaIdSourceFactory - the factory for stanza ID sources to use.public abstract C build()
protected abstract B getThis()
public static javax.net.ssl.KeyManager[] getKeyManagersFrom(java.lang.String keystoreType,
java.lang.String keystorePath,
javax.security.auth.callback.CallbackHandler callbackHandler,
java.lang.String pkcs11Library)
throws java.lang.NoSuchMethodException,
java.lang.SecurityException,
java.lang.ClassNotFoundException,
java.security.KeyStoreException,
java.security.NoSuchProviderException,
java.security.NoSuchAlgorithmException,
java.security.cert.CertificateException,
java.io.IOException,
java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.IllegalArgumentException,
java.lang.reflect.InvocationTargetException,
javax.security.auth.callback.UnsupportedCallbackException,
java.security.UnrecoverableKeyException
java.lang.NoSuchMethodExceptionjava.lang.SecurityExceptionjava.lang.ClassNotFoundExceptionjava.security.KeyStoreExceptionjava.security.NoSuchProviderExceptionjava.security.NoSuchAlgorithmExceptionjava.security.cert.CertificateExceptionjava.io.IOExceptionjava.lang.InstantiationExceptionjava.lang.IllegalAccessExceptionjava.lang.IllegalArgumentExceptionjava.lang.reflect.InvocationTargetExceptionjavax.security.auth.callback.UnsupportedCallbackExceptionjava.security.UnrecoverableKeyException