Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/UserManagerNegotiator.java')
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/UserManagerNegotiator.java71
1 files changed, 71 insertions, 0 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/UserManagerNegotiator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/UserManagerNegotiator.java
new file mode 100644
index 0000000000..5fa6b005d7
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/UserManagerNegotiator.java
@@ -0,0 +1,71 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.internal.util.security;
+
+import org.eclipse.net4j.util.security.IUserManager;
+import org.eclipse.net4j.util.security.SecurityUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class UserManagerNegotiator extends Negotiator
+{
+ public static final String DEFAULT_ALGORITHM_NAME = SecurityUtil.PBE_WITH_MD5_AND_DES;
+
+ private String algorithmName = DEFAULT_ALGORITHM_NAME;
+
+ private IUserManager userManager;
+
+ public UserManagerNegotiator(boolean starter)
+ {
+ super(starter);
+ }
+
+ public String getAlgorithmName()
+ {
+ return algorithmName;
+ }
+
+ public void setAlgorithmName(String algorithmName)
+ {
+ this.algorithmName = algorithmName;
+ }
+
+ public IUserManager getUserManager()
+ {
+ return userManager;
+ }
+
+ public void setUserManager(IUserManager userManager)
+ {
+ this.userManager = userManager;
+ }
+
+ protected byte[] encrypt(String userID, byte[] data) throws SecurityException
+ {
+ return userManager.encrypt(userID, data, algorithmName);
+ }
+
+ @Override
+ protected void doBeforeActivate() throws Exception
+ {
+ super.doBeforeActivate();
+ if (algorithmName == null)
+ {
+ throw new IllegalStateException("algorithmName == null");
+ }
+
+ if (userManager == null)
+ {
+ throw new IllegalStateException("userManager == null");
+ }
+ }
+}

Back to the top