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

File AppServerTrustedAuthServiceImpl.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart0.png
86% of files have more coverage

Code metrics

4
16
2
1
74
39
6
0.38
8
2
3

Classes

Class Line # Actions
AppServerTrustedAuthServiceImpl 35 16 0% 6 22
0.00%
 

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.user.impl.xwiki;
21   
22    import org.slf4j.Logger;
23    import org.slf4j.LoggerFactory;
24   
25    import com.xpn.xwiki.XWikiContext;
26    import com.xpn.xwiki.XWikiException;
27    import com.xpn.xwiki.user.api.XWikiUser;
28   
29    /**
30    * Implements an authentication mechanism which is trusting the App Server authentication. If it fails it falls back to
31    * the standard XWiki authentication.
32    *
33    * @version $Id: 714703cc4f601856358b9dee121a69d33a9751bd $
34    */
 
35    public class AppServerTrustedAuthServiceImpl extends XWikiAuthServiceImpl
36    {
37    private static final Logger LOGGER = LoggerFactory.getLogger(AppServerTrustedAuthServiceImpl.class);
38   
 
39  0 toggle @Override
40    public XWikiUser checkAuth(XWikiContext context) throws XWikiException
41    {
42  0 String user = context.getRequest().getRemoteUser();
43  0 if ((user == null) || user.equals("")) {
44  0 return super.checkAuth(context);
45    } else {
46  0 LOGGER.debug("Launching create user for [{}]", user);
47  0 createUser(user, context);
48  0 LOGGER.debug("Create user done for [{}]", user);
49  0 user = "XWiki." + user;
50    }
51  0 context.setUser(user);
52   
53  0 return new XWikiUser(user);
54    }
55   
56    /**
57    * We cannot authenticate locally since we need to trust the app server for authentication.
58    */
 
59  0 toggle @Override
60    public XWikiUser checkAuth(String username, String password, String rememberme, XWikiContext context)
61    throws XWikiException
62    {
63  0 String user = context.getRequest().getRemoteUser();
64  0 if ((user == null) || user.equals("")) {
65  0 return super.checkAuth(username, password, rememberme, context);
66    } else {
67  0 createUser(user, context);
68  0 user = "XWiki." + user;
69    }
70  0 context.setUser(user);
71   
72  0 return new XWikiUser(user);
73    }
74    }