author | xuelei |
Fri, 08 Apr 2011 02:00:09 -0700 | |
changeset 9246 | c459f79af46b |
parent 5506 | 202f599c92aa |
child 10369 | e9d2e59e53f0 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
||
27 |
package sun.security.ssl; |
|
28 |
||
29 |
import java.io.*; |
|
30 |
import java.net.*; |
|
31 |
import java.util.Date; |
|
32 |
import java.util.Enumeration; |
|
33 |
import java.util.Hashtable; |
|
34 |
import java.util.NoSuchElementException; |
|
35 |
import java.util.Vector; |
|
36 |
||
37 |
import javax.net.ssl.SSLSession; |
|
38 |
import javax.net.ssl.SSLSessionContext; |
|
39 |
import javax.net.ssl.SSLSessionBindingListener; |
|
40 |
import javax.net.ssl.SSLSessionBindingEvent; |
|
41 |
import javax.net.ssl.SSLPeerUnverifiedException; |
|
42 |
import javax.net.ssl.SSLSession; |
|
43 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
44 |
import sun.security.util.Cache; |
2 | 45 |
|
46 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
47 |
final class SSLSessionContextImpl implements SSLSessionContext { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
48 |
private Cache sessionCache; // session cache, session id as key |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
49 |
private Cache sessionHostPortCache; // session cache, "host:port" as key |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
50 |
private int cacheLimit; // the max cache size |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
51 |
private int timeout; // timeout in seconds |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
52 |
|
2 | 53 |
private static final Debug debug = Debug.getInstance("ssl"); |
54 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
55 |
// package private |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
56 |
SSLSessionContextImpl() { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
57 |
cacheLimit = getDefaultCacheLimit(); // default cache size |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
58 |
timeout = 86400; // default, 24 hours |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
59 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
60 |
// use soft reference |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
61 |
sessionCache = Cache.newSoftMemoryCache(cacheLimit, timeout); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
62 |
sessionHostPortCache = Cache.newSoftMemoryCache(cacheLimit, timeout); |
2 | 63 |
} |
64 |
||
65 |
/** |
|
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
66 |
* Returns the <code>SSLSession</code> bound to the specified session id. |
2 | 67 |
*/ |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
68 |
public SSLSession getSession(byte[] sessionId) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
69 |
if (sessionId == null) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
70 |
throw new NullPointerException("session id cannot be null"); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
71 |
} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
72 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
73 |
SSLSessionImpl sess = |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
74 |
(SSLSessionImpl)sessionCache.get(new SessionId(sessionId)); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
75 |
if (!isTimedout(sess)) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
76 |
return sess; |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
77 |
} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
78 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
79 |
return null; |
2 | 80 |
} |
81 |
||
82 |
/** |
|
83 |
* Returns an enumeration of the active SSL sessions. |
|
84 |
*/ |
|
85 |
public Enumeration<byte[]> getIds() { |
|
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
86 |
SessionCacheVisitor scVisitor = new SessionCacheVisitor(); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
87 |
sessionCache.accept(scVisitor); |
2 | 88 |
|
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
89 |
return scVisitor.getSessionIds(); |
2 | 90 |
} |
91 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
92 |
/** |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
93 |
* Sets the timeout limit for cached <code>SSLSession</code> objects |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
94 |
* |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
95 |
* Note that after reset the timeout, the cached session before |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
96 |
* should be timed within the shorter one of the old timeout and the |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
97 |
* new timeout. |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
98 |
*/ |
2 | 99 |
public void setSessionTimeout(int seconds) |
100 |
throws IllegalArgumentException { |
|
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
101 |
if (seconds < 0) { |
2 | 102 |
throw new IllegalArgumentException(); |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
103 |
} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
104 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
105 |
if (timeout != seconds) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
106 |
sessionCache.setTimeout(seconds); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
107 |
sessionHostPortCache.setTimeout(seconds); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
108 |
timeout = seconds; |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
109 |
} |
2 | 110 |
} |
111 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
112 |
/** |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
113 |
* Gets the timeout limit for cached <code>SSLSession</code> objects |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
114 |
*/ |
2 | 115 |
public int getSessionTimeout() { |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
116 |
return timeout; |
2 | 117 |
} |
118 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
119 |
/** |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
120 |
* Sets the size of the cache used for storing |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
121 |
* <code>SSLSession</code> objects. |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
122 |
*/ |
2 | 123 |
public void setSessionCacheSize(int size) |
124 |
throws IllegalArgumentException { |
|
125 |
if (size < 0) |
|
126 |
throw new IllegalArgumentException(); |
|
127 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
128 |
if (cacheLimit != size) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
129 |
sessionCache.setCapacity(size); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
130 |
sessionHostPortCache.setCapacity(size); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
131 |
cacheLimit = size; |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
132 |
} |
2 | 133 |
} |
134 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
135 |
/** |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
136 |
* Gets the size of the cache used for storing |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
137 |
* <code>SSLSession</code> objects. |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
138 |
*/ |
2 | 139 |
public int getSessionCacheSize() { |
140 |
return cacheLimit; |
|
141 |
} |
|
142 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
143 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
144 |
// package-private method, used ONLY by ServerHandshaker |
2 | 145 |
SSLSessionImpl get(byte[] id) { |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
146 |
return (SSLSessionImpl)getSession(id); |
2 | 147 |
} |
148 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
149 |
// package-private method, used ONLY by ClientHandshaker |
2 | 150 |
SSLSessionImpl get(String hostname, int port) { |
151 |
/* |
|
152 |
* If no session caching info is available, we won't |
|
153 |
* get one, so exit before doing a lookup. |
|
154 |
*/ |
|
155 |
if (hostname == null && port == -1) { |
|
156 |
return null; |
|
157 |
} |
|
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
158 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
159 |
SSLSessionImpl sess = |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
160 |
(SSLSessionImpl)sessionHostPortCache.get(getKey(hostname, port)); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
161 |
if (!isTimedout(sess)) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
162 |
return sess; |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
163 |
} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
164 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
165 |
return null; |
2 | 166 |
} |
167 |
||
168 |
private String getKey(String hostname, int port) { |
|
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
169 |
return (hostname + ":" + String.valueOf(port)).toLowerCase(); |
2 | 170 |
} |
171 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
172 |
// cache a SSLSession |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
173 |
// |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
174 |
// In SunJSSE implementation, a session is created while getting a |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
175 |
// client hello or a server hello message, and cached while the |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
176 |
// handshaking finished. |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
177 |
// Here we time the session from the time it cached instead of the |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
178 |
// time it created, which is a little longer than the expected. So |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
179 |
// please do check isTimedout() while getting entry from the cache. |
2 | 180 |
void put(SSLSessionImpl s) { |
181 |
sessionCache.put(s.getSessionId(), s); |
|
182 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
183 |
// If no hostname/port info is available, don't add this one. |
2 | 184 |
if ((s.getPeerHost() != null) && (s.getPeerPort() != -1)) { |
185 |
sessionHostPortCache.put( |
|
186 |
getKey(s.getPeerHost(), s.getPeerPort()), s); |
|
187 |
} |
|
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
188 |
|
2 | 189 |
s.setContext(this); |
190 |
} |
|
191 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
192 |
// package-private method, remove a cached SSLSession |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
193 |
void remove(SessionId key) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
194 |
SSLSessionImpl s = (SSLSessionImpl)sessionCache.get(key); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
195 |
if (s != null) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
196 |
sessionCache.remove(key); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
197 |
sessionHostPortCache.remove( |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
198 |
getKey(s.getPeerHost(), s.getPeerPort())); |
2 | 199 |
} |
200 |
} |
|
201 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
202 |
private int getDefaultCacheLimit() { |
2 | 203 |
int cacheLimit = 0; |
204 |
try { |
|
205 |
String s = java.security.AccessController.doPrivileged( |
|
206 |
new java.security.PrivilegedAction<String>() { |
|
207 |
public String run() { |
|
208 |
return System.getProperty( |
|
209 |
"javax.net.ssl.sessionCacheSize"); |
|
210 |
} |
|
211 |
}); |
|
212 |
cacheLimit = (s != null) ? Integer.valueOf(s).intValue() : 0; |
|
213 |
} catch (Exception e) { |
|
214 |
} |
|
215 |
||
216 |
return (cacheLimit > 0) ? cacheLimit : 0; |
|
217 |
} |
|
218 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
219 |
boolean isTimedout(SSLSession sess) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
220 |
if (timeout == 0) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
221 |
return false; |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
222 |
} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
223 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
224 |
if ((sess != null) && ((sess.getCreationTime() + timeout * 1000L) |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
225 |
<= (System.currentTimeMillis()))) { |
2 | 226 |
sess.invalidate(); |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
227 |
return true; |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
228 |
} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
229 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
230 |
return false; |
2 | 231 |
} |
232 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
233 |
final class SessionCacheVisitor |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
234 |
implements sun.security.util.Cache.CacheVisitor { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
235 |
Vector<byte[]> ids = null; |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
236 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
237 |
// public void visit(java.util.Map<Object, Object> map) {} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
238 |
public void visit(java.util.Map<Object, Object> map) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
239 |
ids = new Vector<byte[]>(map.size()); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
240 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
241 |
for (Object key : map.keySet()) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
242 |
SSLSessionImpl value = (SSLSessionImpl)map.get(key); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
243 |
if (!isTimedout(value)) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
244 |
ids.addElement(((SessionId)key).getId()); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
245 |
} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
246 |
} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
247 |
} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
248 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
249 |
public Enumeration<byte[]> getSessionIds() { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
250 |
return ids != null ? ids.elements() : |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
251 |
new Vector<byte[]>().elements(); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
252 |
} |
2 | 253 |
} |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
254 |
|
2 | 255 |
} |