Package org.jivesoftware.openfire.net
Class TLSWrapper
- java.lang.Object
-
- org.jivesoftware.openfire.net.TLSWrapper
-
public class TLSWrapper extends Object
Creates and initializes the SSLContext instance to use to secure the plain connection. This class is also responsible for encoding and decoding the encrypted data and place it into the corresponding theByteBuffer
.- Author:
- Artur Hefczyc, Hao Chen
-
-
Constructor Summary
Constructors Constructor Description TLSWrapper(Connection connection, boolean clientMode, boolean needClientAuth, String remoteServer)
Deprecated.Use the other constructor.TLSWrapper(ConnectionConfiguration configuration, boolean clientMode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Signals that no more outbound application data will be sent on this TLSHandler.void
enableLogging(boolean logging)
int
getAppBuffSize()
int
getNetBuffSize()
TLSStatus
getStatus()
Returns the current status for this TLSHandler.protected SSLEngine
getTlsEngine()
boolean
isEngineClosed()
Returns whether unwrap(ByteBuffer, ByteBuffer) will accept any more inbound data messages and whether wrap(ByteBuffer, ByteBuffer) will produce any more outbound data messages.ByteBuffer
unwrap(ByteBuffer net, ByteBuffer app)
Attempts to decode SSL/TLS network data into a subsequence of plaintext application data buffers.void
wrap(ByteBuffer app, ByteBuffer net)
Attempts to encode a buffer of plaintext application data into TLS network data.
-
-
-
Constructor Detail
-
TLSWrapper
@Deprecated public TLSWrapper(Connection connection, boolean clientMode, boolean needClientAuth, String remoteServer)
Deprecated.Use the other constructor.- Parameters:
connection
- the connection to wrapclientMode
-true
to use client mode,false
to use server modeneedClientAuth
- unused parameterremoteServer
- unused parameter
-
TLSWrapper
public TLSWrapper(ConnectionConfiguration configuration, boolean clientMode)
-
-
Method Detail
-
getNetBuffSize
public int getNetBuffSize()
-
getAppBuffSize
public int getAppBuffSize()
-
isEngineClosed
public boolean isEngineClosed()
Returns whether unwrap(ByteBuffer, ByteBuffer) will accept any more inbound data messages and whether wrap(ByteBuffer, ByteBuffer) will produce any more outbound data messages.- Returns:
- true if the TLSHandler will not consume anymore network data and will not produce any anymore network data.
-
enableLogging
public void enableLogging(boolean logging)
-
unwrap
public ByteBuffer unwrap(ByteBuffer net, ByteBuffer app) throws SSLException
Attempts to decode SSL/TLS network data into a subsequence of plaintext application data buffers. Depending on the state of the TLSWrapper, this method may consume network data without producing any application data (for example, it may consume handshake data.) If this TLSWrapper has not yet started its initial handshake, this method will automatically start the handshake.- Parameters:
net
- a ByteBuffer containing inbound network dataapp
- a ByteBuffer to hold inbound application data- Returns:
- a ByteBuffer containing inbound application data
- Throws:
SSLException
- A problem was encountered while processing the data that caused the TLSHandler to abort.
-
wrap
public void wrap(ByteBuffer app, ByteBuffer net) throws SSLException
Attempts to encode a buffer of plaintext application data into TLS network data. Depending on the state of the TLSWrapper, this method may produce network data without consuming any application data (for example, it may generate handshake data). If this TLSWrapper has not yet started its initial handshake, this method will automatically start the handshake.- Parameters:
app
- a ByteBuffer containing outbound application datanet
- a ByteBuffer to hold outbound network data- Throws:
SSLException
- A problem was encountered while processing the data that caused the TLSWrapper to abort.
-
close
public void close() throws SSLException
Signals that no more outbound application data will be sent on this TLSHandler.- Throws:
SSLException
- never
-
getStatus
public TLSStatus getStatus()
Returns the current status for this TLSHandler.- Returns:
- the current TLSStatus
-
getTlsEngine
protected SSLEngine getTlsEngine()
-
-