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  /*** Handles the retreival of user login information. Typically an IUserLoginHandler
22   * asks the user for a user name and a password.
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 ILoginInfoProvider
34  {
35      /*** Returns an Object that represents user login information. If the login
36       * is canceled <code>null</code> is returned.
37       */
38      public Object getUserLoginInformation() throws SecurityException;
39      
40      /*** Invoked when an error occured while logging in with the user login information
41       * returned by this IUserLoginHandler.
42       */
43      public void handleError(String message);
44      
45      /*** Returns the maximum number of times a user is allowed to try to login
46       * before the application exits.
47       */
48      public int getMaximumNumberOfLoginTries();
49      
50      // Nested classes ----------------------------------------------------------
51      public static class GuestUserLoginHandler implements java.io.Serializable, ILoginInfoProvider
52      {
53          // Constants -----------------------------------------------------------
54          public static final int MAX_LOGIN_TRIES = 3;
55          
56          // Constants -----------------------------------------------------------
57          private static final Object LOGIN_INFO = new ILoginService.UserLoginInfo("guest", "");
58          
59          // IUserLoginHandler implementation ------------------------------------
60          
61          /*** Returns an Object that represents user login information.
62           */
63          public Object getUserLoginInformation() throws SecurityException
64          {
65              return LOGIN_INFO;
66          }
67  
68          /*** Invoked when an error occured while logging in with the user login information
69           * returned by this IUserLoginHandler.
70           */
71          public void handleError(String message)
72          {
73          }
74          
75          /*** Returns the maximum number of times a user is allowed to try to login
76           * before the application exits.
77           */
78          public int getMaximumNumberOfLoginTries()
79          {
80              return MAX_LOGIN_TRIES;
81          }
82      }    
83  }