summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-05 07:46:35 (EDT)
committerEike Stepper2007-10-05 07:46:35 (EDT)
commitee762ffbc53b26009923bef2864936063cf27c56 (patch)
treea7f814a2722bb204dcbbabeb8fcec346ceba9936
parentec140254755a5ca600f4f3b9896e929c57a6bc39 (diff)
downloadcdo-ee762ffbc53b26009923bef2864936063cf27c56.zip
cdo-ee762ffbc53b26009923bef2864936063cf27c56.tar.gz
cdo-ee762ffbc53b26009923bef2864936063cf27c56.tar.bz2
[205027] Implement challenge/response based negotiator
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205027
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SecurityTest.java8
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/PasswordCredentials.java4
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiator.java11
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IPasswordCredentials.java21
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IPasswordCredentialsProvider.java19
5 files changed, 53 insertions, 10 deletions
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SecurityTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SecurityTest.java
index c7b2630..350a352 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SecurityTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SecurityTest.java
@@ -18,8 +18,8 @@ import org.eclipse.net4j.internal.util.security.ResponseNegotiator;
import org.eclipse.net4j.internal.util.security.UserManager;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.security.IChallengeResponse;
-import org.eclipse.net4j.util.security.ICredentials;
-import org.eclipse.net4j.util.security.ICredentialsProvider;
+import org.eclipse.net4j.util.security.IPasswordCredentials;
+import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
import java.nio.ByteBuffer;
import java.util.concurrent.BlockingQueue;
@@ -41,9 +41,9 @@ public class SecurityTest extends AbstractOMTest
private static final PasswordCredentials CREDENTIALS = new PasswordCredentials(USER_ID, PASSWORD1);
- private ICredentialsProvider credentialsProvider = new ICredentialsProvider()
+ private IPasswordCredentialsProvider credentialsProvider = new IPasswordCredentialsProvider()
{
- public ICredentials getCredentials()
+ public IPasswordCredentials getCredentials()
{
return CREDENTIALS;
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/PasswordCredentials.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/PasswordCredentials.java
index 4b8995f..761e541 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/PasswordCredentials.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/PasswordCredentials.java
@@ -10,10 +10,12 @@
**************************************************************************/
package org.eclipse.net4j.internal.util.security;
+import org.eclipse.net4j.util.security.IPasswordCredentials;
+
/**
* @author Eike Stepper
*/
-public class PasswordCredentials extends Credentials
+public class PasswordCredentials extends Credentials implements IPasswordCredentials
{
private char[] password;
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiator.java
index 1c79f0c..053d09c 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiator.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiator.java
@@ -10,8 +10,9 @@
**************************************************************************/
package org.eclipse.net4j.internal.util.security;
-import org.eclipse.net4j.util.security.ICredentialsProvider;
import org.eclipse.net4j.util.security.INegotiationContext;
+import org.eclipse.net4j.util.security.IPasswordCredentials;
+import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
import org.eclipse.net4j.util.security.SecurityUtil;
import java.nio.ByteBuffer;
@@ -21,18 +22,18 @@ import java.nio.ByteBuffer;
*/
public class ResponseNegotiator extends ChallengeResponseNegotiator
{
- private ICredentialsProvider credentialsProvider;
+ private IPasswordCredentialsProvider credentialsProvider;
public ResponseNegotiator()
{
}
- public ICredentialsProvider getCredentialsProvider()
+ public IPasswordCredentialsProvider getCredentialsProvider()
{
return credentialsProvider;
}
- public void setCredentialsProvider(ICredentialsProvider credentialsProvider)
+ public void setCredentialsProvider(IPasswordCredentialsProvider credentialsProvider)
{
this.credentialsProvider = credentialsProvider;
}
@@ -62,7 +63,7 @@ public class ResponseNegotiator extends ChallengeResponseNegotiator
challenge.get(randomToken);
// Get credentials and encrypt token
- PasswordCredentials credentials = (PasswordCredentials)credentialsProvider.getCredentials();
+ IPasswordCredentials credentials = credentialsProvider.getCredentials();
// Set crypted token into response
byte[] cryptedToken = encryptToken(credentials.getPassword(), randomToken);
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IPasswordCredentials.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IPasswordCredentials.java
new file mode 100644
index 0000000..24c9d6c
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IPasswordCredentials.java
@@ -0,0 +1,21 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.util.security;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IPasswordCredentials extends ICredentials
+{
+ public String getUserID();
+
+ public char[] getPassword();
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IPasswordCredentialsProvider.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IPasswordCredentialsProvider.java
new file mode 100644
index 0000000..fcf14d5
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IPasswordCredentialsProvider.java
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.util.security;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IPasswordCredentialsProvider
+{
+ public IPasswordCredentials getCredentials();
+}