View Javadoc
1   /**
2    * Copyright 2005-2014 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.krad.labs.sessionPolicy;
17  
18  import org.kuali.rice.krad.labs.KradLabsController;
19  import org.kuali.rice.krad.labs.KradLabsForm;
20  import org.kuali.rice.krad.util.GlobalVariables;
21  import org.kuali.rice.krad.web.controller.MethodAccessible;
22  import org.kuali.rice.krad.web.form.UifFormBase;
23  import org.springframework.stereotype.Controller;
24  import org.springframework.validation.BindingResult;
25  import org.springframework.web.bind.annotation.ModelAttribute;
26  import org.springframework.web.bind.annotation.RequestMapping;
27  import org.springframework.web.servlet.ModelAndView;
28  
29  import javax.servlet.http.HttpServletRequest;
30  import javax.servlet.http.HttpServletResponse;
31  
32  /**
33   * Controller class for the session policy lab view
34   *
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   */
37  @Controller
38  @RequestMapping(value = "/sessionPolicy")
39  public class LabsSessionPolicyController extends KradLabsController {
40  
41      @RequestMapping(params = "methodToCall=killSession")
42      public ModelAndView killSession(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
43              HttpServletRequest request, HttpServletResponse response) {
44  
45          request.getSession().invalidate();
46  
47          return getUIFModelAndView(form);
48      }
49  
50      @RequestMapping(params = "methodToCall=sessionTimeout")
51      public ModelAndView sessionTimeout(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
52              HttpServletRequest request, HttpServletResponse response) {
53  
54          GlobalVariables.getMessageMap().addGrowlMessage("Result", "labs.methodInvoked", "sessionTimeout");
55  
56          return getUIFModelAndView(form);
57      }
58  
59      @MethodAccessible
60      @RequestMapping(params = "methodToCall=setSessionTimeout")
61      public ModelAndView setSessionTimeout(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
62              HttpServletRequest request, HttpServletResponse response) {
63  
64          // for testing purposes set the session timeout to three minutes
65          request.getSession().setMaxInactiveInterval(120000);
66          ((KradLabsForm) form).setSessionTimeoutInterval(120000);
67  
68          return getUIFModelAndView(form);
69      }
70  }