public Principal authenticate(String username, String password, XWikiContext context) throws XWikiException { XWikiAuthService authservice = getAuthService(context); if (authservice == null) return super.authenticate(username, password, context); else { try { return authservice.authenticate(username, password, context); } catch (Exception e) { return super.authenticate(username, password, context); } } }
this.authService = new XWikiLDAPAuthServiceImpl(); } else { this.authService = new XWikiAuthServiceImpl();
public XWikiUser checkAuth(XWikiContext context) throws XWikiException { XWikiAuthService authservice = getAuthService(context); if (authservice == null) return super.checkAuth(context); else { try { return authservice.checkAuth(context); } catch (Exception e) { return super.checkAuth(context); } } }
if (isSuperAdmin(cannonicalUsername)) { return authenticateSuperAdmin(password, context); String user = findUser(susername, context); if (user != null) { if (checkPassword(user, password, context)) { return new SimplePrincipal(virtualXwikiName != null ? context.getDatabase() + ":" + user : user); String user = findUser(susername, context); if (user != null) { if (checkPassword(user, password, context)) { return new SimplePrincipal(context.getDatabase() + ":" + user); } else {
XWikiAuthenticator auth = getAuthenticator(context); SecurityRequestWrapper wrappedRequest = new SecurityRequestWrapper(request, null, null, auth.getAuthMethod()); try { return new XWikiUser(getContextUserName(principal, context)); } catch (Exception e) { LOG.error("Failed to authenticate", e);
protected String createUser(String user, XWikiContext context) throws XWikiException { String createuser = getParam("auth_createuser", context); if (LOG.isDebugEnabled()) { LOG.debug("Create user param is " + createuser); } if (createuser != null) { String wikiname = context.getWiki().clearName(user, true, true, context); XWikiDocument userdoc = context.getWiki().getDocument(new DocumentReference(context.getDatabase(), "XWiki", wikiname), context); if (userdoc.isNew()) { if (LOG.isDebugEnabled()) { LOG.debug("User page does not exist for user " + user); } if ("empty".equals(createuser)) { if (LOG.isDebugEnabled()) { LOG.debug("Creating emptry user for user " + user); } context.getWiki().createEmptyUser(wikiname, "edit", context); } } else { if (LOG.isDebugEnabled()) { LOG.debug("User page already exists for user " + user); } } return wikiname; } return user; }
public void showLogin(XWikiContext context) throws XWikiException { try { if (context.getMode() == XWikiContext.MODE_SERVLET) { getAuthenticator(context).showLogin(context.getRequest().getHttpServletRequest(), context.getResponse().getHttpServletResponse(), context); } } catch (IOException e) { LOG.error("Unknown failure when calling showLogin", e); } }
XWikiAuthenticator auth = getAuthenticator(context); SecurityRequestWrapper wrappedRequest = new SecurityRequestWrapper(request, null, null, auth.getAuthMethod()); String userName = getContextUserName(wrappedRequest.getUserPrincipal(), context);
/** * Try both local and global DB login if trylocal is true {@link Principal}. * * @param ldapUid the name of the user to log in. * @param ldapPassword the password of the user to log in. * @param context the XWiki context. * @return the {@link Principal}. * @throws XWikiException error when checking user name and password. */ protected Principal xwikiAuthenticate(String ldapUid, String ldapPassword, XWikiContext context) throws XWikiException { Principal principal = null; XWikiLDAPConfig config = XWikiLDAPConfig.getInstance(); String trylocal = config.getLDAPParam("ldap_trylocal", "0", context); if ("1".equals(trylocal)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Trying authentication against XWiki DB"); } principal = super.authenticate(ldapUid, ldapPassword, context); } return principal; }
public XWikiUser checkAuth(String username, String password, String rememberme, XWikiContext context) throws XWikiException { XWikiAuthService authservice = getAuthService(context); if (authservice == null) return super.checkAuth(username, password, rememberme, context); else { try { return authservice.checkAuth(username, password, rememberme, context); } catch (Exception e) { return super.checkAuth(username, password, rememberme, context); } } }
/** * Try both local and global DB login if trylocal is true {@link Principal}. * * @param ldapUid the name of the user to log in. * @param ldapPassword the password of the user to log in. * @param context the XWiki context. * @return the {@link Principal}. * @throws XWikiException error when checking user name and password. */ protected Principal xwikiAuthenticate(String ldapUid, String ldapPassword, XWikiContext context) throws XWikiException { Principal principal = null; XWikiLDAPConfig config = XWikiLDAPConfig.getInstance(); String trylocal = config.getLDAPParam("ldap_trylocal", "0", context); if ("1".equals(trylocal)) { if (LOG.isDebugEnabled()) { LOG.debug("Trying authentication against XWiki DB"); } principal = super.authenticate(ldapUid, ldapPassword, context); } return principal; }
@Override public XWikiUser checkAuth(XWikiContext context) throws XWikiException { String user = context.getRequest().getRemoteUser(); if ((user == null) || user.equals("")) { return super.checkAuth(context); } else { if (log.isDebugEnabled()) log.debug("Launching create user for " + user); createUser(user, context); if (log.isDebugEnabled()) log.debug("Create user done for " + user); user = "XWiki." + user; } context.setUser(user); return new XWikiUser(user); }
/** * {@inheritDoc} * * @see com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl#checkAuth(com.xpn.xwiki.XWikiContext) */ @Override public XWikiUser checkAuth(XWikiContext context) throws XWikiException { String user = context.getRequest().getRemoteUser(); LOG.debug(MessageFormat.format("Checking auth for remote user {0}", user)); if (StringUtils.isBlank(user)) { return super.checkAuth(context); } else { user = this.extractUsernameFromPrincipal(user); user = createUser(user, context); user = XWIKI_SPACE + DOT + user; } context.setUser(user); return new XWikiUser(user); }
/** * We cannot authenticate locally since we need to trust the app server for authentication. */ @Override public XWikiUser checkAuth(String username, String password, String rememberme, XWikiContext context) throws XWikiException { String user = context.getRequest().getRemoteUser(); if ((user == null) || user.equals("")) { return super.checkAuth(username, password, rememberme, context); } else { createUser(user, context); user = "XWiki." + user; } context.setUser(user); return new XWikiUser(user); } }