commit | author | age
|
9ee357
|
1 |
/* |
U |
2 |
jwtTest - JSON Web Token Testimplementierung |
|
3 |
Copyright (C) 2021 Ulrich Hilger |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU Affero General Public License as |
|
7 |
published by the Free Software Foundation, either version 3 of the |
|
8 |
License, or (at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU Affero General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU Affero General Public License |
|
16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
package de.uhilger.httpserver.auth.session; |
|
19 |
|
|
20 |
import java.util.Date; |
|
21 |
import java.util.Iterator; |
|
22 |
|
|
23 |
/** |
|
24 |
* |
|
25 |
* @author Ulrich Hilger |
|
26 |
* @version 1, 26.05.2021 |
|
27 |
*/ |
|
28 |
public final class SweepThread extends Thread { |
|
29 |
|
|
30 |
private SessionManager v; |
|
31 |
|
|
32 |
public SweepThread(SessionManager v) { |
|
33 |
setSessionVerwalter(v); |
|
34 |
} |
|
35 |
|
|
36 |
public void setSessionVerwalter(SessionManager verwalter) { |
|
37 |
this.v = verwalter; |
|
38 |
} |
|
39 |
|
|
40 |
public void run() { |
|
41 |
// was hier steht wird gestartet mit |
|
42 |
// SweepThread p = new SweepThread(); |
|
43 |
// p.start(); |
|
44 |
Date now = new Date(); |
|
45 |
Iterator sessionIterator = v.sessions(); |
|
46 |
while(sessionIterator.hasNext()) { |
|
47 |
Object o = sessionIterator.next(); |
|
48 |
if(o instanceof Session) { |
|
49 |
Session session = (Session) o; |
|
50 |
Date expiration = session.getExp(); |
|
51 |
if(now.after(expiration)) { |
|
52 |
v.remove(session.getId()); |
|
53 |
} |
|
54 |
} |
|
55 |
} |
|
56 |
} |
|
57 |
} |