1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity.providers;
17
18 import org.acegisecurity.Authentication;
19 import org.acegisecurity.AuthenticationException;
20
21
22 /***
23 * Indicates a class can process a specific {@link
24 * org.acegisecurity.Authentication} implementation.
25 *
26 * @author Ben Alex
27 * @version $Id: AuthenticationProvider.java,v 1.5 2005/11/17 00:55:49 benalex Exp $
28 */
29 public interface AuthenticationProvider {
30
31
32 /***
33 * Performs authentication with the same contract as {@link
34 * org.acegisecurity.AuthenticationManager#authenticate(Authentication)}.
35 *
36 * @param authentication the authentication request object.
37 *
38 * @return a fully authenticated object including credentials. May return
39 * <code>null</code> if the <code>AuthenticationProvider</code> is
40 * unable to support authentication of the passed
41 * <code>Authentication</code> object. In such a case, the next
42 * <code>AuthenticationProvider</code> that supports the presented
43 * <code>Authentication</code> class will be tried.
44 *
45 * @throws AuthenticationException if authentication fails.
46 */
47 public Authentication authenticate(Authentication authentication)
48 throws AuthenticationException;
49
50 /***
51 * Returns <code>true</code> if this <Code>AuthenticationProvider</code>
52 * supports the indicated <Code>Authentication</code> object.
53 *
54 * <p>
55 * Returning <code>true</code> does not guarantee an
56 * <code>AuthenticationProvider</code> will be able to authenticate the
57 * presented instance of the <code>Authentication</code> class. It simply
58 * indicates it can support closer evaluation of it. An
59 * <code>AuthenticationProvider</code> can still return <code>null</code>
60 * from the {@link #authenticate(Authentication)} method to indicate
61 * another <code>AuthenticationProvider</code> should be tried.
62 * </p>
63 *
64 * <P>
65 * Selection of an <code>AuthenticationProvider</code> capable of
66 * performing authentication is conducted at runtime the
67 * <code>ProviderManager</code>.
68 * </p>
69 *
70 * @return <code>true</code> if the implementation can more closely
71 * evaluate the <code>Authentication</code> class presented
72 */
73 public boolean supports(Class authentication);
74 }