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.acting;
18:
19: import java.util.Map;
20:
21: import org.apache.avalon.framework.parameters.Parameters;
22: import org.apache.avalon.framework.thread.ThreadSafe;
23: import org.apache.cocoon.acting.ServiceableAction;
24: import org.apache.cocoon.environment.Redirector;
25: import org.apache.cocoon.environment.SourceResolver;
26: import org.apache.cocoon.webapps.authentication.AuthenticationManager;
27: import org.apache.cocoon.webapps.authentication.user.RequestState;
28:
29: /**
30: * This is the authentication action
31: * This action contains the complete configuration for the authentication
32: * Manager. During configuration the AuthenticationManager class gets this
33: * configuration to configure the instances properly.
34: * The main task of this action is to check if the user is authenticated
35: * using a handler. If not a redirect takes place.
36: *
37: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
38: * @deprecated This block is deprecated and will be removed in future versions.
39: * @version CVS $Id: AuthAction.java 433543 2006-08-22 06:22:54Z crossley $
40: */
41: public final class AuthAction extends ServiceableAction implements
42: ThreadSafe {
43:
44: public Map act(Redirector redirector, SourceResolver resolver,
45: Map objectModel, String source, Parameters par)
46: throws Exception {
47: if (this .getLogger().isDebugEnabled()) {
48: this .getLogger().debug(
49: "BEGIN act resolver=" + resolver + ", objectModel="
50: + objectModel + ", source=" + source
51: + ", par=" + par);
52: }
53: String handlerName = null;
54: String applicationName = null;
55: AuthenticationManager authManager = null;
56: Map map = null;
57:
58: try {
59: handlerName = par.getParameter("handler", null);
60: applicationName = par.getParameter("application", null);
61:
62: authManager = (AuthenticationManager) this .manager
63: .lookup(AuthenticationManager.ROLE);
64:
65: // do authentication
66: if (!authManager.checkAuthentication(redirector,
67: handlerName, applicationName)) {
68: // All events are ignored
69: // the sitemap.xsl ensures that only the redirect is processed
70: } else {
71: RequestState state = authManager.getState();
72: map = state.getHandler().getContext().getContextInfo();
73: }
74: } finally {
75: this .manager.release(authManager);
76: }
77: if (this .getLogger().isDebugEnabled()) {
78: this .getLogger().debug("END act map=" + map);
79: }
80: return map;
81: }
82:
83: }
|