mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 02:27:58 +01:00
Rename 'serviceName' to 'xmppServiceDomain'
Also use 'null' as default value for the resource, to enforce server generated resources. Fixes Smack-665
This commit is contained in:
parent
0c8199650b
commit
f369a009ac
38 changed files with 116 additions and 104 deletions
|
@ -113,12 +113,12 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
|||
* (e.g. 7070 for http://domain.lt:7070/http-bind).
|
||||
* @param filePath the file which is described by the URL
|
||||
* (e.g. /http-bind for http://domain.lt:7070/http-bind).
|
||||
* @param xmppDomain the XMPP service name
|
||||
* @param xmppServiceDomain the XMPP service name
|
||||
* (e.g. domain.lt for the user alice@domain.lt)
|
||||
*/
|
||||
public XMPPBOSHConnection(String username, String password, boolean https, String host, int port, String filePath, DomainBareJid xmppDomain) {
|
||||
public XMPPBOSHConnection(String username, String password, boolean https, String host, int port, String filePath, DomainBareJid xmppServiceDomain) {
|
||||
this(BOSHConfiguration.builder().setUseHttps(https).setHost(host)
|
||||
.setPort(port).setFile(filePath).setServiceName(xmppDomain)
|
||||
.setPort(port).setFile(filePath).setServiceName(xmppServiceDomain)
|
||||
.setUsernameAndPassword(username, password).build());
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
|||
|
||||
// Initialize BOSH client
|
||||
BOSHClientConfig.Builder cfgBuilder = BOSHClientConfig.Builder
|
||||
.create(config.getURI(), config.getServiceName().toString());
|
||||
.create(config.getURI(), config.getXMPPServiceDomain().toString());
|
||||
if (config.isProxyEnabled()) {
|
||||
cfgBuilder.setProxy(config.getProxyAddress(), config.getProxyPort());
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
|||
XMPPBOSHConnection.XMPP_BOSH_NS).setAttribute(
|
||||
BodyQName.createWithPrefix(XMPPBOSHConnection.XMPP_BOSH_NS, "restart",
|
||||
"xmpp"), "true").setAttribute(
|
||||
BodyQName.create(XMPPBOSHConnection.BOSH_URI, "to"), getServiceName().toString()).build());
|
||||
BodyQName.create(XMPPBOSHConnection.BOSH_URI, "to"), getXMPPServiceDomain().toString()).build());
|
||||
Success success = new Success(parser.nextText());
|
||||
getSASLAuthentication().authenticated(success);
|
||||
break;
|
||||
|
|
|
@ -193,7 +193,7 @@ public class MessageTest extends SmackTestCase {
|
|||
public void testHighestPriority() throws Exception {
|
||||
// Create another connection for the same user of connection 1
|
||||
ConnectionConfiguration connectionConfiguration =
|
||||
new ConnectionConfiguration(getHost(), getPort(), getServiceName());
|
||||
new ConnectionConfiguration(getHost(), getPort(), getXMPPServiceDomain());
|
||||
XMPPTCPConnection conn3 = new XMPPConnection(connectionConfiguration);
|
||||
conn3.connect();
|
||||
conn3.login(getUsername(0), getPassword(0), "Home");
|
||||
|
@ -242,7 +242,7 @@ public class MessageTest extends SmackTestCase {
|
|||
public void testHighestShow() throws Exception {
|
||||
// Create another connection for the same user of connection 1
|
||||
ConnectionConfiguration connectionConfiguration =
|
||||
new ConnectionConfiguration(getHost(), getPort(), getServiceName());
|
||||
new ConnectionConfiguration(getHost(), getPort(), getXMPPServiceDomain());
|
||||
XMPPTCPConnection conn3 = new XMPPConnection(connectionConfiguration);
|
||||
conn3.connect();
|
||||
conn3.login(getUsername(0), getPassword(0), "Home");
|
||||
|
@ -291,7 +291,7 @@ public class MessageTest extends SmackTestCase {
|
|||
public void testMostRecentActive() throws Exception {
|
||||
// Create another connection for the same user of connection 1
|
||||
ConnectionConfiguration connectionConfiguration =
|
||||
new ConnectionConfiguration(getHost(), getPort(), getServiceName());
|
||||
new ConnectionConfiguration(getHost(), getPort(), getXMPPServiceDomain());
|
||||
XMPPTCPConnection conn3 = new XMPPConnection(connectionConfiguration);
|
||||
conn3.connect();
|
||||
conn3.login(getUsername(0), getPassword(0), "Home");
|
||||
|
@ -307,7 +307,7 @@ public class MessageTest extends SmackTestCase {
|
|||
getConnection(0).sendStanza(presence);
|
||||
|
||||
connectionConfiguration =
|
||||
new ConnectionConfiguration(getHost(), getPort(), getServiceName());
|
||||
new ConnectionConfiguration(getHost(), getPort(), getXMPPServiceDomain());
|
||||
XMPPTCPConnection conn4 = new XMPPConnection(connectionConfiguration);
|
||||
conn4.connect();
|
||||
conn4.login(getUsername(0), getPassword(0), "Home2");
|
||||
|
@ -326,7 +326,7 @@ public class MessageTest extends SmackTestCase {
|
|||
PacketCollector coll4 = conn4.createPacketCollector(new MessageTypeFilter(Message.Type.chat));
|
||||
|
||||
// Send a message from this resource to indicate most recent activity
|
||||
conn3.sendStanza(new Message("admin@" + getServiceName()));
|
||||
conn3.sendStanza(new Message("admin@" + getXMPPServiceDomain()));
|
||||
|
||||
// User1 sends a message to the bare JID of User0
|
||||
Chat chat = getConnection(1).getChatManager().createChat(getBareJID(0), null);
|
||||
|
|
|
@ -168,7 +168,7 @@ public class PresenceTest extends SmackTestCase {
|
|||
public void testMultipleResources() throws Exception {
|
||||
// Create another connection for the same user of connection 1
|
||||
ConnectionConfiguration connectionConfiguration =
|
||||
new ConnectionConfiguration(getHost(), getPort(), getServiceName());
|
||||
new ConnectionConfiguration(getHost(), getPort(), getXMPPServiceDomain());
|
||||
XMPPTCPConnection conn4 = new XMPPConnection(connectionConfiguration);
|
||||
conn4.connect();
|
||||
conn4.login(getUsername(1), getPassword(1), "Home");
|
||||
|
|
|
@ -434,7 +434,7 @@ public class RosterSmackTest extends SmackTestCase {
|
|||
|
||||
// Create another connection for the same user of connection 1
|
||||
ConnectionConfiguration connectionConfiguration =
|
||||
new ConnectionConfiguration(getHost(), getPort(), getServiceName());
|
||||
new ConnectionConfiguration(getHost(), getPort(), getXMPPServiceDomain());
|
||||
XMPPTCPConnection conn4 = new XMPPConnection(connectionConfiguration);
|
||||
conn4.connect();
|
||||
conn4.login(getUsername(1), getPassword(1), "Home");
|
||||
|
@ -455,7 +455,7 @@ public class RosterSmackTest extends SmackTestCase {
|
|||
assertTrue("Returned a null Presence for an existing user", presence.isAvailable());
|
||||
|
||||
// Check that the right presence is returned for a user+resource
|
||||
presence = roster.getPresenceResource(getUsername(1) + "@" + conn4.getServiceName() + "/Home");
|
||||
presence = roster.getPresenceResource(getUsername(1) + "@" + conn4.getXMPPServiceDomain() + "/Home");
|
||||
assertEquals("Returned the wrong Presence", "Home",
|
||||
StringUtils.parseResource(presence.getFrom()));
|
||||
|
||||
|
@ -466,7 +466,7 @@ public class RosterSmackTest extends SmackTestCase {
|
|||
StringUtils.parseResource(presence.getFrom()));
|
||||
|
||||
// Check the returned presence for a non-existent user+resource
|
||||
presence = roster.getPresenceResource("noname@" + getServiceName() + "/Smack");
|
||||
presence = roster.getPresenceResource("noname@" + getXMPPServiceDomain() + "/Smack");
|
||||
assertFalse("Available presence was returned for a non-existing user", presence.isAvailable());
|
||||
assertEquals("Returned Presence for a non-existing user has the incorrect type",
|
||||
Presence.Type.unavailable, presence.getType());
|
||||
|
@ -501,7 +501,7 @@ public class RosterSmackTest extends SmackTestCase {
|
|||
public void testMultipleResources() throws Exception {
|
||||
// Create another connection for the same user of connection 1
|
||||
ConnectionConfiguration connectionConfiguration =
|
||||
new ConnectionConfiguration(getHost(), getPort(), getServiceName());
|
||||
new ConnectionConfiguration(getHost(), getPort(), getXMPPServiceDomain());
|
||||
XMPPTCPConnection conn4 = new XMPPConnection(connectionConfiguration);
|
||||
conn4.connect();
|
||||
conn4.login(getUsername(1), getPassword(1), "Home");
|
||||
|
@ -566,7 +566,7 @@ public class RosterSmackTest extends SmackTestCase {
|
|||
|
||||
// Create another connection for the same user of connection 0
|
||||
ConnectionConfiguration connectionConfiguration =
|
||||
new ConnectionConfiguration(getHost(), getPort(), getServiceName());
|
||||
new ConnectionConfiguration(getHost(), getPort(), getXMPPServiceDomain());
|
||||
XMPPTCPConnection conn2 = new XMPPConnection(connectionConfiguration);
|
||||
conn2.connect();
|
||||
conn2.login(getUsername(0), getPassword(0), "Home");
|
||||
|
|
|
@ -185,7 +185,7 @@ public abstract class SmackTestCase extends TestCase {
|
|||
* @return the bare XMPP address of the user (e.g. johndoe@jabber.org).
|
||||
*/
|
||||
protected String getBareJID(int index) {
|
||||
return getUsername(index) + "@" + getConnection(index).getServiceName();
|
||||
return getUsername(index) + "@" + getConnection(index).getXMPPServiceDomain();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -207,7 +207,7 @@ public abstract class SmackTestCase extends TestCase {
|
|||
return port;
|
||||
}
|
||||
|
||||
protected String getServiceName() {
|
||||
protected String getXMPPServiceDomain() {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ public abstract class SmackTestCase extends TestCase {
|
|||
// cases, but could fail if the user set a hostname in their XMPP server
|
||||
// that will not resolve as a network connection.
|
||||
host = connections[0].getHost();
|
||||
serviceName = connections[0].getServiceName();
|
||||
serviceName = connections[0].getXMPPServiceDomain();
|
||||
|
||||
if (!createOfflineConnections()) {
|
||||
for (int i = 0; i < getMaxConnections(); i++) {
|
||||
|
|
|
@ -111,7 +111,7 @@ public class DNSUtilTest {
|
|||
}
|
||||
|
||||
private void xmppClientDomainTest() {
|
||||
List<HostAddress> hostAddresses = DNSUtil.resolveXMPPDomain(igniterealtimeDomain);
|
||||
List<HostAddress> hostAddresses = DNSUtil.resolveXMPPServiceDomain(igniterealtimeDomain);
|
||||
HostAddress ha = hostAddresses.get(0);
|
||||
assertEquals(ha.getFQDN(), igniterealtimeXMPPServer);
|
||||
assertEquals(ha.getPort(), igniterealtimeClientPort);
|
||||
|
|
|
@ -303,12 +303,18 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
return config;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public DomainBareJid getServiceName() {
|
||||
if (serviceName != null) {
|
||||
return serviceName;
|
||||
return getXMPPServiceDomain();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainBareJid getXMPPServiceDomain() {
|
||||
if (xmppServiceDomain != null) {
|
||||
return xmppServiceDomain;
|
||||
}
|
||||
return config.getServiceName();
|
||||
return config.getXMPPServiceDomain();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -506,7 +512,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
// from the login() arguments and the configurations service name, as, for example, when SASL External is used,
|
||||
// the username is not given to login but taken from the 'external' certificate.
|
||||
user = response.getJid();
|
||||
serviceName = user.asDomainBareJid();
|
||||
xmppServiceDomain = user.asDomainBareJid();
|
||||
|
||||
Session.Feature sessionFeature = getFeature(Session.ELEMENT, Session.NAMESPACE);
|
||||
// Only bind the session if it's announced as stream feature by the server, is not optional and not disabled
|
||||
|
@ -549,7 +555,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
&& !config.allowNullOrEmptyUsername;
|
||||
}
|
||||
|
||||
private DomainBareJid serviceName;
|
||||
private DomainBareJid xmppServiceDomain;
|
||||
|
||||
protected List<HostAddress> hostAddresses;
|
||||
|
||||
|
@ -567,7 +573,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
hostAddress = new HostAddress(config.host, config.port);
|
||||
hostAddresses.add(hostAddress);
|
||||
} else {
|
||||
hostAddresses = DNSUtil.resolveXMPPDomain(config.serviceName.toString(), failedAddresses);
|
||||
hostAddresses = DNSUtil.resolveXMPPServiceDomain(config.getXMPPServiceDomain().toString(), failedAddresses);
|
||||
}
|
||||
// If we reach this, then hostAddresses *must not* be empty, i.e. there is at least one host added, either the
|
||||
// config.host one or the host representing the service name by DNSUtil
|
||||
|
|
|
@ -22,8 +22,6 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.packet.Session;
|
||||
import org.jivesoftware.smack.proxy.ProxyInfo;
|
||||
|
@ -54,14 +52,13 @@ public abstract class ConnectionConfiguration {
|
|||
SmackConfiguration.getVersion();
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ConnectionConfiguration.class.getName());
|
||||
|
||||
/**
|
||||
* Hostname of the XMPP server. Usually servers use the same service name as the name
|
||||
* 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.
|
||||
*/
|
||||
protected final DomainBareJid serviceName;
|
||||
protected final DomainBareJid xmppServiceDomain;
|
||||
|
||||
protected final String host;
|
||||
protected final int port;
|
||||
|
||||
|
@ -120,9 +117,9 @@ public abstract class ConnectionConfiguration {
|
|||
// Resource can be null, this means that the server must provide one
|
||||
resource = builder.resource;
|
||||
|
||||
serviceName = builder.serviceName;
|
||||
if (serviceName == null) {
|
||||
throw new IllegalArgumentException("Must provide XMPP service name");
|
||||
xmppServiceDomain = builder.xmppServiceDomain;
|
||||
if (xmppServiceDomain == null) {
|
||||
throw new IllegalArgumentException("Must define the XMPP domain");
|
||||
}
|
||||
host = builder.host;
|
||||
port = builder.port;
|
||||
|
@ -159,9 +156,20 @@ public abstract class ConnectionConfiguration {
|
|||
* Returns the server name of the target server.
|
||||
*
|
||||
* @return the server name of the target server.
|
||||
* @deprecated use {@link #getXMPPServiceDomain()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public DomainBareJid getServiceName() {
|
||||
return serviceName;
|
||||
return xmppServiceDomain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XMPP domain used by this configuration.
|
||||
*
|
||||
* @return the XMPP domain.
|
||||
*/
|
||||
public DomainBareJid getXMPPServiceDomain() {
|
||||
return xmppServiceDomain;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -407,19 +415,6 @@ public abstract class ConnectionConfiguration {
|
|||
* @param <C> the resulting connection configuration type parameter.
|
||||
*/
|
||||
public static abstract class Builder<B extends Builder<B, C>, C extends ConnectionConfiguration> {
|
||||
private static final Resourcepart DEFAULT_RESOURCE;
|
||||
|
||||
static {
|
||||
Resourcepart resourcepart = null;
|
||||
try {
|
||||
resourcepart = Resourcepart.from("Smack");
|
||||
}
|
||||
catch (XmppStringprepException e) {
|
||||
LOGGER.log(Level.WARNING, "Could not create default resourcepart", e);
|
||||
}
|
||||
DEFAULT_RESOURCE = resourcepart;
|
||||
}
|
||||
|
||||
private SecurityMode securityMode = SecurityMode.ifpossible;
|
||||
private String keystorePath = System.getProperty("javax.net.ssl.keyStore");
|
||||
private String keystoreType = "jks";
|
||||
|
@ -430,14 +425,14 @@ public abstract class ConnectionConfiguration {
|
|||
private HostnameVerifier hostnameVerifier;
|
||||
private CharSequence username;
|
||||
private String password;
|
||||
private Resourcepart resource = DEFAULT_RESOURCE;
|
||||
private Resourcepart resource;
|
||||
private boolean sendPresence = true;
|
||||
private boolean legacySessionDisabled = false;
|
||||
private ProxyInfo proxy;
|
||||
private CallbackHandler callbackHandler;
|
||||
private boolean debuggerEnabled = SmackConfiguration.DEBUG;
|
||||
private SocketFactory socketFactory;
|
||||
private DomainBareJid serviceName;
|
||||
private DomainBareJid xmppServiceDomain;
|
||||
private String host;
|
||||
private int port = 5222;
|
||||
private boolean allowEmptyOrNullUsername = false;
|
||||
|
@ -471,7 +466,7 @@ public abstract class ConnectionConfiguration {
|
|||
* @return a reference to this builder.
|
||||
*/
|
||||
public B setServiceName(DomainBareJid serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
this.xmppServiceDomain = serviceName;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
|
@ -496,7 +491,7 @@ public abstract class ConnectionConfiguration {
|
|||
* @param resource the non-null CharSequence to use a resource.
|
||||
* @return a reference ot this builder.
|
||||
* @throws XmppStringprepException if the CharSequence is not a valid resourcepart.
|
||||
* @see setResource(Resourcepart)
|
||||
* @see #setResource(Resourcepart)
|
||||
*/
|
||||
public B setResource(CharSequence resource) throws XmppStringprepException {
|
||||
Objects.requireNonNull(resource, "resource must not be null");
|
||||
|
|
|
@ -183,14 +183,14 @@ public class SASLAuthentication {
|
|||
currentMechanism = selectMechanism();
|
||||
final CallbackHandler callbackHandler = configuration.getCallbackHandler();
|
||||
final String host = connection.getHost();
|
||||
final DomainBareJid xmppDomain = connection.getServiceName();
|
||||
final DomainBareJid xmppServiceDomain = connection.getXMPPServiceDomain();
|
||||
|
||||
synchronized (this) {
|
||||
if (callbackHandler != null) {
|
||||
currentMechanism.authenticate(host, xmppDomain, callbackHandler);
|
||||
currentMechanism.authenticate(host, xmppServiceDomain, callbackHandler);
|
||||
}
|
||||
else {
|
||||
currentMechanism.authenticate(username, host, xmppDomain, password);
|
||||
currentMechanism.authenticate(username, host, xmppServiceDomain, password);
|
||||
}
|
||||
// Wait until SASL negotiation finishes
|
||||
wait(connection.getPacketReplyTimeout());
|
||||
|
|
|
@ -78,9 +78,20 @@ public interface XMPPConnection {
|
|||
* authenticating with the server the returned value may be different.
|
||||
*
|
||||
* @return the name of the service provided by the XMPP server.
|
||||
// TODO remove this once the java bugs are fixed, causing a warning
|
||||
// * @deprecated use {@link #getXMPPServiceDomain()} instead.
|
||||
*/
|
||||
// @Deprecated
|
||||
public DomainBareJid getServiceName();
|
||||
|
||||
/**
|
||||
* Returns the XMPP Domain of the service provided by the XMPP server and used for this connection. After
|
||||
* authenticating with the server the returned value may be different.
|
||||
*
|
||||
* @return the XMPP domain of this XMPP session.
|
||||
*/
|
||||
public DomainBareJid getXMPPServiceDomain();
|
||||
|
||||
/**
|
||||
* Returns the host name of the server where the XMPP server is running. This would be the
|
||||
* IP address of the server or a name that may be resolved by a DNS server.
|
||||
|
|
|
@ -149,7 +149,7 @@ public abstract class AbstractDebugger implements SmackDebugger {
|
|||
"User logged (" + connection.getConnectionCounter() + "): "
|
||||
+ (isAnonymous ? "" : localpart)
|
||||
+ "@"
|
||||
+ connection.getServiceName()
|
||||
+ connection.getXMPPServiceDomain()
|
||||
+ ":"
|
||||
+ connection.getPort();
|
||||
title += "/" + user.getResourcepart();
|
||||
|
|
|
@ -91,7 +91,7 @@ public class IQReplyFilter implements StanzaFilter {
|
|||
throw new IllegalArgumentException("Must have a local (user) JID set. Either you didn't configure one or you where not connected at least once");
|
||||
}
|
||||
|
||||
server = conn.getServiceName();
|
||||
server = conn.getXMPPServiceDomain();
|
||||
packetId = iqPacket.getStanzaId();
|
||||
|
||||
StanzaFilter iqFilter = new OrFilter(IQTypeFilter.ERROR, IQTypeFilter.RESULT);
|
||||
|
|
|
@ -109,7 +109,7 @@ public class DNSUtil {
|
|||
* @return List of HostAddress, which encompasses the hostname and port that the
|
||||
* XMPP server can be reached at for the specified domain.
|
||||
*/
|
||||
public static List<HostAddress> resolveXMPPDomain(String domain, List<HostAddress> failedAddresses) {
|
||||
public static List<HostAddress> resolveXMPPServiceDomain(String domain, List<HostAddress> failedAddresses) {
|
||||
domain = idnaTransformer.transform(domain);
|
||||
if (dnsResolver == null) {
|
||||
LOGGER.warning("No DNS Resolver active in Smack, will be unable to perform DNS SRV lookups");
|
||||
|
|
|
@ -69,7 +69,7 @@ public class DummyConnection extends AbstractXMPPConnection {
|
|||
try {
|
||||
return JidCreate.fullFrom(config.getUsername()
|
||||
+ "@"
|
||||
+ config.getServiceName()
|
||||
+ config.getXMPPServiceDomain()
|
||||
+ "/"
|
||||
+ (config.getResource() != null ? config.getResource() : "Test"));
|
||||
}
|
||||
|
|
|
@ -621,7 +621,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
connPanel.add(
|
||||
label,
|
||||
new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
|
||||
JFormattedTextField field = new JFormattedTextField(connection.getServiceName());
|
||||
JFormattedTextField field = new JFormattedTextField(connection.getXMPPServiceDomain());
|
||||
field.setMinimumSize(new java.awt.Dimension(150, 20));
|
||||
field.setMaximumSize(new java.awt.Dimension(150, 20));
|
||||
field.setEditable(false);
|
||||
|
|
|
@ -81,7 +81,7 @@ public class LiteDebugger implements SmackDebugger {
|
|||
* Creates the debug process, which is a GUI window that displays XML traffic.
|
||||
*/
|
||||
private void createDebug() {
|
||||
frame = new JFrame("Smack Debug Window -- " + connection.getServiceName() + ":" +
|
||||
frame = new JFrame("Smack Debug Window -- " + connection.getXMPPServiceDomain() + ":" +
|
||||
connection.getPort());
|
||||
|
||||
// Add listener for window closing event
|
||||
|
|
|
@ -56,7 +56,7 @@ public class CompressionTest extends SmackTestCase {
|
|||
// Request the version of the server
|
||||
Version version = new Version();
|
||||
version.setType(IQ.Type.get);
|
||||
version.setTo(getServiceName());
|
||||
version.setTo(getXMPPServiceDomain());
|
||||
|
||||
// Create a packet collector to listen for a response.
|
||||
PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(version.getStanzaId()));
|
||||
|
@ -84,7 +84,7 @@ public class CompressionTest extends SmackTestCase {
|
|||
*/
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
XMPPTCPConnection setupConnection = new XMPPConnection(getServiceName());
|
||||
XMPPTCPConnection setupConnection = new XMPPConnection(getXMPPServiceDomain());
|
||||
setupConnection.connect();
|
||||
if (!setupConnection.getAccountManager().supportsAccountCreation())
|
||||
fail("Server does not support account creation");
|
||||
|
|
|
@ -114,7 +114,7 @@ public class ServiceDiscoveryManagerTest extends SmackTestCase {
|
|||
public void testDiscoverPublishItemsSupport() {
|
||||
try {
|
||||
boolean canPublish = ServiceDiscoveryManager.getInstanceFor(getConnection(0))
|
||||
.canPublishItems(getServiceName());
|
||||
.canPublishItems(getXMPPServiceDomain());
|
||||
assertFalse("Wildfire does not support publishing...so far!!", canPublish);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@ -135,7 +135,7 @@ public class ServiceDiscoveryManagerTest extends SmackTestCase {
|
|||
itemsToPublish.addItem(itemToPublish);
|
||||
|
||||
try {
|
||||
ServiceDiscoveryManager.getInstanceFor(getConnection(0)).publishItems(getServiceName(),
|
||||
ServiceDiscoveryManager.getInstanceFor(getConnection(0)).publishItems(getXMPPServiceDomain(),
|
||||
itemsToPublish);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
|
@ -224,7 +224,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
|||
try {
|
||||
// Anonymous user joins the new room
|
||||
ConnectionConfiguration connectionConfiguration =
|
||||
new ConnectionConfiguration(getHost(), getPort(), getServiceName());
|
||||
new ConnectionConfiguration(getHost(), getPort(), getXMPPServiceDomain());
|
||||
XMPPTCPConnection anonConnection = new XMPPConnection(connectionConfiguration);
|
||||
anonConnection.connect();
|
||||
anonConnection.loginAnonymously();
|
||||
|
@ -405,7 +405,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
|||
|
||||
public void testDiscoverMUCService() {
|
||||
try {
|
||||
Collection<String> services = MultiUserChat.getServiceNames(getConnection(1));
|
||||
Collection<String> services = MultiUserChat.getXMPPServiceDomains(getConnection(1));
|
||||
assertFalse("No MUC service was found", services.isEmpty());
|
||||
|
||||
// Discover the hosted rooms by the chat service.
|
||||
|
@ -1736,7 +1736,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
|||
XMPPTCPConnection[] conns = new XMPPConnection[5];
|
||||
for (int i = 0; i < conns.length; i++) {
|
||||
ConnectionConfiguration connectionConfiguration =
|
||||
new ConnectionConfiguration(getHost(), getPort(), getServiceName());
|
||||
new ConnectionConfiguration(getHost(), getPort(), getXMPPServiceDomain());
|
||||
connectionConfiguration.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
|
||||
conns[i] = new XMPPTCPConnection(connectionConfiguration);
|
||||
conns[i].connect();
|
||||
|
|
|
@ -52,7 +52,7 @@ public class TestEvents extends SmackTestCase
|
|||
|
||||
private String getService()
|
||||
{
|
||||
return "pubsub." + getServiceName();
|
||||
return "pubsub." + getXMPPServiceDomain();
|
||||
}
|
||||
|
||||
public void testCreateAndGetNode() throws Exception
|
||||
|
|
|
@ -87,6 +87,6 @@ abstract public class PubSubTestCase extends SmackTestCase
|
|||
|
||||
protected String getService()
|
||||
{
|
||||
return "pubsub." + getServiceName();
|
||||
return "pubsub." + getXMPPServiceDomain();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class AMPManager {
|
|||
* @return a boolean indicating if the AMP support is enabled for the given connection
|
||||
*/
|
||||
public static boolean isServiceEnabled(XMPPConnection connection) {
|
||||
connection.getServiceName();
|
||||
connection.getXMPPServiceDomain();
|
||||
return ServiceDiscoveryManager.getInstanceFor(connection).includesFeature(AMPExtension.NAMESPACE);
|
||||
}
|
||||
|
||||
|
|
|
@ -552,7 +552,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
|||
List<Jid> proxies = new ArrayList<>();
|
||||
|
||||
// get all items from XMPP server
|
||||
DiscoverItems discoverItems = serviceDiscoveryManager.discoverItems(this.connection.getServiceName());
|
||||
DiscoverItems discoverItems = serviceDiscoveryManager.discoverItems(this.connection.getXMPPServiceDomain());
|
||||
|
||||
// query all items if they are SOCKS5 proxies
|
||||
for (Item item : discoverItems.getItems()) {
|
||||
|
|
|
@ -302,7 +302,7 @@ public final class EntityCapsManager extends Manager {
|
|||
if (capsExtension == null) {
|
||||
return;
|
||||
}
|
||||
DomainBareJid from = connection.getServiceName();
|
||||
DomainBareJid from = connection.getXMPPServiceDomain();
|
||||
addCapsExtensionInfo(from, capsExtension);
|
||||
}
|
||||
});
|
||||
|
@ -456,7 +456,7 @@ public final class EntityCapsManager extends Manager {
|
|||
* @throws InterruptedException
|
||||
*/
|
||||
public boolean areEntityCapsSupportedByServer() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
return areEntityCapsSupported(connection().getServiceName());
|
||||
return areEntityCapsSupported(connection().getXMPPServiceDomain());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -661,7 +661,7 @@ public final class ServiceDiscoveryManager extends Manager {
|
|||
*/
|
||||
public boolean serverSupportsFeature(String feature) throws NoResponseException, XMPPErrorException,
|
||||
NotConnectedException, InterruptedException {
|
||||
return supportsFeature(connection().getServiceName(), feature);
|
||||
return supportsFeature(connection().getXMPPServiceDomain(), feature);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -702,7 +702,7 @@ public final class ServiceDiscoveryManager extends Manager {
|
|||
public List<DiscoverInfo> findServicesDiscoverInfo(String feature, boolean stopOnFirst, boolean useCache)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
List<DiscoverInfo> serviceDiscoInfo = null;
|
||||
DomainBareJid serviceName = connection().getServiceName();
|
||||
DomainBareJid serviceName = connection().getXMPPServiceDomain();
|
||||
if (useCache) {
|
||||
serviceDiscoInfo = services.get(feature);
|
||||
if (serviceDiscoInfo != null) {
|
||||
|
|
|
@ -273,7 +273,7 @@ public final class AccountManager extends Manager {
|
|||
attributes.put("password", password);
|
||||
Registration reg = new Registration(attributes);
|
||||
reg.setType(IQ.Type.set);
|
||||
reg.setTo(connection().getServiceName());
|
||||
reg.setTo(connection().getXMPPServiceDomain());
|
||||
createPacketCollectorAndSend(reg).nextResultOrThrow();
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ public final class AccountManager extends Manager {
|
|||
map.put("password",newPassword);
|
||||
Registration reg = new Registration(map);
|
||||
reg.setType(IQ.Type.set);
|
||||
reg.setTo(connection().getServiceName());
|
||||
reg.setTo(connection().getXMPPServiceDomain());
|
||||
createPacketCollectorAndSend(reg).nextResultOrThrow();
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ public final class AccountManager extends Manager {
|
|||
attributes.put("remove", "");
|
||||
Registration reg = new Registration(attributes);
|
||||
reg.setType(IQ.Type.set);
|
||||
reg.setTo(connection().getServiceName());
|
||||
reg.setTo(connection().getXMPPServiceDomain());
|
||||
createPacketCollectorAndSend(reg).nextResultOrThrow();
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ public final class AccountManager extends Manager {
|
|||
*/
|
||||
private synchronized void getRegistrationInfo() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
Registration reg = new Registration();
|
||||
reg.setTo(connection().getServiceName());
|
||||
reg.setTo(connection().getXMPPServiceDomain());
|
||||
info = createPacketCollectorAndSend(reg).nextResultOrThrow();
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public abstract class MultiUserChatException extends SmackException {
|
|||
|
||||
/**
|
||||
* Thrown when trying to enter a MUC room that is not hosted a domain providing a MUC service.
|
||||
* Try {@link MultiUserChatManager#getServiceNames()} for a list of client-local domains
|
||||
* Try {@link MultiUserChatManager#getXMPPServiceDomains()} for a list of client-local domains
|
||||
* providing a MUC service.
|
||||
*/
|
||||
public static class NotAMucServiceException extends MultiUserChatException {
|
||||
|
|
|
@ -256,7 +256,7 @@ public final class MultiUserChatManager extends Manager {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public List<DomainBareJid> getServiceNames() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
public List<DomainBareJid> getXMPPServiceDomains() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection());
|
||||
return sdm.findServices(MUCInitialPresence.NAMESPACE, false, false);
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ public final class PingManager extends Manager {
|
|||
connection.createPacketCollectorAndSend(ping).nextResultOrThrow(pingTimeout);
|
||||
}
|
||||
catch (XMPPException exc) {
|
||||
return jid.equals(connection.getServiceName());
|
||||
return jid.equals(connection.getXMPPServiceDomain());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ public final class PingManager extends Manager {
|
|||
public boolean pingMyServer(boolean notifyListeners, long pingTimeout) throws NotConnectedException, InterruptedException {
|
||||
boolean res;
|
||||
try {
|
||||
res = ping(connection().getServiceName(), pingTimeout);
|
||||
res = ping(connection().getXMPPServiceDomain(), pingTimeout);
|
||||
}
|
||||
catch (NoResponseException e) {
|
||||
res = false;
|
||||
|
|
|
@ -96,7 +96,7 @@ public final class PubSubManager extends Manager {
|
|||
if (pubSubService == null) {
|
||||
try {
|
||||
// Perform an educated guess about what the PubSub service's domain bare JID may be
|
||||
pubSubService = JidCreate.domainBareFrom("pubsub." + connection.getServiceName());
|
||||
pubSubService = JidCreate.domainBareFrom("pubsub." + connection.getXMPPServiceDomain());
|
||||
}
|
||||
catch (XmppStringprepException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
|
|
@ -160,7 +160,7 @@ public class PingTest extends InitExtensions {
|
|||
ThreadedDummyConnection con = getAuthentiactedDummyConnection();
|
||||
//@formatter:off
|
||||
String reply =
|
||||
"<iq type='error' id='qrzSp-16' to='test@myserver.com' from='" + con.getServiceName() + "'>" +
|
||||
"<iq type='error' id='qrzSp-16' to='test@myserver.com' from='" + con.getXMPPServiceDomain() + "'>" +
|
||||
"<ping xmlns='urn:xmpp:ping'/>" +
|
||||
"<error type='cancel'>" +
|
||||
"<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" +
|
||||
|
|
|
@ -74,7 +74,7 @@ public class ConnectionUtils {
|
|||
// mock XMPP connection
|
||||
XMPPConnection connection = mock(XMPPConnection.class);
|
||||
when(connection.getUser()).thenReturn(initiatorJID);
|
||||
when(connection.getServiceName()).thenReturn(xmppServer);
|
||||
when(connection.getXMPPServiceDomain()).thenReturn(xmppServer);
|
||||
|
||||
// mock packet collector
|
||||
final PacketCollector collector = mock(PacketCollector.class);
|
||||
|
|
|
@ -915,7 +915,7 @@ public final class Roster extends Manager {
|
|||
* @since 4.1
|
||||
*/
|
||||
public boolean isSubscribedToMyPresence(Jid jid) {
|
||||
if (connection().getServiceName().equals(jid)) {
|
||||
if (connection().getXMPPServiceDomain().equals(jid)) {
|
||||
return true;
|
||||
}
|
||||
RosterEntry entry = getEntry(jid);
|
||||
|
|
|
@ -52,7 +52,7 @@ public class MultiUserChatIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
mucManagerOne = MultiUserChatManager.getInstanceFor(conOne);
|
||||
mucManagerTwo = MultiUserChatManager.getInstanceFor(conTwo);
|
||||
|
||||
List<DomainBareJid> services = mucManagerOne.getServiceNames();
|
||||
List<DomainBareJid> services = mucManagerOne.getXMPPServiceDomains();
|
||||
if (services.isEmpty()) {
|
||||
throw new TestNotPossibleException("No MUC (XEP-45) service found");
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class MultiUserChatLowLevelIntegrationTest extends AbstractSmackLowLevelI
|
|||
performCheck(new ConnectionCallback() {
|
||||
@Override
|
||||
public void connectionCallback(XMPPTCPConnection connection) throws Exception {
|
||||
if (MultiUserChatManager.getInstanceFor(connection).getServiceNames().isEmpty()) {
|
||||
if (MultiUserChatManager.getInstanceFor(connection).getXMPPServiceDomains().isEmpty()) {
|
||||
throw new TestNotPossibleException("MUC component not offered by service");
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class MultiUserChatLowLevelIntegrationTest extends AbstractSmackLowLevelI
|
|||
final MultiUserChatManager multiUserChatManager = MultiUserChatManager.getInstanceFor(connection);
|
||||
final Resourcepart mucNickname = Resourcepart.from("Nick-" + StringUtils.randomString(6));
|
||||
final String randomMucName = StringUtils.randomString(6);
|
||||
final DomainBareJid mucComponent = multiUserChatManager.getServiceNames().get(0);
|
||||
final DomainBareJid mucComponent = multiUserChatManager.getXMPPServiceDomains().get(0);
|
||||
final MultiUserChat muc = multiUserChatManager.getMultiUserChat(JidCreate.bareFrom(
|
||||
Localpart.from(randomMucName), mucComponent));
|
||||
|
||||
|
|
|
@ -400,7 +400,7 @@ public class RTPBridge extends IQ {
|
|||
}
|
||||
|
||||
RTPBridge rtpPacket = new RTPBridge(sessionID);
|
||||
rtpPacket.setTo(RTPBridge.NAME + "." + connection.getServiceName());
|
||||
rtpPacket.setTo(RTPBridge.NAME + "." + connection.getXMPPServiceDomain());
|
||||
|
||||
PacketCollector collector = connection.createPacketCollectorAndSend(rtpPacket);
|
||||
|
||||
|
@ -433,7 +433,7 @@ public class RTPBridge extends IQ {
|
|||
|
||||
ServiceDiscoveryManager disco = ServiceDiscoveryManager
|
||||
.getInstanceFor(connection);
|
||||
// DiscoverItems items = disco.discoverItems(connection.getServiceName());
|
||||
// DiscoverItems items = disco.discoverItems(connection.getXMPPServiceDomain());
|
||||
// Iterator iter = items.getItems();
|
||||
// while (iter.hasNext()) {
|
||||
// DiscoverItems.Item item = (DiscoverItems.Item) iter.next();
|
||||
|
@ -442,7 +442,7 @@ public class RTPBridge extends IQ {
|
|||
// }
|
||||
// }
|
||||
|
||||
DiscoverInfo discoInfo = disco.discoverInfo(connection.getServiceName());
|
||||
DiscoverInfo discoInfo = disco.discoverInfo(connection.getXMPPServiceDomain());
|
||||
for (DiscoverInfo.Identity identity : discoInfo.getIdentities()) {
|
||||
if ((identity.getName() != null) && (identity.getName().startsWith("rtpbridge"))) {
|
||||
return true;
|
||||
|
@ -468,7 +468,7 @@ public class RTPBridge extends IQ {
|
|||
}
|
||||
|
||||
RTPBridge rtpPacket = new RTPBridge(sessionID, RTPBridge.BridgeAction.change);
|
||||
rtpPacket.setTo(RTPBridge.NAME + "." + connection.getServiceName());
|
||||
rtpPacket.setTo(RTPBridge.NAME + "." + connection.getXMPPServiceDomain());
|
||||
rtpPacket.setType(Type.set);
|
||||
|
||||
rtpPacket.setPass(pass);
|
||||
|
@ -505,7 +505,7 @@ public class RTPBridge extends IQ {
|
|||
}
|
||||
|
||||
RTPBridge rtpPacket = new RTPBridge(RTPBridge.BridgeAction.publicip);
|
||||
rtpPacket.setTo(RTPBridge.NAME + "." + xmppConnection.getServiceName());
|
||||
rtpPacket.setTo(RTPBridge.NAME + "." + xmppConnection.getXMPPServiceDomain());
|
||||
rtpPacket.setType(Type.set);
|
||||
|
||||
// LOGGER.debug("Relayed to: " + candidate.getIp() + ":" + candidate.getPort());
|
||||
|
|
|
@ -183,7 +183,7 @@ public class STUN extends SimpleIQ {
|
|||
}
|
||||
|
||||
STUN stunPacket = new STUN();
|
||||
stunPacket.setTo(DOMAIN + "." + connection.getServiceName());
|
||||
stunPacket.setTo(DOMAIN + "." + connection.getXMPPServiceDomain());
|
||||
|
||||
PacketCollector collector = connection.createPacketCollectorAndSend(stunPacket);
|
||||
|
||||
|
@ -213,7 +213,7 @@ public class STUN extends SimpleIQ {
|
|||
LOGGER.fine("Service listing");
|
||||
|
||||
ServiceDiscoveryManager disco = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
DiscoverItems items = disco.discoverItems(connection.getServiceName());
|
||||
DiscoverItems items = disco.discoverItems(connection.getXMPPServiceDomain());
|
||||
|
||||
for (DiscoverItems.Item item : items.getItems()) {
|
||||
DiscoverInfo info = disco.discoverInfo(item.getEntityID());
|
||||
|
|
|
@ -711,8 +711,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
final HostnameVerifier verifier = getConfiguration().getHostnameVerifier();
|
||||
if (verifier == null) {
|
||||
throw new IllegalStateException("No HostnameVerifier set. Use connectionConfiguration.setHostnameVerifier() to configure.");
|
||||
} else if (!verifier.verify(getServiceName().toString(), sslSocket.getSession())) {
|
||||
throw new CertificateException("Hostname verification of certificate failed. Certificate does not authenticate " + getServiceName());
|
||||
} else if (!verifier.verify(getXMPPServiceDomain().toString(), sslSocket.getSession())) {
|
||||
throw new CertificateException("Hostname verification of certificate failed. Certificate does not authenticate " + getXMPPServiceDomain());
|
||||
}
|
||||
|
||||
// Set that TLS was successful
|
||||
|
@ -875,7 +875,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
// possible. The 'to' attribute is *always* available. The 'from' attribute if set by the user and no external
|
||||
// mechanism is used to determine the local entity (user). And the 'id' attribute is available after the first
|
||||
// response from the server (see e.g. RFC 6120 § 9.1.1 Step 2.)
|
||||
CharSequence to = getServiceName();
|
||||
CharSequence to = getXMPPServiceDomain();
|
||||
CharSequence from = null;
|
||||
CharSequence localpart = config.getUsername();
|
||||
if (localpart != null) {
|
||||
|
@ -945,8 +945,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
// We found an opening stream.
|
||||
if ("jabber:client".equals(parser.getNamespace(null))) {
|
||||
streamId = parser.getAttributeValue("", "id");
|
||||
String reportedServiceName = parser.getAttributeValue("", "from");
|
||||
assert(config.getServiceName().equals(reportedServiceName));
|
||||
String reportedServerDomain = parser.getAttributeValue("", "from");
|
||||
assert(config.getXMPPServiceDomain().equals(reportedServerDomain));
|
||||
}
|
||||
break;
|
||||
case "error":
|
||||
|
|
Loading…
Reference in a new issue