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/org.eclipse.emf.cdo
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/org.eclipse.emf.cdo')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOAuthenticatorImpl.java217
1 files changed, 111 insertions, 106 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
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);
+ }
+ }
+}

Back to the top