1
2
3
4
5
6
7
8
9
10
11 package psiprobe.controllers.sessions;
12
13 import jakarta.servlet.http.HttpServletRequest;
14 import jakarta.servlet.http.HttpServletResponse;
15
16 import org.apache.catalina.Context;
17 import org.springframework.beans.factory.annotation.Value;
18 import org.springframework.stereotype.Controller;
19 import org.springframework.web.bind.ServletRequestUtils;
20 import org.springframework.web.bind.annotation.RequestMapping;
21 import org.springframework.web.servlet.ModelAndView;
22
23 import psiprobe.controllers.AbstractContextHandlerController;
24 import psiprobe.model.ApplicationSession;
25 import psiprobe.tools.ApplicationUtils;
26 import psiprobe.tools.SecurityUtils;
27
28
29
30
31 @Controller
32 public class ListSessionAttributesController extends AbstractContextHandlerController {
33
34 @RequestMapping(path = "/attributes.htm")
35 @Override
36 public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
37 throws Exception {
38 return super.handleRequest(request, response);
39 }
40
41 @Override
42 protected ModelAndView handleContext(String contextName, Context context,
43 HttpServletRequest request, HttpServletResponse response) throws Exception {
44
45 boolean privileged = SecurityUtils.hasAttributeValueRole(getServletContext());
46 boolean calcSize =
47 privileged && ServletRequestUtils.getBooleanParameter(request, "size", false);
48 String sid = ServletRequestUtils.getStringParameter(request, "sid");
49
50 ApplicationSession appSession = ApplicationUtils
51 .getApplicationSession(context.getManager().findSession(sid), calcSize, true);
52
53 if (appSession != null) {
54 appSession.setAllowedToViewValues(privileged);
55 return new ModelAndView(getViewName(), "session", appSession);
56 }
57 return new ModelAndView(getViewName());
58 }
59
60 @Value("attributes")
61 @Override
62 public void setViewName(String viewName) {
63 super.setViewName(viewName);
64 }
65
66 }