Changes for page User Authentication

Last modified by Thomas Mortagne on 2023/04/28

<
From version < 64.3 >
edited by Sorin Burjan
on 2013/04/18
To version < 64.2 >
edited by Manuel Smeria
on 2012/12/17
>
Change comment: Rewording, updated links

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.Sorin
1 +XWiki.ManuelSmeria
Content
... ... @@ -186,10 +186,6 @@
186 186  
187 187  The specific packages to track for LDAP are ##com.xpn.xwiki.plugin.ldap## and ##com.xpn.xwiki.user.impl.LDAP##.
188 188  
189 -
190 -Starting with XWiki 4.2 we added a new [[Logging UI>>extensions:Extension.Logging Application]]
191 -
192 -
193 193  In XWiki 3.4 you need to add the following in ##WEB-INF/classes/logback.xml##:
194 194  
195 195  {{code}}
... ... @@ -391,54 +391,54 @@
391 391   private static final Log LOG = LogFactory.getLog(SSOLdapAuthenicationImpl.class);
392 392  
393 393  
394 - public XWikiUser checkAuth(XWikiContext context) throws XWikiException {
395 - String user = getRemoteUser(context);
396 - if ((user != null) || !user.equals("")) {
397 - if (LOG.isInfoEnabled())
398 - LOG.info("Launching create user for " + user);
399 - if ( authenticate(user, context) != null ) {
400 - if (LOG.isInfoEnabled())
401 - LOG.info("Create user done for " + user);
402 - user = "XWiki." + user;
403 - context.setUser(user);
404 - System.out.println("User is set to:" + user);
405 - return new XWikiUser(user);
406 - } else {
407 - LOG.error( "User " + user + " can't be authenticated against ldap" );
408 - }
409 - }
410 - return super.checkAuth(context);
411 - }
390 + public XWikiUser checkAuth(XWikiContext context) throws XWikiException {
391 + String user = getRemoteUser(context);
392 + if ((user != null) || !user.equals("")) {
393 + if (LOG.isInfoEnabled())
394 + LOG.info("Launching create user for " + user);
395 + if ( authenticate(user, context) != null ) {
396 + if (LOG.isInfoEnabled())
397 + LOG.info("Create user done for " + user);
398 + user = "XWiki." + user;
399 + context.setUser(user);
400 + System.out.println("User is set to:" + user);
401 + return new XWikiUser(user);
402 + } else {
403 + LOG.error( "User " + user + " can't be authenticated against ldap" );
404 + }
405 + }
406 + return super.checkAuth(context);
407 + }
412 412  
413 - /**
414 - * We cannot authenticate locally since we need to trust the app server for
415 - * authentication
416 - *
417 - * @param username
418 - * @param password
419 - * @param context
420 - * @return
421 - * @throws XWikiException
422 - */
423 - public XWikiUser checkAuth(String username, String password,
424 - String rememberme, XWikiContext context) throws XWikiException {
425 - String user = getRemoteUser(context);
426 - if ((user == null) || user.equals("")) {
427 - return super.checkAuth(username, password, rememberme, context);
428 - }
429 - return checkAuth(context);
430 - }
409 + /**
410 + * We cannot authenticate locally since we need to trust the app server for
411 + * authentication
412 + *
413 + * @param username
414 + * @param password
415 + * @param context
416 + * @return
417 + * @throws XWikiException
418 + */
419 + public XWikiUser checkAuth(String username, String password,
420 + String rememberme, XWikiContext context) throws XWikiException {
421 + String user = getRemoteUser(context);
422 + if ((user == null) || user.equals("")) {
423 + return super.checkAuth(username, password, rememberme, context);
424 + }
425 + return checkAuth(context);
426 + }
431 431  
432 - private String getRemoteUser(XWikiContext context) {
433 - String userName = context.getRequest().getHttpServletRequest()
434 - .getRemoteUser();
435 - if (userName != null) {
436 - // only take the front of the username@domain
437 - String[] elements = userName.split("@", 2);
438 - userName = elements[0];
439 - }
440 - return userName;
441 - }
428 + private String getRemoteUser(XWikiContext context) {
429 + String userName = context.getRequest().getHttpServletRequest()
430 + .getRemoteUser();
431 + if (userName != null) {
432 + // only take the front of the username@domain
433 + String[] elements = userName.split("@", 2);
434 + userName = elements[0];
435 + }
436 + return userName;
437 + }
442 442  
443 443   public Principal authenticate(String login, XWikiContext context) throws XWikiException
444 444   {

Get Connected