1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-12 14:01:08 +01:00

Use Jid (and subclasses) from jxmpp-jid

Fixes SMACK-634
This commit is contained in:
Florian Schmaus 2015-02-14 17:15:02 +01:00
parent 0ee2d9ed1e
commit 5bb4727c57
180 changed files with 1510 additions and 1032 deletions

View file

@ -30,7 +30,7 @@ import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager;
* <p>
* There are two ways to add this listener. See
* {@link BytestreamManager#addIncomingBytestreamListener(BytestreamListener)} and
* {@link BytestreamManager#addIncomingBytestreamListener(BytestreamListener, String)} for further
* {@link BytestreamManager#addIncomingBytestreamListener(BytestreamListener, org.jxmpp.jid.Jid)} for further
* details.
* <p>
* {@link Socks5BytestreamListener} or {@link InBandBytestreamListener} provide a more specific

View file

@ -22,6 +22,7 @@ import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager;
import org.jxmpp.jid.Jid;
/**
* BytestreamManager provides a generic interface for bytestream managers.
@ -58,14 +59,14 @@ public interface BytestreamManager {
* <p>
* Use this method if you are awaiting an incoming bytestream request from a specific user.
* <p>
* See {@link Socks5BytestreamManager#addIncomingBytestreamListener(BytestreamListener, String)}
* and {@link InBandBytestreamManager#addIncomingBytestreamListener(BytestreamListener, String)}
* See {@link Socks5BytestreamManager#addIncomingBytestreamListener(BytestreamListener, Jid)}
* and {@link InBandBytestreamManager#addIncomingBytestreamListener(BytestreamListener, Jid)}
* for further details.
*
* @param listener the listener to register
* @param initiatorJID the JID of the user that wants to establish a bytestream
*/
public void addIncomingBytestreamListener(BytestreamListener listener, String initiatorJID);
public void addIncomingBytestreamListener(BytestreamListener listener, Jid initiatorJID);
/**
* Removes the listener for the given user.
@ -82,10 +83,10 @@ public interface BytestreamManager {
* since this method doesn't provide a way to tell the user something about the data to be sent.
* <p>
* To establish a bytestream after negotiation the kind of data to be sent (e.g. file transfer)
* use {@link #establishSession(String, String)}.
* use {@link #establishSession(Jid, String)}.
* <p>
* See {@link Socks5BytestreamManager#establishSession(String)} and
* {@link InBandBytestreamManager#establishSession(String)} for further details.
* See {@link Socks5BytestreamManager#establishSession(Jid)} and
* {@link InBandBytestreamManager#establishSession(Jid)} for further details.
*
* @param targetJID the JID of the user a bytestream should be established
* @return the session to send/receive data to/from the user
@ -94,15 +95,15 @@ public interface BytestreamManager {
* @throws InterruptedException if the thread was interrupted while waiting in a blocking
* operation
*/
public BytestreamSession establishSession(String targetJID) throws XMPPException, IOException,
public BytestreamSession establishSession(Jid targetJID) throws XMPPException, IOException,
InterruptedException, SmackException;
/**
* Establishes a bytestream with the given user and returns the session to send/receive data
* to/from the user.
* <p>
* See {@link Socks5BytestreamManager#establishSession(String)} and
* {@link InBandBytestreamManager#establishSession(String)} for further details.
* See {@link Socks5BytestreamManager#establishSession(Jid)} and
* {@link InBandBytestreamManager#establishSession(Jid)} for further details.
*
* @param targetJID the JID of the user a bytestream should be established
* @param sessionID the session ID for the bytestream request
@ -112,7 +113,7 @@ public interface BytestreamManager {
* @throws InterruptedException if the thread was interrupted while waiting in a blocking
* operation
*/
public BytestreamSession establishSession(String targetJID, String sessionID)
public BytestreamSession establishSession(Jid targetJID, String sessionID)
throws XMPPException, IOException, InterruptedException, SmackException;
}

View file

@ -22,6 +22,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest;
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamRequest;
import org.jxmpp.jid.Jid;
/**
* BytestreamRequest provides an interface to handle incoming bytestream requests.
@ -38,7 +39,7 @@ public interface BytestreamRequest {
*
* @return the sender of the bytestream open request
*/
public String getFrom();
public Jid getFrom();
/**
* Returns the session ID of the bytestream open request.

View file

@ -25,7 +25,7 @@ import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
* <p>
* There are two ways to add this listener. See
* {@link InBandBytestreamManager#addIncomingBytestreamListener(BytestreamListener)} and
* {@link InBandBytestreamManager#addIncomingBytestreamListener(BytestreamListener, String)} for
* {@link InBandBytestreamManager#addIncomingBytestreamListener(BytestreamListener, org.jxmpp.jid.Jid)} for
* further details.
*
* @author Henning Staib

View file

@ -39,6 +39,7 @@ import org.jivesoftware.smackx.bytestreams.BytestreamListener;
import org.jivesoftware.smackx.bytestreams.BytestreamManager;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
import org.jivesoftware.smackx.filetransfer.FileTransferManager;
import org.jxmpp.jid.Jid;
/**
* The InBandBytestreamManager class handles establishing In-Band Bytestreams as specified in the <a
@ -55,16 +56,16 @@ import org.jivesoftware.smackx.filetransfer.FileTransferManager;
* flow-control method like <a href="http://xmpp.org/extensions/xep-0079.html">Advanced Message
* Processing</a>. To set the stanza that should be used invoke {@link #setStanza(StanzaType)}.
* <p>
* To establish an In-Band Bytestream invoke the {@link #establishSession(String)} method. This will
* To establish an In-Band Bytestream invoke the {@link #establishSession(Jid)} method. This will
* negotiate an in-band bytestream with the given target JID and return a session.
* <p>
* If a session ID for the In-Band Bytestream was already negotiated (e.g. while negotiating a file
* transfer) invoke {@link #establishSession(String, String)}.
* transfer) invoke {@link #establishSession(Jid, String)}.
* <p>
* To handle incoming In-Band Bytestream requests add an {@link InBandBytestreamListener} to the
* manager. There are two ways to add this listener. If you want to be informed about incoming
* In-Band Bytestreams from a specific user add the listener by invoking
* {@link #addIncomingBytestreamListener(BytestreamListener, String)}. If the listener should
* {@link #addIncomingBytestreamListener(BytestreamListener, Jid)}. If the listener should
* respond to all In-Band Bytestream requests invoke
* {@link #addIncomingBytestreamListener(BytestreamListener)}.
* <p>
@ -147,7 +148,7 @@ public class InBandBytestreamManager implements BytestreamManager {
* assigns a user to a listener that is informed if an In-Band Bytestream request for this user
* is received
*/
private final Map<String, BytestreamListener> userListeners = new ConcurrentHashMap<String, BytestreamListener>();
private final Map<Jid, BytestreamListener> userListeners = new ConcurrentHashMap<>();
/*
* list of listeners that respond to all In-Band Bytestream requests if there are no user
@ -267,7 +268,7 @@ public class InBandBytestreamManager implements BytestreamManager {
* @param listener the listener to register
* @param initiatorJID the JID of the user that wants to establish an In-Band Bytestream
*/
public void addIncomingBytestreamListener(BytestreamListener listener, String initiatorJID) {
public void addIncomingBytestreamListener(BytestreamListener listener, Jid initiatorJID) {
this.userListeners.put(initiatorJID, listener);
}
@ -392,7 +393,7 @@ public class InBandBytestreamManager implements BytestreamManager {
* the data to be sent.
* <p>
* To establish an In-Band Bytestream after negotiation the kind of data to be sent (e.g. file
* transfer) use {@link #establishSession(String, String)}.
* transfer) use {@link #establishSession(Jid, String)}.
*
* @param targetJID the JID of the user an In-Band Bytestream should be established
* @return the session to send/receive data to/from the user
@ -401,7 +402,7 @@ public class InBandBytestreamManager implements BytestreamManager {
* @throws SmackException if there was no response from the server.
* @throws InterruptedException
*/
public InBandBytestreamSession establishSession(String targetJID) throws XMPPException, SmackException, InterruptedException {
public InBandBytestreamSession establishSession(Jid targetJID) throws XMPPException, SmackException, InterruptedException {
String sessionID = getNextSessionID();
return establishSession(targetJID, sessionID);
}
@ -419,7 +420,7 @@ public class InBandBytestreamManager implements BytestreamManager {
* @throws NotConnectedException
* @throws InterruptedException
*/
public InBandBytestreamSession establishSession(String targetJID, String sessionID)
public InBandBytestreamSession establishSession(Jid targetJID, String sessionID)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize, this.stanza);
byteStreamRequest.setTo(targetJID);
@ -504,7 +505,7 @@ public class InBandBytestreamManager implements BytestreamManager {
* @param initiator the initiator's JID
* @return the listener
*/
protected BytestreamListener getUserListener(String initiator) {
protected BytestreamListener getUserListener(Jid initiator) {
return this.userListeners.get(initiator);
}

View file

@ -21,6 +21,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
import org.jxmpp.jid.Jid;
/**
* InBandBytestreamRequest class handles incoming In-Band Bytestream requests.
@ -49,7 +50,7 @@ public class InBandBytestreamRequest implements BytestreamRequest {
*
* @return the sender of the In-Band Bytestream open request
*/
public String getFrom() {
public Jid getFrom() {
return this.byteStreamRequest.getFrom();
}

View file

@ -40,6 +40,7 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Close;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
import org.jxmpp.jid.Jid;
/**
* InBandBytestreamSession class represents an In-Band Bytestream session.
@ -73,7 +74,7 @@ public class InBandBytestreamSession implements BytestreamSession {
private IBBOutputStream outputStream;
/* JID of the remote peer */
private String remoteJID;
private Jid remoteJID;
/* flag to close both streams if one of them is closed */
private boolean closeBothStreamsEnabled = false;
@ -89,7 +90,7 @@ public class InBandBytestreamSession implements BytestreamSession {
* @param remoteJID JID of the remote peer
*/
protected InBandBytestreamSession(XMPPConnection connection, Open byteStreamRequest,
String remoteJID) {
Jid remoteJID) {
this.connection = connection;
this.byteStreamRequest = byteStreamRequest;
this.remoteJID = remoteJID;
@ -556,7 +557,7 @@ public class InBandBytestreamSession implements BytestreamSession {
public boolean accept(Stanza packet) {
// sender equals remote peer
if (!packet.getFrom().equalsIgnoreCase(remoteJID)) {
if (!packet.getFrom().equals(remoteJID)) {
return false;
}

View file

@ -25,7 +25,7 @@ import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
* <p>
* There are two ways to add this listener. See
* {@link Socks5BytestreamManager#addIncomingBytestreamListener(BytestreamListener)} and
* {@link Socks5BytestreamManager#addIncomingBytestreamListener(BytestreamListener, String)} for
* {@link Socks5BytestreamManager#addIncomingBytestreamListener(BytestreamListener, org.jxmpp.jid.Jid)} for
* further details.
*
* @author Henning Staib

View file

@ -21,10 +21,12 @@ import java.net.Socket;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeoutException;
@ -51,6 +53,7 @@ import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
import org.jivesoftware.smackx.disco.packet.DiscoverItems.Item;
import org.jivesoftware.smackx.filetransfer.FileTransferManager;
import org.jxmpp.jid.Jid;
/**
* The Socks5BytestreamManager class handles establishing SOCKS5 Bytestreams as specified in the <a
@ -63,16 +66,16 @@ import org.jivesoftware.smackx.filetransfer.FileTransferManager;
* The stream host is a specialized SOCKS5 proxy setup on a server, or, the initiator can act as the
* stream host.
* <p>
* To establish a SOCKS5 Bytestream invoke the {@link #establishSession(String)} method. This will
* To establish a SOCKS5 Bytestream invoke the {@link #establishSession(Jid)} method. This will
* negotiate a SOCKS5 Bytestream with the given target JID and return a socket.
* <p>
* If a session ID for the SOCKS5 Bytestream was already negotiated (e.g. while negotiating a file
* transfer) invoke {@link #establishSession(String, String)}.
* transfer) invoke {@link #establishSession(Jid, String)}.
* <p>
* To handle incoming SOCKS5 Bytestream requests add an {@link Socks5BytestreamListener} to the
* manager. There are two ways to add this listener. If you want to be informed about incoming
* SOCKS5 Bytestreams from a specific user add the listener by invoking
* {@link #addIncomingBytestreamListener(BytestreamListener, String)}. If the listener should
* {@link #addIncomingBytestreamListener(BytestreamListener, Jid)}. If the listener should
* respond to all SOCKS5 Bytestream requests invoke
* {@link #addIncomingBytestreamListener(BytestreamListener)}.
* <p>
@ -135,7 +138,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* assigns a user to a listener that is informed if a bytestream request for this user is
* received
*/
private final Map<String, BytestreamListener> userListeners = new ConcurrentHashMap<String, BytestreamListener>();
private final Map<Jid, BytestreamListener> userListeners = new ConcurrentHashMap<>();
/*
* list of listeners that respond to all bytestream requests if there are not user specific
@ -153,10 +156,10 @@ public final class Socks5BytestreamManager implements BytestreamManager {
private int proxyConnectionTimeout = 10000;
/* blacklist of errornous SOCKS5 proxies */
private final List<String> proxyBlacklist = Collections.synchronizedList(new LinkedList<String>());
private final Set<Jid> proxyBlacklist = Collections.synchronizedSet(new HashSet<Jid>());
/* remember the last proxy that worked to prioritize it */
private String lastWorkingProxy = null;
private Jid lastWorkingProxy;
/* flag to enable/disable prioritization of last working proxy */
private boolean proxyPrioritizationEnabled = true;
@ -246,7 +249,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* @param listener the listener to register
* @param initiatorJID the JID of the user that wants to establish a SOCKS5 Bytestream
*/
public void addIncomingBytestreamListener(BytestreamListener listener, String initiatorJID) {
public void addIncomingBytestreamListener(BytestreamListener listener, Jid initiatorJID) {
this.userListeners.put(initiatorJID, listener);
}
@ -392,7 +395,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* the data to be sent.
* <p>
* To establish a SOCKS5 Bytestream after negotiation the kind of data to be sent (e.g. file
* transfer) use {@link #establishSession(String, String)}.
* transfer) use {@link #establishSession(Jid, String)}.
*
* @param targetJID the JID of the user a SOCKS5 Bytestream should be established
* @return the Socket to send/receive data to/from the user
@ -402,7 +405,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* @throws InterruptedException if the current thread was interrupted while waiting
* @throws SmackException if there was no response from the server.
*/
public Socks5BytestreamSession establishSession(String targetJID) throws XMPPException,
public Socks5BytestreamSession establishSession(Jid targetJID) throws XMPPException,
IOException, InterruptedException, SmackException {
String sessionID = getNextSessionID();
return establishSession(targetJID, sessionID);
@ -421,7 +424,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* @throws SmackException if the target does not support SOCKS5.
* @throws XMPPException
*/
public Socks5BytestreamSession establishSession(String targetJID, String sessionID)
public Socks5BytestreamSession establishSession(Jid targetJID, String sessionID)
throws IOException, InterruptedException, NoResponseException, SmackException, XMPPException{
XMPPErrorException discoveryException = null;
@ -430,7 +433,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
throw new FeatureNotSupportedException("SOCKS5 Bytestream", targetJID);
}
List<String> proxies = new ArrayList<String>();
List<Jid> proxies = new ArrayList<>();
// determine SOCKS5 proxies from XMPP-server
try {
proxies.addAll(determineProxies());
@ -529,7 +532,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* @throws NotConnectedException
* @throws InterruptedException
*/
private boolean supportsSocks5(String targetJID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
private boolean supportsSocks5(Jid targetJID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(targetJID, Bytestream.NAMESPACE);
}
@ -543,10 +546,10 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* @throws NotConnectedException
* @throws InterruptedException
*/
private List<String> determineProxies() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
private List<Jid> determineProxies() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connection);
List<String> proxies = new ArrayList<String>();
List<Jid> proxies = new ArrayList<>();
// get all items from XMPP server
DiscoverItems discoverItems = serviceDiscoveryManager.discoverItems(this.connection.getServiceName());
@ -591,7 +594,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* @param proxies a list of SOCKS5 proxy JIDs
* @return a list of stream hosts containing the IP address an the port
*/
private List<StreamHost> determineStreamHostInfos(List<String> proxies) {
private List<StreamHost> determineStreamHostInfos(List<Jid> proxies) {
List<StreamHost> streamHosts = new ArrayList<StreamHost>();
// add local proxy on first position if exists
@ -601,7 +604,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
}
// query SOCKS5 proxies for network settings
for (String proxy : proxies) {
for (Jid proxy : proxies) {
Bytestream streamHostRequest = createStreamHostRequest(proxy);
try {
Bytestream response = (Bytestream) connection.createPacketCollectorAndSend(
@ -623,7 +626,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* @param proxy the proxy to query
* @return IQ packet to query a SOCKS5 proxy its network settings
*/
private Bytestream createStreamHostRequest(String proxy) {
private Bytestream createStreamHostRequest(Jid proxy) {
Bytestream request = new Bytestream();
request.setType(IQ.Type.get);
request.setTo(proxy);
@ -678,7 +681,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* @param streamHosts a list of SOCKS5 proxies the target should connect to
* @return a SOCKS5 Bytestream initialization request packet
*/
private Bytestream createBytestreamInitiation(String sessionID, String targetJID,
private Bytestream createBytestreamInitiation(String sessionID, Jid targetJID,
List<StreamHost> streamHosts) {
Bytestream initiation = new Bytestream(sessionID);
@ -758,7 +761,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* @param initiator the initiator's JID
* @return the listener
*/
protected BytestreamListener getUserListener(String initiator) {
protected BytestreamListener getUserListener(Jid initiator) {
return this.userListeners.get(initiator);
}

View file

@ -30,6 +30,7 @@ import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;
import org.jxmpp.jid.Jid;
import org.jxmpp.util.cache.Cache;
import org.jxmpp.util.cache.ExpirationCache;
@ -169,7 +170,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
*
* @return the sender of the SOCKS5 Bytestream initialization request.
*/
public String getFrom() {
public Jid getFrom() {
return this.bytestreamRequest.getFrom();
}

View file

@ -29,6 +29,7 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;
import org.jxmpp.jid.Jid;
/**
* Implementation of a SOCKS5 client used on the initiators side. This is needed because connecting
@ -47,7 +48,8 @@ class Socks5ClientForInitiator extends Socks5Client {
private String sessionID;
/* the target JID used to activate SOCKS5 stream */
private String target;
// TODO fullJid?
private final Jid target;
/**
* Creates a new SOCKS5 client for the initiators side.
@ -59,7 +61,7 @@ class Socks5ClientForInitiator extends Socks5Client {
* @param target the target JID of the SOCKS5 Bytestream
*/
public Socks5ClientForInitiator(StreamHost streamHost, String digest, XMPPConnection connection,
String sessionID, String target) {
String sessionID, Jid target) {
super(streamHost, digest);
this.connection = connection;
this.sessionID = sessionID;

View file

@ -54,7 +54,7 @@ import org.jivesoftware.smack.SmackException;
* <p>
* The local SOCKS5 proxy server refuses all connections except the ones that are explicitly allowed
* in the process of establishing a SOCKS5 Bytestream (
* {@link Socks5BytestreamManager#establishSession(String)}).
* {@link Socks5BytestreamManager#establishSession(org.jxmpp.jid.Jid)}).
* <p>
* This Implementation has the following limitations:
* <ul>

View file

@ -21,6 +21,7 @@ import java.io.IOException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.util.SHA1;
import org.jxmpp.jid.Jid;
/**
* A collection of utility methods for SOcKS5 messages.
@ -38,7 +39,7 @@ class Socks5Utils {
* @param targetJID JID of the target of a SOCKS5 Bytestream
* @return SHA-1 digest of the given parameters
*/
public static String createDigest(String sessionID, String initiatorJID, String targetJID) {
public static String createDigest(String sessionID, Jid initiatorJID, Jid targetJID) {
StringBuilder b = new StringBuilder();
b.append(sessionID).append(initiatorJID).append(targetJID);
return SHA1.hex(b.toString());

View file

@ -23,6 +23,7 @@ import java.util.List;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jxmpp.jid.Jid;
/**
* A packet representing part of a SOCKS5 Bytestream negotiation.
@ -113,7 +114,7 @@ public class Bytestream extends IQ {
* @param address The internet address of the stream host.
* @return The added stream host.
*/
public StreamHost addStreamHost(final String JID, final String address) {
public StreamHost addStreamHost(final Jid JID, final String address) {
return addStreamHost(JID, address, 0);
}
@ -125,7 +126,7 @@ public class Bytestream extends IQ {
* @param port The port on which the remote host is seeking connections.
* @return The added stream host.
*/
public StreamHost addStreamHost(final String JID, final String address, final int port) {
public StreamHost addStreamHost(final Jid JID, final String address, final int port) {
StreamHost host = new StreamHost(JID, address, port);
addStreamHost(host);
@ -156,7 +157,7 @@ public class Bytestream extends IQ {
* @param JID The JID of the desired stream host.
* @return Returns the stream host related to the given JID, or null if there is none.
*/
public StreamHost getStreamHost(final String JID) {
public StreamHost getStreamHost(final Jid JID) {
if (JID == null) {
return null;
}
@ -184,7 +185,7 @@ public class Bytestream extends IQ {
*
* @param JID The JID of the used host.
*/
public void setUsedHost(final String JID) {
public void setUsedHost(final Jid JID) {
this.usedHost = new StreamHostUsed(JID);
}
@ -215,7 +216,7 @@ public class Bytestream extends IQ {
*
* @param targetID The JID of the target of the file transfer.
*/
public void setToActivate(final String targetID) {
public void setToActivate(final Jid targetID) {
this.toActivate = new Activate(targetID);
}
@ -265,13 +266,13 @@ public class Bytestream extends IQ {
public static String ELEMENTNAME = "streamhost";
private final String JID;
private final Jid JID;
private final String addy;
private final int port;
public StreamHost(String jid, String address) {
public StreamHost(Jid jid, String address) {
this(jid, address, 0);
}
@ -281,7 +282,7 @@ public class Bytestream extends IQ {
* @param JID The JID of the stream host.
* @param address The internet address of the stream host.
*/
public StreamHost(final String JID, final String address, int port) {
public StreamHost(final Jid JID, final String address, int port) {
this.JID = JID;
this.addy = address;
this.port = port;
@ -292,7 +293,7 @@ public class Bytestream extends IQ {
*
* @return Returns the JID of the stream host.
*/
public String getJID() {
public Jid getJID() {
return JID;
}
@ -343,14 +344,14 @@ public class Bytestream extends IQ {
public static String ELEMENTNAME = "streamhost-used";
private final String JID;
private final Jid JID;
/**
* Default constructor.
*
* @param JID The JID of the selected stream host.
*/
public StreamHostUsed(final String JID) {
public StreamHostUsed(final Jid JID) {
this.JID = JID;
}
@ -359,7 +360,7 @@ public class Bytestream extends IQ {
*
* @return Returns the JID of the selected stream host.
*/
public String getJID() {
public Jid getJID() {
return JID;
}
@ -385,14 +386,14 @@ public class Bytestream extends IQ {
public static String ELEMENTNAME = "activate";
private final String target;
private final Jid target;
/**
* Default constructor specifying the target of the stream.
*
* @param target The target of the stream.
*/
public Activate(final String target) {
public Activate(final Jid target) {
this.target = target;
}
@ -401,7 +402,7 @@ public class Bytestream extends IQ {
*
* @return Returns the target of the activation.
*/
public String getTarget() {
public Jid getTarget() {
return target;
}

View file

@ -19,7 +19,9 @@ package org.jivesoftware.smackx.bytestreams.socks5.provider;
import java.io.IOException;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
import org.jxmpp.jid.Jid;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@ -41,7 +43,7 @@ public class BytestreamsProvider extends IQProvider<Bytestream> {
String mode = parser.getAttributeValue("", "mode");
// streamhost
String JID = null;
Jid JID = null;
String host = null;
String port = null;
@ -52,15 +54,15 @@ public class BytestreamsProvider extends IQProvider<Bytestream> {
elementName = parser.getName();
if (eventType == XmlPullParser.START_TAG) {
if (elementName.equals(Bytestream.StreamHost.ELEMENTNAME)) {
JID = parser.getAttributeValue("", "jid");
JID = ParserUtils.getJidAttribute(parser);
host = parser.getAttributeValue("", "host");
port = parser.getAttributeValue("", "port");
}
else if (elementName.equals(Bytestream.StreamHostUsed.ELEMENTNAME)) {
toReturn.setUsedHost(parser.getAttributeValue("", "jid"));
toReturn.setUsedHost(ParserUtils.getJidAttribute(parser));
}
else if (elementName.equals(Bytestream.Activate.ELEMENTNAME)) {
toReturn.setToActivate(parser.getAttributeValue("", "jid"));
toReturn.setToActivate(ParserUtils.getJidAttribute(parser));
}
}
else if (eventType == XmlPullParser.END_TAG) {