author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 25859 | jdk/src/java.base/share/classes/sun/security/ssl/SSLSessionContextImpl.java@3317bb8137f4 |
child 50768 | 68fa3d4026ea |
child 56542 | 56aaa6cb3693 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
14665
diff
changeset
|
2 |
* Copyright (c) 1999, 2012, 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.util.Enumeration; |
|
30 |
import java.util.Vector; |
|
10369
e9d2e59e53f0
7059542: JNDI name operations should be locale independent
xuelei
parents:
5506
diff
changeset
|
31 |
import java.util.Locale; |
2 | 32 |
|
33 |
import javax.net.ssl.SSLSession; |
|
34 |
import javax.net.ssl.SSLSessionContext; |
|
35 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
36 |
import sun.security.util.Cache; |
2 | 37 |
|
38 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
39 |
final class SSLSessionContextImpl implements SSLSessionContext { |
10785
1d42311b6355
7092897: sun.security.util.Cache should be generified
mullan
parents:
10369
diff
changeset
|
40 |
private Cache<SessionId, SSLSessionImpl> sessionCache; |
1d42311b6355
7092897: sun.security.util.Cache should be generified
mullan
parents:
10369
diff
changeset
|
41 |
// session cache, session id as key |
1d42311b6355
7092897: sun.security.util.Cache should be generified
mullan
parents:
10369
diff
changeset
|
42 |
private Cache<String, SSLSessionImpl> sessionHostPortCache; |
1d42311b6355
7092897: sun.security.util.Cache should be generified
mullan
parents:
10369
diff
changeset
|
43 |
// session cache, "host:port" as key |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
44 |
private int cacheLimit; // the max cache size |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
45 |
private int timeout; // timeout in seconds |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
46 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
47 |
// package private |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
48 |
SSLSessionContextImpl() { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
49 |
cacheLimit = getDefaultCacheLimit(); // default cache size |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
50 |
timeout = 86400; // default, 24 hours |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
51 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
52 |
// use soft reference |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
53 |
sessionCache = Cache.newSoftMemoryCache(cacheLimit, timeout); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
54 |
sessionHostPortCache = Cache.newSoftMemoryCache(cacheLimit, timeout); |
2 | 55 |
} |
56 |
||
57 |
/** |
|
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
58 |
* Returns the <code>SSLSession</code> bound to the specified session id. |
2 | 59 |
*/ |
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
10785
diff
changeset
|
60 |
@Override |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
61 |
public SSLSession getSession(byte[] sessionId) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
62 |
if (sessionId == null) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
63 |
throw new NullPointerException("session id cannot be null"); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
64 |
} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
65 |
|
10785
1d42311b6355
7092897: sun.security.util.Cache should be generified
mullan
parents:
10369
diff
changeset
|
66 |
SSLSessionImpl sess = sessionCache.get(new SessionId(sessionId)); |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
67 |
if (!isTimedout(sess)) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
68 |
return sess; |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
69 |
} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
70 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
71 |
return null; |
2 | 72 |
} |
73 |
||
74 |
/** |
|
75 |
* Returns an enumeration of the active SSL sessions. |
|
76 |
*/ |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
10785
diff
changeset
|
77 |
@Override |
2 | 78 |
public Enumeration<byte[]> getIds() { |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
79 |
SessionCacheVisitor scVisitor = new SessionCacheVisitor(); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
80 |
sessionCache.accept(scVisitor); |
2 | 81 |
|
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
82 |
return scVisitor.getSessionIds(); |
2 | 83 |
} |
84 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
85 |
/** |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
86 |
* Sets the timeout limit for cached <code>SSLSession</code> objects |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
87 |
* |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
88 |
* Note that after reset the timeout, the cached session before |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
89 |
* 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
|
90 |
* new timeout. |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
91 |
*/ |
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
10785
diff
changeset
|
92 |
@Override |
2 | 93 |
public void setSessionTimeout(int seconds) |
94 |
throws IllegalArgumentException { |
|
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
95 |
if (seconds < 0) { |
2 | 96 |
throw new IllegalArgumentException(); |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
97 |
} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
98 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
99 |
if (timeout != seconds) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
100 |
sessionCache.setTimeout(seconds); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
101 |
sessionHostPortCache.setTimeout(seconds); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
102 |
timeout = seconds; |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
103 |
} |
2 | 104 |
} |
105 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
106 |
/** |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
107 |
* Gets the timeout limit for cached <code>SSLSession</code> objects |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
108 |
*/ |
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
10785
diff
changeset
|
109 |
@Override |
2 | 110 |
public int getSessionTimeout() { |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
111 |
return timeout; |
2 | 112 |
} |
113 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
114 |
/** |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
115 |
* Sets the size of the cache used for storing |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
116 |
* <code>SSLSession</code> objects. |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
117 |
*/ |
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
10785
diff
changeset
|
118 |
@Override |
2 | 119 |
public void setSessionCacheSize(int size) |
120 |
throws IllegalArgumentException { |
|
121 |
if (size < 0) |
|
122 |
throw new IllegalArgumentException(); |
|
123 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
124 |
if (cacheLimit != size) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
125 |
sessionCache.setCapacity(size); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
126 |
sessionHostPortCache.setCapacity(size); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
127 |
cacheLimit = size; |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
128 |
} |
2 | 129 |
} |
130 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
131 |
/** |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
132 |
* Gets the size of the cache used for storing |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
133 |
* <code>SSLSession</code> objects. |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
134 |
*/ |
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
10785
diff
changeset
|
135 |
@Override |
2 | 136 |
public int getSessionCacheSize() { |
137 |
return cacheLimit; |
|
138 |
} |
|
139 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
140 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
141 |
// package-private method, used ONLY by ServerHandshaker |
2 | 142 |
SSLSessionImpl get(byte[] id) { |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
143 |
return (SSLSessionImpl)getSession(id); |
2 | 144 |
} |
145 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
146 |
// package-private method, used ONLY by ClientHandshaker |
2 | 147 |
SSLSessionImpl get(String hostname, int port) { |
148 |
/* |
|
149 |
* If no session caching info is available, we won't |
|
150 |
* get one, so exit before doing a lookup. |
|
151 |
*/ |
|
152 |
if (hostname == null && port == -1) { |
|
153 |
return null; |
|
154 |
} |
|
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
155 |
|
10785
1d42311b6355
7092897: sun.security.util.Cache should be generified
mullan
parents:
10369
diff
changeset
|
156 |
SSLSessionImpl sess = sessionHostPortCache.get(getKey(hostname, port)); |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
157 |
if (!isTimedout(sess)) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
158 |
return sess; |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
159 |
} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
160 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
161 |
return null; |
2 | 162 |
} |
163 |
||
164 |
private String getKey(String hostname, int port) { |
|
10369
e9d2e59e53f0
7059542: JNDI name operations should be locale independent
xuelei
parents:
5506
diff
changeset
|
165 |
return (hostname + ":" + |
e9d2e59e53f0
7059542: JNDI name operations should be locale independent
xuelei
parents:
5506
diff
changeset
|
166 |
String.valueOf(port)).toLowerCase(Locale.ENGLISH); |
2 | 167 |
} |
168 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
169 |
// cache a SSLSession |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
170 |
// |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
171 |
// In SunJSSE implementation, a session is created while getting a |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
172 |
// 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
|
173 |
// handshaking finished. |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
174 |
// 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
|
175 |
// 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
|
176 |
// please do check isTimedout() while getting entry from the cache. |
2 | 177 |
void put(SSLSessionImpl s) { |
178 |
sessionCache.put(s.getSessionId(), s); |
|
179 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
180 |
// If no hostname/port info is available, don't add this one. |
2 | 181 |
if ((s.getPeerHost() != null) && (s.getPeerPort() != -1)) { |
182 |
sessionHostPortCache.put( |
|
183 |
getKey(s.getPeerHost(), s.getPeerPort()), s); |
|
184 |
} |
|
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
185 |
|
2 | 186 |
s.setContext(this); |
187 |
} |
|
188 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
189 |
// package-private method, remove a cached SSLSession |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
190 |
void remove(SessionId key) { |
10785
1d42311b6355
7092897: sun.security.util.Cache should be generified
mullan
parents:
10369
diff
changeset
|
191 |
SSLSessionImpl s = sessionCache.get(key); |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
192 |
if (s != null) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
193 |
sessionCache.remove(key); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
194 |
sessionHostPortCache.remove( |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
195 |
getKey(s.getPeerHost(), s.getPeerPort())); |
2 | 196 |
} |
197 |
} |
|
198 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
199 |
private int getDefaultCacheLimit() { |
2 | 200 |
int cacheLimit = 0; |
201 |
try { |
|
202 |
String s = java.security.AccessController.doPrivileged( |
|
203 |
new java.security.PrivilegedAction<String>() { |
|
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
10785
diff
changeset
|
204 |
@Override |
2 | 205 |
public String run() { |
206 |
return System.getProperty( |
|
207 |
"javax.net.ssl.sessionCacheSize"); |
|
208 |
} |
|
209 |
}); |
|
210 |
cacheLimit = (s != null) ? Integer.valueOf(s).intValue() : 0; |
|
211 |
} catch (Exception e) { |
|
212 |
} |
|
213 |
||
214 |
return (cacheLimit > 0) ? cacheLimit : 0; |
|
215 |
} |
|
216 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
217 |
boolean isTimedout(SSLSession sess) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
218 |
if (timeout == 0) { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
219 |
return false; |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
220 |
} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
221 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
222 |
if ((sess != null) && ((sess.getCreationTime() + timeout * 1000L) |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
223 |
<= (System.currentTimeMillis()))) { |
2 | 224 |
sess.invalidate(); |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
225 |
return true; |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
226 |
} |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
227 |
|
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
228 |
return false; |
2 | 229 |
} |
230 |
||
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
231 |
final class SessionCacheVisitor |
10785
1d42311b6355
7092897: sun.security.util.Cache should be generified
mullan
parents:
10369
diff
changeset
|
232 |
implements Cache.CacheVisitor<SessionId, SSLSessionImpl> { |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
233 |
Vector<byte[]> ids = null; |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
234 |
|
10785
1d42311b6355
7092897: sun.security.util.Cache should be generified
mullan
parents:
10369
diff
changeset
|
235 |
// public void visit(java.util.Map<K,V> map) {} |
14664
e71aa0962e70
8003950: Adds missing Override annotations and removes unnecessary imports in sun.security.ssl
xuelei
parents:
10785
diff
changeset
|
236 |
@Override |
10785
1d42311b6355
7092897: sun.security.util.Cache should be generified
mullan
parents:
10369
diff
changeset
|
237 |
public void visit(java.util.Map<SessionId, SSLSessionImpl> map) { |
1d42311b6355
7092897: sun.security.util.Cache should be generified
mullan
parents:
10369
diff
changeset
|
238 |
ids = new Vector<>(map.size()); |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
239 |
|
10785
1d42311b6355
7092897: sun.security.util.Cache should be generified
mullan
parents:
10369
diff
changeset
|
240 |
for (SessionId key : map.keySet()) { |
1d42311b6355
7092897: sun.security.util.Cache should be generified
mullan
parents:
10369
diff
changeset
|
241 |
SSLSessionImpl value = map.get(key); |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
242 |
if (!isTimedout(value)) { |
10785
1d42311b6355
7092897: sun.security.util.Cache should be generified
mullan
parents:
10369
diff
changeset
|
243 |
ids.addElement(key.getId()); |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
244 |
} |
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 |
public Enumeration<byte[]> getSessionIds() { |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
249 |
return ids != null ? ids.elements() : |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
250 |
new Vector<byte[]>().elements(); |
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
251 |
} |
2 | 252 |
} |
2060
75e464ce81af
4918870: Examine session cache implementation (sun.misc.Cache)
xuelei
parents:
2
diff
changeset
|
253 |
|
2 | 254 |
} |