diff options
author | Laurent Fasani | 2016-10-14 09:17:56 +0000 |
---|---|---|
committer | Eike Stepper | 2016-10-18 16:11:39 +0000 |
commit | 2c26a19b22011eaf364d5446947b7f463e29dac7 (patch) | |
tree | d58c7df7f7a9044fc6549f8757e168c9519f5619 /plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/UserManager.java | |
parent | 193ac7190f01d954b55dcd1bf9eaff1491bfe6e8 (diff) | |
download | cdo-2c26a19b22011eaf364d5446947b7f463e29dac7.tar.gz cdo-2c26a19b22011eaf364d5446947b7f463e29dac7.tar.xz cdo-2c26a19b22011eaf364d5446947b7f463e29dac7.zip |
[502067] Set UserManager as IAuthenticator to allow authentication custo
* Set the userManager as authenticator so that the authenticate
implementation can be overridden
* Keep the same default UserManager authentication delegating to
UserManagerAuthenticator
* Previously, SessionManager.setUserManager was called. It created an
authenticator and set the userManager on it. It is no longer useful
because the userManager is itself the IAuthenticator so setUserManager()
is no longer needed.
Change-Id: I342cb8afbee9af26ed49a54a9caf1555b1c9170a
Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
Diffstat (limited to 'plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/UserManager.java')
-rw-r--r-- | plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/UserManager.java | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/UserManager.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/UserManager.java index d77d7bb430..1237ee25ab 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/UserManager.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/UserManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2012 Eike Stepper (Berlin, Germany) and others. + * Copyright (c) 2008-2016 Eike Stepper (Berlin, Germany) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,8 +13,8 @@ package org.eclipse.net4j.util.security; import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump; import org.eclipse.net4j.util.io.IORuntimeException; import org.eclipse.net4j.util.lifecycle.Lifecycle; +import org.eclipse.net4j.util.lifecycle.LifecycleUtil; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -23,6 +23,8 @@ import java.util.Map; */ public class UserManager extends Lifecycle implements IUserManager, IAuthenticator { + private UserManagerAuthenticator userManagerAuthenticator = new UserManagerAuthenticator(this); + @ExcludeFromDump protected transient Map<String, char[]> users = new HashMap<String, char[]>(); @@ -57,21 +59,8 @@ public class UserManager extends Lifecycle implements IUserManager, IAuthenticat */ public void authenticate(String userID, char[] password) { - char[] userPassword; - synchronized (this) - { - userPassword = users.get(userID); - } - - if (userPassword == null) - { - throw new SecurityException("No such user: " + userID); //$NON-NLS-1$ - } - - if (!Arrays.equals(userPassword, password)) - { - throw new SecurityException("Wrong password for user: " + userID); //$NON-NLS-1$ - } + // delegate to UserManagerAuthenticator + userManagerAuthenticator.authenticate(userID, password); } /** @@ -108,6 +97,7 @@ public class UserManager extends Lifecycle implements IUserManager, IAuthenticat protected void doActivate() throws Exception { super.doActivate(); + LifecycleUtil.activate(userManagerAuthenticator); load(users); } |