Smack

org.jivesoftware.smackx.bytestreams.socks5.packet
Class Bytestream

java.lang.Object
  extended by org.jivesoftware.smack.packet.Packet
      extended by org.jivesoftware.smack.packet.IQ
          extended by org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream

public class Bytestream
extends IQ

A packet representing part of a SOCKS5 Bytestream negotiation.

Author:
Alexander Wenckus

Nested Class Summary
static class Bytestream.Activate
          The packet sent by the stream initiator to the stream proxy to activate the connection.
static class Bytestream.Mode
          The stream can be either a TCP stream or a UDP stream.
static class Bytestream.StreamHost
          Packet extension that represents a potential SOCKS5 proxy for the file transfer.
static class Bytestream.StreamHostUsed
          After selected a SOCKS5 stream host and successfully connecting, the target of the file transfer returns a byte stream packet with the stream host used extension.
 
Nested classes/interfaces inherited from class org.jivesoftware.smack.packet.IQ
IQ.Type
 
Field Summary
 
Fields inherited from class org.jivesoftware.smack.packet.Packet
DEFAULT_LANGUAGE, ID_NOT_AVAILABLE
 
Constructor Summary
Bytestream()
          The default constructor
Bytestream(java.lang.String SID)
          A constructor where the session ID can be specified.
 
Method Summary
 void addStreamHost(Bytestream.StreamHost host)
          Adds a potential stream host that the remote user can transfer the file through.
 Bytestream.StreamHost addStreamHost(java.lang.String JID, java.lang.String address)
          Adds a potential stream host that the remote user can connect to to receive the file.
 Bytestream.StreamHost addStreamHost(java.lang.String JID, java.lang.String address, int port)
          Adds a potential stream host that the remote user can connect to to receive the file.
 int countStreamHosts()
          Returns the count of stream hosts contained in this packet.
 java.lang.String getChildElementXML()
          Returns the sub-element XML section of the IQ packet, or null if there isn't one.
 Bytestream.Mode getMode()
          Returns the transport mode.
 java.lang.String getSessionID()
          Returns the session ID related to the bytestream negotiation.
 Bytestream.StreamHost getStreamHost(java.lang.String JID)
          Returns the stream host related to the given JID, or null if there is none.
 java.util.Collection<Bytestream.StreamHost> getStreamHosts()
          Returns the list of stream hosts contained in the packet.
 Bytestream.Activate getToActivate()
          Returns the activate element of the packet sent to the proxy host to verify the identity of the initiator and match them to the appropriate stream.
 Bytestream.StreamHostUsed getUsedHost()
          Returns the SOCKS5 host connected to by the remote user.
 void setMode(Bytestream.Mode mode)
          Set the transport mode.
 void setSessionID(java.lang.String sessionID)
          Set the session ID related to the bytestream.
 void setToActivate(java.lang.String targetID)
          Upon the response from the target of the used host the activate packet is sent to the SOCKS5 proxy.
 void setUsedHost(java.lang.String JID)
          Upon connecting to the stream host the target of the stream replies to the initiator with the JID of the SOCKS5 host that they used.
 
Methods inherited from class org.jivesoftware.smack.packet.IQ
createErrorResponse, createResultIQ, getType, setType, toXML
 
Methods inherited from class org.jivesoftware.smack.packet.Packet
addExtension, addExtensions, deleteProperty, equals, getDefaultLanguage, getError, getExtension, getExtension, getExtensions, getExtensionsXML, getFrom, getPacketID, getProperty, getPropertyNames, getTo, getXmlns, hashCode, nextID, removeExtension, setDefaultXmlns, setError, setFrom, setPacketID, setProperty, setTo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bytestream

public Bytestream()
The default constructor


Bytestream

public Bytestream(java.lang.String SID)
A constructor where the session ID can be specified.

Parameters:
SID - The session ID related to the negotiation.
See Also:
setSessionID(String)
Method Detail

setSessionID

public void setSessionID(java.lang.String sessionID)
Set the session ID related to the bytestream. The session ID is a unique identifier used to differentiate between stream negotiations.

Parameters:
sessionID - the unique session ID that identifies the transfer.

getSessionID

public java.lang.String getSessionID()
Returns the session ID related to the bytestream negotiation.

Returns:
Returns the session ID related to the bytestream negotiation.
See Also:
setSessionID(String)

setMode

public void setMode(Bytestream.Mode mode)
Set the transport mode. This should be put in the initiation of the interaction.

Parameters:
mode - the transport mode, either UDP or TCP
See Also:
Bytestream.Mode

getMode

public Bytestream.Mode getMode()
Returns the transport mode.

Returns:
Returns the transport mode.
See Also:
setMode(Mode)

addStreamHost

public Bytestream.StreamHost addStreamHost(java.lang.String JID,
                                           java.lang.String address)
Adds a potential stream host that the remote user can connect to to receive the file.

Parameters:
JID - The JID of the stream host.
address - The internet address of the stream host.
Returns:
The added stream host.

addStreamHost

public Bytestream.StreamHost addStreamHost(java.lang.String JID,
                                           java.lang.String address,
                                           int port)
Adds a potential stream host that the remote user can connect to to receive the file.

Parameters:
JID - The JID of the stream host.
address - The internet address of the stream host.
port - The port on which the remote host is seeking connections.
Returns:
The added stream host.

addStreamHost

public void addStreamHost(Bytestream.StreamHost host)
Adds a potential stream host that the remote user can transfer the file through.

Parameters:
host - The potential stream host.

getStreamHosts

public java.util.Collection<Bytestream.StreamHost> getStreamHosts()
Returns the list of stream hosts contained in the packet.

Returns:
Returns the list of stream hosts contained in the packet.

getStreamHost

public Bytestream.StreamHost getStreamHost(java.lang.String JID)
Returns the stream host related to the given JID, or null if there is none.

Parameters:
JID - The JID of the desired stream host.
Returns:
Returns the stream host related to the given JID, or null if there is none.

countStreamHosts

public int countStreamHosts()
Returns the count of stream hosts contained in this packet.

Returns:
Returns the count of stream hosts contained in this packet.

setUsedHost

public void setUsedHost(java.lang.String JID)
Upon connecting to the stream host the target of the stream replies to the initiator with the JID of the SOCKS5 host that they used.

Parameters:
JID - The JID of the used host.

getUsedHost

public Bytestream.StreamHostUsed getUsedHost()
Returns the SOCKS5 host connected to by the remote user.

Returns:
Returns the SOCKS5 host connected to by the remote user.

getToActivate

public Bytestream.Activate getToActivate()
Returns the activate element of the packet sent to the proxy host to verify the identity of the initiator and match them to the appropriate stream.

Returns:
Returns the activate element of the packet sent to the proxy host to verify the identity of the initiator and match them to the appropriate stream.

setToActivate

public void setToActivate(java.lang.String targetID)
Upon the response from the target of the used host the activate packet is sent to the SOCKS5 proxy. The proxy will activate the stream or return an error after verifying the identity of the initiator, using the activate packet.

Parameters:
targetID - The JID of the target of the file transfer.

getChildElementXML

public java.lang.String getChildElementXML()
Description copied from class: IQ
Returns the sub-element XML section of the IQ packet, or null if there isn't one. Packet extensions must be included, if any are defined.

Extensions of this class must override this method.

Specified by:
getChildElementXML in class IQ
Returns:
the child element section of the IQ XML.

Smack

Copyright © 2003-2007 Jive Software.