1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17
18package javax.net.ssl;
19
20import java.util.Enumeration;
21
22/**
23 * A collection of {@code SSLSession}s.
24 */
25public interface SSLSessionContext {
26    /**
27     * Returns an iterable of all session identifiers in this session context.
28     *
29     * @return an iterable of all session identifiers in this session context.
30     */
31    public Enumeration<byte[]> getIds();
32
33    /**
34     * Returns the session for the specified session identifier.
35     *
36     * @param sessionId
37     *            the session identifier of the session to look up.
38     * @return the session for the specified session identifier, or {@code null}
39     *         if the specified session identifier does not refer to a session
40     *         in this context.
41     */
42    public SSLSession getSession(byte[] sessionId);
43
44    /**
45     * Returns the size of the session cache for this session context.
46     *
47     * @return the size of the session cache for this session context, or
48     *         {@code zero} if unlimited.
49     */
50    public int getSessionCacheSize();
51
52    /**
53     * Returns the timeout for sessions in this session context. Sessions
54     * exceeding the timeout are invalidated.
55     *
56     * @return the timeout in seconds, or {@code zero} if unlimited.
57     */
58    public int getSessionTimeout();
59
60    /**
61     * Sets the size of the session cache for this session context.
62     *
63     * @param size
64     *            the size of the session cache, or {@code zero} for unlimited
65     *            cache size.
66     * @throws IllegalArgumentException
67     *             if {@code size} is negative.
68     */
69    public void setSessionCacheSize(int size) throws IllegalArgumentException;
70
71    /**
72     * Sets the timeout for sessions in this context. Sessions exceeding the
73     * timeout are invalidated.
74     *
75     * @param seconds
76     *            the timeout in seconds, or {@code zero} if unlimited.
77     * @throws IllegalArgumentException
78     *             if {@code seconds} is negative.
79     */
80    public void setSessionTimeout(int seconds) throws IllegalArgumentException;
81}
82