View Javadoc

1   /***
2    *  The contents of this file are subject to the Mozilla Public
3    *  License Version 1.1 (the "License"); you may not use this file
4    *  except in compliance with the License. You may obtain a copy of
5    *  the License at http://www.mozilla.org/MPL/
6    *
7    *  Software distributed under the License is distributed on an "AS
8    *  IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9    *  implied. See the License for the specific language governing
10   *  rights and limitations under the License.
11   *
12   *  The Original Code is pow2Toolkit library.
13   *
14   *  The Initial Owner of the Original Code is Power Of Two S.R.L.
15   *  Portions created by Power Of Two S.R.L. are Copyright (C) Power Of Two S.R.L.
16   *  All Rights Reserved.
17   *
18   * Contributor(s):
19   */
20  package com.pow2.struts.action;
21  
22  import javax.servlet.http.HttpServletRequest;
23  
24  import com.pow2.user.UserManager;
25  
26  
27  /***
28   *  Generic dispatcher Action class with Session User validation.
29   *  <br>
30   *  If the current session does NOT provide a valid <code>com.pow2.user.User</code>
31   *  reference, the <code>com.pow2.struts.action.ActionServlet</code> controller class
32   *  returns the ActionForward object specified by
33   *  <code>BaseAction.KEY_INVALID_SESSION</code>.
34   *
35   * @author     Luca Fossato
36   * @version    $Revision: 1.1.1.1 $ $Date: 2004/08/31 20:22:46 $
37   */
38  public class UserValidationDispatcherAction extends DispatcherAction
39  {
40    /***
41     *  Check if the current session holds a valid
42     *  <code>com.pow2.user.User</code> reference.
43     *
44     * @param  HttpServletRequest the input request object
45     * @return true if the current session is valid; false otherwise
46     */
47    protected boolean validateSession(HttpServletRequest request)
48    {
49      return (UserManager.instance().getUser(request) != null);
50    }
51  }