1   // ========================================================================
2   // Copyright 2003-2005 Mort Bay Consulting Pty. Ltd.
3   // ------------------------------------------------------------------------
4   // Licensed under the Apache License, Version 2.0 (the "License");
5   // you may not use this file except in compliance with the License.
6   // You may obtain a copy of the License at 
7   // http://www.apache.org/licenses/LICENSE-2.0
8   // Unless required by applicable law or agreed to in writing, software
9   // distributed under the License is distributed on an "AS IS" BASIS,
10  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  // See the License for the specific language governing permissions and
12  // limitations under the License.
13  // ========================================================================
14  
15  package org.mortbay.jetty;
16  
17  import java.io.IOException;
18  import java.io.Serializable;
19  import java.security.Principal;
20  
21  
22  /** Authenticator Interface.
23   * This is the interface that must be implemented to provide authentication implementations to the HttpContext.
24   */
25  public interface Authenticator extends Serializable
26  {
27      /** Authenticate.
28       * @param realm an <code>UserRealm</code> value
29       * @param pathInContext a <code>String</code> value
30       * @param request a <code>Request</code> value
31       * @param response a <code>Response</code> value. If non-null response is passed, 
32       *              then a failed authentication will result in a challenge response being 
33       *              set in the response.
34       * @return User <code>Principal</code> if authenticated. Null if Authentication
35       * failed. If the SecurityConstraint.__NOBODY instance is returned,
36       * the request is considered as part of the authentication process.
37       * @exception IOException if an error occurs
38       */
39      public Principal authenticate(
40          UserRealm realm,
41          String pathInContext,
42          Request request,
43          Response response)
44          throws IOException;
45  
46      /* ------------------------------------------------------------ */
47      public String getAuthMethod();
48  }