/** * Removes the given session from the cache. */ final void removeSession(NativeSslSession session) { byte[] id = session.getId(); if (id == null || id.length == 0) { return; } onBeforeRemoveSession(session); ByteArray key = new ByteArray(id); synchronized (sessions) { sessions.remove(key); } }
/** * Removes the given session from the cache. */ final void removeSession(NativeSslSession session) { byte[] id = session.getId(); if (id == null || id.length == 0) { return; } onBeforeRemoveSession(session); ByteArray key = new ByteArray(id); synchronized (sessions) { sessions.remove(key); } }
/** * This is provided for API-compatibility only, not intended for use. No guarantees are * made WRT performance or the validity of the returned session. */ @Override public final SSLSession getSession(byte[] sessionId) { if (sessionId == null) { throw new NullPointerException("sessionId"); } ByteArray key = new ByteArray(sessionId); NativeSslSession session; synchronized (sessions) { session = sessions.get(key); } if (session != null && session.isValid()) { return session.toSSLSession(); } return null; }
/** * This is provided for API-compatibility only, not intended for use. No guarantees are * made WRT performance or the validity of the returned session. */ @Override public final SSLSession getSession(byte[] sessionId) { if (sessionId == null) { throw new NullPointerException("sessionId"); } ByteArray key = new ByteArray(sessionId); NativeSslSession session; synchronized (sessions) { session = sessions.get(key); } if (session != null && session.isValid()) { return session.toSSLSession(); } return null; }
/** * Adds the given session to the cache. */ final void cacheSession(NativeSslSession session) { byte[] id = session.getId(); if (id == null || id.length == 0) { return; } synchronized (sessions) { ByteArray key = new ByteArray(id); if (sessions.containsKey(key)) { removeSession(sessions.get(key)); } // Let the subclass know. onBeforeAddSession(session); sessions.put(key, session); } }
/** * Adds the given session to the cache. */ final void cacheSession(NativeSslSession session) { byte[] id = session.getId(); if (id == null || id.length == 0) { return; } synchronized (sessions) { ByteArray key = new ByteArray(id); if (sessions.containsKey(key)) { removeSession(sessions.get(key)); } // Let the subclass know. onBeforeAddSession(session); sessions.put(key, session); } }
/** * Called for server sessions only. Retrieves the session by its ID. Overridden by * {@link ServerSessionContext} to */ final NativeSslSession getSessionFromCache(byte[] sessionId) { if (sessionId == null) { return null; } // First, look in the in-memory cache. NativeSslSession session; synchronized (sessions) { session = sessions.get(new ByteArray(sessionId)); } if (session != null && session.isValid()) { if (session.isSingleUse()) { removeSession(session); } return session; } // Look in persistent cache. We don't currently delete sessions from the persistent // cache, so we may find a multi-use (aka TLS 1.2) session after having received and // then used up one or more single-use (aka TLS 1.3) sessions. return getSessionFromPersistentCache(sessionId); }
/** * Called for server sessions only. Retrieves the session by its ID. Overridden by * {@link ServerSessionContext} to */ final NativeSslSession getSessionFromCache(byte[] sessionId) { if (sessionId == null) { return null; } // First, look in the in-memory cache. NativeSslSession session; synchronized (sessions) { session = sessions.get(new ByteArray(sessionId)); } if (session != null && session.isValid()) { if (session.isSingleUse()) { removeSession(session); } return session; } // Look in persistent cache. We don't currently delete sessions from the persistent // cache, so we may find a multi-use (aka TLS 1.2) session after having received and // then used up one or more single-use (aka TLS 1.3) sessions. return getSessionFromPersistentCache(sessionId); }