1 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 41 42 public class JetspeedAccessController extends Action 43 { 44 45 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 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 jdata.setProfile(newProfile); 106 } 107 108 } 109 110 protected void getACL(RunData data) 111 { 112 data.setACL(null); 113 128 } 129 130 } | Popular Tags |