Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/net/ssl/SSLSessionContext.java
38918 views
/*1* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/242526package javax.net.ssl;2728import java.util.Enumeration;293031/**32* A <code>SSLSessionContext</code> represents a set of33* <code>SSLSession</code>s associated with a single entity. For example,34* it could be associated with a server or client who participates in many35* sessions concurrently.36* <p>37* Not all environments will contain session contexts.38* <p>39* There are <code>SSLSessionContext</code> parameters that affect how40* sessions are stored:41* <UL>42* <LI>Sessions can be set to expire after a specified43* time limit.44* <LI>The number of sessions that can be stored in context45* can be limited.46* </UL>47* A session can be retrieved based on its session id, and all session id's48* in a <code>SSLSessionContext</code> can be listed.49*50* @see SSLSession51*52* @since 1.453* @author Nathan Abramson54* @author David Brownell55*/56public interface SSLSessionContext {5758/**59* Returns the <code>SSLSession</code> bound to the specified session id.60*61* @param sessionId the Session identifier62* @return the <code>SSLSession</code> or null if63* the specified session id does not refer to a valid SSLSession.64*65* @throws NullPointerException if <code>sessionId</code> is null.66*/67public SSLSession getSession(byte[] sessionId);6869/**70* Returns an Enumeration of all session id's grouped under this71* <code>SSLSessionContext</code>.72*73* @return an enumeration of all the Session id's74*/75public Enumeration<byte[]> getIds();7677/**78* Sets the timeout limit for <code>SSLSession</code> objects grouped79* under this <code>SSLSessionContext</code>.80* <p>81* If the timeout limit is set to 't' seconds, a session exceeds the82* timeout limit 't' seconds after its creation time.83* When the timeout limit is exceeded for a session, the84* <code>SSLSession</code> object is invalidated and future connections85* cannot resume or rejoin the session.86* A check for sessions exceeding the timeout is made immediately whenever87* the timeout limit is changed for this <code>SSLSessionContext</code>.88*89* @apiNote Note that the JDK Implementation uses default values for both90* the session cache size and timeout. See91* {@code getSessionCacheSize} and {@code getSessionTimeout} for92* more information. Applications should consider their93* performance requirements and override the defaults if necessary.94*95* @param seconds the new session timeout limit in seconds; zero means96* there is no limit.97*98* @throws IllegalArgumentException if the timeout specified is {@code < 0}.99*100* @see #getSessionTimeout101*/102public void setSessionTimeout(int seconds)103throws IllegalArgumentException;104105/**106* Returns the timeout limit of <code>SSLSession</code> objects grouped107* under this <code>SSLSessionContext</code>.108* <p>109* If the timeout limit is set to 't' seconds, a session exceeds the110* timeout limit 't' seconds after its creation time.111* When the timeout limit is exceeded for a session, the112* <code>SSLSession</code> object is invalidated and future connections113* cannot resume or rejoin the session.114* A check for sessions exceeding the timeout limit is made immediately115* whenever the timeout limit is changed for this116* <code>SSLSessionContext</code>.117*118* @implNote The JDK implementation returns the session timeout as set by119* the {@code setSessionTimeout} method, or if not set, a default120* value of 86400 seconds (24 hours).121*122* @return the session timeout limit in seconds; zero means there is no123* limit.124*125* @see #setSessionTimeout126*/127public int getSessionTimeout();128129/**130* Sets the size of the cache used for storing <code>SSLSession</code>131* objects grouped under this <code>SSLSessionContext</code>.132*133* @apiNote Note that the JDK Implementation uses default values for both134* the session cache size and timeout. See135* {@code getSessionCacheSize} and {@code getSessionTimeout} for136* more information. Applications should consider their137* performance requirements and override the defaults if necessary.138*139* @param size the new session cache size limit; zero means there is no140* limit.141*142* @throws IllegalArgumentException if the specified size is {@code < 0}.143*144* @see #getSessionCacheSize145*/146public void setSessionCacheSize(int size)147throws IllegalArgumentException;148149/**150* Returns the size of the cache used for storing <code>SSLSession</code>151* objects grouped under this <code>SSLSessionContext</code>.152*153* @implNote The JDK implementation returns the cache size as set by154* the {@code setSessionCacheSize} method, or if not set, the155* value of the {@systemProperty javax.net.ssl.sessionCacheSize}156* system property. If neither is set, it returns a default157* value of 20480.158*159* @return size of the session cache; zero means there is no size limit.160*161* @see #setSessionCacheSize162*/163public int getSessionCacheSize();164}165166167