View Javadoc

1   /*
2    *   Copyright 2004 The Apache Software Foundation
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    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *   Unless required by applicable law or agreed to in writing, software
11   *   distributed under the License is distributed on an "AS IS" BASIS,
12   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *   See the License for the specific language governing permissions and
14   *   limitations under the License.
15   *
16   */
17  package org.apache.ldap.server.authn;
18  
19  
20  import javax.naming.Context;
21  import javax.naming.NamingException;
22  
23  import org.apache.ldap.server.configuration.AuthenticatorConfiguration;
24  import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
25  import org.apache.ldap.server.jndi.ServerContext;
26  import org.apache.ldap.server.partition.ContextPartitionNexus;
27  
28  
29  /***
30   * Authenticates users who access {@link ContextPartitionNexus}.
31   * <p>
32   * {@link Authenticator}s are registered to and configured by
33   * {@link AuthenticationService} interceptor.
34   * <p>
35   * {@link AuthenticationService} authenticates users by calling
36   * {@link #authenticate(ServerContext)}, and then {@link Authenticator}
37   * checks JNDI {@link Context} environment properties
38   * ({@link Context#SECURITY_PRINCIPAL} and {@link Context#SECURITY_CREDENTIALS})
39   * of current {@link Context}.
40   *
41   * @see AbstractAuthenticator
42   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
43   * @version $Rev: 264732 $
44   */
45  public interface Authenticator
46  {
47      /***
48       * Returns the type of this authenticator (e.g. <tt>'simple'</tt>,
49       * <tt>'none'</tt>,...).
50       */
51      public String getAuthenticatorType();
52      
53      /***
54       * Called by {@link AuthenticationService} to indicate that this
55       * authenticator is being placed into service.
56       */
57      public void init( ContextFactoryConfiguration factoryCfg, AuthenticatorConfiguration cfg ) throws NamingException;
58      
59      /***
60       * Called by {@link AuthenticationService} to indicate that this
61       * authenticator is being removed from service.
62       */
63      public void destroy();
64  
65      /***
66       * Performs authentication and returns the principal if succeeded.
67       */
68      public LdapPrincipal authenticate( ServerContext ctx ) throws NamingException;
69  }