01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.webapps.authentication.components;
18:
19: import org.apache.cocoon.ProcessingException;
20: import org.apache.cocoon.webapps.authentication.configuration.HandlerConfiguration;
21: import org.apache.cocoon.webapps.authentication.user.UserHandler;
22: import org.apache.excalibur.source.SourceParameters;
23: import org.w3c.dom.Document;
24:
25: /**
26: * Verify if a user can be authenticated.
27: * An authenticator can implement all the usual component lifecycle interfaces
28: * and gets the information set.
29: * An authenticator must be implemented in a thread safe manner!
30: *
31: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
32: * @deprecated This block is deprecated and will be removed in future versions.
33: * @version CVS $Id: Authenticator.java 433543 2006-08-22 06:22:54Z crossley $
34: */
35: public interface Authenticator {
36:
37: /**
38: * This object describes the success or the failure of an attempt
39: * to authenticate a user.
40: * The boolean flag valid specifies a success (valid) or a failure
41: * (not valid).
42: * The document result contains in the case of a success the
43: * authentication xml that is store in the session.
44: * In the case of a failure, the result can contain information
45: * about the failure (or the document can be null).
46: * If in the case of a failure the result contains information,
47: * the xml must follow this format:
48: * <root>
49: * <failed/>
50: * if data is available data is included, otherwise:
51: * <data>No information</data>
52: * If exception message contains info, it is included into failed
53: * </root>
54: * The root element is removed and the contained elements are stored
55: * into the temporary context.
56: */
57: public static class AuthenticationResult {
58:
59: public final boolean valid;
60: public final Document result;
61:
62: public AuthenticationResult(final boolean valid,
63: final Document result) {
64: this .valid = valid;
65: this .result = result;
66: }
67:
68: }
69:
70: /**
71: * Try to authenticate the user.
72: * @return An AuthenticationResult that is either valid (authentication
73: * successful) or invalid (authentication failed.
74: * @throws ProcessingException Only if an error occurs
75: */
76: AuthenticationResult authenticate(
77: HandlerConfiguration configuration,
78: SourceParameters parameters) throws ProcessingException;
79:
80: /**
81: * This notifies the authenticator that a user logs out of the given
82: * handler.
83: * After the authenticator is notified, the AuthenticationManager
84: * removes the authentication context, eventually the session etc.
85: */
86: void logout(UserHandler handler);
87: }
|