Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-06-11 05:49:15 +0000
committerEike Stepper2012-06-11 05:49:15 +0000
commitf1db8cd1815ae61d194044ddad8d6ae0fea15cdc (patch)
treefe65873c47124c3baef1745e5224c5803a10dec0 /plugins
parent912124f7f602c766f25ededa9af1e51c459503be (diff)
downloadcdo-f1db8cd1815ae61d194044ddad8d6ae0fea15cdc.tar.gz
cdo-f1db8cd1815ae61d194044ddad8d6ae0fea15cdc.tar.xz
cdo-f1db8cd1815ae61d194044ddad8d6ae0fea15cdc.zip
[380629] Design a default Security model
https://bugs.eclipse.org/bugs/show_bug.cgi?id=380629
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/NotAuthenticatedException.java41
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionImpl.java619
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/AuthenticationIndication.java203
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/OpenSessionRequest.java424
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/AuthenticationRequest.java129
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/OpenSessionIndication.java347
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.admin/src/org/eclipse/emf/cdo/ui/internal/admin/CDOAdminView.java37
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java49
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOAuthenticatorImpl.java217
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionIndication.java162
11 files changed, 1207 insertions, 1035 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/NotAuthenticatedException.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/NotAuthenticatedException.java
new file mode 100644
index 0000000000..f2f64b20f0
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/NotAuthenticatedException.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.emf.cdo.common.util;
+
+/**
+ * An unchecked {@link SecurityException security exception} indicating that a user has canceled an attempt to authenticate himself.
+ *
+ * @author Eike Stepper
+ * @since 4.1
+ */
+public class NotAuthenticatedException extends SecurityException
+{
+ private static final long serialVersionUID = 1L;
+
+ public NotAuthenticatedException()
+ {
+ }
+
+ public NotAuthenticatedException(String s)
+ {
+ super(s);
+ }
+
+ public NotAuthenticatedException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public NotAuthenticatedException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionImpl.java
index 754d908af1..97d812f51b 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionImpl.java
@@ -1,304 +1,315 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Simon McDuff - bug 226778
- * Simon McDuff - bug 230832
- * Simon McDuff - bug 233490
- * Simon McDuff - bug 213402
- * Victor Roldan Betancort - maintenance
- * Andre Dietisheim - bug 256649
- */
-package org.eclipse.emf.cdo.internal.net4j;
-
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.internal.common.model.CDOPackageRegistryImpl;
-import org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionConfigurationImpl.RepositoryInfo;
-import org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocol;
-import org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactionRequest;
-import org.eclipse.emf.cdo.net4j.CDONet4jSession;
-import org.eclipse.emf.cdo.net4j.CDOSession;
-import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
-import org.eclipse.emf.cdo.spi.common.commit.CDOCommitInfoUtil;
-import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-
-import org.eclipse.emf.internal.cdo.session.CDOSessionImpl;
-import org.eclipse.emf.internal.cdo.session.DelegatingSessionProtocol;
-
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.signal.ISignalProtocol;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.util.io.IStreamWrapper;
-
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.OpenSessionResult;
-
-/**
- * @author Eike Stepper
- */
-@SuppressWarnings("deprecation")
-public class CDONet4jSessionImpl extends CDOSessionImpl implements org.eclipse.emf.cdo.net4j.CDOSession
-{
- private IStreamWrapper streamWrapper;
-
- private IConnector connector;
-
- private String repositoryName;
-
- private long signalTimeout = SignalProtocol.DEFAULT_TIMEOUT;
-
- public CDONet4jSessionImpl()
- {
- }
-
- public IStreamWrapper getStreamWrapper()
- {
- return streamWrapper;
- }
-
- public void setStreamWrapper(IStreamWrapper streamWrapper)
- {
- this.streamWrapper = streamWrapper;
- }
-
- public IConnector getConnector()
- {
- return connector;
- }
-
- public void setConnector(IConnector connector)
- {
- this.connector = connector;
- }
-
- public String getRepositoryName()
- {
- return repositoryName;
- }
-
- public void setRepositoryName(String repositoryName)
- {
- this.repositoryName = repositoryName;
- }
-
- public long getSignalTimeout()
- {
- return signalTimeout;
- }
-
- public void setSignalTimeout(long signalTimeout)
- {
- this.signalTimeout = signalTimeout;
-
- // Deal with the possibility that the sessionProtocol has already been created.
- CDOClientProtocol clientProtocol = getClientProtocol();
- if (clientProtocol != null)
- {
- clientProtocol.setTimeout(this.signalTimeout);
- }
- }
-
- @Override
- public OptionsImpl options()
- {
- return (OptionsImpl)super.options();
- }
-
- @Override
- protected OptionsImpl createOptions()
- {
- return new OptionsImpl();
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- OpenSessionResult result = openSession();
-
- super.doActivate();
-
- InternalCDOPackageRegistry packageRegistry = getPackageRegistry();
- if (packageRegistry == null)
- {
- packageRegistry = new CDOPackageRegistryImpl();
- setPackageRegistry(packageRegistry);
- }
-
- packageRegistry.setPackageProcessor(this);
- packageRegistry.setPackageLoader(this);
- packageRegistry.activate();
-
- InternalCDORevisionManager revisionManager = getRevisionManager();
- if (revisionManager == null)
- {
- revisionManager = (InternalCDORevisionManager)CDORevisionUtil.createRevisionManager();
- setRevisionManager(revisionManager);
- }
-
- revisionManager.setSupportingAudits(getRepositoryInfo().isSupportingAudits());
- revisionManager.setSupportingBranches(getRepositoryInfo().isSupportingBranches());
- revisionManager.setRevisionLoader(getSessionProtocol());
- revisionManager.setRevisionLocker(this);
- revisionManager.activate();
-
- InternalCDOBranchManager branchManager = getBranchManager();
- if (branchManager == null)
- {
- branchManager = CDOBranchUtil.createBranchManager();
- setBranchManager(branchManager);
- }
-
- branchManager.setBranchLoader(getSessionProtocol());
- branchManager.setTimeProvider(getRepositoryInfo());
- branchManager.initMainBranch(isMainBranchLocal(), getRepositoryInfo().getCreationTime());
- branchManager.activate();
-
- InternalCDOCommitInfoManager commitInfoManager = getCommitInfoManager();
- if (commitInfoManager == null)
- {
- commitInfoManager = CDOCommitInfoUtil.createCommitInfoManager();
- setCommitInfoManager(commitInfoManager);
- }
-
- commitInfoManager.setCommitInfoLoader(getSessionProtocol());
- commitInfoManager.activate();
-
- for (InternalCDOPackageUnit packageUnit : result.getPackageUnits())
- {
- getPackageRegistry().putPackageUnit(packageUnit);
- }
-
- getRepositoryInfo().getTimeStamp(true);
- }
-
- private CDOClientProtocol createProtocol()
- {
- CDOClientProtocol protocol = new CDOClientProtocol();
- protocol.setTimeout(signalTimeout);
- protocol.setInfraStructure(this);
- if (streamWrapper != null)
- {
- protocol.setStreamWrapper(streamWrapper);
- }
-
- protocol.open(connector);
- return protocol;
- }
-
- /**
- * Gets the CDOClientProtocol instance, which may be wrapped inside a DelegatingSessionProtocol
- */
- private CDOClientProtocol getClientProtocol()
- {
- CDOSessionProtocol protocol = getSessionProtocol();
- CDOClientProtocol clientProtocol;
- if (protocol instanceof DelegatingSessionProtocol)
- {
- clientProtocol = (CDOClientProtocol)((DelegatingSessionProtocol)protocol).getDelegate();
- }
- else
- {
- clientProtocol = (CDOClientProtocol)protocol;
- }
-
- return clientProtocol;
- }
-
- protected OpenSessionResult openSession()
- {
- CDOClientProtocol protocol = createProtocol();
- setSessionProtocol(protocol);
- hookSessionProtocol();
-
- // TODO (CD) The next call is on the CDOClientProtocol; shouldn't it be on the DelegatingSessionProtocol instead?
- OpenSessionResult result = protocol.openSession(repositoryName, options().isPassiveUpdateEnabled(), options()
- .getPassiveUpdateMode(), options().getLockNotificationMode());
-
- setSessionID(result.getSessionID());
- setUserID(result.getUserID());
- setLastUpdateTime(result.getLastUpdateTime());
- setRepositoryInfo(new RepositoryInfo(repositoryName, result, this));
- return result;
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- super.doDeactivate();
-
- getCommitInfoManager().deactivate();
- getRevisionManager().deactivate();
- getBranchManager().deactivate();
- getPackageRegistry().deactivate();
- }
-
- /**
- * @author Eike Stepper
- */
- protected class OptionsImpl extends org.eclipse.emf.internal.cdo.session.CDOSessionImpl.OptionsImpl implements
- org.eclipse.emf.cdo.net4j.CDOSession.Options
- {
- private int commitTimeout = CommitTransactionRequest.DEFAULT_MONITOR_TIMEOUT_SECONDS;
-
- private int progressInterval = CommitTransactionRequest.DEFAULT_MONITOR_PROGRESS_SECONDS;
-
- public OptionsImpl()
- {
- }
-
- @Override
- public CDONet4jSession getContainer()
- {
- return (CDONet4jSession)super.getContainer();
- }
-
- public ISignalProtocol<org.eclipse.emf.cdo.net4j.CDONet4jSession> getNet4jProtocol()
- {
- CDOSessionProtocol protocol = getSessionProtocol();
- if (protocol instanceof DelegatingSessionProtocol)
- {
- protocol = ((DelegatingSessionProtocol)protocol).getDelegate();
- }
-
- @SuppressWarnings("unchecked")
- ISignalProtocol<CDONet4jSession> signalProtocol = (ISignalProtocol<CDONet4jSession>)protocol;
- return signalProtocol;
- }
-
- public ISignalProtocol<CDOSession> getProtocol()
- {
- @SuppressWarnings("unchecked")
- ISignalProtocol<CDOSession> net4jProtocol = (ISignalProtocol<CDOSession>)(ISignalProtocol<?>)getNet4jProtocol();
- return net4jProtocol;
- }
-
- public int getCommitTimeout()
- {
- return commitTimeout;
- }
-
- public synchronized void setCommitTimeout(int commitTimeout)
- {
- this.commitTimeout = commitTimeout;
- }
-
- public int getProgressInterval()
- {
- return progressInterval;
- }
-
- public synchronized void setProgressInterval(int progressInterval)
- {
- this.progressInterval = progressInterval;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * Simon McDuff - bug 226778
+ * Simon McDuff - bug 230832
+ * Simon McDuff - bug 233490
+ * Simon McDuff - bug 213402
+ * Victor Roldan Betancort - maintenance
+ * Andre Dietisheim - bug 256649
+ */
+package org.eclipse.emf.cdo.internal.net4j;
+
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.common.util.NotAuthenticatedException;
+import org.eclipse.emf.cdo.internal.common.model.CDOPackageRegistryImpl;
+import org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionConfigurationImpl.RepositoryInfo;
+import org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocol;
+import org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactionRequest;
+import org.eclipse.emf.cdo.net4j.CDONet4jSession;
+import org.eclipse.emf.cdo.net4j.CDOSession;
+import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
+import org.eclipse.emf.cdo.spi.common.commit.CDOCommitInfoUtil;
+import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
+
+import org.eclipse.emf.internal.cdo.session.CDOSessionImpl;
+import org.eclipse.emf.internal.cdo.session.DelegatingSessionProtocol;
+
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.signal.ISignalProtocol;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.io.IStreamWrapper;
+
+import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
+import org.eclipse.emf.spi.cdo.CDOSessionProtocol.OpenSessionResult;
+
+/**
+ * @author Eike Stepper
+ */
+@SuppressWarnings("deprecation")
+public class CDONet4jSessionImpl extends CDOSessionImpl implements org.eclipse.emf.cdo.net4j.CDOSession
+{
+ private IStreamWrapper streamWrapper;
+
+ private IConnector connector;
+
+ private String repositoryName;
+
+ private long signalTimeout = SignalProtocol.DEFAULT_TIMEOUT;
+
+ public CDONet4jSessionImpl()
+ {
+ }
+
+ public IStreamWrapper getStreamWrapper()
+ {
+ return streamWrapper;
+ }
+
+ public void setStreamWrapper(IStreamWrapper streamWrapper)
+ {
+ this.streamWrapper = streamWrapper;
+ }
+
+ public IConnector getConnector()
+ {
+ return connector;
+ }
+
+ public void setConnector(IConnector connector)
+ {
+ this.connector = connector;
+ }
+
+ public String getRepositoryName()
+ {
+ return repositoryName;
+ }
+
+ public void setRepositoryName(String repositoryName)
+ {
+ this.repositoryName = repositoryName;
+ }
+
+ public long getSignalTimeout()
+ {
+ return signalTimeout;
+ }
+
+ public void setSignalTimeout(long signalTimeout)
+ {
+ this.signalTimeout = signalTimeout;
+
+ // Deal with the possibility that the sessionProtocol has already been created.
+ CDOClientProtocol clientProtocol = getClientProtocol();
+ if (clientProtocol != null)
+ {
+ clientProtocol.setTimeout(this.signalTimeout);
+ }
+ }
+
+ @Override
+ public OptionsImpl options()
+ {
+ return (OptionsImpl)super.options();
+ }
+
+ @Override
+ protected OptionsImpl createOptions()
+ {
+ return new OptionsImpl();
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ OpenSessionResult result = openSession();
+ if (result == null)
+ {
+ throw new NotAuthenticatedException();
+ }
+
+ super.doActivate();
+
+ InternalCDOPackageRegistry packageRegistry = getPackageRegistry();
+ if (packageRegistry == null)
+ {
+ packageRegistry = new CDOPackageRegistryImpl();
+ setPackageRegistry(packageRegistry);
+ }
+
+ packageRegistry.setPackageProcessor(this);
+ packageRegistry.setPackageLoader(this);
+ packageRegistry.activate();
+
+ InternalCDORevisionManager revisionManager = getRevisionManager();
+ if (revisionManager == null)
+ {
+ revisionManager = (InternalCDORevisionManager)CDORevisionUtil.createRevisionManager();
+ setRevisionManager(revisionManager);
+ }
+
+ revisionManager.setSupportingAudits(getRepositoryInfo().isSupportingAudits());
+ revisionManager.setSupportingBranches(getRepositoryInfo().isSupportingBranches());
+ revisionManager.setRevisionLoader(getSessionProtocol());
+ revisionManager.setRevisionLocker(this);
+ revisionManager.activate();
+
+ InternalCDOBranchManager branchManager = getBranchManager();
+ if (branchManager == null)
+ {
+ branchManager = CDOBranchUtil.createBranchManager();
+ setBranchManager(branchManager);
+ }
+
+ branchManager.setBranchLoader(getSessionProtocol());
+ branchManager.setTimeProvider(getRepositoryInfo());
+ branchManager.initMainBranch(isMainBranchLocal(), getRepositoryInfo().getCreationTime());
+ branchManager.activate();
+
+ InternalCDOCommitInfoManager commitInfoManager = getCommitInfoManager();
+ if (commitInfoManager == null)
+ {
+ commitInfoManager = CDOCommitInfoUtil.createCommitInfoManager();
+ setCommitInfoManager(commitInfoManager);
+ }
+
+ commitInfoManager.setCommitInfoLoader(getSessionProtocol());
+ commitInfoManager.activate();
+
+ for (InternalCDOPackageUnit packageUnit : result.getPackageUnits())
+ {
+ getPackageRegistry().putPackageUnit(packageUnit);
+ }
+
+ getRepositoryInfo().getTimeStamp(true);
+ }
+
+ private CDOClientProtocol createProtocol()
+ {
+ CDOClientProtocol protocol = new CDOClientProtocol();
+ protocol.setTimeout(signalTimeout);
+ protocol.setInfraStructure(this);
+ if (streamWrapper != null)
+ {
+ protocol.setStreamWrapper(streamWrapper);
+ }
+
+ protocol.open(connector);
+ return protocol;
+ }
+
+ /**
+ * Gets the CDOClientProtocol instance, which may be wrapped inside a DelegatingSessionProtocol
+ */
+ private CDOClientProtocol getClientProtocol()
+ {
+ CDOSessionProtocol protocol = getSessionProtocol();
+ CDOClientProtocol clientProtocol;
+ if (protocol instanceof DelegatingSessionProtocol)
+ {
+ clientProtocol = (CDOClientProtocol)((DelegatingSessionProtocol)protocol).getDelegate();
+ }
+ else
+ {
+ clientProtocol = (CDOClientProtocol)protocol;
+ }
+
+ return clientProtocol;
+ }
+
+ protected OpenSessionResult openSession()
+ {
+ CDOClientProtocol protocol = createProtocol();
+ setSessionProtocol(protocol);
+ hookSessionProtocol();
+
+ // TODO (CD) The next call is on the CDOClientProtocol; shouldn't it be on the DelegatingSessionProtocol instead?
+ OpenSessionResult result = protocol.openSession(repositoryName, options().isPassiveUpdateEnabled(), options()
+ .getPassiveUpdateMode(), options().getLockNotificationMode());
+
+ if (result == null)
+ {
+ // Skip to response because the user has canceled the authentication
+ return null;
+ }
+
+ setSessionID(result.getSessionID());
+ setUserID(result.getUserID());
+ setLastUpdateTime(result.getLastUpdateTime());
+ setRepositoryInfo(new RepositoryInfo(repositoryName, result, this));
+ return result;
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ super.doDeactivate();
+
+ getCommitInfoManager().deactivate();
+ getRevisionManager().deactivate();
+ getBranchManager().deactivate();
+ getPackageRegistry().deactivate();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ protected class OptionsImpl extends org.eclipse.emf.internal.cdo.session.CDOSessionImpl.OptionsImpl implements
+ org.eclipse.emf.cdo.net4j.CDOSession.Options
+ {
+ private int commitTimeout = CommitTransactionRequest.DEFAULT_MONITOR_TIMEOUT_SECONDS;
+
+ private int progressInterval = CommitTransactionRequest.DEFAULT_MONITOR_PROGRESS_SECONDS;
+
+ public OptionsImpl()
+ {
+ }
+
+ @Override
+ public CDONet4jSession getContainer()
+ {
+ return (CDONet4jSession)super.getContainer();
+ }
+
+ public ISignalProtocol<org.eclipse.emf.cdo.net4j.CDONet4jSession> getNet4jProtocol()
+ {
+ CDOSessionProtocol protocol = getSessionProtocol();
+ if (protocol instanceof DelegatingSessionProtocol)
+ {
+ protocol = ((DelegatingSessionProtocol)protocol).getDelegate();
+ }
+
+ @SuppressWarnings("unchecked")
+ ISignalProtocol<CDONet4jSession> signalProtocol = (ISignalProtocol<CDONet4jSession>)protocol;
+ return signalProtocol;
+ }
+
+ public ISignalProtocol<CDOSession> getProtocol()
+ {
+ @SuppressWarnings("unchecked")
+ ISignalProtocol<CDOSession> net4jProtocol = (ISignalProtocol<CDOSession>)(ISignalProtocol<?>)getNet4jProtocol();
+ return net4jProtocol;
+ }
+
+ public int getCommitTimeout()
+ {
+ return commitTimeout;
+ }
+
+ public synchronized void setCommitTimeout(int commitTimeout)
+ {
+ this.commitTimeout = commitTimeout;
+ }
+
+ public int getProgressInterval()
+ {
+ return progressInterval;
+ }
+
+ public synchronized void setProgressInterval(int progressInterval)
+ {
+ this.progressInterval = progressInterval;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/AuthenticationIndication.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/AuthenticationIndication.java
index f2147739d2..361377c551 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/AuthenticationIndication.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/AuthenticationIndication.java
@@ -1,101 +1,102 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.common.CDOAuthenticationResult;
-
-import org.eclipse.net4j.signal.IndicationWithMonitoring;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
-
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
-/**
- * @author Eike Stepper
- */
-public class AuthenticationIndication extends IndicationWithMonitoring
-{
- private byte[] randomToken;
-
- public AuthenticationIndication(SignalProtocol<?> protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_AUTHENTICATION);
- }
-
- @Override
- public CDOClientProtocol getProtocol()
- {
- return (CDOClientProtocol)super.getProtocol();
- }
-
- protected InternalCDOSession getSession()
- {
- return (InternalCDOSession)getProtocol().getSession();
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
- {
- randomToken = in.readByteArray();
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
- {
- monitor.begin();
- Async async = monitor.forkAsync();
-
- try
- {
- CDOAuthenticator authenticator = getSession().getAuthenticator();
- if (authenticator == null)
- {
- throw new IllegalStateException("No authenticator configured"); //$NON-NLS-1$
- }
-
- CDOAuthenticationResult result = authenticator.authenticate(randomToken);
- if (result == null)
- {
- throw new SecurityException("Not authenticated"); //$NON-NLS-1$
- }
-
- String userID = result.getUserID();
- if (userID == null)
- {
- throw new SecurityException("No user ID"); //$NON-NLS-1$
- }
-
- byte[] cryptedToken = result.getCryptedToken();
- if (cryptedToken == null)
- {
- throw new SecurityException("No crypted token"); //$NON-NLS-1$
- }
-
- out.writeBoolean(true);
- result.write(out);
- }
- catch (Exception ex)
- {
- out.writeBoolean(false);
- throw ex;
- }
- finally
- {
- async.stop();
- monitor.done();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.emf.cdo.internal.net4j.protocol;
+
+import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
+import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.spi.common.CDOAuthenticationResult;
+
+import org.eclipse.net4j.signal.IndicationWithMonitoring;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
+
+import org.eclipse.emf.spi.cdo.InternalCDOSession;
+
+/**
+ * @author Eike Stepper
+ */
+public class AuthenticationIndication extends IndicationWithMonitoring
+{
+ private byte[] randomToken;
+
+ public AuthenticationIndication(SignalProtocol<?> protocol)
+ {
+ super(protocol, CDOProtocolConstants.SIGNAL_AUTHENTICATION);
+ }
+
+ @Override
+ public CDOClientProtocol getProtocol()
+ {
+ return (CDOClientProtocol)super.getProtocol();
+ }
+
+ protected InternalCDOSession getSession()
+ {
+ return (InternalCDOSession)getProtocol().getSession();
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
+ {
+ randomToken = in.readByteArray();
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
+ {
+ monitor.begin();
+ Async async = monitor.forkAsync();
+
+ try
+ {
+ CDOAuthenticator authenticator = getSession().getAuthenticator();
+ if (authenticator == null)
+ {
+ throw new IllegalStateException("No authenticator configured"); //$NON-NLS-1$
+ }
+
+ CDOAuthenticationResult result = authenticator.authenticate(randomToken);
+ if (result == null)
+ {
+ out.writeBoolean(false);
+ return;
+ }
+
+ String userID = result.getUserID();
+ if (userID == null)
+ {
+ throw new SecurityException("No user ID"); //$NON-NLS-1$
+ }
+
+ byte[] cryptedToken = result.getCryptedToken();
+ if (cryptedToken == null)
+ {
+ throw new SecurityException("No crypted token"); //$NON-NLS-1$
+ }
+
+ out.writeBoolean(true);
+ result.write(out);
+ }
+ catch (Exception ex)
+ {
+ out.writeBoolean(false);
+ throw ex;
+ }
+ finally
+ {
+ async.stop();
+ monitor.done();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/OpenSessionRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/OpenSessionRequest.java
index d51eef58a5..38c013b4b3 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/OpenSessionRequest.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/OpenSessionRequest.java
@@ -1,209 +1,215 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Simon McDuff - bug 230832
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository;
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.LockNotificationMode;
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOID.ObjectType;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.OpenSessionResult;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class OpenSessionRequest extends CDOClientRequestWithMonitoring<OpenSessionResult>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, OpenSessionRequest.class);
-
- private String repositoryName;
-
- private boolean passiveUpdateEnabled;
-
- private PassiveUpdateMode passiveUpdateMode;
-
- private LockNotificationMode lockNotificationMode;
-
- private OpenSessionResult result;
-
- public OpenSessionRequest(CDOClientProtocol protocol, String repositoryName, boolean passiveUpdateEnabled,
- PassiveUpdateMode passiveUpdateMode, LockNotificationMode lockNotificationMode)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_OPEN_SESSION);
- this.repositoryName = repositoryName;
- this.passiveUpdateEnabled = passiveUpdateEnabled;
- this.passiveUpdateMode = passiveUpdateMode;
- this.lockNotificationMode = lockNotificationMode;
- }
-
- @Override
- protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing repositoryName: {0}", repositoryName); //$NON-NLS-1$
- }
-
- out.writeString(repositoryName);
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing passiveUpdateEnabled: {0}", passiveUpdateEnabled); //$NON-NLS-1$
- }
-
- out.writeBoolean(passiveUpdateEnabled);
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing passiveUpdateMode: {0}", passiveUpdateMode); //$NON-NLS-1$
- }
-
- out.writeEnum(passiveUpdateMode);
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing lockNotificationMode: {0}", lockNotificationMode); //$NON-NLS-1$
- }
-
- out.writeEnum(lockNotificationMode);
- }
-
- @Override
- protected OpenSessionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException
- {
- int sessionID = in.readInt();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read sessionID: {0}", sessionID); //$NON-NLS-1$
- }
-
- String userID = in.readString();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read userID: {0}", userID); //$NON-NLS-1$
- }
-
- String repositoryUUID = in.readString();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read repositoryUUID: {0}", repositoryUUID); //$NON-NLS-1$
- }
-
- CDOCommonRepository.Type repositoryType = in.readEnum(CDOCommonRepository.Type.class);
- if (TRACER.isEnabled())
- {
- TRACER.format("Read repositoryType: {0}", repositoryType); //$NON-NLS-1$
- }
-
- CDOCommonRepository.State repositoryState = in.readEnum(CDOCommonRepository.State.class);
- if (TRACER.isEnabled())
- {
- TRACER.format("Read repositoryState: {0}", repositoryState); //$NON-NLS-1$
- }
-
- String storeType = in.readString();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read storeType: {0}", storeType); //$NON-NLS-1$
- }
-
- Set<CDOID.ObjectType> objectIDTypes = new HashSet<ObjectType>();
- int types = in.readInt();
- for (int i = 0; i < types; i++)
- {
- CDOID.ObjectType objectIDType = in.readEnum(CDOID.ObjectType.class);
- if (TRACER.isEnabled())
- {
- TRACER.format("Read objectIDType: {0}", objectIDType); //$NON-NLS-1$
- }
-
- objectIDTypes.add(objectIDType);
- }
-
- long repositoryCreationTime = in.readLong();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read repositoryCreationTime: {0}", CDOCommonUtil.formatTimeStamp(repositoryCreationTime)); //$NON-NLS-1$
- }
-
- long lastUpdateTime = in.readLong();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read lastUpdateTime: {0}", CDOCommonUtil.formatTimeStamp(lastUpdateTime)); //$NON-NLS-1$
- }
-
- CDOID rootResourceID = in.readCDOID();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read rootResourceID: {0}", rootResourceID); //$NON-NLS-1$
- }
-
- boolean repositorySupportingAudits = in.readBoolean();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read repositorySupportingAudits: {0}", repositorySupportingAudits); //$NON-NLS-1$
- }
-
- boolean repositorySupportingBranches = in.readBoolean();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read repositorySupportingBranches: {0}", repositorySupportingBranches); //$NON-NLS-1$
- }
-
- boolean repositorySupportingEcore = in.readBoolean();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read repositorySupportingEcore: {0}", repositorySupportingEcore); //$NON-NLS-1$
- }
-
- boolean repositoryEnsuringReferentialIntegrity = in.readBoolean();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read repositoryEnsuringReferentialIntegrity: {0}", repositoryEnsuringReferentialIntegrity); //$NON-NLS-1$
- }
-
- IDGenerationLocation repositoryIDGenerationLocation = in.readEnum(IDGenerationLocation.class);
- if (TRACER.isEnabled())
- {
- TRACER.format("Read repositoryIDGenerationLocation: {0}", repositoryIDGenerationLocation); //$NON-NLS-1$
- }
-
- result = new OpenSessionResult(sessionID, userID, repositoryUUID, repositoryType, repositoryState, storeType,
- objectIDTypes, repositoryCreationTime, lastUpdateTime, rootResourceID, repositorySupportingAudits,
- repositorySupportingBranches, repositorySupportingEcore, repositoryEnsuringReferentialIntegrity,
- repositoryIDGenerationLocation);
-
- CDOPackageUnit[] packageUnits = in.readCDOPackageUnits(null);
- for (int i = 0; i < packageUnits.length; i++)
- {
- result.getPackageUnits().add((InternalCDOPackageUnit)packageUnits[i]);
- }
-
- return result;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * Simon McDuff - bug 230832
+ */
+package org.eclipse.emf.cdo.internal.net4j.protocol;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository;
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.LockNotificationMode;
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOID.ObjectType;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
+import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
+
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.spi.cdo.CDOSessionProtocol.OpenSessionResult;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class OpenSessionRequest extends CDOClientRequestWithMonitoring<OpenSessionResult>
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, OpenSessionRequest.class);
+
+ private String repositoryName;
+
+ private boolean passiveUpdateEnabled;
+
+ private PassiveUpdateMode passiveUpdateMode;
+
+ private LockNotificationMode lockNotificationMode;
+
+ private OpenSessionResult result;
+
+ public OpenSessionRequest(CDOClientProtocol protocol, String repositoryName, boolean passiveUpdateEnabled,
+ PassiveUpdateMode passiveUpdateMode, LockNotificationMode lockNotificationMode)
+ {
+ super(protocol, CDOProtocolConstants.SIGNAL_OPEN_SESSION);
+ this.repositoryName = repositoryName;
+ this.passiveUpdateEnabled = passiveUpdateEnabled;
+ this.passiveUpdateMode = passiveUpdateMode;
+ this.lockNotificationMode = lockNotificationMode;
+ }
+
+ @Override
+ protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing repositoryName: {0}", repositoryName); //$NON-NLS-1$
+ }
+
+ out.writeString(repositoryName);
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing passiveUpdateEnabled: {0}", passiveUpdateEnabled); //$NON-NLS-1$
+ }
+
+ out.writeBoolean(passiveUpdateEnabled);
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing passiveUpdateMode: {0}", passiveUpdateMode); //$NON-NLS-1$
+ }
+
+ out.writeEnum(passiveUpdateMode);
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing lockNotificationMode: {0}", lockNotificationMode); //$NON-NLS-1$
+ }
+
+ out.writeEnum(lockNotificationMode);
+ }
+
+ @Override
+ protected OpenSessionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException
+ {
+ int sessionID = in.readInt();
+ if (sessionID == 0)
+ {
+ // The user has canceled the authentication
+ return null;
+ }
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read sessionID: {0}", sessionID); //$NON-NLS-1$
+ }
+
+ String userID = in.readString();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read userID: {0}", userID); //$NON-NLS-1$
+ }
+
+ String repositoryUUID = in.readString();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read repositoryUUID: {0}", repositoryUUID); //$NON-NLS-1$
+ }
+
+ CDOCommonRepository.Type repositoryType = in.readEnum(CDOCommonRepository.Type.class);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read repositoryType: {0}", repositoryType); //$NON-NLS-1$
+ }
+
+ CDOCommonRepository.State repositoryState = in.readEnum(CDOCommonRepository.State.class);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read repositoryState: {0}", repositoryState); //$NON-NLS-1$
+ }
+
+ String storeType = in.readString();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read storeType: {0}", storeType); //$NON-NLS-1$
+ }
+
+ Set<CDOID.ObjectType> objectIDTypes = new HashSet<ObjectType>();
+ int types = in.readInt();
+ for (int i = 0; i < types; i++)
+ {
+ CDOID.ObjectType objectIDType = in.readEnum(CDOID.ObjectType.class);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read objectIDType: {0}", objectIDType); //$NON-NLS-1$
+ }
+
+ objectIDTypes.add(objectIDType);
+ }
+
+ long repositoryCreationTime = in.readLong();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read repositoryCreationTime: {0}", CDOCommonUtil.formatTimeStamp(repositoryCreationTime)); //$NON-NLS-1$
+ }
+
+ long lastUpdateTime = in.readLong();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read lastUpdateTime: {0}", CDOCommonUtil.formatTimeStamp(lastUpdateTime)); //$NON-NLS-1$
+ }
+
+ CDOID rootResourceID = in.readCDOID();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read rootResourceID: {0}", rootResourceID); //$NON-NLS-1$
+ }
+
+ boolean repositorySupportingAudits = in.readBoolean();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read repositorySupportingAudits: {0}", repositorySupportingAudits); //$NON-NLS-1$
+ }
+
+ boolean repositorySupportingBranches = in.readBoolean();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read repositorySupportingBranches: {0}", repositorySupportingBranches); //$NON-NLS-1$
+ }
+
+ boolean repositorySupportingEcore = in.readBoolean();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read repositorySupportingEcore: {0}", repositorySupportingEcore); //$NON-NLS-1$
+ }
+
+ boolean repositoryEnsuringReferentialIntegrity = in.readBoolean();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read repositoryEnsuringReferentialIntegrity: {0}", repositoryEnsuringReferentialIntegrity); //$NON-NLS-1$
+ }
+
+ IDGenerationLocation repositoryIDGenerationLocation = in.readEnum(IDGenerationLocation.class);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read repositoryIDGenerationLocation: {0}", repositoryIDGenerationLocation); //$NON-NLS-1$
+ }
+
+ result = new OpenSessionResult(sessionID, userID, repositoryUUID, repositoryType, repositoryState, storeType,
+ objectIDTypes, repositoryCreationTime, lastUpdateTime, rootResourceID, repositorySupportingAudits,
+ repositorySupportingBranches, repositorySupportingEcore, repositoryEnsuringReferentialIntegrity,
+ repositoryIDGenerationLocation);
+
+ CDOPackageUnit[] packageUnits = in.readCDOPackageUnits(null);
+ for (int i = 0; i < packageUnits.length; i++)
+ {
+ result.getPackageUnits().add((InternalCDOPackageUnit)packageUnits[i]);
+ }
+
+ return result;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/AuthenticationRequest.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/AuthenticationRequest.java
index ba174abdc5..163350a3a9 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/AuthenticationRequest.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/AuthenticationRequest.java
@@ -1,51 +1,78 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.common.CDOAuthenticationResult;
-
-import org.eclipse.net4j.signal.RequestWithMonitoring;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-/**
- * @author Eike Stepper
- */
-public class AuthenticationRequest extends RequestWithMonitoring<CDOAuthenticationResult>
-{
- private byte[] randomToken;
-
- public AuthenticationRequest(CDOServerProtocol protocol, byte[] randomToken)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_AUTHENTICATION);
- this.randomToken = randomToken;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
- {
- out.writeByteArray(randomToken);
- }
-
- @Override
- protected CDOAuthenticationResult confirming(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
- {
- boolean authenticated = in.readBoolean();
- if (!authenticated)
- {
- return null;
- }
-
- return new CDOAuthenticationResult(in);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.emf.cdo.server.internal.net4j.protocol;
+
+import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.common.util.NotAuthenticatedException;
+import org.eclipse.emf.cdo.spi.common.CDOAuthenticationResult;
+
+import org.eclipse.net4j.signal.RemoteException;
+import org.eclipse.net4j.signal.RequestWithMonitoring;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
+/**
+ * @author Eike Stepper
+ */
+public class AuthenticationRequest extends RequestWithMonitoring<CDOAuthenticationResult>
+{
+ private byte[] randomToken;
+
+ public AuthenticationRequest(CDOServerProtocol protocol, byte[] randomToken)
+ {
+ super(protocol, CDOProtocolConstants.SIGNAL_AUTHENTICATION);
+ this.randomToken = randomToken;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
+ {
+ out.writeByteArray(randomToken);
+ }
+
+ @Override
+ protected CDOAuthenticationResult confirming(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
+ {
+ try
+ {
+ boolean authenticated = in.readBoolean();
+ if (authenticated)
+ {
+ return new CDOAuthenticationResult(in);
+ }
+ }
+ catch (RemoteException ex)
+ {
+ if (ex.getCause() instanceof NotAuthenticatedException)
+ {
+ // Skip silently because user has canceled the authentication
+ }
+ else
+ {
+ throw ex;
+ }
+ }
+ catch (Exception ex)
+ {
+ if (ex instanceof NotAuthenticatedException)
+ {
+ // Skip silently because user has canceled the authentication
+ }
+ else
+ {
+ throw ex;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/OpenSessionIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/OpenSessionIndication.java
index 24e2229f77..4fd4566d1e 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/OpenSessionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/OpenSessionIndication.java
@@ -1,168 +1,179 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.LockNotificationMode;
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.IRepositoryProvider;
-import org.eclipse.emf.cdo.server.RepositoryNotFoundException;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-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.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class OpenSessionIndication extends CDOServerIndicationWithMonitoring
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, OpenSessionIndication.class);
-
- private String repositoryName;
-
- private boolean passiveUpdateEnabled;
-
- private PassiveUpdateMode passiveUpdateMode;
-
- private LockNotificationMode lockNotificationMode;
-
- private InternalRepository repository;
-
- private InternalSession session;
-
- public OpenSessionIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_OPEN_SESSION);
- }
-
- @Override
- protected InternalRepository getRepository()
- {
- return repository;
- }
-
- @Override
- protected InternalSession getSession()
- {
- return session;
- }
-
- @Override
- protected void indicating(CDODataInput in, OMMonitor monitor) throws Exception
- {
- repositoryName = in.readString();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read repositoryName: {0}", repositoryName); //$NON-NLS-1$
- }
-
- passiveUpdateEnabled = in.readBoolean();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read passiveUpdateEnabled: {0}", passiveUpdateEnabled); //$NON-NLS-1$
- }
-
- passiveUpdateMode = in.readEnum(PassiveUpdateMode.class);
- if (TRACER.isEnabled())
- {
- TRACER.format("Read passiveUpdateMode: {0}", passiveUpdateMode); //$NON-NLS-1$
- }
-
- lockNotificationMode = in.readEnum(LockNotificationMode.class);
- if (TRACER.isEnabled())
- {
- TRACER.format("Read lockNotificationMode: {0}", lockNotificationMode); //$NON-NLS-1$
- }
- }
-
- @Override
- protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception
- {
- monitor.begin();
- Async async = monitor.forkAsync();
-
- try
- {
- CDOServerProtocol protocol = getProtocol();
- IRepositoryProvider repositoryProvider = protocol.getRepositoryProvider();
- repository = (InternalRepository)repositoryProvider.getRepository(repositoryName);
- if (repository == null)
- {
- throw new RepositoryNotFoundException(repositoryName);
- }
-
- InternalSessionManager sessionManager = repository.getSessionManager();
- session = sessionManager.openSession(protocol);
- session.setPassiveUpdateEnabled(passiveUpdateEnabled);
- session.setPassiveUpdateMode(passiveUpdateMode);
- session.setLockNotificationMode(lockNotificationMode);
-
- protocol.setInfraStructure(session);
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing sessionID: {0}", session.getSessionID()); //$NON-NLS-1$
- }
-
- out.writeInt(session.getSessionID());
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing userID: {0}", session.getUserID()); //$NON-NLS-1$
- }
-
- out.writeString(session.getUserID());
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing repositoryUUID: {0}", repository.getUUID()); //$NON-NLS-1$
- }
-
- out.writeString(repository.getUUID());
- out.writeEnum(repository.getType());
- out.writeEnum(repository.getState());
- out.writeString(repository.getStoreType());
-
- Set<CDOID.ObjectType> objectIDTypes = repository.getObjectIDTypes();
- int types = objectIDTypes.size();
- out.writeInt(types);
- for (CDOID.ObjectType objectIDType : objectIDTypes)
- {
- out.writeEnum(objectIDType);
- }
-
- out.writeLong(repository.getCreationTime());
- out.writeLong(repository.getLastCommitTimeStamp());
- out.writeCDOID(repository.getRootResourceID());
- out.writeBoolean(repository.isSupportingAudits());
- out.writeBoolean(repository.isSupportingBranches());
- out.writeBoolean(repository.isSupportingEcore());
- out.writeBoolean(repository.isEnsuringReferentialIntegrity());
- out.writeEnum(repository.getIDGenerationLocation());
-
- CDOPackageUnit[] packageUnits = repository.getPackageRegistry().getPackageUnits();
- out.writeCDOPackageUnits(packageUnits);
- }
- finally
- {
- async.stop();
- monitor.done();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.emf.cdo.server.internal.net4j.protocol;
+
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.LockNotificationMode;
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.common.util.NotAuthenticatedException;
+import org.eclipse.emf.cdo.server.IRepositoryProvider;
+import org.eclipse.emf.cdo.server.RepositoryNotFoundException;
+import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
+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.om.monitor.OMMonitor;
+import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class OpenSessionIndication extends CDOServerIndicationWithMonitoring
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, OpenSessionIndication.class);
+
+ private String repositoryName;
+
+ private boolean passiveUpdateEnabled;
+
+ private PassiveUpdateMode passiveUpdateMode;
+
+ private LockNotificationMode lockNotificationMode;
+
+ private InternalRepository repository;
+
+ private InternalSession session;
+
+ public OpenSessionIndication(CDOServerProtocol protocol)
+ {
+ super(protocol, CDOProtocolConstants.SIGNAL_OPEN_SESSION);
+ }
+
+ @Override
+ protected InternalRepository getRepository()
+ {
+ return repository;
+ }
+
+ @Override
+ protected InternalSession getSession()
+ {
+ return session;
+ }
+
+ @Override
+ protected void indicating(CDODataInput in, OMMonitor monitor) throws Exception
+ {
+ repositoryName = in.readString();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read repositoryName: {0}", repositoryName); //$NON-NLS-1$
+ }
+
+ passiveUpdateEnabled = in.readBoolean();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read passiveUpdateEnabled: {0}", passiveUpdateEnabled); //$NON-NLS-1$
+ }
+
+ passiveUpdateMode = in.readEnum(PassiveUpdateMode.class);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read passiveUpdateMode: {0}", passiveUpdateMode); //$NON-NLS-1$
+ }
+
+ lockNotificationMode = in.readEnum(LockNotificationMode.class);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read lockNotificationMode: {0}", lockNotificationMode); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception
+ {
+ monitor.begin();
+ Async async = monitor.forkAsync();
+
+ try
+ {
+ CDOServerProtocol protocol = getProtocol();
+ IRepositoryProvider repositoryProvider = protocol.getRepositoryProvider();
+ repository = (InternalRepository)repositoryProvider.getRepository(repositoryName);
+ if (repository == null)
+ {
+ throw new RepositoryNotFoundException(repositoryName);
+ }
+
+ try
+ {
+ InternalSessionManager sessionManager = repository.getSessionManager();
+ session = sessionManager.openSession(protocol);
+ }
+ catch (NotAuthenticatedException ex)
+ {
+ // Skip response because the user has canceled the authentication
+ out.writeInt(0);
+ return;
+ }
+
+ session.setPassiveUpdateEnabled(passiveUpdateEnabled);
+ session.setPassiveUpdateMode(passiveUpdateMode);
+ session.setLockNotificationMode(lockNotificationMode);
+
+ protocol.setInfraStructure(session);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing sessionID: {0}", session.getSessionID()); //$NON-NLS-1$
+ }
+
+ out.writeInt(session.getSessionID());
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing userID: {0}", session.getUserID()); //$NON-NLS-1$
+ }
+
+ out.writeString(session.getUserID());
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing repositoryUUID: {0}", repository.getUUID()); //$NON-NLS-1$
+ }
+
+ out.writeString(repository.getUUID());
+ out.writeEnum(repository.getType());
+ out.writeEnum(repository.getState());
+ out.writeString(repository.getStoreType());
+
+ Set<CDOID.ObjectType> objectIDTypes = repository.getObjectIDTypes();
+ int types = objectIDTypes.size();
+ out.writeInt(types);
+ for (CDOID.ObjectType objectIDType : objectIDTypes)
+ {
+ out.writeEnum(objectIDType);
+ }
+
+ out.writeLong(repository.getCreationTime());
+ out.writeLong(repository.getLastCommitTimeStamp());
+ out.writeCDOID(repository.getRootResourceID());
+ out.writeBoolean(repository.isSupportingAudits());
+ out.writeBoolean(repository.isSupportingBranches());
+ out.writeBoolean(repository.isSupportingEcore());
+ out.writeBoolean(repository.isEnsuringReferentialIntegrity());
+ out.writeEnum(repository.getIDGenerationLocation());
+
+ CDOPackageUnit[] packageUnits = repository.getPackageRegistry().getPackageUnits();
+ out.writeCDOPackageUnits(packageUnits);
+ }
+ finally
+ {
+ async.stop();
+ monitor.done();
+ }
+ }
+}
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 9071820d08..20ccd3a454 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
@@ -19,6 +19,7 @@ import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.common.util.NotAuthenticatedException;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.server.IPermissionManager;
import org.eclipse.emf.cdo.server.ISession;
@@ -453,6 +454,11 @@ public class SessionManager extends Container<ISession> implements InternalSessi
{
byte[] randomToken = createRandomToken();
CDOAuthenticationResult result = protocol.sendAuthenticationChallenge(randomToken);
+ if (result == null)
+ {
+ throw new NotAuthenticatedException();
+ }
+
String userID = result.getUserID();
byte[] cryptedToken = encryptToken(userID, randomToken);
@@ -462,7 +468,7 @@ public class SessionManager extends Container<ISession> implements InternalSessi
return userID;
}
- throw new SecurityException("User not authenticated"); //$NON-NLS-1$
+ throw new SecurityException("Access denied"); //$NON-NLS-1$
}
catch (SecurityException ex)
{
@@ -470,6 +476,12 @@ public class SessionManager extends Container<ISession> implements InternalSessi
}
catch (Exception ex)
{
+ Throwable cause = ex.getCause();
+ if (cause instanceof SecurityException)
+ {
+ throw (SecurityException)cause;
+ }
+
throw new SecurityException(ex);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui.admin/src/org/eclipse/emf/cdo/ui/internal/admin/CDOAdminView.java b/plugins/org.eclipse.emf.cdo.ui.admin/src/org/eclipse/emf/cdo/ui/internal/admin/CDOAdminView.java
index 0e6d7b60e2..495f97ab59 100644
--- a/plugins/org.eclipse.emf.cdo.ui.admin/src/org/eclipse/emf/cdo/ui/internal/admin/CDOAdminView.java
+++ b/plugins/org.eclipse.emf.cdo.ui.admin/src/org/eclipse/emf/cdo/ui/internal/admin/CDOAdminView.java
@@ -14,6 +14,7 @@ import org.eclipse.emf.cdo.admin.CDOAdminClient;
import org.eclipse.emf.cdo.admin.CDOAdminClientManager;
import org.eclipse.emf.cdo.admin.CDOAdminClientRepository;
import org.eclipse.emf.cdo.common.admin.CDOAdminRepository;
+import org.eclipse.emf.cdo.common.util.NotAuthenticatedException;
import org.eclipse.emf.cdo.net4j.CDONet4jSession;
import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration;
import org.eclipse.emf.cdo.ui.internal.admin.bundle.OM;
@@ -21,6 +22,7 @@ import org.eclipse.emf.cdo.ui.shared.SharedIcons;
import org.eclipse.emf.internal.cdo.session.CDOSessionFactory;
+import org.eclipse.net4j.signal.RemoteException;
import org.eclipse.net4j.ui.Net4jItemProvider.RemoveAction;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.container.IManagedContainer;
@@ -271,12 +273,37 @@ public class CDOAdminView extends ContainerView
@Override
protected void doRun(IProgressMonitor progressMonitor) throws Exception
{
- CDONet4jSession session = repository.openSession(this);
- if (session != null)
+ try
{
- IManagedContainer container = adminManager.getContainer();
- String description = "session" + getNextSessionNumber();
- container.putElement(CDOSessionFactory.PRODUCT_GROUP, "admin", description, session);
+ CDONet4jSession session = repository.openSession(this);
+ if (session != null)
+ {
+ IManagedContainer container = adminManager.getContainer();
+ String description = "session" + getNextSessionNumber();
+ container.putElement(CDOSessionFactory.PRODUCT_GROUP, "admin", description, session);
+ }
+ }
+ catch (RemoteException ex)
+ {
+ if (ex.getCause() instanceof NotAuthenticatedException)
+ {
+ // Skip silently because user has canceled the authentication
+ }
+ else
+ {
+ throw ex;
+ }
+ }
+ catch (Exception ex)
+ {
+ if (ex instanceof NotAuthenticatedException)
+ {
+ // Skip silently because user has canceled the authentication
+ }
+ else
+ {
+ throw ex;
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java
index a6924487dc..10633ed604 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenSessionAction.java
@@ -12,6 +12,7 @@
package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.common.model.CDOPackageRegistryPopulator;
+import org.eclipse.emf.cdo.common.util.NotAuthenticatedException;
import org.eclipse.emf.cdo.internal.ui.bundle.OM;
import org.eclipse.emf.cdo.internal.ui.dialogs.OpenSessionDialog;
import org.eclipse.emf.cdo.internal.ui.messages.Messages;
@@ -20,6 +21,7 @@ import org.eclipse.emf.cdo.ui.widgets.SessionComposite;
import org.eclipse.emf.internal.cdo.session.CDOSessionFactory;
+import org.eclipse.net4j.signal.RemoteException;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.ui.actions.LongRunningAction;
@@ -66,27 +68,52 @@ public final class OpenSessionAction extends LongRunningAction
{
try
{
+ IManagedContainer container = getContainer();
+ String productGroup = CDOSessionFactory.PRODUCT_GROUP;
String description = sessionComposite.getSessionDescription();
- final InternalCDOSession session = (InternalCDOSession)getContainer().getElement(CDOSessionFactory.PRODUCT_GROUP,
- "cdo", description); //$NON-NLS-1$
+ InternalCDOSession session = (InternalCDOSession)container.getElement(productGroup, "cdo", description); //$NON-NLS-1$
if (sessionComposite.isAutomaticRegistry())
{
CDOPackageRegistryPopulator.populate(session.getPackageRegistry());
}
}
- catch (final RuntimeException ex)
+ catch (RemoteException ex)
{
- OM.LOG.error(ex);
- getDisplay().asyncExec(new Runnable()
+ Throwable cause = ex.getCause();
+ if (cause instanceof NotAuthenticatedException)
{
- public void run()
- {
- MessageDialog.openError(getShell(), getText(), Messages.getString("OpenSessionAction.3") //$NON-NLS-1$
- + ex.getMessage());
- }
- });
+ // Skip silently because user has canceled the authentication
+ }
+ else
+ {
+ showError(cause);
+ }
}
+ catch (Exception ex)
+ {
+ if (ex instanceof NotAuthenticatedException)
+ {
+ // Skip silently because user has canceled the authentication
+ }
+ else
+ {
+ showError(ex);
+ }
+ }
+ }
+
+ protected void showError(final Throwable ex)
+ {
+ OM.LOG.error(ex);
+ getDisplay().asyncExec(new Runnable()
+ {
+ public void run()
+ {
+ MessageDialog.openError(getShell(), getText(), Messages.getString("OpenSessionAction.3") //$NON-NLS-1$
+ + ex.getMessage());
+ }
+ });
}
protected IManagedContainer getContainer()
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOAuthenticatorImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOAuthenticatorImpl.java
index e6badf66de..79a1bf13df 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOAuthenticatorImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOAuthenticatorImpl.java
@@ -1,106 +1,111 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.emf.internal.cdo.session;
-
-import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
-import org.eclipse.emf.cdo.spi.common.CDOAuthenticationResult;
-
-import org.eclipse.net4j.util.security.IPasswordCredentials;
-import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
-import org.eclipse.net4j.util.security.SecurityUtil;
-
-/**
- * @author Eike Stepper
- */
-public class CDOAuthenticatorImpl implements CDOAuthenticator
-{
- private String encryptionAlgorithmName = SecurityUtil.PBE_WITH_MD5_AND_DES;
-
- private byte[] encryptionSaltBytes = SecurityUtil.DEFAULT_SALT;
-
- private int encryptionIterationCount = SecurityUtil.DEFAULT_ITERATION_COUNT;
-
- private IPasswordCredentialsProvider credentialsProvider;
-
- public CDOAuthenticatorImpl()
- {
- }
-
- public String getEncryptionAlgorithmName()
- {
- return encryptionAlgorithmName;
- }
-
- public void setEncryptionAlgorithmName(String encryptionAlgorithmName)
- {
- this.encryptionAlgorithmName = encryptionAlgorithmName;
- }
-
- public byte[] getEncryptionSaltBytes()
- {
- return encryptionSaltBytes;
- }
-
- public void setEncryptionSaltBytes(byte[] encryptionSaltBytes)
- {
- this.encryptionSaltBytes = encryptionSaltBytes;
- }
-
- public int getEncryptionIterationCount()
- {
- return encryptionIterationCount;
- }
-
- public void setEncryptionIterationCount(int encryptionIterationCount)
- {
- this.encryptionIterationCount = encryptionIterationCount;
- }
-
- public IPasswordCredentialsProvider getCredentialsProvider()
- {
- return credentialsProvider;
- }
-
- public void setCredentialsProvider(IPasswordCredentialsProvider credentialsProvider)
- {
- this.credentialsProvider = credentialsProvider;
- }
-
- public CDOAuthenticationResult authenticate(byte[] randomToken)
- {
- if (credentialsProvider == null)
- {
- throw new IllegalStateException("No credentials provider configured"); //$NON-NLS-1$
- }
-
- IPasswordCredentials credentials = credentialsProvider.getCredentials();
- String userID = credentials.getUserID();
- byte[] cryptedToken = encryptToken(credentials.getPassword(), randomToken);
- return new CDOAuthenticationResult(userID, cryptedToken);
- }
-
- protected byte[] encryptToken(char[] password, byte[] token)
- {
- try
- {
- return SecurityUtil.encrypt(token, password, encryptionAlgorithmName, encryptionSaltBytes,
- encryptionIterationCount);
- }
- catch (RuntimeException ex)
- {
- throw ex;
- }
- catch (Exception ex)
- {
- throw new SecurityException(ex);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.emf.internal.cdo.session;
+
+import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
+import org.eclipse.emf.cdo.spi.common.CDOAuthenticationResult;
+
+import org.eclipse.net4j.util.security.IPasswordCredentials;
+import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
+import org.eclipse.net4j.util.security.SecurityUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOAuthenticatorImpl implements CDOAuthenticator
+{
+ private String encryptionAlgorithmName = SecurityUtil.PBE_WITH_MD5_AND_DES;
+
+ private byte[] encryptionSaltBytes = SecurityUtil.DEFAULT_SALT;
+
+ private int encryptionIterationCount = SecurityUtil.DEFAULT_ITERATION_COUNT;
+
+ private IPasswordCredentialsProvider credentialsProvider;
+
+ public CDOAuthenticatorImpl()
+ {
+ }
+
+ public String getEncryptionAlgorithmName()
+ {
+ return encryptionAlgorithmName;
+ }
+
+ public void setEncryptionAlgorithmName(String encryptionAlgorithmName)
+ {
+ this.encryptionAlgorithmName = encryptionAlgorithmName;
+ }
+
+ public byte[] getEncryptionSaltBytes()
+ {
+ return encryptionSaltBytes;
+ }
+
+ public void setEncryptionSaltBytes(byte[] encryptionSaltBytes)
+ {
+ this.encryptionSaltBytes = encryptionSaltBytes;
+ }
+
+ public int getEncryptionIterationCount()
+ {
+ return encryptionIterationCount;
+ }
+
+ public void setEncryptionIterationCount(int encryptionIterationCount)
+ {
+ this.encryptionIterationCount = encryptionIterationCount;
+ }
+
+ public IPasswordCredentialsProvider getCredentialsProvider()
+ {
+ return credentialsProvider;
+ }
+
+ public void setCredentialsProvider(IPasswordCredentialsProvider credentialsProvider)
+ {
+ this.credentialsProvider = credentialsProvider;
+ }
+
+ public CDOAuthenticationResult authenticate(byte[] randomToken)
+ {
+ if (credentialsProvider == null)
+ {
+ throw new IllegalStateException("No credentials provider configured"); //$NON-NLS-1$
+ }
+
+ IPasswordCredentials credentials = credentialsProvider.getCredentials();
+ if (credentials != null)
+ {
+ String userID = credentials.getUserID();
+ byte[] cryptedToken = encryptToken(credentials.getPassword(), randomToken);
+ return new CDOAuthenticationResult(userID, cryptedToken);
+ }
+
+ return null;
+ }
+
+ protected byte[] encryptToken(char[] password, byte[] token)
+ {
+ try
+ {
+ return SecurityUtil.encrypt(token, password, encryptionAlgorithmName, encryptionSaltBytes,
+ encryptionIterationCount);
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new SecurityException(ex);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionIndication.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionIndication.java
index bd9411fd9a..6eee8c0ee2 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionIndication.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionIndication.java
@@ -1,79 +1,83 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.signal;
-
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedIOUtil;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.internal.net4j.bundle.OM;
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-class RemoteExceptionIndication extends Indication
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, RemoteExceptionIndication.class);
-
- private Throwable t;
-
- public RemoteExceptionIndication(SignalProtocol<?> protocol)
- {
- super(protocol, SignalProtocol.SIGNAL_REMOTE_EXCEPTION);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- int correlationID = in.readInt();
- boolean responding = in.readBoolean();
- String message = in.readString();
- if (TRACER.isEnabled())
- {
- String msg = RemoteExceptionRequest.getFirstLine(message);
- TRACER.format("Reading remote exception for signal {0}: {1}", correlationID, msg); //$NON-NLS-1$
- }
-
- try
- {
- t = deserializeThrowable(in.readByteArray());
- }
- catch (Throwable couldNotLoadExceptionClass)
- {
- // Fall through
- }
-
- if (t == null)
- {
- t = new RemoteException(message, responding);
- }
-
- getProtocol().handleRemoteException(correlationID, t, responding);
- }
-
- public static Throwable deserializeThrowable(byte[] bytes)
- {
- try
- {
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- DataInputStream dis = new DataInputStream(bais);
- return (Throwable)ExtendedIOUtil.readObject(dis, OM.class.getClassLoader());
- }
- catch (IOException ex)
- {
- return null;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.signal;
+
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedIOUtil;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.internal.net4j.bundle.OM;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+class RemoteExceptionIndication extends Indication
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SIGNAL, RemoteExceptionIndication.class);
+
+ private Throwable t;
+
+ public RemoteExceptionIndication(SignalProtocol<?> protocol)
+ {
+ super(protocol, SignalProtocol.SIGNAL_REMOTE_EXCEPTION);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ int correlationID = in.readInt();
+ boolean responding = in.readBoolean();
+ String message = in.readString();
+ if (TRACER.isEnabled())
+ {
+ String msg = RemoteExceptionRequest.getFirstLine(message);
+ TRACER.format("Reading remote exception for signal {0}: {1}", correlationID, msg); //$NON-NLS-1$
+ }
+
+ try
+ {
+ t = deserializeThrowable(in.readByteArray());
+ }
+ catch (Throwable couldNotLoadExceptionClass)
+ {
+ // Fall through
+ }
+
+ if (t == null)
+ {
+ t = new RemoteException(message, responding);
+ }
+
+ SignalProtocol<?> protocol = getProtocol();
+ if (protocol != null)
+ {
+ protocol.handleRemoteException(correlationID, t, responding);
+ }
+ }
+
+ public static Throwable deserializeThrowable(byte[] bytes)
+ {
+ try
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ DataInputStream dis = new DataInputStream(bais);
+ return (Throwable)ExtendedIOUtil.readObject(dis, OM.class.getClassLoader());
+ }
+ catch (IOException ex)
+ {
+ return null;
+ }
+ }
+}

Back to the top