1 /**
2 * Copyright 2005-2013 The Kuali Foundation
3 *
4 * Licensed under the Educational Community 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 at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * 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 and
14 * limitations under the License.
15 */
16 package org.kuali.rice.ksb.messaging.web;
17
18 import javax.servlet.http.HttpServletRequest;
19 import javax.servlet.http.HttpServletResponse;
20
21 import org.apache.struts.action.RequestProcessor;
22 import org.kuali.rice.krad.UserSession;
23 import org.kuali.rice.krad.util.GlobalVariables;
24 import org.kuali.rice.krad.util.KRADUtils;
25
26 /**
27 * A RequestProcessor implementation for Struts which handles determining whether or not access
28 * should be allowed to the requested KSB page.
29 *
30 * @author Kuali Rice Team (rice.collab@kuali.org)
31 */
32 public class KSBStrutsRequestProcessor extends RequestProcessor {
33
34 /**
35 * This overridden method ...
36 *
37 * @see org.apache.struts.action.RequestProcessor#processPreprocess(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
38 */
39 @Override
40 protected boolean processPreprocess(HttpServletRequest request,
41 HttpServletResponse response) {
42 final UserSession session = KRADUtils.getUserSessionFromRequest(request);
43
44 if (session == null) {
45 throw new IllegalStateException("the user session has not been established");
46 }
47
48 GlobalVariables.setUserSession(session);
49 GlobalVariables.clear();
50 return super.processPreprocess(request, response);
51 }
52 }