Path: blob/master/src/java.base/share/classes/javax/net/ssl/SSLSessionContext.java
41159 views
/*1* Copyright (c) 1997, 2019, 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. For example, stateless38* session resumption.39* <p>40* Session contexts may not contain all sessions. For example, stateless41* sessions are not stored in the session context.42* <p>43* There are <code>SSLSessionContext</code> parameters that affect how44* sessions are stored:45* <UL>46* <LI>Sessions can be set to expire after a specified47* time limit.48* <LI>The number of sessions that can be stored in context49* can be limited.50* </UL>51* A session can be retrieved based on its session id, and all session id's52* in a <code>SSLSessionContext</code> can be listed.53*54* @see SSLSession55*56* @since 1.457* @author Nathan Abramson58* @author David Brownell59*/60public interface SSLSessionContext {6162/**63* Returns the <code>SSLSession</code> bound to the specified session id.64*65* @param sessionId the Session identifier66* @return the <code>SSLSession</code> or null if67* the specified session id does not refer to a valid SSLSession.68*69* @throws NullPointerException if <code>sessionId</code> is null.70*/71public SSLSession getSession(byte[] sessionId);7273/**74* Returns an Enumeration of all known session id's grouped under this75* <code>SSLSessionContext</code>.76* <p>Session contexts may not contain all sessions. For example,77* stateless sessions are not stored in the session context.78*79* @return an enumeration of all the Session id's80*/81public Enumeration<byte[]> getIds();8283/**84* Sets the timeout limit for <code>SSLSession</code> objects grouped85* under this <code>SSLSessionContext</code>.86* <p>87* If the timeout limit is set to 't' seconds, a session exceeds the88* timeout limit 't' seconds after its creation time.89* When the timeout limit is exceeded for a session, the90* <code>SSLSession</code> object is invalidated and future connections91* cannot resume or rejoin the session.92* A check for sessions exceeding the timeout is made immediately whenever93* the timeout limit is changed for this <code>SSLSessionContext</code>.94*95* @apiNote Note that the JDK Implementation uses default values for both96* the session cache size and timeout. See97* {@code getSessionCacheSize} and {@code getSessionTimeout} for98* more information. Applications should consider their99* performance requirements and override the defaults if necessary.100*101* @param seconds the new session timeout limit in seconds; zero means102* there is no limit.103*104* @throws IllegalArgumentException if the timeout specified is {@code < 0}.105*106* @see #getSessionTimeout107*/108public void setSessionTimeout(int seconds)109throws IllegalArgumentException;110111/**112* Returns the timeout limit of <code>SSLSession</code> objects grouped113* under this <code>SSLSessionContext</code>.114* <p>115* If the timeout limit is set to 't' seconds, a session exceeds the116* timeout limit 't' seconds after its creation time.117* When the timeout limit is exceeded for a session, the118* <code>SSLSession</code> object is invalidated and future connections119* cannot resume or rejoin the session.120* A check for sessions exceeding the timeout limit is made immediately121* whenever the timeout limit is changed for this122* <code>SSLSessionContext</code>.123*124* @implNote The JDK implementation returns the session timeout as set by125* the {@code setSessionTimeout} method, or if not set, a default126* value of 86400 seconds (24 hours).127*128* @return the session timeout limit in seconds; zero means there is no129* limit.130*131* @see #setSessionTimeout132*/133public int getSessionTimeout();134135/**136* Sets the size of the cache used for storing <code>SSLSession</code>137* objects grouped under this <code>SSLSessionContext</code>.138*139* @apiNote Note that the JDK Implementation uses default values for both140* the session cache size and timeout. See141* {@code getSessionCacheSize} and {@code getSessionTimeout} for142* more information. Applications should consider their143* performance requirements and override the defaults if necessary.144*145* @param size the new session cache size limit; zero means there is no146* limit.147*148* @throws IllegalArgumentException if the specified size is {@code < 0}.149*150* @see #getSessionCacheSize151*/152public void setSessionCacheSize(int size)153throws IllegalArgumentException;154155/**156* Returns the size of the cache used for storing <code>SSLSession</code>157* objects grouped under this <code>SSLSessionContext</code>.158*159* @implNote The JDK implementation returns the cache size as set by160* the {@code setSessionCacheSize} method, or if not set, the161* value of the {@systemProperty javax.net.ssl.sessionCacheSize}162* system property. If neither is set, it returns a default163* value of 20480.164*165* @return size of the session cache; zero means there is no size limit.166*167* @see #setSessionCacheSize168*/169public int getSessionCacheSize();170}171172173