KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > mask > struts > SecurityMaskAuthenticator


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: SecurityMaskAuthenticator.java,v $
31  * Revision 1.2 2005/04/09 17:19:50 colinmacleod
32  * Changed copyright text to GPL v2 explicitly.
33  *
34  * Revision 1.1.1.1 2005/03/10 17:49:54 colinmacleod
35  * Restructured ivata op around Hibernate/PicoContainer.
36  * Renamed ivata groupware.
37  *
38  * Revision 1.1 2004/12/29 14:09:32 colinmacleod
39  * Changed subproject name from masks to mask
40  *
41  * Revision 1.1 2004/11/12 18:28:27 colinmacleod
42  * Added security session mask authenticator.
43  *
44  * -----------------------------------------------------------------------------
45  */

46 package com.ivata.groupware.mask.struts;
47
48 import java.io.Serializable JavaDoc;
49
50 import javax.servlet.http.HttpSession JavaDoc;
51
52 import com.ivata.groupware.admin.security.server.SecuritySession;
53 import com.ivata.mask.web.struts.MaskAuthenticator;
54
55 /**
56  * <p>
57  * Authenticates the current user against the <strong>ivata groupware</strong> security
58  * session.
59  * </p>
60  *
61  * @since Nov 12, 2004
62  * @author Colin MacLeod
63  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
64  * @version $Revision: 1.2 $
65  */

66
67 public class SecurityMaskAuthenticator implements MaskAuthenticator, Serializable JavaDoc {
68
69     /**
70      * <p>
71      * Authenticates the current user against the <strong>ivata groupware</strong> security
72      * session.
73      * </p>
74      *
75      * @return <code>null</code>, if this is a valid, logged-in user, otherwise
76      * &quot;<code>login</code>&quot;.
77      * @see com.ivata.mask.web.struts.MaskAuthenticator#authenticate(javax.servlet.http.HttpSession, boolean)
78      */

79     public String JavaDoc authenticate(final HttpSession JavaDoc session,
80             final boolean login) {
81         SecuritySession securitySession = (SecuritySession)
82             session.getAttribute("securitySession");
83
84         // if we're logging in, or there is a valid security session, that means
85
// carry on as normal...
86
if (login
87                 || ((securitySession != null)
88                         && !securitySession.isGuest())) {
89             return null;
90         }
91         // otherwise login...
92
return "login";
93     }
94
95 }
96
Popular Tags