Package com.yahoo.jrt
Class TlsCryptoSocket
java.lang.Object
com.yahoo.jrt.TlsCryptoSocket
- All Implemented Interfaces:
CryptoSocket
A
CryptoSocket using TLS (SSLEngine)- Author:
- bjorncs
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.yahoo.jrt.CryptoSocket
CryptoSocket.FlushResult, CryptoSocket.HandshakeResult -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchannel()Obtain the underlying socket channel used by this CryptoSocket.com.yahoo.security.tls.ConnectionAuthContextReturns the auth context for the current connection (given handshake completed)voidCalled whenCryptoSocket.handshake()returnsCryptoSocket.HandshakeResult.NEED_WORKto perform compute-heavy tasks.intdrain(ByteBuffer dst) Similar to read, but this function is not allowed to read from the underlying socket.voidThis function can be called at any time to drop any currently empty internal buffers.flush()Try to flush data in the write pipeline that is not depenedent on data not yet written by the application into the underlying socket.intThis function should be called after handshaking has completed before calling the read function.Try to progress the initial connection handshake.voidinjectReadData(com.yahoo.jrt.Buffer data) intread(ByteBuffer dst) Called when the underlying socket has available data.intwrite(ByteBuffer src) Called when the application has data it wants to write.
-
Constructor Details
-
TlsCryptoSocket
-
-
Method Details
-
injectReadData
public void injectReadData(com.yahoo.jrt.Buffer data) -
channel
Description copied from interface:CryptoSocketObtain the underlying socket channel used by this CryptoSocket.- Specified by:
channelin interfaceCryptoSocket
-
handshake
Description copied from interface:CryptoSocketTry to progress the initial connection handshake. Handshaking will be done once, before any normal reads or writes are performed. Re-negotiation at a later stage will not be permitted. This function will be called multiple times until the status is either DONE or an IOException is thrown. When NEED_READ or NEED_WRITE is returned, the handshake function will be called again when the appropriate io event has triggered. When NEED_WORK is returned, theCryptoSocket.doHandshakeWork()will be called (possibly in another thread) before this function is called again.- Specified by:
handshakein interfaceCryptoSocket- Throws:
IOException
-
doHandshakeWork
public void doHandshakeWork()Description copied from interface:CryptoSocketCalled whenCryptoSocket.handshake()returnsCryptoSocket.HandshakeResult.NEED_WORKto perform compute-heavy tasks. This method may be called from another thread to avoid blocking the transport thread.- Specified by:
doHandshakeWorkin interfaceCryptoSocket
-
getMinimumReadBufferSize
public int getMinimumReadBufferSize()Description copied from interface:CryptoSocketThis function should be called after handshaking has completed before calling the read function. It dictates the minimum size of the application read buffer presented to the read function. This is needed to support frame-based stateless decryption of incoming data.- Specified by:
getMinimumReadBufferSizein interfaceCryptoSocket
-
read
Description copied from interface:CryptoSocketCalled when the underlying socket has available data. Read through the entire input pipeline. The semantics are the same as with a normal socket read except it can also fail for cryptographic reasons.- Specified by:
readin interfaceCryptoSocket- Throws:
IOException
-
drain
Description copied from interface:CryptoSocketSimilar to read, but this function is not allowed to read from the underlying socket. This is to enable the application to make sure that there is no more input data in the read pipeline that is independent of data not yet read from the actual socket. Draining data from the input pipeline is done to prevent masking read events.- Specified by:
drainin interfaceCryptoSocket- Throws:
IOException
-
write
Description copied from interface:CryptoSocketCalled when the application has data it wants to write. Write through the entire output pipeline. The semantics are the same as with a normal socket write.- Specified by:
writein interfaceCryptoSocket- Throws:
IOException
-
flush
Description copied from interface:CryptoSocketTry to flush data in the write pipeline that is not depenedent on data not yet written by the application into the underlying socket. This is to enable the application to identify pending work that may not be completed until the underlying socket is ready for writing more data. When NEED_WRITE is returned, either write or flush will be called again when the appropriate io event has triggered.- Specified by:
flushin interfaceCryptoSocket- Throws:
IOException
-
dropEmptyBuffers
public void dropEmptyBuffers()Description copied from interface:CryptoSocketThis function can be called at any time to drop any currently empty internal buffers. Typically called after drain or flush indicates that no further progress can be made.- Specified by:
dropEmptyBuffersin interfaceCryptoSocket
-
connectionAuthContext
public com.yahoo.security.tls.ConnectionAuthContext connectionAuthContext()Description copied from interface:CryptoSocketReturns the auth context for the current connection (given handshake completed)- Specified by:
connectionAuthContextin interfaceCryptoSocket
-