1 /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * 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.springframework.security.providers; 17 18 import org.springframework.security.Authentication; 19 import org.springframework.security.AuthenticationException; 20 21 22 /** 23 * Indicates a class can process a specific {@link 24 * org.springframework.security.Authentication} implementation. 25 * 26 * @author Ben Alex 27 * @version $Id: AuthenticationProvider.java 2217 2007-10-27 00:45:30Z luke_t $ 28 */ 29 public interface AuthenticationProvider { 30 //~ Methods ======================================================================================================== 31 32 /** 33 * Performs authentication with the same contract as {@link 34 * org.springframework.security.AuthenticationManager#authenticate(Authentication)}. 35 * 36 * @param authentication the authentication request object. 37 * 38 * @return a fully authenticated object including credentials. May return <code>null</code> if the 39 * <code>AuthenticationProvider</code> is unable to support authentication of the passed 40 * <code>Authentication</code> object. In such a case, the next <code>AuthenticationProvider</code> that 41 * supports the presented <code>Authentication</code> class will be tried. 42 * 43 * @throws AuthenticationException if authentication fails. 44 */ 45 Authentication authenticate(Authentication authentication) 46 throws AuthenticationException; 47 48 /** 49 * Returns <code>true</code> if this <Code>AuthenticationProvider</code> supports the indicated 50 * <Code>Authentication</code> object. 51 * <p> 52 * Returning <code>true</code> does not guarantee an <code>AuthenticationProvider</code> will be able to 53 * authenticate the presented instance of the <code>Authentication</code> class. It simply indicates it can support 54 * closer evaluation of it. An <code>AuthenticationProvider</code> can still return <code>null</code> from the 55 * {@link #authenticate(Authentication)} method to indicate another <code>AuthenticationProvider</code> should be 56 * tried. 57 * </p> 58 * <p>Selection of an <code>AuthenticationProvider</code> capable of performing authentication is 59 * conducted at runtime the <code>ProviderManager</code>.</p> 60 * 61 * @param authentication DOCUMENT ME! 62 * 63 * @return <code>true</code> if the implementation can more closely evaluate the <code>Authentication</code> class 64 * presented 65 */ 66 boolean supports(Class authentication); 67 }