public class SocketConnection extends Object implements Connection
Connection.ClientAuth, Connection.CompressionPolicy, Connection.State, Connection.TLSPolicy| Constructor and Description |
|---|
SocketConnection(PacketDeliverer backupDeliverer,
Socket socket,
boolean isSecure)
Deprecated.
Create a new session using the supplied socket.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCompression()
Deprecated.
Adds the compression filter to the connection but only filter incoming traffic.
|
void |
close()
Deprecated.
Closes the connection after trying to send a stream end tag.
|
void |
deliver(org.xmpp.packet.Packet packet)
Deprecated.
Delivers the packet to this connection without checking the recipient.
|
void |
deliverRawText(String text)
Deprecated.
Delivers raw text to this connection.
|
void |
forceClose()
Deprecated.
Closes the connection without sending any data (not even a stream end-tag).
|
byte[] |
getAddress()
Deprecated.
Returns the raw IP address of this
InetAddress
object. |
Connection.CompressionPolicy |
getCompressionPolicy()
Deprecated.
Returns whether compression is optional or is disabled.
|
ConnectionConfiguration |
getConfiguration()
Deprecated.
Returns a representation of the desired state for this connection.
|
String |
getHostAddress()
Deprecated.
Returns the IP address string in textual presentation.
|
String |
getHostName()
Deprecated.
Gets the host name for this IP address.
|
long |
getIdleTimeout()
Deprecated.
|
static Collection<SocketConnection> |
getInstances()
Deprecated.
|
Certificate[] |
getLocalCertificates()
Deprecated.
Returns the local underlying
X509Certificate
chain for the connection. |
int |
getMajorXMPPVersion()
Deprecated.
Returns the major version of XMPP being used by this connection
(major_version.minor_version.
|
int |
getMinorXMPPVersion()
Deprecated.
Returns the minor version of XMPP being used by this connection
(major_version.minor_version.
|
PacketDeliverer |
getPacketDeliverer()
Deprecated.
Returns the packet deliverer to use when delivering a packet over the socket fails.
|
Certificate[] |
getPeerCertificates()
Deprecated.
Returns the underlying
X509Certificate for
the connection of the peer. |
int |
getPort()
Deprecated.
Returns the port that the connection uses.
|
Connection.TLSPolicy |
getTlsPolicy()
Deprecated.
Returns whether TLS is mandatory, optional or is disabled.
|
TLSStreamHandler |
getTLSStreamHandler()
Deprecated.
Returns the stream handler responsible for securing the plain connection and providing
the corresponding input and output streams.
|
Writer |
getWriter()
Deprecated.
Returns the Writer used to send data to the connection.
|
void |
init(LocalSession owner)
Deprecated.
Initializes the connection with it's owning session.
|
boolean |
isClosed()
Deprecated.
Returns true if the connection/session is closed.
|
boolean |
isCompressed()
Deprecated.
Returns true if the connection is using compression.
|
boolean |
isFlashClient()
Deprecated.
Returns true if the connected client is a flash client.
|
boolean |
isSecure()
Deprecated.
Returns true if this connection is secure.
|
boolean |
isUsingSelfSignedCertificate()
Deprecated.
Returns true if the other peer of this session presented a self-signed certificate.
|
void |
registerCloseListener(ConnectionCloseListener listener,
Object handbackMessage)
Deprecated.
Registers a listener for close event notification.
|
void |
removeCloseListener(ConnectionCloseListener listener)
Deprecated.
Removes a registered close event listener.
|
void |
setCompressionPolicy(Connection.CompressionPolicy compressionPolicy)
Deprecated.
Sets whether compression is enabled or is disabled.
|
void |
setFlashClient(boolean flashClient)
Deprecated.
Sets whether the connected client is a flash client.
|
void |
setIdleTimeout(long timeout)
Deprecated.
Sets the number of milliseconds a connection has to be idle to be closed.
|
void |
setSocketReader(SocketReader socketReader)
Deprecated.
|
void |
setTlsPolicy(Connection.TLSPolicy tlsPolicy)
Deprecated.
Sets whether TLS is mandatory, optional or is disabled.
|
void |
setUsingSelfSignedCertificate(boolean isSelfSigned)
Deprecated.
Keeps track if the other peer of this session presented a self-signed certificate.
|
void |
setXMPPVersion(int majorVersion,
int minorVersion)
Deprecated.
Sets the XMPP version information.
|
void |
startCompression()
Deprecated.
Start compressing outgoing traffic for this connection.
|
void |
startTLS(boolean clientMode)
Deprecated.
Secures the plain connection by negotiating TLS with the other peer.
|
void |
startTLS(boolean clientMode,
String remoteServer,
Connection.ClientAuth authentication)
Deprecated.
|
void |
systemShutdown()
Deprecated.
Notification message indicating that the server is being shutdown.
|
String |
toString()
Deprecated.
|
boolean |
validate()
Deprecated.
Verifies that the connection is still live.
|
public SocketConnection(PacketDeliverer backupDeliverer, Socket socket, boolean isSecure) throws IOException
backupDeliverer - the packet deliverer this connection will use when socket is closed.socket - the socket to represent.isSecure - true if this is a secure connection.IOException - if there was a socket error while sending the packet.public static Collection<SocketConnection> getInstances()
public TLSStreamHandler getTLSStreamHandler()
@Deprecated public void startTLS(boolean clientMode, String remoteServer, Connection.ClientAuth authentication) throws Exception
Connectiontrue in the clientMode parameter and the server
receiving the TLS request must pass false in the clientMode parameter.
Both servers should specify the xmpp domain of the other server in the remoteServer
parameter.
In the case of client-2-server the XMPP server must pass false in the
clientMode parameter since it will behave as the server in the TLS negotiation. The
remoteServer parameter will always be null.
startTLS in interface ConnectionclientMode - boolean indicating if this entity is a client or a server in the TLS negotiation.remoteServer - xmpp domain of the remote server or null. When null a
ClientTrustManager will be used for verifying certificates
otherwise a ServerTrustManager will be used.authentication - policy to use for authenticating the remote peer.Exception - if an error occured while securing the connection.public void startTLS(boolean clientMode)
throws IOException
Connectiontrue in the clientMode parameter and the server
receiving the TLS request must pass false in the clientMode parameter.
In the case of client-2-server the XMPP server must pass false in the
clientMode parameter since it will behave as the server in the TLS negotiation.
startTLS in interface ConnectionclientMode - boolean indicating if this entity is a client or a server in the TLS negotiation.IOExceptionpublic void addCompression()
ConnectionaddCompression in interface Connectionpublic void startCompression()
ConnectionstartCompression in interface Connectionpublic ConnectionConfiguration getConfiguration()
ConnectiongetConfiguration in interface Connectionpublic boolean validate()
Connectionvalidate in interface Connectionpublic void init(LocalSession owner)
Connectioninit in interface Connectionowner - the session that owns this connectionpublic void registerCloseListener(ConnectionCloseListener listener, Object handbackMessage)
ConnectionregisterCloseListener in interface Connectionlistener - the listener to register for events.handbackMessage - the object to send in the event notification.public void removeCloseListener(ConnectionCloseListener listener)
ConnectionremoveCloseListener in interface Connectionlistener - the listener to deregister for close events.public byte[] getAddress()
throws UnknownHostException
ConnectionInetAddress
object. The result is in network byte order: the highest order
byte of the address is in getAddress()[0].getAddress in interface ConnectionUnknownHostException - if IP address of host could not be determined.public String getHostAddress() throws UnknownHostException
ConnectiongetHostAddress in interface ConnectionUnknownHostException - if IP address of host could not be determined.public String getHostName() throws UnknownHostException
ConnectionIf this InetAddress was created with a host name,
this host name will be remembered and returned;
otherwise, a reverse name lookup will be performed
and the result will be returned based on the system
configured name lookup service. If a lookup of the name service
is required, call
getCanonicalHostName.
If there is a security manager, its
checkConnect method is first called
with the hostname and -1
as its arguments to see if the operation is allowed.
If the operation is not allowed, it will return
the textual representation of the IP address.
getHostName in interface ConnectionUnknownHostException - if IP address of host could not be determined.InetAddress.getCanonicalHostName(),
SecurityManager.checkConnect(java.lang.String, int)public int getPort()
public Writer getWriter()
deliver(Packet)
method should be used to send data instead of using the writer directly.
You must synchronize on the writer before writing data to it to ensure
data consistency:
Writer writer = connection.getWriter();
synchronized(writer) {
// write data....
}public boolean isClosed()
ConnectionisClosed in interface Connectionpublic boolean isSecure()
ConnectionisSecure in interface Connectionpublic boolean isCompressed()
ConnectionisCompressed in interface Connectionpublic Connection.TLSPolicy getTlsPolicy()
ConnectiongetTlsPolicy in interface Connectionpublic void setTlsPolicy(Connection.TLSPolicy tlsPolicy)
setTlsPolicy in interface ConnectiontlsPolicy - whether TLS is mandatory, optional or is disabled.public Connection.CompressionPolicy getCompressionPolicy()
ConnectiongetCompressionPolicy in interface Connectionpublic void setCompressionPolicy(Connection.CompressionPolicy compressionPolicy)
setCompressionPolicy in interface ConnectioncompressionPolicy - whether Compression is enabled or is disabled.public long getIdleTimeout()
public void setIdleTimeout(long timeout)
timeout - the number of milliseconds a connection has to be idle to be closed.public int getMajorXMPPVersion()
ConnectiongetMajorXMPPVersion in interface Connectionpublic int getMinorXMPPVersion()
ConnectiongetMinorXMPPVersion in interface Connectionpublic void setXMPPVersion(int majorVersion,
int minorVersion)
setXMPPVersion in interface ConnectionmajorVersion - the major version.minorVersion - the minor version.public boolean isFlashClient()
ConnectionisFlashClient in interface Connectionpublic void setFlashClient(boolean flashClient)
setFlashClient in interface ConnectionflashClient - true if the if the connection is a flash client.public Certificate[] getLocalCertificates()
ConnectionX509Certificate
chain for the connection.getLocalCertificates in interface Connectionpublic Certificate[] getPeerCertificates()
ConnectionX509Certificate for
the connection of the peer.getPeerCertificates in interface Connectionpublic void setUsingSelfSignedCertificate(boolean isSelfSigned)
ConnectionsetUsingSelfSignedCertificate in interface ConnectionisSelfSigned - true if the other peer presented a self-signed certificate.public boolean isUsingSelfSignedCertificate()
ConnectionisUsingSelfSignedCertificate in interface Connectionpublic PacketDeliverer getPacketDeliverer()
ConnectiongetPacketDeliverer in interface Connectionpublic void forceClose()
public void close()
close in interface Closeableclose in interface AutoCloseableclose in interface Connectionpublic void systemShutdown()
ConnectionsystemShutdown in interface Connectionpublic void deliver(org.xmpp.packet.Packet packet)
throws UnauthorizedException,
PacketException
Connectionsocket.send(packet.getWriteBuffer()).deliver in interface Connectionpacket - the packet to deliver.UnauthorizedException - if a permission error was detected.PacketExceptionpublic void deliverRawText(String text)
ConnectionConnection.deliver(org.xmpp.packet.Packet).This method avoids having to get the writer of this connection and mess directly with the writer. Therefore, this method ensures a correct delivery of the stanza even if other threads were sending data concurrently.
deliverRawText in interface Connectiontext - the XML stanzas represented kept in a String.public void setSocketReader(SocketReader socketReader)
Copyright © 2003-2008 Jive Software.