001/** 002 * Copyright 2005-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.ksb.messaging.web; 017 018import javax.servlet.http.HttpServletRequest; 019import javax.servlet.http.HttpServletResponse; 020 021import org.apache.struts.action.RequestProcessor; 022import org.kuali.rice.krad.UserSession; 023import org.kuali.rice.krad.util.GlobalVariables; 024import org.kuali.rice.krad.util.KRADUtils; 025 026/** 027 * A RequestProcessor implementation for Struts which handles determining whether or not access 028 * should be allowed to the requested KSB page. 029 * 030 * @author Kuali Rice Team (rice.collab@kuali.org) 031 */ 032public class KSBStrutsRequestProcessor extends RequestProcessor { 033 034 /** 035 * This overridden method ... 036 * 037 * @see org.apache.struts.action.RequestProcessor#processPreprocess(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) 038 */ 039 @Override 040 protected boolean processPreprocess(HttpServletRequest request, 041 HttpServletResponse response) { 042 final UserSession session = KRADUtils.getUserSessionFromRequest(request); 043 044 if (session == null) { 045 throw new IllegalStateException("the user session has not been established"); 046 } 047 048 GlobalVariables.setUserSession(session); 049 GlobalVariables.clear(); 050 return super.processPreprocess(request, response); 051 } 052}