01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.messaging.web;
18:
19: import java.io.IOException;
20:
21: import javax.servlet.ServletException;
22: import javax.servlet.http.HttpServletRequest;
23: import javax.servlet.http.HttpServletResponse;
24:
25: import org.apache.struts.action.Action;
26: import org.apache.struts.action.ActionForm;
27: import org.apache.struts.action.ActionForward;
28: import org.apache.struts.action.ActionMapping;
29: import org.apache.struts.action.RequestProcessor;
30: import org.kuali.bus.auth.AuthorizationService;
31: import org.kuali.rice.RiceConstants;
32: import org.kuali.rice.core.Core;
33:
34: /**
35: * A RequestProcessor implementation for Struts which handles determining whether or not access
36: * should be allowed to the requested KSB page.
37: *
38: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
39: */
40: public class KSBStrutsRequestProcessor extends RequestProcessor {
41:
42: @Override
43: protected ActionForward processActionPerform(
44: HttpServletRequest request, HttpServletResponse response,
45: Action action, ActionForm form, ActionMapping mapping)
46: throws IOException, ServletException {
47: if (!isAdministrator(request)) {
48: return mapping.findForward("NotAuthorized");
49: }
50: return super .processActionPerform(request, response, action,
51: form, mapping);
52: }
53:
54: private boolean isAdministrator(HttpServletRequest request) {
55: AuthorizationService authService = (AuthorizationService) Core
56: .getCurrentContextConfig().getObject(
57: RiceConstants.KSB_AUTH_SERVICE);
58: // if no auth service is defined then everyone's an admin
59: return authService == null
60: || authService.isAdministrator(request);
61: }
62:
63: }
|