KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > webapps > authentication > components > Authenticator


1 /*
2  * Copyright 1999-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 package org.apache.cocoon.webapps.authentication.components;
17
18 import org.apache.cocoon.ProcessingException;
19 import org.apache.cocoon.webapps.authentication.configuration.HandlerConfiguration;
20 import org.apache.cocoon.webapps.authentication.user.UserHandler;
21 import org.apache.excalibur.source.SourceParameters;
22 import org.w3c.dom.Document JavaDoc;
23
24 /**
25  * Verify if a user can be authenticated.
26  * An authenticator can implement all the usual component lifecycle interfaces
27  * and gets the information set.
28  * An authenticator must be implemented in a thread safe manner!
29  *
30  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
31  * @version CVS $Id: Authenticator.java 105794 2004-11-19 07:41:03Z antonio $
32 */

33 public interface Authenticator {
34
35     /**
36      * This object describes the success or the failure of an attempt
37      * to authenticate a user.
38      * The boolean flag valid specifies a success (valid) or a failure
39      * (not valid).
40      * The document result contains in the case of a success the
41      * authentication xml that is store in the session.
42      * In the case of a failure, the result can contain information
43      * about the failure (or the document can be null).
44      * If in the case of a failure the result contains information,
45      * the xml must follow this format:
46      * <root>
47      * <failed/>
48      * if data is available data is included, otherwise:
49      * <data>No information</data>
50      * If exception message contains info, it is included into failed
51      * </root>
52      * The root element is removed and the contained elements are stored
53      * into the temporary context.
54      */

55     public static class AuthenticationResult {
56         
57         public final boolean valid;
58         public final Document JavaDoc result;
59
60         public AuthenticationResult(final boolean valid,
61                                     final Document JavaDoc result) {
62             this.valid = valid;
63             this.result = result;
64         }
65
66     }
67
68     /**
69      * Try to authenticate the user.
70      * @return An AuthenticationResult that is either valid (authentication
71      * successful) or invalid (authentication failed.
72      * @throws ProcessingException Only if an error occurs
73      */

74     AuthenticationResult authenticate(HandlerConfiguration configuration,
75                                       SourceParameters parameters)
76     throws ProcessingException;
77     
78     /**
79      * This notifies the authenticator that a user logs out of the given
80      * handler.
81      * After the authenticator is notified, the AuthenticationManager
82      * removes the authentication context, eventually the session etc.
83      */

84     void logout(UserHandler handler);
85 }
Popular Tags