summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-05 10:12:33 (EDT)
committerEike Stepper2007-10-05 10:12:33 (EDT)
commit218cdbdc7a3e8cad6e0c102a215e393263ade1be (patch)
tree3a958a419155e499e07040a73f1ae41cdd01e779
parentc40df69c69f0bea41af2c962de289a1a943872eb (diff)
downloadcdo-218cdbdc7a3e8cad6e0c102a215e393263ade1be.zip
cdo-218cdbdc7a3e8cad6e0c102a215e393263ade1be.tar.gz
cdo-218cdbdc7a3e8cad6e0c102a215e393263ade1be.tar.bz2
[205027] Implement challenge/response based negotiator
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205027
-rw-r--r--features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/plugin.xml4
-rw-r--r--plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java7
-rw-r--r--plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ControlChannel.java5
-rw-r--r--plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java4
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SecurityTest.java5
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/security/CredentialsDialog.java75
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/security/InteractiveCredentialsProvider.java40
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java8
-rw-r--r--plugins/org.eclipse.net4j.util/plugin.xml12
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiatorConfigurer.java62
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiatorFactory.java29
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/FileUserManagerFactory.java33
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/NegotiatorFactory.java26
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/RandomizerFactory.java40
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiatorFactory.java29
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/UserManagerFactory.java26
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/ICredentialsProvider.java2
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/INegotiationContext.java2
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IPasswordCredentialsProvider.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Net4jConfigurator.java47
21 files changed, 450 insertions, 12 deletions
diff --git a/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml b/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml
index b12a08e..7f56a1b 100644
--- a/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml
+++ b/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<cdoServer>
- <acceptor type="tcp" listenAddr="0.0.0.0" port="2036"/>
+ <acceptor type="tcp" listenAddr="0.0.0.0" port="2036">
+ <negotiator type="challenge" description="/temp/users.db"/>
+ </acceptor>
<repository name="repo1">
<property name="overrideUUID" value="1ff5d226-b1f0-40fb-aba2-0c31b38c764f"/>
diff --git a/plugins/org.eclipse.emf.cdo.server/plugin.xml b/plugins/org.eclipse.emf.cdo.server/plugin.xml
index 1242aa9..680d314 100644
--- a/plugins/org.eclipse.emf.cdo.server/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.server/plugin.xml
@@ -26,6 +26,10 @@
productGroup="org.eclipse.net4j.serverProtocols"
type="cdo"
class="org.eclipse.emf.cdo.internal.server.protocol.CDOPluginProtocolFactory"/>
+ <factory
+ type="challenge"
+ productGroup="org.eclipse.net4j.Negotiators"
+ class="org.eclipse.net4j.internal.util.security.ChallengeNegotiatorFactory"/>
</extension>
<extension
diff --git a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java
index b3d744b..ba3ba25 100644
--- a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java
+++ b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java
@@ -14,6 +14,7 @@ import org.eclipse.net4j.ConnectorException;
import org.eclipse.net4j.IBuffer;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.IProtocol;
+import org.eclipse.net4j.util.security.INegotiationContext;
import org.eclipse.internal.net4j.Channel;
import org.eclipse.internal.net4j.Connector;
@@ -77,6 +78,12 @@ public abstract class JVMConnector extends Connector
}
@Override
+ protected INegotiationContext createNegotiationContext()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
protected void registerChannelWithPeer(int channelID, short channelIndex, IProtocol protocol)
throws ConnectorException
{
diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ControlChannel.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ControlChannel.java
index 7e3cf8e..79b450f 100644
--- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ControlChannel.java
+++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/ControlChannel.java
@@ -19,6 +19,7 @@ import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
import org.eclipse.net4j.util.concurrent.ISynchronizer;
import org.eclipse.net4j.util.security.INegotiationContext;
+import org.eclipse.net4j.util.security.INegotiationContext.Receiver;
import org.eclipse.internal.net4j.BufferUtil;
import org.eclipse.internal.net4j.Channel;
@@ -125,7 +126,9 @@ public final class ControlChannel extends Channel
ConcurrencyUtil.sleep(20);
negotiationContext = getConnector().getNegotiationContext();
}
- negotiationContext.getBuffer();
+
+ Receiver receiver = negotiationContext.getReceiver();
+ receiver.receiveBuffer(negotiationContext, byteBuffer);
break;
}
diff --git a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java
index 31646ca..981d04c 100644
--- a/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java
+++ b/plugins/org.eclipse.net4j.tcp/src/org/eclipse/net4j/internal/tcp/TCPConnector.java
@@ -391,6 +391,7 @@ public abstract class TCPConnector extends Connector implements ITCPConnector, I
{
IBuffer buffer = getBufferProvider().provideBuffer();
ByteBuffer byteBuffer = buffer.startPutting(ControlChannel.CONTROL_CHANNEL_INDEX);
+ byteBuffer.put(ControlChannel.OPCODE_NEGOTIATION);
buffers.put(byteBuffer, buffer);
return byteBuffer;
}
@@ -406,9 +407,12 @@ public abstract class TCPConnector extends Connector implements ITCPConnector, I
{
if (success)
{
+ setState(ConnectorState.CONNECTED);
}
else
{
+ OM.LOG.error("Connector negotiation failed: " + TCPConnector.this);
+ deactivate();
}
super.setFinished(success);
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 1bccea5..d4a4cba 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
@@ -43,6 +43,11 @@ public class SecurityTest extends AbstractOMTest
private IPasswordCredentialsProvider credentialsProvider = new IPasswordCredentialsProvider()
{
+ public boolean isInteractive()
+ {
+ return false;
+ }
+
public IPasswordCredentials getCredentials()
{
return CREDENTIALS;
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/security/CredentialsDialog.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/security/CredentialsDialog.java
new file mode 100644
index 0000000..6fc8689
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/security/CredentialsDialog.java
@@ -0,0 +1,75 @@
+/***************************************************************************
+ * 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.internal.ui.security;
+
+import org.eclipse.net4j.internal.util.security.PasswordCredentials;
+import org.eclipse.net4j.util.internal.ui.bundle.OM;
+import org.eclipse.net4j.util.security.IPasswordCredentials;
+import org.eclipse.net4j.util.ui.widgets.BaseDialog;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Eike Stepper
+ */
+public class CredentialsDialog extends BaseDialog<Viewer>
+{
+ private static final String TITLE = "Login";
+
+ private static final String MESSAGE = "Enter your user ID and password.";
+
+ private Text userIDControl;
+
+ private Text passwordControl;
+
+ private IPasswordCredentials credentials;
+
+ public CredentialsDialog()
+ {
+ super(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DEFAULT_SHELL_STYLE | SWT.APPLICATION_MODAL,
+ TITLE, MESSAGE, OM.Activator.INSTANCE.getDialogSettings());
+ }
+
+ public IPasswordCredentials getCredentials()
+ {
+ return credentials;
+ }
+
+ @Override
+ protected void createUI(Composite parent)
+ {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(2, false));
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ new Label(composite, SWT.NONE).setText("User ID:");
+ userIDControl = new Text(composite, SWT.BORDER);
+
+ new Label(composite, SWT.NONE).setText("Password:");
+ passwordControl = new Text(composite, SWT.BORDER | SWT.PASSWORD);
+ }
+
+ @Override
+ protected void okPressed()
+ {
+ String userID = userIDControl.getText();
+ String password = passwordControl.getText();
+ credentials = new PasswordCredentials(userID, password.toCharArray());
+ super.okPressed();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/security/InteractiveCredentialsProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/security/InteractiveCredentialsProvider.java
new file mode 100644
index 0000000..14d2eb3
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/internal/ui/security/InteractiveCredentialsProvider.java
@@ -0,0 +1,40 @@
+/***************************************************************************
+ * 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.internal.ui.security;
+
+import org.eclipse.net4j.util.security.IPasswordCredentials;
+import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
+
+/**
+ * @author Eike Stepper
+ */
+public class InteractiveCredentialsProvider implements IPasswordCredentialsProvider
+{
+ public InteractiveCredentialsProvider()
+ {
+ }
+
+ public boolean isInteractive()
+ {
+ return true;
+ }
+
+ public IPasswordCredentials getCredentials()
+ {
+ CredentialsDialog dialog = new CredentialsDialog();
+ if (dialog.open() == CredentialsDialog.OK)
+ {
+ return dialog.getCredentials();
+ }
+
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java
index 136deb8..9a612cb 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java
@@ -10,6 +10,9 @@
**************************************************************************/
package org.eclipse.net4j.util.ui;
+import org.eclipse.net4j.util.internal.ui.security.InteractiveCredentialsProvider;
+import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@@ -23,6 +26,11 @@ public final class UIUtil
{
}
+ public static IPasswordCredentialsProvider createInteractiveCredentialsProvider()
+ {
+ return new InteractiveCredentialsProvider();
+ }
+
public static Composite createGridComposite(Composite parent, int columns)
{
Composite composite = new Composite(parent, SWT.NONE);
diff --git a/plugins/org.eclipse.net4j.util/plugin.xml b/plugins/org.eclipse.net4j.util/plugin.xml
index 697c158..04e1992 100644
--- a/plugins/org.eclipse.net4j.util/plugin.xml
+++ b/plugins/org.eclipse.net4j.util/plugin.xml
@@ -19,5 +19,17 @@
<extension-point id="factories" name="Factories" schema="schema/factories.exsd"/>
<extension-point id="elementProcessors" name="Element Processors" schema="schema/elementProcessors.exsd"/>
+
+ <extension
+ point="org.eclipse.net4j.util.factories">
+ <factory
+ productGroup="org.eclipse.net4j.randomizers"
+ type="default"
+ class="org.eclipse.net4j.internal.util.security.RandomizerFactory"/>
+ <factory
+ productGroup="org.eclipse.net4j.userManagers"
+ type="file"
+ class="org.eclipse.net4j.internal.util.security.FileUserManagerFactory"/>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiatorConfigurer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiatorConfigurer.java
new file mode 100644
index 0000000..1eab18e
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiatorConfigurer.java
@@ -0,0 +1,62 @@
+/***************************************************************************
+ * 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.internal.util.security;
+
+import org.eclipse.net4j.util.container.IElementProcessor;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.security.IRandomizer;
+import org.eclipse.net4j.util.security.IUserManager;
+
+/**
+ * @author Eike Stepper
+ */
+public class ChallengeNegotiatorConfigurer implements IElementProcessor
+{
+ public ChallengeNegotiatorConfigurer()
+ {
+ }
+
+ public Object process(IManagedContainer container, String productGroup, String factoryType, String description,
+ Object element)
+ {
+ if (element instanceof ChallengeNegotiator)
+ {
+ ChallengeNegotiator negotiator = (ChallengeNegotiator)element;
+ if (negotiator.getRandomizer() == null)
+ {
+ IRandomizer randomizer = getRandomizer(container);
+ negotiator.setRandomizer(randomizer);
+ }
+
+ if (negotiator.getUserManager() == null)
+ {
+ IUserManager userManager = getUserManager(container, description);
+ negotiator.setUserManager(userManager);
+ }
+ }
+
+ return element;
+ }
+
+ protected IRandomizer getRandomizer(IManagedContainer container)
+ {
+ String productGroup = RandomizerFactory.PRODUCT_GROUP;
+ String type = RandomizerFactory.TYPE;
+ return (IRandomizer)container.getElement(productGroup, type, null);
+ }
+
+ protected IUserManager getUserManager(IManagedContainer container, String fileName)
+ {
+ String productGroup = FileUserManagerFactory.PRODUCT_GROUP;
+ String type = FileUserManagerFactory.TYPE;
+ return (IUserManager)container.getElement(productGroup, type, fileName);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiatorFactory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiatorFactory.java
new file mode 100644
index 0000000..4add97e
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiatorFactory.java
@@ -0,0 +1,29 @@
+/***************************************************************************
+ * 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.internal.util.security;
+
+/**
+ * @author Eike Stepper
+ */
+public class ChallengeNegotiatorFactory extends NegotiatorFactory
+{
+ public static final String TYPE = "challenge";
+
+ public ChallengeNegotiatorFactory()
+ {
+ super(TYPE);
+ }
+
+ public ChallengeNegotiator create(String description)
+ {
+ return new ChallengeNegotiator();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/FileUserManagerFactory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/FileUserManagerFactory.java
new file mode 100644
index 0000000..569a7c0
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/FileUserManagerFactory.java
@@ -0,0 +1,33 @@
+/***************************************************************************
+ * 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.internal.util.security;
+
+/**
+ * TODO Consider file attributes when creating initially empty file
+ *
+ * @author Eike Stepper
+ */
+public class FileUserManagerFactory extends UserManagerFactory
+{
+ public static final String TYPE = "file";
+
+ public FileUserManagerFactory()
+ {
+ super(TYPE);
+ }
+
+ public FileUserManager create(String description)
+ {
+ FileUserManager userManager = new FileUserManager();
+ userManager.setFileName(description);
+ return userManager;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/NegotiatorFactory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/NegotiatorFactory.java
new file mode 100644
index 0000000..264bd44
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/NegotiatorFactory.java
@@ -0,0 +1,26 @@
+/***************************************************************************
+ * 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.internal.util.security;
+
+import org.eclipse.net4j.internal.util.factory.Factory;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class NegotiatorFactory extends Factory
+{
+ public static final String PRODUCT_GROUP = "org.eclipse.net4j.Negotiators";
+
+ public NegotiatorFactory(String type)
+ {
+ super(PRODUCT_GROUP, type);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/RandomizerFactory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/RandomizerFactory.java
new file mode 100644
index 0000000..3d78ca6
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/RandomizerFactory.java
@@ -0,0 +1,40 @@
+/***************************************************************************
+ * 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.internal.util.security;
+
+import org.eclipse.net4j.internal.util.factory.Factory;
+import org.eclipse.net4j.util.factory.ProductCreationException;
+
+/**
+ * @author Eike Stepper
+ */
+public class RandomizerFactory extends Factory
+{
+ public static final String PRODUCT_GROUP = "org.eclipse.net4j.randomizers";
+
+ public static final String TYPE = "default";
+
+ public RandomizerFactory(String type)
+ {
+ super(PRODUCT_GROUP, type);
+ }
+
+ public Randomizer create(String description) throws ProductCreationException
+ {
+ Randomizer randomizer = new Randomizer();
+ if (description != null)
+ {
+ randomizer.setAlgorithmName(description);
+ }
+
+ return randomizer;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiatorFactory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiatorFactory.java
new file mode 100644
index 0000000..82fa0e2
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiatorFactory.java
@@ -0,0 +1,29 @@
+/***************************************************************************
+ * 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.internal.util.security;
+
+/**
+ * @author Eike Stepper
+ */
+public class ResponseNegotiatorFactory extends NegotiatorFactory
+{
+ public static final String TYPE = "response";
+
+ public ResponseNegotiatorFactory()
+ {
+ super(TYPE);
+ }
+
+ public ResponseNegotiator create(String description)
+ {
+ return new ResponseNegotiator();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/UserManagerFactory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/UserManagerFactory.java
new file mode 100644
index 0000000..8419af7
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/UserManagerFactory.java
@@ -0,0 +1,26 @@
+/***************************************************************************
+ * 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.internal.util.security;
+
+import org.eclipse.net4j.internal.util.factory.Factory;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class UserManagerFactory extends Factory
+{
+ public static final String PRODUCT_GROUP = "org.eclipse.net4j.userManagers";
+
+ public UserManagerFactory(String type)
+ {
+ super(PRODUCT_GROUP, type);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/ICredentialsProvider.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/ICredentialsProvider.java
index 6990167..7ce75cf 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/ICredentialsProvider.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/ICredentialsProvider.java
@@ -15,5 +15,7 @@ package org.eclipse.net4j.util.security;
*/
public interface ICredentialsProvider
{
+ public boolean isInteractive();
+
public ICredentials getCredentials();
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/INegotiationContext.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/INegotiationContext.java
index dca0282..9840fac 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/INegotiationContext.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/INegotiationContext.java
@@ -21,6 +21,8 @@ public interface INegotiationContext
public void transmitBuffer(ByteBuffer buffer);
+ public Receiver getReceiver();
+
public void setReceiver(Receiver receiver);
public Enum<?> getState();
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
index fcf14d5..2e0aef6 100644
--- 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
@@ -13,7 +13,7 @@ package org.eclipse.net4j.util.security;
/**
* @author Eike Stepper
*/
-public interface IPasswordCredentialsProvider
+public interface IPasswordCredentialsProvider extends ICredentialsProvider
{
public IPasswordCredentials getCredentials();
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Net4jConfigurator.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Net4jConfigurator.java
index d35fe35..f72cf03 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Net4jConfigurator.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/Net4jConfigurator.java
@@ -12,7 +12,9 @@ package org.eclipse.internal.net4j;
import org.eclipse.net4j.IAcceptor;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
+import org.eclipse.net4j.internal.util.security.NegotiatorFactory;
import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.security.INegotiator;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.internal.net4j.bundle.OM;
@@ -63,22 +65,49 @@ public class Net4jConfigurator
List<IAcceptor> acceptors = new ArrayList<IAcceptor>();
Document document = getDocument(configFile);
- NodeList elements = document.getElementsByTagName("acceptor");
- for (int i = 0; i < elements.getLength(); i++)
+ NodeList acceptorConfigs = document.getElementsByTagName("acceptor");
+ for (int i = 0; i < acceptorConfigs.getLength(); i++)
{
- Element acceptorConfig = (Element)elements.item(i);
- String type = acceptorConfig.getAttribute("type");
- String listenAddr = acceptorConfig.getAttribute("listenAddr");
- String port = acceptorConfig.getAttribute("port");
- String description = (listenAddr == null ? "" : listenAddr) + (port == null ? "" : ":" + port);
-
- IAcceptor acceptor = (IAcceptor)container.getElement(AcceptorFactory.PRODUCT_GROUP, type, description);
+ Element acceptorConfig = (Element)acceptorConfigs.item(i);
+ IAcceptor acceptor = configureAcceptor(acceptorConfig);
acceptors.add(acceptor);
}
return acceptors.toArray(new IAcceptor[acceptors.size()]);
}
+ protected IAcceptor configureAcceptor(Element acceptorConfig)
+ {
+ String type = acceptorConfig.getAttribute("type");
+ String listenAddr = acceptorConfig.getAttribute("listenAddr");
+ String port = acceptorConfig.getAttribute("port");
+ String description = (listenAddr == null ? "" : listenAddr) + (port == null ? "" : ":" + port);
+ Acceptor acceptor = (Acceptor)container.getElement(AcceptorFactory.PRODUCT_GROUP, type, description);
+
+ NodeList negotiatorConfigs = acceptorConfig.getElementsByTagName("negotiator");
+ if (negotiatorConfigs.getLength() > 1)
+ {
+ throw new IllegalStateException("A maximum of one negotiator can be configured for acceptor " + acceptor);
+ }
+
+ if (negotiatorConfigs.getLength() == 1)
+ {
+ Element negotiatorConfig = (Element)negotiatorConfigs.item(0);
+ INegotiator negotiator = configureNegotiator(negotiatorConfig);
+ acceptor.setNegotiator(negotiator);
+ }
+
+ return acceptor;
+ }
+
+ protected INegotiator configureNegotiator(Element negotiatorConfig)
+ {
+ String type = negotiatorConfig.getAttribute("type");
+ String description = negotiatorConfig.getAttribute("description");
+ INegotiator negotiator = (INegotiator)container.getElement(NegotiatorFactory.PRODUCT_GROUP, type, description);
+ return negotiator;
+ }
+
protected Document getDocument(File configFile) throws ParserConfigurationException, SAXException, IOException
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();