1 17 18 19 20 package org.apache.lenya.cms.cocoon.acting; 21 22 import java.util.Collections ; 23 import java.util.Map ; 24 25 import org.apache.avalon.framework.parameters.Parameters; 26 import org.apache.cocoon.environment.ObjectModelHelper; 27 import org.apache.cocoon.environment.Redirector; 28 import org.apache.cocoon.environment.Request; 29 import org.apache.cocoon.environment.Session; 30 import org.apache.cocoon.environment.SourceResolver; 31 import org.apache.lenya.util.Stack; 32 33 36 public class DelegatingAuthorizerAction extends AccessControlAction { 37 38 41 public Map act( 42 Redirector redirector, 43 SourceResolver resolver, 44 Map objectModel, 45 String src, 46 Parameters parameters) 47 throws Exception { 48 49 return super.act(redirector, resolver, objectModel, src, parameters); 50 } 51 52 55 protected Map doAct( 56 Redirector redirector, 57 SourceResolver resolver, 58 Map objectModel, 59 String source, 60 Parameters parameters) 61 throws Exception { 62 63 Request request = ObjectModelHelper.getRequest(objectModel); 64 65 setHistory(request); 66 67 boolean authorized = getAccessController().authorize(request); 68 69 Map result = null; 70 if (authorized) { 71 result = Collections.EMPTY_MAP; 72 } 73 74 return result; 75 } 76 77 public static final String HISTORY = 78 DelegatingAuthorizerAction.class.getPackage().getName() + ".History"; 79 80 84 protected void setHistory(Request request) { 85 Session session = request.getSession(true); 86 87 Stack history = (Stack) session.getAttribute(HISTORY); 88 89 if (history == null) { 90 history = new Stack(10); 91 session.setAttribute(HISTORY, history); 92 } 93 94 String url = request.getRequestURI(); 95 String context = request.getContextPath(); 96 if (context == null) { 97 context = ""; 98 } 99 url = url.substring(context.length()); 100 101 history.push(url); 102 103 } 104 105 } 106 | Popular Tags |