mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 22:32:06 +01:00
Introduce packet.Element
Re-work filetransfer/bytestream stanza toXML() method to use XmlStringBuilder. Move the ELEMENT and NAMESPACE definitions in the right place, ie. the stanza class.
This commit is contained in:
parent
f05b208120
commit
8526f8ab29
20 changed files with 203 additions and 199 deletions
|
@ -0,0 +1,39 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright © 2014 Florian Schmaus
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jivesoftware.smack.packet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface to represent a XML element. This is similar to {@link PacketExtension}, but does not
|
||||||
|
* carry a namespace and is usually included as child element of an packet extension.
|
||||||
|
*/
|
||||||
|
public interface Element {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the root element name.
|
||||||
|
*
|
||||||
|
* @return the element name.
|
||||||
|
*/
|
||||||
|
public String getElementName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the XML representation of the PacketExtension.
|
||||||
|
*
|
||||||
|
* @return the packet extension as XML.
|
||||||
|
*/
|
||||||
|
public CharSequence toXML();
|
||||||
|
}
|
|
@ -40,6 +40,8 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
*/
|
*/
|
||||||
public abstract class IQ extends Packet {
|
public abstract class IQ extends Packet {
|
||||||
|
|
||||||
|
public static final String QUERY_ELEMENT = "query";
|
||||||
|
|
||||||
private Type type = Type.get;
|
private Type type = Type.get;
|
||||||
|
|
||||||
public IQ() {
|
public IQ() {
|
||||||
|
|
|
@ -28,14 +28,7 @@ package org.jivesoftware.smack.packet;
|
||||||
* @see org.jivesoftware.smack.provider.PacketExtensionProvider
|
* @see org.jivesoftware.smack.provider.PacketExtensionProvider
|
||||||
* @author Matt Tucker
|
* @author Matt Tucker
|
||||||
*/
|
*/
|
||||||
public interface PacketExtension {
|
public interface PacketExtension extends Element {
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the root element name.
|
|
||||||
*
|
|
||||||
* @return the element name.
|
|
||||||
*/
|
|
||||||
public String getElementName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the root element XML namespace.
|
* Returns the root element XML namespace.
|
||||||
|
@ -44,10 +37,4 @@ public interface PacketExtension {
|
||||||
*/
|
*/
|
||||||
public String getNamespace();
|
public String getNamespace();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the XML representation of the PacketExtension.
|
|
||||||
*
|
|
||||||
* @return the packet extension as XML.
|
|
||||||
*/
|
|
||||||
public CharSequence toXML();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smack.util;
|
package org.jivesoftware.smack.util;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.Element;
|
||||||
import org.jivesoftware.smack.packet.PacketExtension;
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
|
|
||||||
public class XmlStringBuilder implements Appendable, CharSequence {
|
public class XmlStringBuilder implements Appendable, CharSequence {
|
||||||
|
@ -32,6 +33,11 @@ public class XmlStringBuilder implements Appendable, CharSequence {
|
||||||
prelude(pe);
|
prelude(pe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public XmlStringBuilder(Element e) {
|
||||||
|
this();
|
||||||
|
halfOpenElement(e.getElementName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does nothing if content is null.
|
* Does nothing if content is null.
|
||||||
*
|
*
|
||||||
|
@ -83,8 +89,8 @@ public class XmlStringBuilder implements Appendable, CharSequence {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmlStringBuilder closeElement(PacketExtension pe) {
|
public XmlStringBuilder closeElement(Element e) {
|
||||||
closeElement(pe.getElementName());
|
closeElement(e.getElementName());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,11 +131,6 @@ public class InBandBytestreamManager implements BytestreamManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The XMPP namespace of the In-Band Bytestream
|
|
||||||
*/
|
|
||||||
public static final String NAMESPACE = "http://jabber.org/protocol/ibb";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum block size that is allowed for In-Band Bytestreams
|
* Maximum block size that is allowed for In-Band Bytestreams
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -451,8 +451,8 @@ public class InBandBytestreamSession implements BytestreamSession {
|
||||||
public void processPacket(Packet packet) throws NotConnectedException {
|
public void processPacket(Packet packet) throws NotConnectedException {
|
||||||
// get data packet extension
|
// get data packet extension
|
||||||
DataPacketExtension data = (DataPacketExtension) packet.getExtension(
|
DataPacketExtension data = (DataPacketExtension) packet.getExtension(
|
||||||
DataPacketExtension.ELEMENT_NAME,
|
DataPacketExtension.ELEMENT,
|
||||||
InBandBytestreamManager.NAMESPACE);
|
DataPacketExtension.NAMESPACE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check if sequence was not used already (see XEP-0047 Section 2.2)
|
* check if sequence was not used already (see XEP-0047 Section 2.2)
|
||||||
|
@ -514,8 +514,8 @@ public class InBandBytestreamSession implements BytestreamSession {
|
||||||
public void processPacket(Packet packet) {
|
public void processPacket(Packet packet) {
|
||||||
// get data packet extension
|
// get data packet extension
|
||||||
DataPacketExtension data = (DataPacketExtension) packet.getExtension(
|
DataPacketExtension data = (DataPacketExtension) packet.getExtension(
|
||||||
DataPacketExtension.ELEMENT_NAME,
|
DataPacketExtension.ELEMENT,
|
||||||
InBandBytestreamManager.NAMESPACE);
|
DataPacketExtension.NAMESPACE);
|
||||||
|
|
||||||
// check if encoded data is valid
|
// check if encoded data is valid
|
||||||
if (data.getDecodedData() == null) {
|
if (data.getDecodedData() == null) {
|
||||||
|
@ -563,8 +563,8 @@ public class InBandBytestreamSession implements BytestreamSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
// stanza contains data packet extension
|
// stanza contains data packet extension
|
||||||
PacketExtension packetExtension = packet.getExtension(DataPacketExtension.ELEMENT_NAME,
|
PacketExtension packetExtension = packet.getExtension(DataPacketExtension.ELEMENT,
|
||||||
InBandBytestreamManager.NAMESPACE);
|
DataPacketExtension.NAMESPACE);
|
||||||
if (packetExtension == null || !(packetExtension instanceof DataPacketExtension)) {
|
if (packetExtension == null || !(packetExtension instanceof DataPacketExtension)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a request to close an In-Band Bytestream.
|
* Represents a request to close an In-Band Bytestream.
|
||||||
|
@ -26,6 +26,8 @@ import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
|
||||||
*/
|
*/
|
||||||
public class Close extends IQ {
|
public class Close extends IQ {
|
||||||
|
|
||||||
|
public static final String ELEMENT = "close";
|
||||||
|
|
||||||
/* unique session ID identifying this In-Band Bytestream */
|
/* unique session ID identifying this In-Band Bytestream */
|
||||||
private final String sessionID;
|
private final String sessionID;
|
||||||
|
|
||||||
|
@ -52,17 +54,13 @@ public class Close extends IQ {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChildElementXML() {
|
public XmlStringBuilder getChildElementXML() {
|
||||||
StringBuilder buf = new StringBuilder();
|
XmlStringBuilder xml = new XmlStringBuilder();
|
||||||
buf.append("<close ");
|
xml.halfOpenElement(ELEMENT);
|
||||||
buf.append("xmlns=\"");
|
xml.xmlnsAttribute(DataPacketExtension.NAMESPACE);
|
||||||
buf.append(InBandBytestreamManager.NAMESPACE);
|
xml.attribute("sid", sessionID);
|
||||||
buf.append("\" ");
|
xml.closeEmptyElement();
|
||||||
buf.append("sid=\"");
|
return xml;
|
||||||
buf.append(sessionID);
|
|
||||||
buf.append("\"");
|
|
||||||
buf.append("/>");
|
|
||||||
return buf.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a chunk of data sent over an In-Band Bytestream encapsulated in an
|
* Represents a chunk of data sent over an In-Band Bytestream encapsulated in an
|
||||||
|
@ -60,8 +61,9 @@ public class Data extends IQ {
|
||||||
return this.dataPacketExtension;
|
return this.dataPacketExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getChildElementXML() {
|
@Override
|
||||||
return this.dataPacketExtension.toXML();
|
public XmlStringBuilder getChildElementXML() {
|
||||||
|
return dataPacketExtension.toXML();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.PacketExtension;
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a chunk of data of an In-Band Bytestream within an IQ stanza or a
|
* Represents a chunk of data of an In-Band Bytestream within an IQ stanza or a
|
||||||
|
@ -31,7 +31,12 @@ public class DataPacketExtension implements PacketExtension {
|
||||||
/**
|
/**
|
||||||
* The element name of the data packet extension.
|
* The element name of the data packet extension.
|
||||||
*/
|
*/
|
||||||
public final static String ELEMENT_NAME = "data";
|
public final static String ELEMENT = "data";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The XMPP namespace of the In-Band Bytestream
|
||||||
|
*/
|
||||||
|
public static final String NAMESPACE = "http://jabber.org/protocol/ibb";
|
||||||
|
|
||||||
/* unique session ID identifying this In-Band Bytestream */
|
/* unique session ID identifying this In-Band Bytestream */
|
||||||
private final String sessionID;
|
private final String sessionID;
|
||||||
|
@ -121,32 +126,22 @@ public class DataPacketExtension implements PacketExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getElementName() {
|
public String getElementName() {
|
||||||
return ELEMENT_NAME;
|
return ELEMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNamespace() {
|
public String getNamespace() {
|
||||||
return InBandBytestreamManager.NAMESPACE;
|
return NAMESPACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toXML() {
|
@Override
|
||||||
StringBuilder buf = new StringBuilder();
|
public XmlStringBuilder toXML() {
|
||||||
buf.append("<");
|
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||||
buf.append(getElementName());
|
xml.attribute("seq", Long.toString(seq));
|
||||||
buf.append(" ");
|
xml.attribute("sid", sessionID);
|
||||||
buf.append("xmlns=\"");
|
xml.rightAngelBracket();
|
||||||
buf.append(InBandBytestreamManager.NAMESPACE);
|
xml.append(data);
|
||||||
buf.append("\" ");
|
xml.closeElement(this);
|
||||||
buf.append("seq=\"");
|
return xml;
|
||||||
buf.append(seq);
|
|
||||||
buf.append("\" ");
|
|
||||||
buf.append("sid=\"");
|
|
||||||
buf.append(sessionID);
|
|
||||||
buf.append("\">");
|
|
||||||
buf.append(data);
|
|
||||||
buf.append("</");
|
|
||||||
buf.append(getElementName());
|
|
||||||
buf.append(">");
|
|
||||||
return buf.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
|
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,6 +29,8 @@ import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaTyp
|
||||||
*/
|
*/
|
||||||
public class Open extends IQ {
|
public class Open extends IQ {
|
||||||
|
|
||||||
|
public static final String ELEMENT = "open";
|
||||||
|
|
||||||
/* unique session ID identifying this In-Band Bytestream */
|
/* unique session ID identifying this In-Band Bytestream */
|
||||||
private final String sessionID;
|
private final String sessionID;
|
||||||
|
|
||||||
|
@ -109,23 +111,15 @@ public class Open extends IQ {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChildElementXML() {
|
public XmlStringBuilder getChildElementXML() {
|
||||||
StringBuilder buf = new StringBuilder();
|
XmlStringBuilder xml = new XmlStringBuilder();
|
||||||
buf.append("<open ");
|
xml.halfOpenElement(ELEMENT);
|
||||||
buf.append("xmlns=\"");
|
xml.xmlnsAttribute(DataPacketExtension.NAMESPACE);
|
||||||
buf.append(InBandBytestreamManager.NAMESPACE);
|
xml.attribute("block-size", Integer.toString(blockSize));
|
||||||
buf.append("\" ");
|
xml.attribute("sid", sessionID);
|
||||||
buf.append("block-size=\"");
|
xml.attribute("stanza", stanza.toString().toLowerCase(Locale.US));
|
||||||
buf.append(blockSize);
|
xml.closeEmptyElement();
|
||||||
buf.append("\" ");
|
return xml;
|
||||||
buf.append("sid=\"");
|
|
||||||
buf.append(sessionID);
|
|
||||||
buf.append("\" ");
|
|
||||||
buf.append("stanza=\"");
|
|
||||||
buf.append(stanza.toString().toLowerCase(Locale.US));
|
|
||||||
buf.append("\"");
|
|
||||||
buf.append("/>");
|
|
||||||
return buf.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,11 +125,6 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The XMPP namespace of the SOCKS5 Bytestream
|
|
||||||
*/
|
|
||||||
public static final String NAMESPACE = "http://jabber.org/protocol/bytestreams";
|
|
||||||
|
|
||||||
/* prefix used to generate session IDs */
|
/* prefix used to generate session IDs */
|
||||||
private static final String SESSION_ID_PREFIX = "js5_";
|
private static final String SESSION_ID_PREFIX = "js5_";
|
||||||
|
|
||||||
|
@ -322,7 +317,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
||||||
|
|
||||||
// check if service discovery is not already disposed by connection shutdown
|
// check if service discovery is not already disposed by connection shutdown
|
||||||
if (serviceDiscoveryManager != null) {
|
if (serviceDiscoveryManager != null) {
|
||||||
serviceDiscoveryManager.removeFeature(NAMESPACE);
|
serviceDiscoveryManager.removeFeature(Bytestream.NAMESPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -540,7 +535,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
*/
|
*/
|
||||||
private boolean supportsSocks5(String targetJID) throws NoResponseException, XMPPErrorException, NotConnectedException {
|
private boolean supportsSocks5(String targetJID) throws NoResponseException, XMPPErrorException, NotConnectedException {
|
||||||
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(targetJID, NAMESPACE);
|
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(targetJID, Bytestream.NAMESPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -732,9 +727,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
||||||
*/
|
*/
|
||||||
private void enableService() {
|
private void enableService() {
|
||||||
ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(this.connection);
|
ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(this.connection);
|
||||||
if (!manager.includesFeature(NAMESPACE)) {
|
manager.addFeature(Bytestream.NAMESPACE);
|
||||||
manager.addFeature(NAMESPACE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,8 +21,9 @@ import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.Element;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.PacketExtension;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A packet representing part of a SOCKS5 Bytestream negotiation.
|
* A packet representing part of a SOCKS5 Bytestream negotiation.
|
||||||
|
@ -30,6 +31,10 @@ import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
* @author Alexander Wenckus
|
* @author Alexander Wenckus
|
||||||
*/
|
*/
|
||||||
public class Bytestream extends IQ {
|
public class Bytestream extends IQ {
|
||||||
|
/**
|
||||||
|
* The XMPP namespace of the SOCKS5 Bytestream
|
||||||
|
*/
|
||||||
|
public static final String NAMESPACE = "http://jabber.org/protocol/bytestreams";
|
||||||
|
|
||||||
private String sessionID;
|
private String sessionID;
|
||||||
|
|
||||||
|
@ -213,48 +218,51 @@ public class Bytestream extends IQ {
|
||||||
this.toActivate = new Activate(targetID);
|
this.toActivate = new Activate(targetID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getChildElementXML() {
|
@Override
|
||||||
StringBuilder buf = new StringBuilder();
|
public XmlStringBuilder getChildElementXML() {
|
||||||
|
XmlStringBuilder xml = new XmlStringBuilder();
|
||||||
|
xml.openElement(IQ.QUERY_ELEMENT);
|
||||||
|
xml.xmlnsAttribute(NAMESPACE);
|
||||||
|
|
||||||
buf.append("<query xmlns=\"http://jabber.org/protocol/bytestreams\"");
|
switch(getType()) {
|
||||||
if (this.getType().equals(IQ.Type.set)) {
|
case set:
|
||||||
if (getSessionID() != null) {
|
if (getSessionID() != null) {
|
||||||
buf.append(" sid=\"").append(getSessionID()).append("\"");
|
xml.attribute("sid", getSessionID());
|
||||||
}
|
}
|
||||||
if (getMode() != null) {
|
if (getMode() != null) {
|
||||||
buf.append(" mode = \"").append(getMode()).append("\"");
|
xml.attribute("mode", getMode());
|
||||||
}
|
}
|
||||||
buf.append(">");
|
xml.rightAngelBracket();
|
||||||
if (getToActivate() == null) {
|
if (getToActivate() == null) {
|
||||||
for (StreamHost streamHost : getStreamHosts()) {
|
for (StreamHost streamHost : getStreamHosts()) {
|
||||||
buf.append(streamHost.toXML());
|
xml.append(streamHost.toXML());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buf.append(getToActivate().toXML());
|
xml.append(getToActivate().toXML());
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (this.getType().equals(IQ.Type.result)) {
|
case result:
|
||||||
buf.append(">");
|
xml.rightAngelBracket();
|
||||||
if (getUsedHost() != null) {
|
if (getUsedHost() != null) {
|
||||||
buf.append(getUsedHost().toXML());
|
xml.append(getUsedHost().toXML());
|
||||||
}
|
}
|
||||||
// A result from the server can also contain stream hosts
|
// A result from the server can also contain stream hosts
|
||||||
else if (countStreamHosts() > 0) {
|
else if (countStreamHosts() > 0) {
|
||||||
for (StreamHost host : streamHosts) {
|
for (StreamHost host : streamHosts) {
|
||||||
buf.append(host.toXML());
|
xml.append(host.toXML());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case get:
|
||||||
|
xml.closeEmptyElement();
|
||||||
|
return xml;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
else if (this.getType().equals(IQ.Type.get)) {
|
xml.closeElement(IQ.QUERY_ELEMENT);
|
||||||
return buf.append("/>").toString();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
buf.append("</query>");
|
|
||||||
|
|
||||||
return buf.toString();
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -263,9 +271,7 @@ public class Bytestream extends IQ {
|
||||||
*
|
*
|
||||||
* @author Alexander Wenckus
|
* @author Alexander Wenckus
|
||||||
*/
|
*/
|
||||||
public static class StreamHost implements PacketExtension {
|
public static class StreamHost implements Element {
|
||||||
|
|
||||||
public static String NAMESPACE = "";
|
|
||||||
|
|
||||||
public static String ELEMENTNAME = "streamhost";
|
public static String ELEMENTNAME = "streamhost";
|
||||||
|
|
||||||
|
@ -322,29 +328,22 @@ public class Bytestream extends IQ {
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNamespace() {
|
|
||||||
return NAMESPACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getElementName() {
|
public String getElementName() {
|
||||||
return ELEMENTNAME;
|
return ELEMENTNAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toXML() {
|
@Override
|
||||||
StringBuilder buf = new StringBuilder();
|
public XmlStringBuilder toXML() {
|
||||||
|
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||||
buf.append("<").append(getElementName()).append(" ");
|
xml.attribute("jid", getJID());
|
||||||
buf.append("jid=\"").append(getJID()).append("\" ");
|
xml.attribute("host", getAddress());
|
||||||
buf.append("host=\"").append(getAddress()).append("\" ");
|
|
||||||
if (getPort() != 0) {
|
if (getPort() != 0) {
|
||||||
buf.append("port=\"").append(getPort()).append("\"");
|
xml.attribute("port", Integer.toString(getPort()));
|
||||||
|
} else {
|
||||||
|
xml.attribute("zeroconf", "_jabber.bytestreams");
|
||||||
}
|
}
|
||||||
else {
|
xml.closeEmptyElement();
|
||||||
buf.append("zeroconf=\"_jabber.bytestreams\"");
|
return xml;
|
||||||
}
|
|
||||||
buf.append("/>");
|
|
||||||
|
|
||||||
return buf.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,9 +353,7 @@ public class Bytestream extends IQ {
|
||||||
*
|
*
|
||||||
* @author Alexander Wenckus
|
* @author Alexander Wenckus
|
||||||
*/
|
*/
|
||||||
public static class StreamHostUsed implements PacketExtension {
|
public static class StreamHostUsed implements Element {
|
||||||
|
|
||||||
public String NAMESPACE = "";
|
|
||||||
|
|
||||||
public static String ELEMENTNAME = "streamhost-used";
|
public static String ELEMENTNAME = "streamhost-used";
|
||||||
|
|
||||||
|
@ -380,20 +377,16 @@ public class Bytestream extends IQ {
|
||||||
return JID;
|
return JID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNamespace() {
|
|
||||||
return NAMESPACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getElementName() {
|
public String getElementName() {
|
||||||
return ELEMENTNAME;
|
return ELEMENTNAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toXML() {
|
@Override
|
||||||
StringBuilder buf = new StringBuilder();
|
public XmlStringBuilder toXML() {
|
||||||
buf.append("<").append(getElementName()).append(" ");
|
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||||
buf.append("jid=\"").append(getJID()).append("\" ");
|
xml.attribute("jid", getJID());
|
||||||
buf.append("/>");
|
xml.closeEmptyElement();
|
||||||
return buf.toString();
|
return xml;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,9 +395,7 @@ public class Bytestream extends IQ {
|
||||||
*
|
*
|
||||||
* @author Alexander Wenckus
|
* @author Alexander Wenckus
|
||||||
*/
|
*/
|
||||||
public static class Activate implements PacketExtension {
|
public static class Activate implements Element {
|
||||||
|
|
||||||
public String NAMESPACE = "";
|
|
||||||
|
|
||||||
public static String ELEMENTNAME = "activate";
|
public static String ELEMENTNAME = "activate";
|
||||||
|
|
||||||
|
@ -428,20 +419,17 @@ public class Bytestream extends IQ {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNamespace() {
|
|
||||||
return NAMESPACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getElementName() {
|
public String getElementName() {
|
||||||
return ELEMENTNAME;
|
return ELEMENTNAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toXML() {
|
@Override
|
||||||
StringBuilder buf = new StringBuilder();
|
public XmlStringBuilder toXML() {
|
||||||
buf.append("<").append(getElementName()).append(">");
|
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||||
buf.append(getTarget());
|
xml.rightAngelBracket();
|
||||||
buf.append("</").append(getElementName()).append(">");
|
xml.escape(getTarget());
|
||||||
return buf.toString();
|
xml.closeElement(this);
|
||||||
|
return xml;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -405,8 +405,10 @@ public class ServiceDiscoveryManager extends Manager {
|
||||||
*/
|
*/
|
||||||
public void addFeature(String feature) {
|
public void addFeature(String feature) {
|
||||||
synchronized (features) {
|
synchronized (features) {
|
||||||
features.add(feature);
|
if (!features.contains(feature)) {
|
||||||
renewEntityCapsVersion();
|
features.add(feature);
|
||||||
|
renewEntityCapsVersion();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smack.packet.XMPPError;
|
import org.jivesoftware.smack.packet.XMPPError;
|
||||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
|
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
||||||
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager;
|
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||||
import org.jivesoftware.smackx.xdata.Form;
|
import org.jivesoftware.smackx.xdata.Form;
|
||||||
|
@ -103,9 +103,9 @@ public class FileTransferNegotiator extends Manager {
|
||||||
|
|
||||||
List<String> namespaces = new ArrayList<String>();
|
List<String> namespaces = new ArrayList<String>();
|
||||||
namespaces.addAll(Arrays.asList(NAMESPACE));
|
namespaces.addAll(Arrays.asList(NAMESPACE));
|
||||||
namespaces.add(InBandBytestreamManager.NAMESPACE);
|
namespaces.add(DataPacketExtension.NAMESPACE);
|
||||||
if (!IBB_ONLY) {
|
if (!IBB_ONLY) {
|
||||||
namespaces.add(Socks5BytestreamManager.NAMESPACE);
|
namespaces.add(Bytestream.NAMESPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String namespace : namespaces) {
|
for (String namespace : namespaces) {
|
||||||
|
@ -130,9 +130,9 @@ public class FileTransferNegotiator extends Manager {
|
||||||
|
|
||||||
List<String> namespaces = new ArrayList<String>();
|
List<String> namespaces = new ArrayList<String>();
|
||||||
namespaces.addAll(Arrays.asList(NAMESPACE));
|
namespaces.addAll(Arrays.asList(NAMESPACE));
|
||||||
namespaces.add(InBandBytestreamManager.NAMESPACE);
|
namespaces.add(DataPacketExtension.NAMESPACE);
|
||||||
if (!IBB_ONLY) {
|
if (!IBB_ONLY) {
|
||||||
namespaces.add(Socks5BytestreamManager.NAMESPACE);
|
namespaces.add(Bytestream.NAMESPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String namespace : namespaces) {
|
for (String namespace : namespaces) {
|
||||||
|
@ -150,9 +150,9 @@ public class FileTransferNegotiator extends Manager {
|
||||||
*/
|
*/
|
||||||
public static Collection<String> getSupportedProtocols() {
|
public static Collection<String> getSupportedProtocols() {
|
||||||
List<String> protocols = new ArrayList<String>();
|
List<String> protocols = new ArrayList<String>();
|
||||||
protocols.add(InBandBytestreamManager.NAMESPACE);
|
protocols.add(DataPacketExtension.NAMESPACE);
|
||||||
if (!IBB_ONLY) {
|
if (!IBB_ONLY) {
|
||||||
protocols.add(Socks5BytestreamManager.NAMESPACE);
|
protocols.add(Bytestream.NAMESPACE);
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableList(protocols);
|
return Collections.unmodifiableList(protocols);
|
||||||
}
|
}
|
||||||
|
@ -227,10 +227,10 @@ public class FileTransferNegotiator extends Manager {
|
||||||
boolean isIBB = false;
|
boolean isIBB = false;
|
||||||
for (FormField.Option option : field.getOptions()) {
|
for (FormField.Option option : field.getOptions()) {
|
||||||
variable = option.getValue();
|
variable = option.getValue();
|
||||||
if (variable.equals(Socks5BytestreamManager.NAMESPACE) && !IBB_ONLY) {
|
if (variable.equals(Bytestream.NAMESPACE) && !IBB_ONLY) {
|
||||||
isByteStream = true;
|
isByteStream = true;
|
||||||
}
|
}
|
||||||
else if (variable.equals(InBandBytestreamManager.NAMESPACE)) {
|
else if (variable.equals(DataPacketExtension.NAMESPACE)) {
|
||||||
isIBB = true;
|
isIBB = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,10 +354,10 @@ public class FileTransferNegotiator extends Manager {
|
||||||
boolean isByteStream = false;
|
boolean isByteStream = false;
|
||||||
boolean isIBB = false;
|
boolean isIBB = false;
|
||||||
for (String variable : field.getValues()) {
|
for (String variable : field.getValues()) {
|
||||||
if (variable.equals(Socks5BytestreamManager.NAMESPACE) && !IBB_ONLY) {
|
if (variable.equals(Bytestream.NAMESPACE) && !IBB_ONLY) {
|
||||||
isByteStream = true;
|
isByteStream = true;
|
||||||
}
|
}
|
||||||
else if (variable.equals(InBandBytestreamManager.NAMESPACE)) {
|
else if (variable.equals(DataPacketExtension.NAMESPACE)) {
|
||||||
isIBB = true;
|
isIBB = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,9 +385,9 @@ public class FileTransferNegotiator extends Manager {
|
||||||
FormField field = new FormField(STREAM_DATA_FIELD_NAME);
|
FormField field = new FormField(STREAM_DATA_FIELD_NAME);
|
||||||
field.setType(FormField.TYPE_LIST_SINGLE);
|
field.setType(FormField.TYPE_LIST_SINGLE);
|
||||||
if (!IBB_ONLY) {
|
if (!IBB_ONLY) {
|
||||||
field.addOption(new FormField.Option(Socks5BytestreamManager.NAMESPACE));
|
field.addOption(new FormField.Option(Bytestream.NAMESPACE));
|
||||||
}
|
}
|
||||||
field.addOption(new FormField.Option(InBandBytestreamManager.NAMESPACE));
|
field.addOption(new FormField.Option(DataPacketExtension.NAMESPACE));
|
||||||
form.addField(field);
|
form.addField(field);
|
||||||
return form;
|
return form;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
|
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
|
||||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest;
|
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest;
|
||||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamSession;
|
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamSession;
|
||||||
|
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
||||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||||
|
|
||||||
|
@ -92,7 +93,7 @@ public class IBBTransferNegotiator extends StreamNegotiator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getNamespaces() {
|
public String[] getNamespaces() {
|
||||||
return new String[] { InBandBytestreamManager.NAMESPACE };
|
return new String[] { DataPacketExtension.NAMESPACE };
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream negotiateIncomingStream(Packet streamInitiation) throws NotConnectedException {
|
InputStream negotiateIncomingStream(Packet streamInitiation) throws NotConnectedException {
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getNamespaces() {
|
public String[] getNamespaces() {
|
||||||
return new String[] { Socks5BytestreamManager.NAMESPACE };
|
return new String[] { Bytestream.NAMESPACE };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class InBandBytestreamSessionMessageTest {
|
||||||
|
|
||||||
public void verify(Message request, IQ response) {
|
public void verify(Message request, IQ response) {
|
||||||
DataPacketExtension dpe = (DataPacketExtension) request.getExtension(
|
DataPacketExtension dpe = (DataPacketExtension) request.getExtension(
|
||||||
DataPacketExtension.ELEMENT_NAME, InBandBytestreamManager.NAMESPACE);
|
DataPacketExtension.ELEMENT, DataPacketExtension.NAMESPACE);
|
||||||
assertEquals(lastSeq++, dpe.getSeq());
|
assertEquals(lastSeq++, dpe.getSeq());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class DataPacketExtensionTest {
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
DataPacketExtension data = new DataPacketExtension("i781hf64", 0, "DATA");
|
DataPacketExtension data = new DataPacketExtension("i781hf64", 0, "DATA");
|
||||||
assertXMLEqual(control, data.toXML());
|
assertXMLEqual(control, data.toXML().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,13 @@ package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
||||||
|
|
||||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
|
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
|
||||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -72,12 +72,14 @@ public class DataTest {
|
||||||
.asString(outputProperties);
|
.asString(outputProperties);
|
||||||
|
|
||||||
DataPacketExtension dpe = mock(DataPacketExtension.class);
|
DataPacketExtension dpe = mock(DataPacketExtension.class);
|
||||||
String dataTag = XMLBuilder.create("data")
|
XmlStringBuilder dataTag = new XmlStringBuilder();
|
||||||
.a("xmlns", "http://jabber.org/protocol/ibb")
|
dataTag.halfOpenElement(DataPacketExtension.ELEMENT);
|
||||||
.a("seq", "0")
|
dataTag.xmlnsAttribute(DataPacketExtension.NAMESPACE);
|
||||||
.a("sid", "i781hf64")
|
dataTag.attribute("seq", "0");
|
||||||
.t(encodedData)
|
dataTag.attribute("sid", "i781hf64");
|
||||||
.asString(outputProperties);
|
dataTag.rightAngelBracket();
|
||||||
|
dataTag.escape(encodedData);
|
||||||
|
dataTag.closeElement(DataPacketExtension.ELEMENT);
|
||||||
when(dpe.toXML()).thenReturn(dataTag);
|
when(dpe.toXML()).thenReturn(dataTag);
|
||||||
Data data = new Data(dpe);
|
Data data = new Data(dpe);
|
||||||
data.setFrom("romeo@montague.lit/orchard");
|
data.setFrom("romeo@montague.lit/orchard");
|
||||||
|
|
|
@ -127,11 +127,11 @@ public class Socks5ByteStreamManagerTest {
|
||||||
Socks5BytestreamManager byteStreamManager = Socks5BytestreamManager.getBytestreamManager(connection);
|
Socks5BytestreamManager byteStreamManager = Socks5BytestreamManager.getBytestreamManager(connection);
|
||||||
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
|
|
||||||
assertTrue(discoveryManager.includesFeature(Socks5BytestreamManager.NAMESPACE));
|
assertTrue(discoveryManager.includesFeature(Bytestream.NAMESPACE));
|
||||||
|
|
||||||
byteStreamManager.disableService();
|
byteStreamManager.disableService();
|
||||||
|
|
||||||
assertFalse(discoveryManager.includesFeature(Socks5BytestreamManager.NAMESPACE));
|
assertFalse(discoveryManager.includesFeature(Bytestream.NAMESPACE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,7 +182,7 @@ public class Socks5ByteStreamManagerTest {
|
||||||
|
|
||||||
// build discover info that supports the SOCKS5 feature
|
// build discover info that supports the SOCKS5 feature
|
||||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||||
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
|
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||||
|
|
||||||
// return that SOCKS5 is supported if target is queried
|
// return that SOCKS5 is supported if target is queried
|
||||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||||
|
@ -233,7 +233,7 @@ public class Socks5ByteStreamManagerTest {
|
||||||
|
|
||||||
// build discover info that supports the SOCKS5 feature
|
// build discover info that supports the SOCKS5 feature
|
||||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||||
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
|
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||||
|
|
||||||
// return that SOCKS5 is supported if target is queried
|
// return that SOCKS5 is supported if target is queried
|
||||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||||
|
@ -297,7 +297,7 @@ public class Socks5ByteStreamManagerTest {
|
||||||
|
|
||||||
// build discover info that supports the SOCKS5 feature
|
// build discover info that supports the SOCKS5 feature
|
||||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||||
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
|
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||||
|
|
||||||
// return that SOCKS5 is supported if target is queried
|
// return that SOCKS5 is supported if target is queried
|
||||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||||
|
@ -388,7 +388,7 @@ public class Socks5ByteStreamManagerTest {
|
||||||
|
|
||||||
// build discover info that supports the SOCKS5 feature
|
// build discover info that supports the SOCKS5 feature
|
||||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||||
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
|
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||||
|
|
||||||
// return that SOCKS5 is supported if target is queried
|
// return that SOCKS5 is supported if target is queried
|
||||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||||
|
@ -478,7 +478,7 @@ public class Socks5ByteStreamManagerTest {
|
||||||
|
|
||||||
// build discover info that supports the SOCKS5 feature
|
// build discover info that supports the SOCKS5 feature
|
||||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||||
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
|
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||||
|
|
||||||
// return that SOCKS5 is supported if target is queried
|
// return that SOCKS5 is supported if target is queried
|
||||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||||
|
@ -560,7 +560,7 @@ public class Socks5ByteStreamManagerTest {
|
||||||
|
|
||||||
// build discover info that supports the SOCKS5 feature
|
// build discover info that supports the SOCKS5 feature
|
||||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||||
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
|
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||||
|
|
||||||
// return that SOCKS5 is supported if target is queried
|
// return that SOCKS5 is supported if target is queried
|
||||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||||
|
@ -654,7 +654,7 @@ public class Socks5ByteStreamManagerTest {
|
||||||
|
|
||||||
// build discover info that supports the SOCKS5 feature
|
// build discover info that supports the SOCKS5 feature
|
||||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||||
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
|
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||||
|
|
||||||
// return that SOCKS5 is supported if target is queried
|
// return that SOCKS5 is supported if target is queried
|
||||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||||
|
@ -773,7 +773,7 @@ public class Socks5ByteStreamManagerTest {
|
||||||
|
|
||||||
// build discover info that supports the SOCKS5 feature
|
// build discover info that supports the SOCKS5 feature
|
||||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||||
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
|
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||||
|
|
||||||
// return that SOCKS5 is supported if target is queried
|
// return that SOCKS5 is supported if target is queried
|
||||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||||
|
@ -1003,7 +1003,7 @@ public class Socks5ByteStreamManagerTest {
|
||||||
private void createResponses(Verification<Bytestream, Bytestream> streamHostUsedVerification) {
|
private void createResponses(Verification<Bytestream, Bytestream> streamHostUsedVerification) {
|
||||||
// build discover info that supports the SOCKS5 feature
|
// build discover info that supports the SOCKS5 feature
|
||||||
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
|
||||||
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
|
discoverInfo.addFeature(Bytestream.NAMESPACE);
|
||||||
|
|
||||||
// return that SOCKS5 is supported if target is queried
|
// return that SOCKS5 is supported if target is queried
|
||||||
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
|
||||||
|
|
Loading…
Reference in a new issue