1 module hunt.net.ssl.SSLSessionContext;
2 
3 // dfmt off
4 version(WITH_HUNT_SECURITY):
5 // dfmt on
6 
7 import hunt.net.ssl.SSLSession;
8 import hunt.collection;
9 
10 
11 /**
12  * A <code>SSLSessionContext</code> represents a set of
13  * <code>SSLSession</code>s associated with a single entity. For example,
14  * it could be associated with a server or client who participates in many
15  * sessions concurrently.
16  * <p>
17  * Not all environments will contain session contexts.
18  * <p>
19  * There are <code>SSLSessionContext</code> parameters that affect how
20  * sessions are stored:
21  * <UL>
22  *      <LI>Sessions can be set to expire after a specified
23  *      time limit.
24  *      <LI>The number of sessions that can be stored in context
25  *      can be limited.
26  * </UL>
27  * A session can be retrieved based on its session id, and all session id's
28  * in a <code>SSLSessionContext</code> can be listed.
29  *
30  * @see SSLSession
31  *
32  * @author Nathan Abramson
33  * @author David Brownell
34  */
35 interface SSLSessionContext {
36 
37     /**
38      * Returns the <code>SSLSession</code> bound to the specified session id.
39      *
40      * @param sessionId the Connection identifier
41      * @return the <code>SSLSession</code> or null if
42      * the specified session id does not refer to a valid SSLSession.
43      *
44      * @throws NullPointerException if <code>sessionId</code> is null.
45      */
46     SSLSession getSession(byte[] sessionId);
47 
48     /**
49      * Returns an Enumeration of all session id's grouped under this
50      * <code>SSLSessionContext</code>.
51      *
52      * @return an enumeration of all the Connection id's
53      */
54     Enumeration!(byte[]) getIds();
55 
56     /**
57      * Sets the timeout limit for <code>SSLSession</code> objects grouped
58      * under this <code>SSLSessionContext</code>.
59      * <p>
60      * If the timeout limit is set to 't' seconds, a session exceeds the
61      * timeout limit 't' seconds after its creation time.
62      * When the timeout limit is exceeded for a session, the
63      * <code>SSLSession</code> object is invalidated and future connections
64      * cannot resume or rejoin the session.
65      * A check for sessions exceeding the timeout is made immediately whenever
66      * the timeout limit is changed for this <code>SSLSessionContext</code>.
67      *
68      * @param seconds the new session timeout limit in seconds; zero means
69      *          there is no limit.
70      *
71      * @exception IllegalArgumentException if the timeout specified is {@code < 0}.
72      * @see #getSessionTimeout
73      */
74     void setSessionTimeout(int seconds);
75 
76     /**
77      * Returns the timeout limit of <code>SSLSession</code> objects grouped
78      * under this <code>SSLSessionContext</code>.
79      * <p>
80      * If the timeout limit is set to 't' seconds, a session exceeds the
81      * timeout limit 't' seconds after its creation time.
82      * When the timeout limit is exceeded for a session, the
83      * <code>SSLSession</code> object is invalidated and future connections
84      * cannot resume or rejoin the session.
85      * A check for sessions exceeding the timeout limit is made immediately
86      * whenever the timeout limit is changed for this
87      * <code>SSLSessionContext</code>.
88      *
89      * @return the session timeout limit in seconds; zero means there is no
90      * limit.
91      * @see #setSessionTimeout
92      */
93     int getSessionTimeout();
94 
95     /**
96      * Sets the size of the cache used for storing
97      * <code>SSLSession</code> objects grouped under this
98      * <code>SSLSessionContext</code>.
99      *
100      * @param size the new session cache size limit; zero means there is no
101      * limit.
102      * @exception IllegalArgumentException if the specified size is {@code < 0}.
103      * @see #getSessionCacheSize
104      */
105     void setSessionCacheSize(int size);
106 
107     /**
108      * Returns the size of the cache used for storing
109      * <code>SSLSession</code> objects grouped under this
110      * <code>SSLSessionContext</code>.
111      *
112      * @return size of the session cache; zero means there is no size limit.
113      * @see #setSessionCacheSize
114      */
115     int getSessionCacheSize();
116 
117 }