Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] open a client session when running a security manager
[CDO] open a client session when running a security manager [message #1229533] Thu, 09 January 2014 16:46 Go to next message
Laurent Le Moux is currently offline Laurent Le MouxFriend
Messages: 184
Registered: September 2011
Senior Member
Hi all,

I followed the security manager wiki and now I would like my CDO client to open a session using a login / password.

I tried to use the following URL : tcp://Administrator:0000@localhost:2036.
But I get the following exception :
java.lang.IllegalStateException: A user ID on this connector requires a negotiator

Is it the right way to connect to my repository ?
What negociator should be added to the acceptor declared in my cdo-server.xml, if any (none is actually declared in the security manager wiki...) ?

I tried to have a look to the sessions view code in CDO Git but could not find my way...

Kind regards,

Laurent
Re: [CDO] open a client session when running a security manager [message #1229541 is a reply to message #1229533] Thu, 09 January 2014 17:12 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 09.01.2014 17:46, schrieb Laurent Le Moux:
> Hi all,
>
> I followed the security manager wiki and now I would like my CDO client to open a session using a login / password.
You mean programmatically? Or via the CDO Sessions view?

> I tried to use the following URL : tcp://Administrator:0000@localhost:2036.
This URL can be used with the older Net4j authentication that is negotiator based. The wiki page mentioned above refers
to the newer CDO authentication. In many possible client configurations it would work out of the box. If it doesn't,
please tell us what you've tried.

In the CDO Sessions view's Open Session dialog you would enter:

tcp://localhost
repoName

If you followed the Security Manager tutorial a second dialog for the user credentials would pop up then.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



> But I get the following exception :
> java.lang.IllegalStateException: A user ID on this connector requires a negotiator
>
> Is it the right way to connect to my repository ?
> What negociator should be added to the acceptor declared in my cdo-server.xml, if any (none is actually declared in
> the security manager wiki...) ?
>
> I tried to have a look to the sessions view code in CDO Git but could not find my way...
>
> Kind regards,
>
> Laurent


Re: [CDO] open a client session when running a security manager [message #1229794 is a reply to message #1229541] Fri, 10 January 2014 08:22 Go to previous messageGo to next message
Laurent Le Moux is currently offline Laurent Le MouxFriend
Messages: 184
Registered: September 2011
Senior Member
Hi Eike,

I indeed want to connect to the repository programmatically, trying to achieve something similar to the CDO Sessions view behaviour (which works fine !).

With the security manager activated on the server side, I get a NotAuthenticatedException if I try to use the classical URL (tcp://localhost) without providing somehow the expected user login and password.

So my RCP application now starts with a login dialog but I don't know how to pass the login & password parameters now that the former authentication mecanism is not to be used anymore.

Please find hereafter the code of my LoginDialog#okPressed method that fails with an IllegalStateException : A user ID on this connector requires a negotiator.

	@Override
	protected void okPressed() {
		user = txtUser.getText();
		password = txtPassword.getText();

		Preferences preferences = DefaultScope.INSTANCE
				.getNode("AdministrationTool");
		try {
			if (!preferences.nodeExists("/default/AdministrationTool")) {
				ILog logger = Activator.getDefault().getLog();
				IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
						"Configuration file 'AdministrationTool.ini' not found.");
				logger.log(status);
				super.cancelPressed();
			} else {
				String cdoServerURI = preferences.get("Protocol", "") + "://"
						+ user + ":" + password + "@"
						+ preferences.get("ServerName", "") + ":"
						+ preferences.get("ServerPort", "");
				connector = Net4jUtil.getConnector(IPluginContainer.INSTANCE,
						cdoServerURI);
				CDONet4jSessionConfiguration sessionConfig = CDONet4jUtil
						.createNet4jSessionConfiguration();
				sessionConfig.setConnector(connector);
				sessionConfig.setRepositoryName(preferences.get("Repository",
						""));
				session = sessionConfig.openNet4jSession();
				context = EclipseContextFactory.getServiceContext(Activator
						.getContext());
				context.set("openedCDOSession", session);

				super.okPressed();
			}
		} catch (Exception e) {
			ILog logger = Activator.getDefault().getLog();
			IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
			logger.log(status);
			super.cancelPressed();
		}
	}


I also take the opportunity to wish you and the whole CDO team a happy new year and to thank you all for the great job you achieve.

Laurent
Re: [CDO] open a client session when running a security manager [message #1229818 is a reply to message #1229794] Fri, 10 January 2014 09:39 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 10.01.2014 09:22, schrieb Laurent Le Moux:
> Hi Eike,
>
> I indeed want to connect to the repository programmatically, trying to achieve something similar to the CDO Sessions
> view behaviour (which works fine !).
That is because it uses CDONet4jSessionFactory ;-)

>
> With the security manager activated on the server side, I get a NotAuthenticatedException if I try to use the
> classical URL (tcp://localhost) without providing somehow the expected user login and password.
>
> So my RCP application now starts with a login dialog but I don't know how to pass the login & password parameters now
> that the former authentication mecanism is not to be used anymore.
>
> Please find hereafter the code of my LoginDialog#okPressed method that fails with an IllegalStateException : A user ID
> on this connector requires a negotiator.
>
>
> @Override
> protected void okPressed() {
> user = txtUser.getText();
> password = txtPassword.getText();
>
> Preferences preferences = DefaultScope.INSTANCE
> .getNode("AdministrationTool");
> try {
> if (!preferences.nodeExists("/default/AdministrationTool")) {
> ILog logger = Activator.getDefault().getLog();
> IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
> "Configuration file 'AdministrationTool.ini' not found.");
> logger.log(status);
> super.cancelPressed();
> } else {
> String cdoServerURI = preferences.get("Protocol", "") + "://"
> + user + ":" + password + "@"
You shouldn't embed the password into this URL.

> + preferences.get("ServerName", "") + ":"
> + preferences.get("ServerPort", "");
> connector = Net4jUtil.getConnector(IPluginContainer.INSTANCE,
> cdoServerURI);
> CDONet4jSessionConfiguration sessionConfig = CDONet4jUtil
> .createNet4jSessionConfiguration();
> sessionConfig.setConnector(connector);
> sessionConfig.setRepositoryName(preferences.get("Repository",
> ""));
You should add this to get a popup dialog for the credentials (when they're needed):

IPasswordCredentialsProvider credentialsProvider =
(IPasswordCredentialsProvider)IPluginContainer.INSTANCE.getElement(CredentialsProviderFactory.PRODUCT_GROUP,
"interactive", null);
sessionConfig.setCredentialsProvider(credentialsProvider);

Or this for fixed credentials:

IPasswordCredentialsProvider credentialsProvider = new PasswordCredentialsProvider(user, password);
sessionConfig.setCredentialsProvider(credentialsProvider);


> session = sessionConfig.openNet4jSession();
> context = EclipseContextFactory.getServiceContext(Activator
> .getContext());
> context.set("openedCDOSession", session);
>
> super.okPressed();
> }
> } catch (Exception e) {
> ILog logger = Activator.getDefault().getLog();
> IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
> logger.log(status);
> super.cancelPressed();
> }
> }
>
>
> I also take the opportunity to wish you and the whole CDO team a happy new year and to thank you all for the great job
> you achieve.
Thanks a lot in the name of the team ;-)

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] open a client session when running a security manager [message #1229910 is a reply to message #1229818] Fri, 10 January 2014 14:22 Go to previous messageGo to next message
Laurent Le Moux is currently offline Laurent Le MouxFriend
Messages: 184
Registered: September 2011
Senior Member
Following your tips, my login dialog with fixed credentials is now working.
But I decided to use CDO popup dialog instead.
So I removed mine and changed Application#start the following way :

	public Object start(IApplicationContext context) throws Exception {
		Preferences preferences = DefaultScope.INSTANCE.getNode("AdministrationTool");
		if (!preferences.get("Repository", "").isEmpty()) {
			Display display = PlatformUI.createDisplay();
			String cdoServerURI = preferences.get("Protocol", "") + "://"
					+ preferences.get("ServerName", "") + ":" + preferences.get("ServerPort", "");
			connector = Net4jUtil.getConnector(IPluginContainer.INSTANCE, cdoServerURI);
			CDONet4jSessionConfiguration sessionConfig = CDONet4jUtil.createNet4jSessionConfiguration();
			sessionConfig.setConnector(connector);
			sessionConfig.setRepositoryName(preferences.get("Repository", ""));
			IPasswordCredentialsProvider credentialsProvider =
					(IPasswordCredentialsProvider)IPluginContainer.INSTANCE.getElement(CredentialsProviderFactory.PRODUCT_GROUP,
					"interactive", null);
			//IPasswordCredentialsProvider credentialsProvider = new PasswordCredentialsProvider("Administrator", "0000");
			sessionConfig.setCredentialsProvider(credentialsProvider);
			session = sessionConfig.openNet4jSession();
			IEclipseContext ctx = EclipseContextFactory.getServiceContext(Activator.getContext());
			ctx.set("openedCDOSession", session);
			try {
				int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
				if (returnCode == PlatformUI.RETURN_RESTART)
					return IApplication.EXIT_RESTART;
			} finally {
				display.dispose();
			}
		} else {
			ILog logger = Activator.getDefault().getLog();
			IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
					"Problem occured while loading configuration file 'AdministrationTool.ini'.");
			logger.log(status);			
		}
		return IApplication.EXIT_OK;
	}


With fixed and hardcoded credentials, it still works.
But, using the interactive credentials provider factory, the application immediately hangs at startup. No window opens, no message at all in the console, not even the workspace directory "runtime-AdministrationTool.product" is created.

The factory has been declared in plugin.xml as well as the org.eclipse.net4j.util.ui dependency :

   <extension
         point="org.eclipse.net4j.util.factories">
      <factory
            class="org.eclipse.net4j.util.internal.ui.InteractiveCredentialsProviderFactory"
            productGroup="org.eclipse.net4j.util.security.credentialsProviders"
            type="interactive">
      </factory>
   </extension>


Any idea why this is happening ?
Re: [CDO] open a client session when running a security manager [message #1229961 is a reply to message #1229910] Fri, 10 January 2014 17:01 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
So where does it get stuck?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] open a client session when running a security manager [message #1230044 is a reply to message #1229961] Fri, 10 January 2014 21:27 Go to previous messageGo to next message
Laurent Le Moux is currently offline Laurent Le MouxFriend
Messages: 184
Registered: September 2011
Senior Member
It gets stuck at : session = sessionConfig.openNet4jSession();
If I let it go, I finally get the following exception :
org.eclipse.emf.cdo.common.util.TransportException: java.util.concurrent.TimeoutException
	at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocol.send(CDOClientProtocol.java:511)
	at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocol.openSession(CDOClientProtocol.java:110)
	at org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionImpl.openSession(CDONet4jSessionImpl.java:244)
	at org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionImpl.doActivate(CDONet4jSessionImpl.java:139)
	at org.eclipse.net4j.util.lifecycle.Lifecycle.internalActivate(Lifecycle.java:76)
	at org.eclipse.net4j.util.lifecycle.ShareableLifecycle.internalActivate(ShareableLifecycle.java:43)
	at org.eclipse.net4j.util.lifecycle.Lifecycle.activate(Lifecycle.java:162)
	at org.eclipse.emf.internal.cdo.session.CDOSessionConfigurationImpl.openSession(CDOSessionConfigurationImpl.java:359)
	at org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionConfigurationImpl.openNet4jSession(CDONet4jSessionConfigurationImpl.java:104)
	at administrationtool.Application.start(Application.java:51)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: java.util.concurrent.TimeoutException
	at org.eclipse.net4j.util.io.IOTimeoutException.createTimeoutException(IOTimeoutException.java:46)
	at org.eclipse.net4j.signal.Signal.runSync(Signal.java:260)
	at org.eclipse.net4j.signal.SignalProtocol.startSignal(SignalProtocol.java:442)
	at org.eclipse.net4j.signal.RequestWithConfirmation.doSend(RequestWithConfirmation.java:89)
	at org.eclipse.net4j.signal.RequestWithConfirmation.send(RequestWithConfirmation.java:75)
	at org.eclipse.net4j.signal.RequestWithMonitoring.send(RequestWithMonitoring.java:97)
	at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocol.send(CDOClientProtocol.java:503)
	... 22 more
Caused by: org.eclipse.net4j.util.io.IOTimeoutException
	at org.eclipse.net4j.buffer.BufferInputStream.computeTimeout(BufferInputStream.java:216)
	at org.eclipse.net4j.buffer.BufferInputStream.ensureBuffer(BufferInputStream.java:189)
	at org.eclipse.net4j.buffer.BufferInputStream.read(BufferInputStream.java:116)
	at java.io.DataInputStream.readInt(Unknown Source)
	at org.eclipse.net4j.util.io.ExtendedDataInput$Delegating.readInt(ExtendedDataInput.java:100)
	at org.eclipse.emf.cdo.internal.net4j.protocol.OpenSessionRequest.confirming(OpenSessionRequest.java:109)
	at org.eclipse.emf.cdo.internal.net4j.protocol.OpenSessionRequest.confirming(OpenSessionRequest.java:1)
	at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientRequestWithMonitoring.confirming(CDOClientRequestWithMonitoring.java:124)
	at org.eclipse.net4j.signal.RequestWithMonitoring.confirming(RequestWithMonitoring.java:171)
	at org.eclipse.net4j.signal.RequestWithConfirmation.doExtendedInput(RequestWithConfirmation.java:125)
	at org.eclipse.net4j.signal.Signal.doInput(Signal.java:331)
	at org.eclipse.net4j.signal.RequestWithConfirmation.doExecute(RequestWithConfirmation.java:105)
	at org.eclipse.net4j.signal.RequestWithMonitoring.doExecute(RequestWithMonitoring.java:235)
	at org.eclipse.net4j.signal.SignalActor.execute(SignalActor.java:53)
	at org.eclipse.net4j.signal.Signal.runSync(Signal.java:256)
	... 27 more


and nothing on the server side...
Re: [CDO] open a client session when running a security manager [message #1232681 is a reply to message #1230044] Fri, 17 January 2014 13:37 Go to previous messageGo to next message
Laurent Le Moux is currently offline Laurent Le MouxFriend
Messages: 184
Registered: September 2011
Senior Member
Hi again,

I just spent again some time on my problem concerning interactive credentials setting.

Looking in CDO Git, it appears InteractiveCredentialsProvider#getCredentials internally calls UIUtil#getActiveWorkbenchWindow.
But, in my running context (in Application#start), the workbench is not yet started.
In fact, PlatformUI#createAndRunWorkbench gets called only after I'm trying to open a net4j session...

I guess the reason of my problem is as simple as that... Embarrassed

Regards,

Laurent
Re: [CDO] open a client session when running a security manager [message #1232707 is a reply to message #1232681] Fri, 17 January 2014 14:35 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 17.01.2014 14:37, schrieb Laurent Le Moux:
> Hi again,
>
> I just spent again some time on my problem concerning interactive credentials setting.
>
> Looking in CDO Git, it appears InteractiveCredentialsProvider#getCredentials internally calls
> UIUtil#getActiveWorkbenchWindow.
> But, in my running context (in Application#start), the workbench is not yet started.
> In fact, PlatformUI#createAndRunWorkbench gets called only after I'm trying to open a net4j session...
>
> I guess the reason of my problem is as simple as that... :blush:

Have you set a breakpoint and debugged that code? To me it seems that it should work even without an active workbench
window:

Shell shell;

try
{
IWorkbenchWindow window = UIUtil.getActiveWorkbenchWindow();
shell = window.getShell();
}
catch (Exception ex)
{
shell = new Shell(display);
}

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] open a client session when running a security manager [message #1233836 is a reply to message #1232707] Mon, 20 January 2014 15:58 Go to previous messageGo to next message
Laurent Le Moux is currently offline Laurent Le MouxFriend
Messages: 184
Registered: September 2011
Senior Member
Hi Eike,

I guess you're right...
I wanted to set a breakpoint but unfortunately I was not able to specify where to find the attached source code...

So I decided to install Eclipse Modeling Luna 4.4 M4 and tried a simple test RCP application (see attached zip file) but I still get the same problem.

I wonder if there's something wrong with my installation / configuration ?

Kind regards,

Laurent
Re: [CDO] open a client session when running a security manager [message #1242261 is a reply to message #1233836] Sun, 09 February 2014 08:30 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 20.01.2014 16:58, schrieb Laurent Le Moux:
> Hi Eike,
>
> I guess you're right...
> I wanted to set a breakpoint but unfortunately I was not able to specify where to find the attached source code...
>
> So I decided to install Eclipse Modeling Luna 4.4 M4 and tried a simple test RCP application (see attached zip file) but I still get the same problem.
>
> I wonder if there's something wrong with my installation / configuration ?
No, the bug is in your Application.start() method. If you move the PlatformUI.createDisplay() call *after* the
sessionConfig.openNet4jSession() call it works perfectly.

Explanation: The openNet4jSession() blocks the current thread until the server has sent the response to the
OpenSessionRequest. But with authentication the server first sends an AuthenticationRequest (Challenge) back to the
client, where it is executed on a background thread. If this execution involves the InteractiveCredentialsProvider, or
any other Display.syncExec() calls, you end up in a deadlock if the thread of the original OpenSessionRequest is the UI
thread.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] open a client session when running a security manager [message #1244064 is a reply to message #1242261] Tue, 11 February 2014 21:26 Go to previous message
Laurent Le Moux is currently offline Laurent Le MouxFriend
Messages: 184
Registered: September 2011
Senior Member
Hi Eike,

I had a similar issue when invoking session.changeCredentials() to let my user change his / her password.
Execution in a job distinct from the UI thread solved the problem.
So I thank you twice... Wink

Regards,

Laurent
Previous Topic:Adding Custom_ID to EObjects
Next Topic:[Xcore] Something wrong with casts?
Goto Forum:
  


Current Time: Sat Apr 20 02:53:22 GMT 2024

Powered by FUDForum. Page generated in 0.03796 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top