1
2
3
4
5
6
7
8
9
10
11 package psiprobe;
12
13 import jakarta.servlet.ServletException;
14
15 import java.io.IOException;
16
17 import org.apache.catalina.connector.Request;
18 import org.apache.catalina.connector.Response;
19 import org.apache.catalina.valves.ValveBase;
20
21 import psiprobe.model.ApplicationSession;
22 import psiprobe.model.IpInfo;
23
24
25
26
27 public class Tomcat10AgentValve extends ValveBase {
28
29
30
31
32 public Tomcat10AgentValve() {
33 super(true);
34 }
35
36 @Override
37 public void invoke(Request request, Response response) throws IOException, ServletException {
38 getNext().invoke(request, response);
39
40 if (request.getSession(false) != null) {
41 String ip = IpInfo.getClientAddress(request.getRequest());
42
43 request.getSession(false).setAttribute(ApplicationSession.LAST_ACCESSED_BY_IP, ip);
44 request.getSession(false).setAttribute(ApplicationSession.LAST_ACCESSED_LOCALE,
45 request.getLocale());
46 }
47 }
48
49 }