1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.modules.actions;
18
19 import org.apache.turbine.util.RunData;
20 import org.apache.turbine.modules.Action;
21 import org.apache.turbine.TurbineConstants;
22
23 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
24 import org.apache.jetspeed.services.logging.JetspeedLogger;
25 import org.apache.jetspeed.services.rundata.JetspeedRunData;
26 import org.apache.jetspeed.services.Profiler;
27 import org.apache.jetspeed.services.resources.JetspeedResources;
28 import org.apache.jetspeed.om.profile.Profile;
29 import org.apache.jetspeed.om.security.JetspeedUser;
30 import org.apache.jetspeed.services.security.nosecurity.FakeJetspeedUser;
31 import org.apache.jetspeed.services.JetspeedSecurity;
32
33 /***
34 Calls the profiler to load the requested PSML resource based on request params
35 Its necessary to load the profile from this action, not the SessionValidator
36 in order to get the cached ACL list from logon
37
38 @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
39 @version $Id: JetspeedAccessController.java,v 1.10 2004/02/23 02:59:06 jford Exp $
40 */
41
42 public class JetspeedAccessController extends Action
43 {
44
45 /***
46 * Static initialization of the logger for this class
47 */
48 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(JetspeedAccessController.class.getName());
49
50 public void doPerform( RunData data ) throws Exception
51 {
52 JetspeedUser user = (JetspeedUser)data.getUser();
53
54 getACL(data);
55 JetspeedRunData jdata = null;
56
57 try
58 {
59 jdata = (JetspeedRunData)data;
60 }
61 catch (ClassCastException e)
62 {
63 logger.error("The RunData object does not implement the expected interface, "
64 + "please verify the RunData factory settings", e);
65 return;
66 }
67
68 Profile newProfile = null;
69 Profile currentProfile = null;
70
71 try
72 {
73
74 newProfile = Profiler.getProfile(jdata);
75 currentProfile = jdata.getProfile();
76 }
77 catch (Throwable other)
78 {
79 data.setScreenTemplate(JetspeedResources.getString(TurbineConstants.TEMPLATE_ERROR));
80 String message = other.getMessage() != null ? other.getMessage() : other.toString();
81 data.setMessage(message);
82 data.setStackTrace(org.apache.turbine.util.StringUtils.stackTrace(other), other);
83
84 if (currentProfile == null)
85 {
86 currentProfile = Profiler.createProfile();
87 }
88 if (newProfile == null)
89 {
90 newProfile = Profiler.createProfile();
91 }
92 if (data.getUser() == null)
93 {
94 JetspeedUser juser = new FakeJetspeedUser(JetspeedSecurity.getAnonymousUserName(), false);
95 data.setUser(juser);
96 }
97 }
98
99
100 if ((currentProfile == null)
101 || (!currentProfile.equals(newProfile)))
102 {
103
104
105 jdata.setProfile(newProfile);
106 }
107
108 }
109
110 protected void getACL(RunData data)
111 {
112 data.setACL(null);
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128 }
129
130 }