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 |
reinit(LocalSession session)
Reinitializes the connection to switch to a different session.
|
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,
boolean directTLS)
Secures the plain connection by negotiating TLS with the other peer.
|
boolean |
validate()
Verifies that the connection is still live.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
deliver, deliverRawText, getAddress, getConfiguration, getHostAddress, getHostName, systemShutdown
protected LocalSession session
public int getMajorXMPPVersion()
Connection
getMajorXMPPVersion
in interface Connection
public int getMinorXMPPVersion()
Connection
getMinorXMPPVersion
in interface Connection
public Certificate[] getLocalCertificates()
Connection
X509Certificate
chain for the connection.getLocalCertificates
in interface Connection
null
is returned.public Certificate[] getPeerCertificates()
Connection
X509Certificate
for
the connection of the peer.getPeerCertificates
in interface Connection
public void setUsingSelfSignedCertificate(boolean isSelfSigned)
Connection
setUsingSelfSignedCertificate
in interface Connection
isSelfSigned
- true if the other peer presented a self-signed certificate.public boolean isUsingSelfSignedCertificate()
Connection
isUsingSelfSignedCertificate
in interface Connection
public boolean isClosed()
Connection
isClosed
in interface Connection
public Connection.CompressionPolicy getCompressionPolicy()
Connection
getCompressionPolicy
in interface Connection
public Connection.TLSPolicy getTlsPolicy()
Connection
getTlsPolicy
in interface Connection
public boolean isCompressed()
Connection
isCompressed
in interface Connection
public boolean isFlashClient()
Connection
isFlashClient
in interface Connection
public void setFlashClient(boolean flashClient)
Connection
setFlashClient
in interface Connection
flashClient
- true if the if the connection is a flash client.public void setXMPPVersion(int majorVersion, int minorVersion)
Connection
setXMPPVersion
in interface Connection
majorVersion
- the major version.minorVersion
- the minor version.public void setCompressionPolicy(Connection.CompressionPolicy compressionPolicy)
Connection
setCompressionPolicy
in interface Connection
compressionPolicy
- whether Compression is enabled or is disabled.public void setTlsPolicy(Connection.TLSPolicy tlsPolicy)
Connection
setTlsPolicy
in interface Connection
tlsPolicy
- whether TLS is mandatory, optional or is disabled.public PacketDeliverer getPacketDeliverer()
Connection
getPacketDeliverer
in interface Connection
public void startTLS(boolean clientMode, boolean directTLS) throws Exception
Connection
true
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 Connection
clientMode
- boolean indicating if this entity is a client or a server in the TLS negotiation.directTLS
- boolean indicating if the negotiation is directTLS (true) or startTLS (false).Exception
- if an error occured while securing the connection.public void addCompression()
Connection
addCompression
in interface Connection
public void startCompression()
Connection
startCompression
in interface Connection
public boolean isSecure()
Connection
isSecure
in interface Connection
public boolean validate()
Connection
validate
in interface Connection
public void init(LocalSession session)
Connection
init
in interface Connection
session
- the session that owns this connectionpublic void reinit(LocalSession session)
Connection
reinit
in interface Connection
session
- The new session now owning the connection.public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in interface Connection
public void registerCloseListener(ConnectionCloseListener listener, Object handbackMessage)
Connection
registerCloseListener
in interface Connection
listener
- the listener to register for events.handbackMessage
- the object to send in the event notification.public void removeCloseListener(ConnectionCloseListener listener)
Connection
removeCloseListener
in interface Connection
listener
- the listener to deregister for close events.public abstract void closeVirtualConnection()
Copyright © 2003–2019 Ignite Realtime. All rights reserved.