1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package fr.cnes.doi.services;
20
21 import java.util.List;
22
23 import org.apache.logging.log4j.LogManager;
24 import org.apache.logging.log4j.Logger;
25
26 import fr.cnes.doi.db.AbstractTokenDBHelper;
27 import fr.cnes.doi.exception.DOIDbException;
28 import fr.cnes.doi.security.TokenSecurity;
29 import java.util.ArrayList;
30
31
32
33
34
35
36
37 public class UpdateTokenDataBase implements Runnable {
38
39
40
41
42 private static final Logger LOG = LogManager.getLogger(UpdateTokenDataBase.class.getName());
43
44
45
46
47 private final AbstractTokenDBHelper tokenDB = TokenSecurity.getInstance().getTokenDB();
48
49
50
51
52 @Override
53 public void run() {
54 LOG.info("Executing task that remove expired token from database.");
55 List<String> tokenList;
56 try {
57 tokenList = tokenDB.getTokens();
58 } catch (DOIDbException ex) {
59 tokenList = new ArrayList<>();
60 }
61 for (final String token : tokenList) {
62 if (TokenSecurity.getInstance().isExpired(token)) {
63 LOG.info("Token {} is expired", token);
64 }
65 }
66 }
67
68 }