View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.security;
20  
21  import org.eclipse.jetty.server.UserIdentity;
22  
23  
24  /* ------------------------------------------------------------ */
25  /**
26   * Login Service Interface.
27   * <p>
28   * The Login service provides an abstract mechanism for an {@link Authenticator}
29   * to check credentials and to create a {@link UserIdentity} using the 
30   * set {@link IdentityService}.
31   */
32  public interface LoginService
33  {
34      
35      /* ------------------------------------------------------------ */
36      /**
37       * @return Get the name of the login service (aka Realm name)
38       */
39      String getName();
40      
41      /* ------------------------------------------------------------ */
42      /** Login a user.
43       * @param username The user name
44       * @param credentials The users credentials
45       * @return A UserIdentity if the credentials matched, otherwise null
46       */
47      UserIdentity login(String username,Object credentials);
48      
49      /* ------------------------------------------------------------ */
50      /** Validate a user identity.
51       * Validate that a UserIdentity previously created by a call 
52       * to {@link #login(String, Object)} is still valid.
53       * @param user The user to validate
54       * @return true if authentication has not been revoked for the user.
55       */
56      boolean validate(UserIdentity user);
57      
58      /* ------------------------------------------------------------ */
59      /** Get the IdentityService associated with this Login Service.
60       * @return the IdentityService associated with this Login Service.
61       */
62      IdentityService getIdentityService();
63      
64      /* ------------------------------------------------------------ */
65      /** Set the IdentityService associated with this Login Service.
66       * @param service the IdentityService associated with this Login Service.
67       */
68      void setIdentityService(IdentityService service);
69      
70      void logout(UserIdentity user);
71  
72  }