On Sat, Nov 7, 2009 at 22:52, Sergiu Dumitriu <sergiu(a)xwiki.com> wrote:
On 11/04/2009 01:12 PM, tmortagne (SVN) wrote:
Author: tmortagne
Date: 2009-11-04 13:12:41 +0100 (Wed, 04 Nov 2009)
New Revision: 24871
Modified:
platform/core/branches/xwiki-core-2.0/xwiki-core/src/main/java/com/xpn/xwiki/user/impl/xwiki/XWikiAuthServiceImpl.java
Log:
XWIKI-4549: Impossible to connect with local user in a subwiki of a path based multiwiki
mode farm
Modified:
platform/core/branches/xwiki-core-2.0/xwiki-core/src/main/java/com/xpn/xwiki/user/impl/xwiki/XWikiAuthServiceImpl.java
===================================================================
---
platform/core/branches/xwiki-core-2.0/xwiki-core/src/main/java/com/xpn/xwiki/user/impl/xwiki/XWikiAuthServiceImpl.java
2009-11-04 12:12:33 UTC (rev 24870)
+++
platform/core/branches/xwiki-core-2.0/xwiki-core/src/main/java/com/xpn/xwiki/user/impl/xwiki/XWikiAuthServiceImpl.java
2009-11-04 12:12:41 UTC (rev 24871)
@@ -23,7 +23,9 @@
import java.io.IOException;
import java.net.URL;
import java.security.Principal;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -52,19 +54,30 @@
{
private static final Log log = LogFactory.getLog(XWikiAuthServiceImpl.class);
- protected XWikiAuthenticator authenticator;
+ /**
+ * Each wiki has its own authenticator.
+ */
+ protected Map<String, XWikiAuthenticator> authenticators = new
HashMap<String, XWikiAuthenticator>();
Something should be synchronized here...
Indeed, thanks for catching it.
protected XWikiAuthenticator
getAuthenticator(XWikiContext context) throws XWikiException
{
- if (this.authenticator != null) {
- return this.authenticator;
+ String wikiName = context.getDatabase();
+
+ if (wikiName != null) {
+ wikiName = wikiName.toLowerCase();
}
+ XWikiAuthenticator authenticator = this.authenticators.get(wikiName);
+
+ if (authenticator != null) {
+ return authenticator;
+ }
+
try {
XWiki xwiki = context.getWiki();
if
("basic".equals(xwiki.Param("xwiki.authentication"))) {
- this.authenticator = new MyBasicAuthenticator();
+ authenticator = new MyBasicAuthenticator();
SecurityConfig sconfig = new SecurityConfig(false);
sconfig.setAuthMethod("BASIC");
if (xwiki.Param("xwiki.authentication.realmname") != null) {
@@ -72,9 +85,9 @@
} else {
sconfig.setRealmName("XWiki");
}
- this.authenticator.init(null, sconfig);
+ authenticator.init(null, sconfig);
} else {
- this.authenticator = new MyFormAuthenticator();
+ authenticator = new MyFormAuthenticator();
SecurityConfig sconfig = new SecurityConfig(false);
sconfig.setAuthMethod("FORM");
@@ -164,13 +177,15 @@
fconfig.setInitParameter(FormAuthenticator.LOGIN_SUBMIT_PATTERN_KEY,
xwiki.Param(
"xwiki.authentication.loginsubmitpage",
"/loginsubmit/XWiki/XWikiLogin"));
- this.authenticator.init(fconfig, sconfig);
+ authenticator.init(fconfig, sconfig);
}
- return this.authenticator;
+ this.authenticators.put(wikiName, authenticator);
+
+ return authenticator;
} catch (Exception e) {
throw new XWikiException(XWikiException.MODULE_XWIKI_USER,
XWikiException.ERROR_XWIKI_USER_INIT,
- "Cannot initialize authentication system", e);
+ "Cannot initialize authentication system for wiki [" +
wikiName + "]", e);
}
}
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
--
Thomas Mortagne