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 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(Collection<String> saslMechanisms)
Enable the given SASL mechanisms.
|
B |
addEnabledSaslMechanism(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() |
protected abstract B |
getThis() |
B |
performSaslAnonymousAuthentication()
Perform anonymous authentication using SASL ANONYMOUS.
|
B |
performSaslExternalAuthentication(SSLContext sslContext)
Perform authentication using SASL EXTERNAL.
|
B |
setAuthzid(EntityBareJid authzid)
Set the XMPP address to be used as authorization identity.
|
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 |
setCustomX509TrustManager(X509TrustManager x509TrustManager) |
B |
setDebuggerFactory(SmackDebuggerFactory debuggerFactory)
Set the Smack debugger factory used to construct Smack debuggers.
|
B |
setDnssecMode(ConnectionConfiguration.DnssecMode dnssecMode) |
B |
setEnabledSSLCiphers(String[] enabledSSLCiphers)
Set the enabled SSL/TLS ciphers.
|
B |
setEnabledSSLProtocols(String[] enabledSSLProtocols)
Set the enabled SSL/TLS protocols.
|
B |
setHost(org.minidns.dnsname.DnsName host)
Set the name of the host providing the XMPP service.
|
B |
setHost(String host)
Set the name of the host providing the XMPP service.
|
B |
setHostAddress(InetAddress address)
Set the Internet address of the host providing the XMPP service.
|
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 |
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(CharSequence resource)
Set the resource we are requesting from the server.
|
B |
setResource(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(DomainBareJid serviceName)
Deprecated.
use
setXmppDomain(DomainBareJid) instead. |
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.
|
B |
setXmppDomain(DomainBareJid xmppDomain)
Set the XMPP domain.
|
B |
setXmppDomain(String xmppServiceDomain)
Set the XMPP domain.
|
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 authenticate@Deprecated public B setServiceName(DomainBareJid serviceName)
setXmppDomain(DomainBareJid)
instead.serviceName
- the service namepublic B setXmppDomain(DomainBareJid xmppDomain)
xmppDomain
- the XMPP domain.public B setXmppDomain(String xmppServiceDomain) throws XmppStringprepException
xmppServiceDomain
- the XMPP domain.XmppStringprepException
- if the given string is not a domain bare JID.public B setResource(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 setResource(CharSequence resource) throws XmppStringprepException
resource
- the non-null CharSequence to use a resource.XmppStringprepException
- if the CharSequence is not a valid resourcepart.setResource(Resourcepart)
public B setHostAddress(InetAddress address)
setHost(String)
.address
- the Internet address of the host providing the XMPP service.public B setHost(String 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.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.public B setCallbackHandler(CallbackHandler callbackHandler)
callbackHandler
- to obtain information, such as the password or
principal information during the SASL authentication.public B setDnssecMode(ConnectionConfiguration.DnssecMode dnssecMode)
public B setCustomX509TrustManager(X509TrustManager x509TrustManager)
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
- public B setSendPresence(boolean sendPresence)
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(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(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(String saslMechanism)
addEnabledSaslMechanism(Collection)
for a discussion about enabled SASL mechanisms.saslMechanism
- the name of the mechanism to enable.public B addEnabledSaslMechanism(Collection<String> saslMechanisms)
saslMechanisms
- a collection of names of mechanisms to enable.public B setAuthzid(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.