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: */
18: package org.apache.lenya.cms.ac.usecases;
19:
20: import java.util.Map;
21: import java.util.Vector;
22:
23: import org.apache.lenya.ac.Identity;
24: import org.apache.lenya.cms.repository.RepositoryUtil;
25: import org.apache.cocoon.components.ContextHelper;
26: import org.apache.cocoon.environment.ObjectModelHelper;
27: import org.apache.cocoon.environment.Request;
28: import org.apache.cocoon.environment.Session;
29:
30: /**
31: * Usecase to log a user out.
32: *
33: * @version $Id: Logout.java 407305 2006-05-17 16:21:49Z andreas $
34: */
35: public class Logout extends AccessControlUsecase {
36:
37: /**
38: * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
39: */
40: protected void initParameters() {
41: super .initParameters();
42: Map objectModel = ContextHelper.getObjectModel(getContext());
43: Request request = ObjectModelHelper.getRequest(objectModel);
44: Session session = request.getSession(false);
45:
46: if (session != null) {
47: Vector history = (Vector) session
48: .getAttribute(Login.HISTORY_SESSION_ATTRIBUTE);
49: setParameter("history", history.toArray());
50: }
51: }
52:
53: /**
54: * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
55: */
56: protected void doExecute() throws Exception {
57:
58: Map objectModel = ContextHelper.getObjectModel(getContext());
59: Request request = ObjectModelHelper.getRequest(objectModel);
60: Session session = request.getSession(false);
61:
62: if (session != null) {
63: session.removeAttribute(Identity.class.getName());
64: RepositoryUtil.removeSession(manager, request);
65: session.removeAttribute(Login.HISTORY_SESSION_ATTRIBUTE);
66: }
67: }
68: }
|