Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-10-18 16:00:21 +0000
committerEike Stepper2010-10-18 16:00:21 +0000
commitbd7f5a7ce21f963e06ac746d774d4db0ce4f8d51 (patch)
tree70569bc18f41203d5b08a21b9f8cbb5784aebc0d
parentf886a28fb26610097ee8fc45ed31876f3d1dfbd8 (diff)
downloadcdo-bd7f5a7ce21f963e06ac746d774d4db0ce4f8d51.tar.gz
cdo-bd7f5a7ce21f963e06ac746d774d4db0ce4f8d51.tar.xz
cdo-bd7f5a7ce21f963e06ac746d774d4db0ce4f8d51.zip
[327296] Clean up relation between Session and SessionConfig
https://bugs.eclipse.org/bugs/show_bug.cgi?id=327296
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOAuthenticatorImpl.java96
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java106
2 files changed, 97 insertions, 105 deletions
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
new file mode 100644
index 0000000000..a6edeed8a8
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOAuthenticatorImpl.java
@@ -0,0 +1,96 @@
+package org.eclipse.emf.internal.cdo.session;
+
+import org.eclipse.emf.cdo.common.protocol.CDOAuthenticationResult;
+import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
+
+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);
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java
index 22242306dc..a9ad6f2d60 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java
@@ -14,7 +14,6 @@ import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.common.protocol.CDOAuthenticationResult;
import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
import org.eclipse.emf.cdo.session.CDOSession;
@@ -25,9 +24,6 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
import org.eclipse.emf.internal.cdo.messages.Messages;
-import org.eclipse.net4j.util.security.IPasswordCredentials;
-import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
-import org.eclipse.net4j.util.security.SecurityUtil;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
import org.eclipse.emf.spi.cdo.InternalCDOSessionConfiguration;
@@ -41,7 +37,7 @@ public abstract class CDOSessionConfigurationImpl implements InternalCDOSessionC
private PassiveUpdateMode passiveUpdateMode = PassiveUpdateMode.INVALIDATIONS;
- private CDOAuthenticator authenticator = new AuthenticatorImpl();
+ private CDOAuthenticator authenticator = new CDOAuthenticatorImpl();
private CDOSession.ExceptionHandler exceptionHandler;
@@ -254,104 +250,4 @@ public abstract class CDOSessionConfigurationImpl implements InternalCDOSessionC
throw new IllegalStateException(Messages.getString("CDOSessionConfigurationImpl.0")); //$NON-NLS-1$
}
}
-
- /**
- * @author Eike Stepper
- */
- protected class AuthenticatorImpl 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 AuthenticatorImpl()
- {
- }
-
- public String getEncryptionAlgorithmName()
- {
- return encryptionAlgorithmName;
- }
-
- public void setEncryptionAlgorithmName(String encryptionAlgorithmName)
- {
- checkSessionNotOpened();
- this.encryptionAlgorithmName = encryptionAlgorithmName;
- }
-
- public byte[] getEncryptionSaltBytes()
- {
- return encryptionSaltBytes;
- }
-
- public void setEncryptionSaltBytes(byte[] encryptionSaltBytes)
- {
- checkSessionNotOpened();
- this.encryptionSaltBytes = encryptionSaltBytes;
- }
-
- public int getEncryptionIterationCount()
- {
- return encryptionIterationCount;
- }
-
- public void setEncryptionIterationCount(int encryptionIterationCount)
- {
- checkSessionNotOpened();
- this.encryptionIterationCount = encryptionIterationCount;
- }
-
- public IPasswordCredentialsProvider getCredentialsProvider()
- {
- return credentialsProvider;
- }
-
- public void setCredentialsProvider(IPasswordCredentialsProvider credentialsProvider)
- {
- checkSessionNotOpened();
- 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);
- }
- }
-
- private void checkSessionNotOpened()
- {
- if (session != null)
- {
- throw new IllegalStateException("Not allowed after the session has been opened"); //$NON-NLS-1$
- }
- }
- }
}

Back to the top