Package io.netty.handler.ssl
Class OpenSslSessionCache.NativeSslSession
java.lang.Object
io.netty.handler.ssl.OpenSslSessionCache.NativeSslSession
- All Implemented Interfaces:
OpenSslInternalSession
,OpenSslSession
,SSLSession
- Enclosing class:
OpenSslSessionCache
static final class OpenSslSessionCache.NativeSslSession
extends Object
implements OpenSslInternalSession
OpenSslInternalSession
implementation which wraps the native SSL_SESSION* while in cache.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final long
private boolean
private final OpenSslSessionId
private long
(package private) static final ResourceLeakDetector
<OpenSslSessionCache.NativeSslSession> private final ResourceLeakTracker
<OpenSslSessionCache.NativeSslSession> private final String
private final int
private final long
private final long
private boolean
-
Constructor Summary
ConstructorsConstructorDescriptionNativeSslSession
(long session, String peerHost, int peerPort, long timeout, Map<String, Object> keyValueStorage) -
Method Summary
Modifier and TypeMethodDescription(package private) void
close()
boolean
(package private) void
free()
int
long
byte[]
getId()
long
int
int
String[]
void
handshakeFinished
(byte[] id, String cipher, String protocol, byte[] peerCertificate, byte[][] peerCertificateChain, long creationTime, long timeout) Called once the handshake has completed.int
hashCode()
boolean
Returns true if the peer has provided certificates during the handshake.void
boolean
isValid()
(package private) boolean
isValid
(long now) Return the underlyingMap
that is used by the following methods:SSLSession.putValue(String, Object)
SSLSession.removeValue(String)
SSLSession.getValue(String)
SSLSession.getValueNames()
TheMap
must be thread-safe!void
Called on a handshake session before being exposed to aTrustManager
.void
void
removeValue
(String name) (package private) long
session()
Return theOpenSslSessionId
that can be used to identify this session.void
setLastAccessedTime
(long time) Set the last access time which will be returned bySSLSession.getLastAccessedTime()
.void
setLocalCertificate
(Certificate[] localCertificate) Set the local certificate chain that is used.void
setSessionDetails
(long creationTime, long lastAccessedTime, OpenSslSessionId id, Map<String, Object> keyValueStorage) Set the details for the session which might come from a cache.(package private) boolean
void
tryExpandApplicationBufferSize
(int packetLengthDataOnly) Expand (or increase) the value returned bySSLSession.getApplicationBufferSize()
if necessary.(package private) boolean
upRef()
-
Field Details
-
LEAK_DETECTOR
-
leakTracker
-
keyValueStorage
-
session
private final long session -
peerHost
-
peerPort
private final int peerPort -
id
-
timeout
private final long timeout -
creationTime
private final long creationTime -
lastAccessedTime
private volatile long lastAccessedTime -
valid
private volatile boolean valid -
freed
private boolean freed
-
-
Constructor Details
-
NativeSslSession
-
-
Method Details
-
keyValueStorage
Description copied from interface:OpenSslInternalSession
Return the underlyingMap
that is used by the following methods:SSLSession.putValue(String, Object)
SSLSession.removeValue(String)
SSLSession.getValue(String)
-
SSLSession.getValueNames()
Map
must be thread-safe!- Specified by:
keyValueStorage
in interfaceOpenSslInternalSession
- Returns:
- storage
-
prepareHandshake
public void prepareHandshake()Description copied from interface:OpenSslInternalSession
Called on a handshake session before being exposed to aTrustManager
. Session data must be cleared by this call.- Specified by:
prepareHandshake
in interfaceOpenSslInternalSession
-
setSessionDetails
public void setSessionDetails(long creationTime, long lastAccessedTime, OpenSslSessionId id, Map<String, Object> keyValueStorage) Description copied from interface:OpenSslInternalSession
Set the details for the session which might come from a cache.- Specified by:
setSessionDetails
in interfaceOpenSslInternalSession
- Parameters:
creationTime
- the time at which the session was created.lastAccessedTime
- the time at which the session was last accessed via the session infrastructure (cache).id
- theOpenSslSessionId
keyValueStorage
- the key value store. SeeOpenSslInternalSession.keyValueStorage()
.
-
shouldBeSingleUse
boolean shouldBeSingleUse() -
session
long session() -
upRef
boolean upRef() -
free
void free() -
close
void close() -
sessionId
Description copied from interface:OpenSslInternalSession
Return theOpenSslSessionId
that can be used to identify this session.- Specified by:
sessionId
in interfaceOpenSslInternalSession
-
isValid
boolean isValid(long now) -
setLocalCertificate
Description copied from interface:OpenSslInternalSession
Set the local certificate chain that is used. It is not expected that this array will be changed at all and so its ok to not copy the array.- Specified by:
setLocalCertificate
in interfaceOpenSslInternalSession
-
getSessionContext
- Specified by:
getSessionContext
in interfaceOpenSslSession
- Specified by:
getSessionContext
in interfaceSSLSession
-
tryExpandApplicationBufferSize
public void tryExpandApplicationBufferSize(int packetLengthDataOnly) Description copied from interface:OpenSslInternalSession
Expand (or increase) the value returned bySSLSession.getApplicationBufferSize()
if necessary.This is only called in a synchronized block, so no need to use atomic operations.
- Specified by:
tryExpandApplicationBufferSize
in interfaceOpenSslInternalSession
- Parameters:
packetLengthDataOnly
- The packet size which exceeds the currentSSLSession.getApplicationBufferSize()
.
-
handshakeFinished
public void handshakeFinished(byte[] id, String cipher, String protocol, byte[] peerCertificate, byte[][] peerCertificateChain, long creationTime, long timeout) Description copied from interface:OpenSslInternalSession
Called once the handshake has completed.- Specified by:
handshakeFinished
in interfaceOpenSslInternalSession
-
getId
public byte[] getId()- Specified by:
getId
in interfaceSSLSession
-
getCreationTime
public long getCreationTime()- Specified by:
getCreationTime
in interfaceSSLSession
-
setLastAccessedTime
public void setLastAccessedTime(long time) Description copied from interface:OpenSslInternalSession
Set the last access time which will be returned bySSLSession.getLastAccessedTime()
.- Specified by:
setLastAccessedTime
in interfaceOpenSslInternalSession
- Parameters:
time
- the time
-
getLastAccessedTime
public long getLastAccessedTime()- Specified by:
getLastAccessedTime
in interfaceSSLSession
-
invalidate
public void invalidate()- Specified by:
invalidate
in interfaceSSLSession
-
isValid
public boolean isValid()- Specified by:
isValid
in interfaceSSLSession
-
putValue
- Specified by:
putValue
in interfaceSSLSession
-
getValue
- Specified by:
getValue
in interfaceSSLSession
-
removeValue
- Specified by:
removeValue
in interfaceSSLSession
-
getValueNames
- Specified by:
getValueNames
in interfaceSSLSession
-
getPeerCertificates
- Specified by:
getPeerCertificates
in interfaceSSLSession
-
hasPeerCertificates
public boolean hasPeerCertificates()Description copied from interface:OpenSslSession
Returns true if the peer has provided certificates during the handshake.This method is similar to
SSLSession.getPeerCertificates()
but it does not throw aSSLPeerUnverifiedException
if no certs are provided, making it more efficient to check if a mTLS connection is used.- Specified by:
hasPeerCertificates
in interfaceOpenSslSession
- Returns:
- true if peer certificates are available.
-
getLocalCertificates
- Specified by:
getLocalCertificates
in interfaceSSLSession
-
getPeerCertificateChain
- Specified by:
getPeerCertificateChain
in interfaceSSLSession
-
getPeerPrincipal
- Specified by:
getPeerPrincipal
in interfaceSSLSession
-
getLocalPrincipal
- Specified by:
getLocalPrincipal
in interfaceSSLSession
-
getCipherSuite
- Specified by:
getCipherSuite
in interfaceSSLSession
-
getProtocol
- Specified by:
getProtocol
in interfaceSSLSession
-
getPeerHost
- Specified by:
getPeerHost
in interfaceSSLSession
-
getPeerPort
public int getPeerPort()- Specified by:
getPeerPort
in interfaceSSLSession
-
getPacketBufferSize
public int getPacketBufferSize()- Specified by:
getPacketBufferSize
in interfaceSSLSession
-
getApplicationBufferSize
public int getApplicationBufferSize()- Specified by:
getApplicationBufferSize
in interfaceSSLSession
-
hashCode
public int hashCode() -
equals
-