View Javadoc

1   // ========================================================================
2   // Copyright (c) 2008-2009 Mort Bay Consulting Pty. Ltd.
3   // ------------------------------------------------------------------------
4   // All rights reserved. This program and the accompanying materials
5   // are made available under the terms of the Eclipse Public License v1.0
6   // and Apache License v2.0 which accompanies this distribution.
7   // The Eclipse Public License is available at 
8   // http://www.eclipse.org/legal/epl-v10.html
9   // The Apache License v2.0 is available at
10  // http://www.opensource.org/licenses/apache2.0.php
11  // You may elect to redistribute this code under either of these licenses. 
12  // ========================================================================
13  
14  package org.eclipse.jetty.security;
15  
16  import java.util.Set;
17  
18  import javax.servlet.ServletContext;
19  import javax.servlet.ServletRequest;
20  import javax.servlet.ServletResponse;
21  
22  import org.eclipse.jetty.server.Server;
23  
24  /**
25   * This is like the JASPI ServerAuthContext but is intended to be easier to use
26   * and allow lazy auth.
27   * 
28   * @version $Rev: 4793 $ $Date: 2009-03-19 00:00:01 +0100 (Thu, 19 Mar 2009) $
29   */
30  public interface Authenticator
31  {
32      void setConfiguration(Configuration configuration);
33      String getAuthMethod();
34      
35      Authentication validateRequest(ServletRequest request, ServletResponse response, boolean mandatory) throws ServerAuthException;
36      Authentication.Status secureResponse(ServletRequest request, ServletResponse response, boolean mandatory, Authentication validatedUser) throws ServerAuthException;
37      
38      interface Configuration
39      {
40          String getAuthMethod();
41          String getRealmName();
42          boolean isLazy();
43          String getInitParameter(String key);
44          Set<String> getInitParameterNames();
45          LoginService getLoginService();
46          IdentityService getIdentityService();
47      }
48      
49      interface Factory
50      {
51          Authenticator getAuthenticator(Server server, ServletContext context, Configuration configuration);
52      }
53  }