1/*2 * Copyright 2000-2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.modules.actions;
1819import org.apache.turbine.util.RunData;
20import org.apache.turbine.modules.Action;
21import org.apache.turbine.TurbineConstants;
2223import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
24import org.apache.jetspeed.services.logging.JetspeedLogger;
25import org.apache.jetspeed.services.rundata.JetspeedRunData;
26import org.apache.jetspeed.services.Profiler;
27import org.apache.jetspeed.services.resources.JetspeedResources;
28import org.apache.jetspeed.om.profile.Profile;
29import org.apache.jetspeed.om.security.JetspeedUser;
30import org.apache.jetspeed.services.security.nosecurity.FakeJetspeedUser;
31import org.apache.jetspeed.services.JetspeedSecurity;
3233/***34 Calls the profiler to load the requested PSML resource based on request params35 Its necessary to load the profile from this action, not the SessionValidator36 in order to get the cached ACL list from logon3738@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*/4142publicclassJetspeedAccessControllerextends Action
43 {
4445/***46 * Static initialization of the logger for this class47 */48privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(JetspeedAccessController.class.getName());
4950publicvoid doPerform( RunData data ) throws Exception
51 {
52JetspeedUser user = (JetspeedUser)data.getUser();
5354 getACL(data);
55JetspeedRunData jdata = null;
5657try58 {
59 jdata = (JetspeedRunData)data;
60 }
61catch (ClassCastException e)
62 {
63 logger.error("The RunData object does not implement the expected interface, "64 + "please verify the RunData factory settings", e);
65return;
66 }
6768Profile newProfile = null;
69Profile currentProfile = null;
7071try72 {
73// get the profile and store it in the RunData74 newProfile = Profiler.getProfile(jdata);
75 currentProfile = jdata.getProfile();
76 }
77catch (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);
8384if (currentProfile == null)
85 {
86 currentProfile = Profiler.createProfile();
87 }
88if (newProfile == null)
89 {
90 newProfile = Profiler.createProfile();
91 }
92if (data.getUser() == null)
93 {
94JetspeedUser juser = newFakeJetspeedUser(JetspeedSecurity.getAnonymousUserName(), false);
95 data.setUser(juser);
96 }
97 }
9899100if ((currentProfile == null)
101 || (!currentProfile.equals(newProfile)))
102 {
103// the profile changed due to the request parameters,104// change it in the RunData105 jdata.setProfile(newProfile);
106 }
107108 }
109110protectedvoid getACL(RunData data)
111 {
112 data.setACL(null);
113/*114 if ( data.getUser() != null && data.getUser().hasLoggedIn() )115 {116 AccessControlList acl = (AccessControlList)117 data.getSession().getValue(AccessControlList.SESSION_KEY);118 if ( acl == null )119 {120 //acl = TurbineSecurity.getACL( data.getUser() );121 acl = null;122 data.getSession().putValue( AccessControlList.SESSION_KEY,123 (Object)acl );124 }125 data.setACL(acl);126 }127*/128 }
129130 }