Package io.netty.handler.ssl
Class OpenSslSessionCache
- java.lang.Object
-
- io.netty.handler.ssl.OpenSslSessionCache
-
- All Implemented Interfaces:
io.netty.internal.tcnative.SSLSessionCache
- Direct Known Subclasses:
OpenSslClientSessionCache
class OpenSslSessionCache extends java.lang.Object implements io.netty.internal.tcnative.SSLSessionCache
SSLSessionCache
implementation for our native SSL implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
OpenSslSessionCache.NativeSslSession
OpenSslInternalSession
implementation which wraps the native SSL_SESSION* while in cache.
-
Field Summary
Fields Modifier and Type Field Description private static int
DEFAULT_CACHE_SIZE
private static OpenSslInternalSession[]
EMPTY_SESSIONS
private OpenSslEngineMap
engineMap
private java.util.concurrent.atomic.AtomicInteger
maximumCacheSize
private int
sessionCounter
private java.util.Map<OpenSslSessionId,OpenSslSessionCache.NativeSslSession>
sessions
private java.util.concurrent.atomic.AtomicInteger
sessionTimeout
-
Constructor Summary
Constructors Constructor Description OpenSslSessionCache(OpenSslEngineMap engineMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
clear()
Clear the cache and free all cached SSL_SESSION*.(package private) boolean
containsSessionWithId(OpenSslSessionId id)
Returnstrue
if there is a session for the given id in the cache.private void
expungeInvalidSessions()
(package private) java.util.List<OpenSslSessionId>
getIds()
Returns a snapshot of the session ids of the current valid sessions.long
getSession(long ssl, byte[] sessionId)
(package private) OpenSslInternalSession
getSession(OpenSslSessionId id)
Return theOpenSslInternalSession
which is cached for the given id.(package private) int
getSessionCacheSize()
(package private) int
getSessionTimeout()
private void
notifyRemovalAndFree(OpenSslSessionCache.NativeSslSession session)
(package private) void
removeSessionWithId(OpenSslSessionId id)
Remove the session with the given id from the cacheboolean
sessionCreated(long ssl, long sslSession)
protected boolean
sessionCreated(OpenSslSessionCache.NativeSslSession session)
Called once a newOpenSslInternalSession
was created.protected void
sessionRemoved(OpenSslSessionCache.NativeSslSession session)
Called once anOpenSslInternalSession
was removed from the cache.(package private) boolean
setSession(long ssl, OpenSslInternalSession session, java.lang.String host, int port)
(package private) void
setSessionCacheSize(int size)
(package private) void
setSessionTimeout(int seconds)
-
-
-
Field Detail
-
EMPTY_SESSIONS
private static final OpenSslInternalSession[] EMPTY_SESSIONS
-
DEFAULT_CACHE_SIZE
private static final int DEFAULT_CACHE_SIZE
-
engineMap
private final OpenSslEngineMap engineMap
-
sessions
private final java.util.Map<OpenSslSessionId,OpenSslSessionCache.NativeSslSession> sessions
-
maximumCacheSize
private final java.util.concurrent.atomic.AtomicInteger maximumCacheSize
-
sessionTimeout
private final java.util.concurrent.atomic.AtomicInteger sessionTimeout
-
sessionCounter
private int sessionCounter
-
-
Constructor Detail
-
OpenSslSessionCache
OpenSslSessionCache(OpenSslEngineMap engineMap)
-
-
Method Detail
-
setSessionTimeout
final void setSessionTimeout(int seconds)
-
getSessionTimeout
final int getSessionTimeout()
-
sessionCreated
protected boolean sessionCreated(OpenSslSessionCache.NativeSslSession session)
Called once a newOpenSslInternalSession
was created.- Parameters:
session
- the new session.- Returns:
true
if the session should be cached,false
otherwise.
-
sessionRemoved
protected void sessionRemoved(OpenSslSessionCache.NativeSslSession session)
Called once anOpenSslInternalSession
was removed from the cache.- Parameters:
session
- the session to remove.
-
setSessionCacheSize
final void setSessionCacheSize(int size)
-
getSessionCacheSize
final int getSessionCacheSize()
-
expungeInvalidSessions
private void expungeInvalidSessions()
-
sessionCreated
public boolean sessionCreated(long ssl, long sslSession)
- Specified by:
sessionCreated
in interfaceio.netty.internal.tcnative.SSLSessionCache
-
getSession
public final long getSession(long ssl, byte[] sessionId)
- Specified by:
getSession
in interfaceio.netty.internal.tcnative.SSLSessionCache
-
setSession
boolean setSession(long ssl, OpenSslInternalSession session, java.lang.String host, int port)
-
removeSessionWithId
final void removeSessionWithId(OpenSslSessionId id)
Remove the session with the given id from the cache
-
containsSessionWithId
final boolean containsSessionWithId(OpenSslSessionId id)
Returnstrue
if there is a session for the given id in the cache.
-
notifyRemovalAndFree
private void notifyRemovalAndFree(OpenSslSessionCache.NativeSslSession session)
-
getSession
final OpenSslInternalSession getSession(OpenSslSessionId id)
Return theOpenSslInternalSession
which is cached for the given id.
-
getIds
final java.util.List<OpenSslSessionId> getIds()
Returns a snapshot of the session ids of the current valid sessions.
-
clear
void clear()
Clear the cache and free all cached SSL_SESSION*.
-
-