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.auth.acting;
18:
19: import java.util.HashMap;
20: import java.util.Map;
21:
22: import org.apache.avalon.framework.parameters.Parameters;
23: import org.apache.cocoon.ProcessingException;
24: import org.apache.cocoon.environment.Redirector;
25: import org.apache.cocoon.environment.SourceResolver;
26: import org.apache.cocoon.auth.ApplicationManager;
27:
28: /**
29: * This action logs the current user out of a given application.
30: *
31: * @version $Id: LogoutAction.java 433543 2006-08-22 06:22:54Z crossley $
32: */
33: public final class LogoutAction extends AbstractAuthAction {
34:
35: /**
36: * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector, org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
37: */
38: public Map act(final Redirector redirector,
39: final SourceResolver resolver, final Map objectModel,
40: final String source, final Parameters par) throws Exception {
41: if (this .getLogger().isDebugEnabled()) {
42: this .getLogger().debug(
43: "BEGIN act resolver=" + resolver + ", objectModel="
44: + objectModel + ", source=" + source
45: + ", par=" + par);
46: }
47:
48: final String applicationName = par.getParameter("application");
49:
50: final String modeString = par.getParameter("mode", "terminate");
51: final String mode;
52: if (modeString.equals("terminate")) {
53: mode = ApplicationManager.LOGOUT_MODE_TERMINATE_SESSION_IF_UNUSED;
54: } else if (modeString.equalsIgnoreCase("keep")) {
55: mode = ApplicationManager.LOGOUT_MODE_KEEP_SESSION;
56: } else {
57: throw new ProcessingException("Unknown mode " + modeString);
58: }
59:
60: final Map logoutContext = new HashMap();
61: logoutContext.put(
62: ApplicationManager.LOGOUT_CONTEXT_PARAMETERS_KEY, par);
63: logoutContext.put(ApplicationManager.LOGOUT_CONTEXT_MODE_KEY,
64: mode);
65:
66: this .applicationManager.logout(applicationName, logoutContext);
67:
68: if (this .getLogger().isDebugEnabled()) {
69: this .getLogger().debug("END act map={}");
70: }
71:
72: return EMPTY_MAP;
73: }
74:
75: }
|