1 package org.apache.turbine.modules.actions.sessionvalidator;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.commons.configuration.Configuration;
23
24 import org.apache.commons.lang.StringUtils;
25
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28
29 import org.apache.turbine.Turbine;
30 import org.apache.turbine.TurbineConstants;
31
32 import org.apache.turbine.pipeline.PipelineData;
33 import org.apache.turbine.services.security.TurbineSecurity;
34
35 import org.apache.turbine.util.RunData;
36 import org.apache.turbine.util.TurbineException;
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 public class TemplateSessionValidator
58 extends SessionValidator
59 {
60
61 private static Log log = LogFactory.getLog(TemplateSessionValidator.class);
62
63
64
65
66
67
68
69
70
71 @Deprecated
72 @Override
73 public void doPerform(RunData data)
74 throws TurbineException
75 {
76 Configuration conf = Turbine.getConfiguration();
77
78
79 data.populate();
80
81
82 if (data.getUser() == null)
83 {
84 log.debug("Fixing up empty User Object!");
85 data.setUser(TurbineSecurity.getAnonymousUser());
86 data.save();
87 }
88
89
90 if (!data.hasScreen() && StringUtils.isEmpty(
91 data.getTemplateInfo().getScreenTemplate()))
92 {
93 String template = conf.getString(
94 TurbineConstants.TEMPLATE_HOMEPAGE);
95
96 if (StringUtils.isNotEmpty(template))
97 {
98 data.getTemplateInfo().setScreenTemplate(template);
99 }
100 else
101 {
102 data.setScreen(conf.getString(
103 TurbineConstants.SCREEN_HOMEPAGE));
104 }
105 }
106
107
108
109 else if (data.getParameters().containsKey("_session_access_counter")
110 && !TurbineSecurity.isAnonymousUser(data.getUser()))
111 {
112
113 if (data.getParameters().getInt("_session_access_counter")
114 < (((Integer) data.getUser().getTemp(
115 "_session_access_counter")).intValue() - 1))
116 {
117 if (data.getTemplateInfo().getScreenTemplate() != null)
118 {
119 data.getUser().setTemp("prev_template",
120 data.getTemplateInfo().getScreenTemplate()
121 .replace('/', ','));
122 data.getTemplateInfo().setScreenTemplate(conf.getString(
123 TurbineConstants.TEMPLATE_INVALID_STATE));
124 }
125 else
126 {
127 data.getUser().setTemp("prev_screen",
128 data.getScreen().replace('/', ','));
129 data.setScreen(conf.getString(
130 TurbineConstants.SCREEN_INVALID_STATE));
131 }
132 data.getUser().setTemp("prev_parameters", data.getParameters());
133 data.setAction("");
134 }
135 }
136
137
138
139 if (data.getTemplateInfo().getScreenTemplate() != null)
140 {
141 data.setScreen(null);
142 }
143 }
144
145
146
147
148
149
150
151
152 @Override
153 public void doPerform(PipelineData pipelineData)
154 throws TurbineException
155 {
156 RunData data = getRunData(pipelineData);
157 doPerform(data);
158 }
159
160
161
162
163 }