View Javadoc

1   /* (c) Copyright 2003 Caleigo AB, All rights reserved. 
2    * 
3    * This library is free software; you can redistribute it and/or
4    * modify it under the terms of the GNU Lesser General Public
5    * License as published by the Free Software Foundation; either
6    * version 2.1 of the License, or (at your option) any later version.
7    * 
8    * This library is distributed in the hope that it will be useful,
9    * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11   * Lesser General Public License for more details.
12   * 
13   * You should have received a copy of the GNU Lesser General Public
14   * License along with this library; if not, write to the Free Software
15   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16   *  
17   */
18  
19  package org.caleigo.security;
20  
21  /*** An ILoginHandler handles the process of login in a user. It uses an IUserLoginHandler
22   * for user interaction.
23   *
24   * @author  Mattias Hagstrand
25   * @version 1.00
26   *
27   *//*
28    *
29    * WHEN        WHO               WHY & WHAT
30    * -----------------------------------------------------------------------------
31    * 2002-10-16  Mattias Hagstrand    Creation
32    */
33  public interface ILoginHandler
34  {
35      
36      /*** Tries to log in a user.
37       *
38       * @param loginInfo An object that contains login information, such as user name, password.
39       * @return A UserInfo object if succesfull, <code>null</code> otherwise.
40       * @throws SecurityException if the login fails.
41       */
42      public UserInfo login(Object loginInfo);
43          
44      // Nested classes ----------------------------------------------------------
45      
46      /*** Default implementation of ILoginHandler that acceps all logins and logouts.
47       * All logins gets the user is guest.
48       */
49      public static class DefaultLoginHandler implements ILoginHandler
50      {        
51          // ILoginHandler implementation ----------------------------------------
52          
53          /*** Tries to log in a user.
54           *
55           * @param loginInfo An object that contains login information, such as user name, password.
56           * @return A UserInfo object if succesfull, <code>null</code> otherwise.
57           * @throws SecurityException if the login fails.
58           */
59          public UserInfo login(Object loginInformation)
60          {
61              UserInfo userInfo = new UserInfo.DefaultUserInfo();
62              userInfo.setCurrentUserID("guest");
63              return userInfo;
64          }
65      }
66  }