From b091f6161eb7881b3b7098349718b00c5590f0e3 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 22 Mar 2013 18:14:01 +0000 Subject: [PATCH] SMACK-430 Re-activated code that throws an exception if createOutgoingFileTransfer() was called with a bare JID git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_3_0@13576 b35dd754-fafc-0310-a699-88a17e54d16e --- .../filetransfer/FileTransferManager.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/source/org/jivesoftware/smackx/filetransfer/FileTransferManager.java b/source/org/jivesoftware/smackx/filetransfer/FileTransferManager.java index 664450b0d..6e413fa31 100644 --- a/source/org/jivesoftware/smackx/filetransfer/FileTransferManager.java +++ b/source/org/jivesoftware/smackx/filetransfer/FileTransferManager.java @@ -27,6 +27,7 @@ import org.jivesoftware.smack.filter.PacketTypeFilter; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.packet.XMPPError; +import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smackx.packet.StreamInitiation; import java.util.ArrayList; @@ -125,18 +126,21 @@ public class FileTransferManager { * Creates an OutgoingFileTransfer to send a file to another user. * * @param userID - * The fully qualified jabber ID with resource of the user to + * The fully qualified jabber ID (i.e. full JID) with resource of the user to * send the file to. * @return The send file object on which the negotiated transfer can be run. + * @exception IllegalArgumentException if userID is null or not a full JID */ public OutgoingFileTransfer createOutgoingFileTransfer(String userID) { -// Why is this only accepting fully qualified JID? -// if (userID == null || StringUtils.parseName(userID).length() <= 0 -// || StringUtils.parseServer(userID).length() <= 0 -// || StringUtils.parseResource(userID).length() <= 0) { -// throw new IllegalArgumentException( -// "The provided user id was not fully qualified"); -// } + if (userID == null) { + throw new IllegalArgumentException("userID was null"); + } + // We need to create outgoing file transfers with a full JID since this method will later + // use XEP-0095 to negotiate the stream. This is done with IQ stanzas that need to be addressed to a full JID + // in order to reach an client entity. + else if (!StringUtils.isFullJID(userID)) { + throw new IllegalArgumentException("The provided user id was not a full JID (i.e. with resource part)"); + } return new OutgoingFileTransfer(connection.getUser(), userID, fileTransferNegotiator.getNextStreamID(),