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.acegisecurity.providers.jaas;
17
18 import org.acegisecurity.Authentication;
19
20 import java.io.IOException;
21
22 import javax.security.auth.callback.Callback;
23 import javax.security.auth.callback.UnsupportedCallbackException;
24
25
26 /**
27 * The JaasAuthenticationCallbackHandler is similar to the
28 * javax.security.auth.callback.CallbackHandler interface in that it defines a
29 * handle method. The JaasAuthenticationCallbackHandler is only asked to
30 * handle one Callback instance at at time rather than an array of all
31 * Callbacks, as the javax... CallbackHandler defines.
32 *
33 * <p>
34 * Before a JaasAuthenticationCallbackHandler is asked to 'handle' any
35 * callbacks, it is first passed the Authentication object that the login
36 * attempt is for. NOTE: The Authentication object has not been
37 * 'authenticated' yet.
38 * </p>
39 *
40 * @author Ray Krueger
41 * @version $Id: JaasAuthenticationCallbackHandler.java 1784 2007-02-24 21:00:24Z luke_t $
42 *
43 * @see JaasNameCallbackHandler
44 * @see JaasPasswordCallbackHandler
45 * @see <a
46 * href="http://java.sun.com/j2se/1.4.2/docs/api/javax/security/auth/callback/Callback.html">Callback</a>
47 * @see <a href="http://java.sun.com/j2se/1.4.2/docs/api/javax/security/auth/callback/CallbackHandler.html">
48 * CallbackHandler</a>
49 */
50 public interface JaasAuthenticationCallbackHandler {
51 //~ Methods ========================================================================================================
52
53 /**
54 * Handle the <a
55 * href="http://java.sun.com/j2se/1.4.2/docs/api/javax/security/auth/callback/Callback.html">Callback</a>. The
56 * handle method will be called for every callback instance sent from the LoginContext. Meaning that The handle
57 * method may be called multiple times for a given JaasAuthenticationCallbackHandler.
58 *
59 * @param callback
60 * @param auth The Authentication object currently being authenticated.
61 *
62 * @throws IOException
63 * @throws UnsupportedCallbackException
64 */
65 void handle(Callback callback, Authentication auth)
66 throws IOException, UnsupportedCallbackException;
67 }