public abstract class VirtualConnection extends Object implements Connection
Default values and common behavior of virtual connections are modeled in this class. Subclasses should just need to specify how packets are delivered and what means closing the connection.
Connection.ClientAuth, Connection.CompressionPolicy, Connection.State, Connection.TLSPolicy| Modifier and Type | Field and Description |
|---|---|
protected LocalSession |
session |
| Constructor and Description |
|---|
VirtualConnection() |
| Modifier and Type | Method and Description |
|---|---|
void |
addCompression()
Adds the compression filter to the connection but only filter incoming traffic.
|
void |
close()
Closes the session, the virtual connection and notifies listeners that the connection
has been closed.
|
abstract void |
closeVirtualConnection()
Closes the virtual connection.
|
Connection.CompressionPolicy |
getCompressionPolicy()
Returns whether compression is optional or is disabled.
|
Certificate[] |
getLocalCertificates()
Returns the local underlying
X509Certificate
chain for the connection. |
int |
getMajorXMPPVersion()
Returns the major version of XMPP being used by this connection
(major_version.minor_version.
|
int |
getMinorXMPPVersion()
Returns the minor version of XMPP being used by this connection
(major_version.minor_version.
|
PacketDeliverer |
getPacketDeliverer()
Returns the packet deliverer to use when delivering a packet over the socket fails.
|
Certificate[] |
getPeerCertificates()
Returns the underlying
X509Certificate for
the connection of the peer. |
Connection.TLSPolicy |
getTlsPolicy()
Returns whether TLS is mandatory, optional or is disabled.
|
void |
init(LocalSession session)
Initializes the connection with it's owning session.
|
boolean |
isClosed()
Returns true if the connection/session is closed.
|
boolean |
isCompressed()
Returns true if the connection is using compression.
|
boolean |
isFlashClient()
Returns true if the connected client is a flash client.
|
boolean |
isSecure()
Returns true if this connection is secure.
|
boolean |
isUsingSelfSignedCertificate()
Returns true if the other peer of this session presented a self-signed certificate.
|
void |
registerCloseListener(ConnectionCloseListener listener,
Object handbackMessage)
Registers a listener for close event notification.
|
void |
removeCloseListener(ConnectionCloseListener listener)
Removes a registered close event listener.
|
void |
setCompressionPolicy(Connection.CompressionPolicy compressionPolicy)
Sets whether compression is enabled or is disabled.
|
void |
setFlashClient(boolean flashClient)
Sets whether the connected client is a flash client.
|
void |
setTlsPolicy(Connection.TLSPolicy tlsPolicy)
Sets whether TLS is mandatory, optional or is disabled.
|
void |
setUsingSelfSignedCertificate(boolean isSelfSigned)
Keeps track if the other peer of this session presented a self-signed certificate.
|
void |
setXMPPVersion(int majorVersion,
int minorVersion)
Sets the XMPP version information.
|
void |
startCompression()
Start compressing outgoing traffic for this connection.
|
void |
startTLS(boolean clientMode)
Secures the plain connection by negotiating TLS with the other peer.
|
void |
startTLS(boolean clientMode,
String remoteServer,
Connection.ClientAuth authentication)
Deprecated.
|
boolean |
validate()
Verifies that the connection is still live.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdeliver, deliverRawText, getAddress, getConfiguration, getHostAddress, getHostName, systemShutdownprotected LocalSession session
public int getMajorXMPPVersion()
ConnectiongetMajorXMPPVersion in interface Connectionpublic int getMinorXMPPVersion()
ConnectiongetMinorXMPPVersion in interface Connectionpublic 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 boolean isClosed()
ConnectionisClosed in interface Connectionpublic Connection.CompressionPolicy getCompressionPolicy()
ConnectiongetCompressionPolicy in interface Connectionpublic Connection.TLSPolicy getTlsPolicy()
ConnectiongetTlsPolicy in interface Connectionpublic boolean isCompressed()
ConnectionisCompressed in interface Connectionpublic boolean isFlashClient()
ConnectionisFlashClient in interface Connectionpublic void setFlashClient(boolean flashClient)
ConnectionsetFlashClient in interface ConnectionflashClient - true if the if the connection is a flash client.public void setXMPPVersion(int majorVersion,
int minorVersion)
ConnectionsetXMPPVersion in interface ConnectionmajorVersion - the major version.minorVersion - the minor version.public void setCompressionPolicy(Connection.CompressionPolicy compressionPolicy)
ConnectionsetCompressionPolicy in interface ConnectioncompressionPolicy - whether Compression is enabled or is disabled.public void setTlsPolicy(Connection.TLSPolicy tlsPolicy)
ConnectionsetTlsPolicy in interface ConnectiontlsPolicy - whether TLS is mandatory, optional or is disabled.public PacketDeliverer getPacketDeliverer()
ConnectiongetPacketDeliverer in interface Connection@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 Exception
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.Exception - if an error occured while securing the connection.public void addCompression()
ConnectionaddCompression in interface Connectionpublic void startCompression()
ConnectionstartCompression in interface Connectionpublic boolean isSecure()
ConnectionisSecure in interface Connectionpublic boolean validate()
Connectionvalidate in interface Connectionpublic void init(LocalSession session)
Connectioninit in interface Connectionsession - the session that owns this connectionpublic void close()
close in interface Closeableclose in interface AutoCloseableclose in interface 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 abstract void closeVirtualConnection()
Copyright © 2003-2008 Jive Software.