summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-04 06:33:07 (EDT)
committerEike Stepper2007-10-04 06:33:07 (EDT)
commit9fd1d2acef1f41a29efcb848f9ae0f3a82b58f88 (patch)
treefb4580076bcd92dfaa1d6e875bd8d1a3f935b90d
parent46b49ec6795edb1d1a6a9c6fcbdec9938f4395af (diff)
downloadcdo-9fd1d2acef1f41a29efcb848f9ae0f3a82b58f88.zip
cdo-9fd1d2acef1f41a29efcb848f9ae0f3a82b58f88.tar.gz
cdo-9fd1d2acef1f41a29efcb848f9ae0f3a82b58f88.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.java38
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiator.java2
2 files changed, 30 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 98d3fb0..adef1c6 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
@@ -12,9 +12,12 @@ package org.eclipse.net4j.util.tests;
import org.eclipse.net4j.internal.util.security.ChallengeNegotiator;
import org.eclipse.net4j.internal.util.security.NegotiationContext;
+import org.eclipse.net4j.internal.util.security.PasswordCredentials;
import org.eclipse.net4j.internal.util.security.Randomizer;
import org.eclipse.net4j.internal.util.security.ResponseNegotiator;
import org.eclipse.net4j.internal.util.security.UserManager;
+import org.eclipse.net4j.util.security.ICredentials;
+import org.eclipse.net4j.util.security.ICredentialsProvider;
import java.nio.ByteBuffer;
@@ -23,6 +26,20 @@ import java.nio.ByteBuffer;
*/
public class SecurityTest extends AbstractOMTest
{
+ private static final String USER_ID = "stepper";
+
+ private static final char[] PASSWORD = "eike2007".toCharArray();
+
+ private static final PasswordCredentials CREDENTIALS = new PasswordCredentials(USER_ID, PASSWORD);
+
+ private ICredentialsProvider credentialsProvider = new ICredentialsProvider()
+ {
+ public ICredentials getCredentials()
+ {
+ return CREDENTIALS;
+ }
+ };
+
private Randomizer randomizer = new Randomizer();
private UserManager userManager = new UserManager();
@@ -49,23 +66,26 @@ public class SecurityTest extends AbstractOMTest
{
randomizer.activate();
userManager.activate();
- userManager.addUser("stepper", "eike2007".toCharArray());
+ userManager.addUser(USER_ID, PASSWORD);
+
+ ResponseNegotiator client = new ResponseNegotiator();
+ client.setCredentialsProvider(credentialsProvider);
+ client.activate();
- ResponseNegotiator responseNegotiator = new ResponseNegotiator();
new Thread()
{
@Override
public void run()
{
- ChallengeNegotiator negotiator = new ChallengeNegotiator();
- negotiator.setRandomizer(randomizer);
- negotiator.setUserManager(userManager);
- negotiator.setTokenLength(1024);
+ ChallengeNegotiator server = new ChallengeNegotiator();
+ server.setRandomizer(randomizer);
+ server.setUserManager(userManager);
+ server.setTokenLength(1024);
try
{
- negotiator.activate();
- negotiator.startNegotiation(challengeContext);
+ server.activate();
+ server.startNegotiation(challengeContext);
NegotiationContext.State result = challengeContext.waitForResult(2000);
System.out.println(result);
}
@@ -76,7 +96,7 @@ public class SecurityTest extends AbstractOMTest
}
finally
{
- negotiator.deactivate();
+ server.deactivate();
}
}
}.start();
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 80d4160..46bde97 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
@@ -20,7 +20,7 @@ import java.nio.ByteBuffer;
/**
* @author Eike Stepper
*/
-public class ResponseNegotiator extends UserManagerNegotiator implements IChallengeResponse
+public class ResponseNegotiator extends Negotiator implements IChallengeResponse
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, ResponseNegotiator.class);