01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15:
16: package org.acegisecurity.providers;
17:
18: import org.acegisecurity.Authentication;
19: import org.acegisecurity.AuthenticationException;
20:
21: /**
22: * Indicates a class can process a specific {@link
23: * org.acegisecurity.Authentication} implementation.
24: *
25: * @author Ben Alex
26: * @version $Id: AuthenticationProvider.java 1784 2007-02-24 21:00:24Z luke_t $
27: */
28: public interface AuthenticationProvider {
29: //~ Methods ========================================================================================================
30:
31: /**
32: * Performs authentication with the same contract as {@link
33: * org.acegisecurity.AuthenticationManager#authenticate(Authentication)}.
34: *
35: * @param authentication the authentication request object.
36: *
37: * @return a fully authenticated object including credentials. May return <code>null</code> if the
38: * <code>AuthenticationProvider</code> is unable to support authentication of the passed
39: * <code>Authentication</code> object. In such a case, the next <code>AuthenticationProvider</code> that
40: * supports the presented <code>Authentication</code> class will be tried.
41: *
42: * @throws AuthenticationException if authentication fails.
43: */
44: Authentication authenticate(Authentication authentication)
45: throws AuthenticationException;
46:
47: /**
48: * Returns <code>true</code> if this <Code>AuthenticationProvider</code> supports the indicated
49: * <Code>Authentication</code> object.
50: * <p>
51: * Returning <code>true</code> does not guarantee an <code>AuthenticationProvider</code> will be able to
52: * authenticate the presented instance of the <code>Authentication</code> class. It simply indicates it can support
53: * closer evaluation of it. An <code>AuthenticationProvider</code> can still return <code>null</code> from the
54: * {@link #authenticate(Authentication)} method to indicate another <code>AuthenticationProvider</code> should be
55: * tried.
56: * </p>
57: * <p>Selection of an <code>AuthenticationProvider</code> capable of performing authentication is
58: * conducted at runtime the <code>ProviderManager</code>.</p>
59: *
60: * @param authentication DOCUMENT ME!
61: *
62: * @return <code>true</code> if the implementation can more closely evaluate the <code>Authentication</code> class
63: * presented
64: */
65: boolean supports(Class authentication);
66: }
|