1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package fr.ifremer.coser.web.actions.auth;
23
24 import com.opensymphony.xwork2.ActionContext;
25 import com.opensymphony.xwork2.ActionInvocation;
26 import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
27
28 import java.util.Map;
29
30
31
32
33
34
35
36
37
38
39 public class LoginInterceptor extends AbstractInterceptor {
40
41 private static final long serialVersionUID = 1L;
42
43 public static final String SESSION_PARAMETER_LOGIN = "login";
44
45 @Override
46 public String intercept(ActionInvocation invocation) throws Exception {
47 ActionContext context = invocation.getInvocationContext();
48 Map<String, Object> session = context.getSession();
49 Object login = session.get(SESSION_PARAMETER_LOGIN);
50 String result;
51 if (login == null) {
52
53 result = "redirect-login";
54 } else {
55 result = invocation.invoke();
56 }
57 return result;
58 }
59 }