Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2013-10-18 20:55:32 +0000
committerChristian W. Damus2013-10-25 15:20:05 +0000
commit98dd1927de57f31ef26e6f265a2879eec3ba350c (patch)
tree437d55d1713d54dbb38cf0dc4d2b58f7764e6c4a /plugins/org.eclipse.emf.cdo.server
parent09aee65510418cc81c7ca8523256b78aec78fe7e (diff)
downloadcdo-98dd1927de57f31ef26e6f265a2879eec3ba350c.tar.gz
cdo-98dd1927de57f31ef26e6f265a2879eec3ba350c.tar.xz
cdo-98dd1927de57f31ef26e6f265a2879eec3ba350c.zip
[399306] [Security] Add password management
https://bugs.eclipse.org/bugs/show_bug.cgi?id=399306 Initial implementation of Change Password signal in the CDO protocol: - client->server request to initiate password change - server->client request to change password, implemented via the Diffie-Hellman key agreement utility - optional API for pluggable credentials providers to provide updates to the user's credentials - updated default interactive credentials provider to use a new CredentialsUpdateDialog to get a new password from the user (with implicit authentication) And an administrative Change Password signal: - client->server request to initiate password reset - server->client request to reset password, implemented via the Diffie-Hellman key agreement utility - updated default interactive credentials provider to use a new CredentialsResetDialog to authenticate the administrator (regular users may not reset passwords) and generate a new password to return to the server. The password is then shown to the administrator in a dialog to share it with the user whose password was reset
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server')
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java83
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSession.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedServerSessionProtocol.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/ISessionProtocol.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalSessionManager.java17
7 files changed, 177 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java
index 4a52229b93..051b538335 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Christian W. Damus (CEA LIST) - 399306
*/
package org.eclipse.emf.cdo.internal.server;
@@ -517,6 +518,28 @@ public class ServerCDOView extends AbstractCDOView implements org.eclipse.emf.cd
throw new UnsupportedOperationException();
}
+ /**
+ * Server sessions may not be used to change the user's credentials: it must
+ * be done client-side by interaction with the user.
+ *
+ * @since 4.3
+ */
+ public void changeCredentials()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Server sessions may not be used to reset a user's credentials: it must
+ * be done client-side by interaction with an adminstrator.
+ *
+ * @since 4.3
+ */
+ public void resetCredentials(String userID)
+ {
+ throw new UnsupportedOperationException();
+ }
+
public InternalCDORevisionManager getRevisionManager()
{
return repository.getRevisionManager();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java
index 11c168bc33..ace06a84e2 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java
@@ -9,6 +9,7 @@
* Eike Stepper - initial API and implementation
* Simon McDuff - bug 201266
* Simon McDuff - bug 202725
+ * Christian W. Damus (CEA LIST) - 399306
*/
package org.eclipse.emf.cdo.internal.server;
@@ -31,6 +32,7 @@ import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.emf.cdo.spi.server.InternalSession;
import org.eclipse.emf.cdo.spi.server.InternalSessionManager;
+import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.container.Container;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
@@ -39,6 +41,7 @@ import org.eclipse.net4j.util.security.DiffieHellman;
import org.eclipse.net4j.util.security.DiffieHellman.Client.Response;
import org.eclipse.net4j.util.security.DiffieHellman.Server.Challenge;
import org.eclipse.net4j.util.security.IAuthenticator;
+import org.eclipse.net4j.util.security.IAuthenticator2;
import org.eclipse.net4j.util.security.IUserManager;
import org.eclipse.net4j.util.security.UserManagerAuthenticator;
@@ -436,6 +439,86 @@ public class SessionManager extends Container<ISession> implements InternalSessi
}
}
+ public void changeUserCredentials(ISessionProtocol sessionProtocol)
+ {
+ changeUserCredentials(sessionProtocol, null, false);
+ }
+
+ public void resetUserCredentials(ISessionProtocol sessionProtocol, String userID)
+ {
+ changeUserCredentials(sessionProtocol, userID, true);
+ }
+
+ protected void changeUserCredentials(ISessionProtocol sessionProtocol, String userID, boolean isReset)
+ {
+
+ if (sessionProtocol == null)
+ {
+ return;
+ }
+
+ if (authenticationServer == null || authenticator == null)
+ {
+ return;
+ }
+
+ if (!(authenticator instanceof IAuthenticator2))
+ {
+ throw new SecurityException("Current authenticator does not permit password updates"); //$NON-NLS-1$
+ }
+
+ try
+ {
+ Challenge challenge = authenticationServer.getChallenge();
+ Response response = sessionProtocol.sendChangeCredentialsChallenge(challenge, userID, isReset);
+ if (response == null)
+ {
+ throw new NotAuthenticatedException();
+ }
+
+ ByteArrayInputStream baos = new ByteArrayInputStream(authenticationServer.handleResponse(response));
+ @SuppressWarnings("resource")
+ ExtendedDataInputStream stream = new ExtendedDataInputStream(baos);
+
+ if (isReset)
+ {
+ String adminID = stream.readString();
+ char[] adminPassword = stream.readString().toCharArray();
+ if (!ObjectUtil.equals(userID, stream.readString()))
+ {
+ throw new SecurityException("Attempt to reset password of a different user than requested"); //$NON-NLS-1$
+ }
+ char[] newPassword = stream.readString().toCharArray();
+
+ // this will throw if the current credentials are not authenticated as an administrator
+ ((IAuthenticator2)authenticator).resetPassword(adminID, adminPassword, userID, newPassword);
+ }
+ else
+ {
+ userID = stream.readString(); // user can change any password that she can authenticate on the old password
+ char[] password = stream.readString().toCharArray();
+ char[] newPassword = stream.readString().toCharArray();
+
+ // this will throw if the "old password" provided by the user is not correct
+ ((IAuthenticator2)authenticator).updatePassword(userID, password, newPassword);
+ }
+ }
+ catch (SecurityException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ Throwable cause = ex.getCause();
+ if (cause instanceof SecurityException)
+ {
+ throw (SecurityException)cause;
+ }
+
+ throw new SecurityException(ex);
+ }
+ }
+
@Override
protected void doActivate() throws Exception
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSession.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSession.java
index b2e1abda80..5f99a9df65 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSession.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSession.java
@@ -8,6 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
* Andre Dietisheim - bug 256649
+ * Christian W. Damus (CEA LIST) - 399306
*/
package org.eclipse.emf.cdo.internal.server.embedded;
@@ -66,6 +67,28 @@ public class EmbeddedClientSession extends CDOSessionImpl implements CDOSession
throw new UnsupportedOperationException();
}
+ /**
+ * Changing the user's password in an embedded client session is not supported:
+ * it must be done interactively with the user in a client session.
+ *
+ * @since 4.3
+ */
+ public void changeCredentials()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Resetting a user's password in an embedded client session is not supported:
+ * it must be done interactively in a client session.
+ *
+ * @since 4.3
+ */
+ public void resetCredentials(String userID)
+ {
+ throw new UnsupportedOperationException();
+ }
+
@Override
protected void doActivate() throws Exception
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java
index 07e6bbb346..a2bbf9b669 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Christian W. Damus (CEA LIST) - 399306
*/
package org.eclipse.emf.cdo.internal.server.embedded;
@@ -595,6 +596,24 @@ public class EmbeddedClientSessionProtocol extends Lifecycle implements CDOSessi
return result;
}
+ /**
+ * Change of credentials may not be requested by embedded client sessions, only by
+ * interactive user client sessions.
+ */
+ public void requestChangeCredentials()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Reset of credentials may not be requested by embedded client sessions, only by
+ * interactive client sessions.
+ */
+ public void requestResetCredentials(String userID)
+ {
+ throw new UnsupportedOperationException();
+ }
+
@Override
protected void doActivate() throws Exception
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedServerSessionProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedServerSessionProtocol.java
index 98425e1119..deb256a718 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedServerSessionProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedServerSessionProtocol.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Christian W. Damus (CEA LIST) - 399306
*/
package org.eclipse.emf.cdo.internal.server.embedded;
@@ -70,6 +71,11 @@ public class EmbeddedServerSessionProtocol extends Lifecycle implements ISession
throw new UnsupportedOperationException();
}
+ public Response sendChangeCredentialsChallenge(Challenge challenge, String userID, boolean isReset) throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+
public void sendRepositoryTypeNotification(CDOCommonRepository.Type oldType, CDOCommonRepository.Type newType)
{
EmbeddedClientSession clientSession = clientSessionProtocol.getSession();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/ISessionProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/ISessionProtocol.java
index d23bef2ca1..911b88c74b 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/ISessionProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/ISessionProtocol.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Christian W. Damus (CEA LIST) - 399306
*/
package org.eclipse.emf.cdo.spi.server;
@@ -44,6 +45,11 @@ public interface ISessionProtocol extends CDOProtocol
*/
public Response sendAuthenticationChallenge(Challenge challenge) throws Exception;
+ /**
+ * @since 4.3
+ */
+ public Response sendChangeCredentialsChallenge(Challenge challenge, String userID, boolean isReset) throws Exception;
+
public void sendRepositoryTypeNotification(CDOCommonRepository.Type oldType, CDOCommonRepository.Type newType)
throws Exception;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalSessionManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalSessionManager.java
index 0f30df3bcd..1623720a3b 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalSessionManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalSessionManager.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Christian W. Damus (CEA LIST) - 399306
*/
package org.eclipse.emf.cdo.spi.server;
@@ -64,6 +65,22 @@ public interface InternalSessionManager extends ISessionManager
public void setAuthenticationServer(DiffieHellman.Server authenticationServer);
/**
+ * Initiates the change-credentials protocol with the client and processes the
+ * client response to update the user's credentials.
+ *
+ * @since 4.3
+ */
+ public void changeUserCredentials(ISessionProtocol sessionProtocol);
+
+ /**
+ * Initiates the administrative reset-credentials protocol with the client and
+ * processes the client response to reset the specified {@code userID}'s credentials.
+ *
+ * @since 4.3
+ */
+ public void resetUserCredentials(ISessionProtocol sessionProtocol, String userID);
+
+ /**
* @since 4.1
*/
public IPermissionManager getPermissionManager();

Back to the top