151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/*
289e6fad5ebb5cd58f12593021fb86dfea5334091Przemyslaw Szczepaniak * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is free software; you can redistribute it and/or modify it
651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * under the terms of the GNU General Public License version 2 only, as
751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * published by the Free Software Foundation.  Oracle designates this
851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * particular file as subject to the "Classpath" exception as provided
951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * by Oracle in the LICENSE file that accompanied this code.
1051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
1151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is distributed in the hope that it will be useful, but WITHOUT
1251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * version 2 for more details (a copy is included in the LICENSE file that
1551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * accompanied this code).
1651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
1751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * You should have received a copy of the GNU General Public License version
1851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 2 along with this work; if not, write to the Free Software Foundation,
1951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
2151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or visit www.oracle.com if you need additional information or have any
2351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * questions.
2451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */
2551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
2651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
2751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipackage javax.net.ssl;
2851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
2951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskiimport java.util.Enumeration;
3051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
3151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
3251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/**
3351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * A <code>SSLSessionContext</code> represents a set of
3451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>SSLSession</code>s associated with a single entity. For example,
3551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * it could be associated with a server or client who participates in many
3651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * sessions concurrently.
3751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>
3851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Not all environments will contain session contexts.
3951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>
4051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * There are <code>SSLSessionContext</code> parameters that affect how
4151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * sessions are stored:
4251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <UL>
4351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *      <LI>Sessions can be set to expire after a specified
4451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *      time limit.
4551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *      <LI>The number of sessions that can be stored in context
4651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *      can be limited.
4751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * </UL>
4851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * A session can be retrieved based on its session id, and all session id's
4951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * in a <code>SSLSessionContext</code> can be listed.
5051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
5151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see SSLSession
5251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
5351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4
5451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @author Nathan Abramson
5551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @author David Brownell
5651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */
5751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipublic interface SSLSessionContext {
5851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
5951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    /**
6051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * Returns the <code>SSLSession</code> bound to the specified session id.
6151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
6251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @param sessionId the Session identifier
6351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @return the <code>SSLSession</code> or null if
6451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * the specified session id does not refer to a valid SSLSession.
6551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
6651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @throws NullPointerException if <code>sessionId</code> is null.
6751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     */
6851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    public SSLSession getSession(byte[] sessionId);
6951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
7051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    /**
7151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * Returns an Enumeration of all session id's grouped under this
7251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * <code>SSLSessionContext</code>.
7351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
7451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @return an enumeration of all the Session id's
7551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     */
7651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    public Enumeration<byte[]> getIds();
7751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
7851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    /**
7951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * Sets the timeout limit for <code>SSLSession</code> objects grouped
8051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * under this <code>SSLSessionContext</code>.
8151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * <p>
8251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * If the timeout limit is set to 't' seconds, a session exceeds the
8351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * timeout limit 't' seconds after its creation time.
8451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * When the timeout limit is exceeded for a session, the
8551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * <code>SSLSession</code> object is invalidated and future connections
8651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * cannot resume or rejoin the session.
8751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * A check for sessions exceeding the timeout is made immediately whenever
8851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * the timeout limit is changed for this <code>SSLSessionContext</code>.
8951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
9051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @param seconds the new session timeout limit in seconds; zero means
9151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *          there is no limit.
9251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
9389e6fad5ebb5cd58f12593021fb86dfea5334091Przemyslaw Szczepaniak     * @exception IllegalArgumentException if the timeout specified is {@code < 0}.
9451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @see #getSessionTimeout
9551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     */
9651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    public void setSessionTimeout(int seconds)
9751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski                 throws IllegalArgumentException;
9851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
9951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    /**
10051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * Returns the timeout limit of <code>SSLSession</code> objects grouped
10151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * under this <code>SSLSessionContext</code>.
10251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * <p>
10351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * If the timeout limit is set to 't' seconds, a session exceeds the
10451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * timeout limit 't' seconds after its creation time.
10551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * When the timeout limit is exceeded for a session, the
10651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * <code>SSLSession</code> object is invalidated and future connections
10751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * cannot resume or rejoin the session.
10851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * A check for sessions exceeding the timeout limit is made immediately
10951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * whenever the timeout limit is changed for this
11051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * <code>SSLSessionContext</code>.
11151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
11251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @return the session timeout limit in seconds; zero means there is no
11351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * limit.
11451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @see #setSessionTimeout
11551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     */
11651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    public int getSessionTimeout();
11751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
11851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    /**
11951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * Sets the size of the cache used for storing
12051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * <code>SSLSession</code> objects grouped under this
12151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * <code>SSLSessionContext</code>.
12251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
12351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @param size the new session cache size limit; zero means there is no
12451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * limit.
12589e6fad5ebb5cd58f12593021fb86dfea5334091Przemyslaw Szczepaniak     * @exception IllegalArgumentException if the specified size is {@code < 0}.
12651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @see #getSessionCacheSize
12751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     */
12851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    public void setSessionCacheSize(int size)
12951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski                 throws IllegalArgumentException;
13051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
13151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    /**
13251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * Returns the size of the cache used for storing
13351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * <code>SSLSession</code> objects grouped under this
13451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * <code>SSLSessionContext</code>.
13551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
13651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @return size of the session cache; zero means there is no size limit.
13751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @see #setSessionCacheSize
13851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     */
13951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    public int getSessionCacheSize();
14051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
14151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski}
142