1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.web

File LogoutAction.java

 

Coverage histogram

../../../../img/srcFileCovDistChart8.png
56% of files have more coverage

Code metrics

4
16
1
1
80
37
3
0.19
16
1
3

Classes

Class Line # Actions
LogoutAction 41 16 0% 3 6
0.7142857371.4%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.web;
21   
22    import javax.servlet.http.HttpSession;
23   
24    import org.apache.commons.lang3.StringUtils;
25    import org.xwiki.model.EntityType;
26    import org.xwiki.model.reference.DocumentReference;
27    import org.xwiki.model.reference.DocumentReferenceResolver;
28    import org.xwiki.model.reference.EntityReference;
29    import org.xwiki.model.reference.WikiReference;
30   
31    import com.xpn.xwiki.XWikiContext;
32    import com.xpn.xwiki.XWikiException;
33   
34    /**
35    * Action for processing logout requests. The actual logout request processing is done before this action is invoked,
36    * the URL will trigger the authenticator automatically. This action just cleans up the session and redirects to a view
37    * page.
38    *
39    * @version $Id: 596b7ed7ed2758461d36c16e27fc40f3461bea78 $
40    */
 
41    public class LogoutAction extends XWikiAction
42    {
 
43  8 toggle @Override
44    public boolean action(XWikiContext context) throws XWikiException
45    {
46  8 XWikiRequest request = context.getRequest();
47  8 XWikiResponse response = context.getResponse();
48   
49    // Destroy the current session, if any, so that any private data stored in the session won't be accessible by
50    // the next user on the same computer
51  8 HttpSession currentSession = request.getSession(false);
52  8 if (currentSession != null) {
53  8 synchronized (currentSession) {
54  8 currentSession.invalidate();
55    // Early registration of a new session, so that the client gets to know the new session identifier early
56    // A new session is going to be needed after the redirect anyway
57  8 request.getSession(true);
58    }
59    }
60   
61    // Process redirect
62  8 String redirect;
63  8 redirect = context.getRequest().getParameter("xredirect");
64  8 if (StringUtils.isEmpty(redirect)) {
65  0 DocumentReferenceResolver<EntityReference> resolver =
66    Utils.getComponent(DocumentReferenceResolver.TYPE_REFERENCE);
67   
68    // Get default document
69  0 DocumentReference reference = resolver.resolve(null, EntityType.DOCUMENT);
70   
71    // Set wiki reference to current wiki
72  0 reference = reference.setWikiReference(new WikiReference(context.getWikiId()));
73   
74    // Create URL to the wiki home page
75  0 redirect = context.getWiki().getURL(reference, "view", context);
76    }
77  8 sendRedirect(response, redirect);
78  8 return false;
79    }
80    }