Skip to content

Commit c8ee9d5

Browse files
add missing files to git
1 parent a02301b commit c8ee9d5

2 files changed

Lines changed: 459 additions & 0 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/* WolfSSLSessionContext.java
2+
*
3+
* Copyright (C) 2006-2021 wolfSSL Inc.
4+
*
5+
* This file is part of wolfSSL.
6+
*
7+
* wolfSSL is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* wolfSSL is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20+
*/
21+
22+
package com.wolfssl.provider.jsse;
23+
24+
import com.wolfssl.WolfSSL;
25+
import com.wolfssl.WolfSSLException;
26+
import com.wolfssl.WolfSSLJNIException;
27+
import com.wolfssl.WolfSSLSession;
28+
import java.util.Enumeration;
29+
import java.util.logging.Level;
30+
import java.util.logging.Logger;
31+
import javax.net.ssl.SSLSession;
32+
import javax.net.ssl.SSLSessionContext;
33+
34+
public class WolfSSLSessionContext implements SSLSessionContext {
35+
private WolfSSLAuthStore store;
36+
private WolfSSLSession sslCtx;
37+
38+
private int sesTimout;
39+
private int sesCache;
40+
41+
public WolfSSLSessionContext(WolfSSLAuthStore in, int defaultCacheSize) {
42+
this.store = in;
43+
this.sesCache = defaultCacheSize;
44+
this.sesTimout = 86400; /* this is the default value found in SunJSSE too */
45+
}
46+
47+
48+
@Override
49+
public SSLSession getSession(byte[] sessionId) {
50+
return store.getSession(sessionId);
51+
}
52+
53+
54+
@Override
55+
public Enumeration<byte[]> getIds() {
56+
return store.getAllIDs();
57+
}
58+
59+
60+
@Override
61+
public void setSessionTimeout(int in) throws IllegalArgumentException {
62+
this.sesTimout = in;
63+
64+
/* check for any new timeouts after timeout has been set */
65+
store.updateTimeouts(in);
66+
}
67+
68+
@Override
69+
public int getSessionTimeout() {
70+
return this.sesTimout;
71+
}
72+
73+
74+
@Override
75+
public void setSessionCacheSize(int in)
76+
throws IllegalArgumentException {
77+
78+
if (in < 0) {
79+
throw new IllegalArgumentException("size can not be less than 0");
80+
}
81+
82+
/* resize store array if needed */
83+
if (this.sesCache != in) {
84+
store.resizeCache(in);
85+
}
86+
this.sesCache = in;
87+
}
88+
89+
@Override
90+
public int getSessionCacheSize() {
91+
return this.sesCache;
92+
}
93+
94+
}

0 commit comments

Comments
 (0)