View Javadoc
1   /**
2    * Copyright 2005-2016 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.uif.view;
17  
18  import org.kuali.rice.krad.datadictionary.DictionaryBeanBase;
19  
20  import java.io.Serializable;
21  
22  /**
23   * Holds configuration related to session handling of a view (and its related form)
24   *
25   * <p>
26   * The framework will keep track of the session for which a view is rendered in. When a request such as a
27   * post is made, the session id for the view will be compared against the current session. If different, or no
28   * session exists, a timeout will be assumed and the framework will take the action configured on this
29   * policy
30   * </p>
31   *
32   * <p>
33   * If none of the options are set here, the framework will allow a request after a timeout to go uninterrupted
34   * </p>
35   *
36   * <p>
37   * Notes carrying out the configured view session policy requires the filter
38   * {@link org.kuali.rice.krad.web.filter.UifSessionTimeoutFilter} to be configured first in the list of filters
39   * for the servlet
40   * </p>
41   *
42   * @author Kuali Rice Team (rice.collab@kuali.org)
43   */
44  public class ViewSessionPolicy extends DictionaryBeanBase implements Serializable {
45      private static final long serialVersionUID = -5187545712142535662L;
46  
47      private boolean redirectToHome;
48      private String redirectUrl;
49      private boolean renderTimeoutView;
50      private boolean enableTimeoutWarning;
51      private int timeoutWarningSeconds;
52  
53      public ViewSessionPolicy() {
54          super();
55  
56          timeoutWarningSeconds = 120;
57      }
58  
59      /**
60       * Indicates when a session timeout occurs the user should be redirect to the application home url
61       * (determined by the configuration parameter 'application.url')
62       *
63       * @return true if the user should be redirected to the home URL
64       */
65      public boolean isRedirectToHome() {
66          return redirectToHome;
67      }
68  
69      /**
70       * Setter for indicating whether the user should be redirected to the home URL on session timeout
71       *
72       * @param redirectToHome
73       */
74      public void setRedirectToHome(boolean redirectToHome) {
75          this.redirectToHome = redirectToHome;
76      }
77  
78      /**
79       * URL the user should be redirected to when a session timeout occurs
80       *
81       * @return url to redirect user to
82       */
83      public String getRedirectUrl() {
84          return redirectUrl;
85      }
86  
87      /**
88       * Setter for the URL to redirect the user to when a session timeout occurs
89       *
90       * @param redirectUrl
91       */
92      public void setRedirectUrl(String redirectUrl) {
93          this.redirectUrl = redirectUrl;
94      }
95  
96      /**
97       * Indicates the user should be shown the timeout message view when a session timeout occurs
98       *
99       * @return true if the timeout view should be shown on session timeout
100      */
101     public boolean isRenderTimeoutView() {
102         return renderTimeoutView;
103     }
104 
105     /**
106      * Setter to indicate the timeout view should be shown on session timeout
107      *
108      * @param renderTimeoutView
109      */
110     public void setRenderTimeoutView(boolean renderTimeoutView) {
111         this.renderTimeoutView = renderTimeoutView;
112     }
113 
114     /**
115      * Enables the session timeout warning dialog and timeout dialog for the view
116      *
117      * <p>
118      * When enabled, a timer will be kept on the client to warning the user when their session is about
119      * to timeout, and if the timeout actually occurs. The amount of time before a timeout to warn is specified
120      * by {@link #getTimeoutWarningSeconds()}
121      * </p>
122      *
123      * <p>
124      * The dialogs shown for the warning and timeout are configured by the dialog groups with ids
125      * {@link org.kuali.rice.krad.uif.util.ComponentFactory#SESSION_TIMEOUT_WARNING_DIALOG} and
126      * {@link org.kuali.rice.krad.uif.util.ComponentFactory#SESSION_TIMEOUT_DIALOG}
127      * </p>
128      *
129      * @return true if the timeout warning dialog should be enabled
130      */
131     public boolean isEnableTimeoutWarning() {
132         return enableTimeoutWarning;
133     }
134 
135     /**
136      * Setter for enabling the session timeout warning dialog
137      *
138      * @param enableTimeoutWarning
139      */
140     public void setEnableTimeoutWarning(boolean enableTimeoutWarning) {
141         this.enableTimeoutWarning = enableTimeoutWarning;
142     }
143 
144     /**
145      * When {@link #isEnableTimeoutWarning()} is true, the number of seconds before a timeout occurs to give a
146      * warning (default is 120 (2 minutes))
147      *
148      * @return number of seconds before timeout to give warning dialog
149      */
150     public int getTimeoutWarningSeconds() {
151         return timeoutWarningSeconds;
152     }
153 
154     /**
155      * Setter for the number of seconds before timeout to give a warning dialog
156      *
157      * @param timeoutWarningSeconds
158      */
159     public void setTimeoutWarningSeconds(int timeoutWarningSeconds) {
160         this.timeoutWarningSeconds = timeoutWarningSeconds;
161     }
162 }