Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-09-21 20:53:54 -0400
committerEike Stepper2013-09-21 20:53:54 -0400
commitdc8364330b7013c4edd54ef30b9d74f7ad9f234a (patch)
tree28d39377c79c7f4c4a0f70c85725b88a7a271237
parent32b9825d0d19b5bd18e4c3bf4d66b5312f0551d3 (diff)
downloadcdo-dc8364330b7013c4edd54ef30b9d74f7ad9f234a.tar.gz
cdo-dc8364330b7013c4edd54ef30b9d74f7ad9f234a.tar.xz
cdo-dc8364330b7013c4edd54ef30b9d74f7ad9f234a.zip
Add convenience constructors to PasswordCredentials
-rw-r--r--plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityItemContainer.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/DirectoryImpl.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/RealmImpl.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java13
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/PasswordCredentials.java16
5 files changed, 53 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityItemContainer.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityItemContainer.java
index dc4bac9f92..c162988209 100644
--- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityItemContainer.java
+++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityItemContainer.java
@@ -10,6 +10,8 @@
*/
package org.eclipse.emf.cdo.security;
+import org.eclipse.net4j.util.security.IPasswordCredentials;
+
/**
* A {@link SecurityItemProvider security item provider} that {@link SecurityItem items}
* such as {@link User users} or {@link Role roles} can be added to or removed from.
@@ -32,6 +34,11 @@ public interface SecurityItemContainer extends SecurityItemProvider
/**
* @since 4.3
*/
+ public User addUser(IPasswordCredentials credentials);
+
+ /**
+ * @since 4.3
+ */
public User setPassword(String id, String password);
public Role removeRole(String id);
diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/DirectoryImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/DirectoryImpl.java
index 4b515e6bff..31fa69edd5 100644
--- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/DirectoryImpl.java
+++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/DirectoryImpl.java
@@ -19,6 +19,8 @@ import org.eclipse.emf.cdo.security.SecurityItem;
import org.eclipse.emf.cdo.security.SecurityPackage;
import org.eclipse.emf.cdo.security.User;
+import org.eclipse.net4j.util.security.IPasswordCredentials;
+
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
@@ -157,6 +159,14 @@ public class DirectoryImpl extends SecurityItemImpl implements Directory
/**
* @since 4.3
*/
+ public User addUser(IPasswordCredentials credentials)
+ {
+ return addUser(credentials.getUserID(), new String(credentials.getPassword()));
+ }
+
+ /**
+ * @since 4.3
+ */
public User setPassword(String id, String password)
{
return getRealm().setPassword(id, password);
diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/RealmImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/RealmImpl.java
index d8c78056ea..162dae5728 100644
--- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/RealmImpl.java
+++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/RealmImpl.java
@@ -23,6 +23,8 @@ import org.eclipse.emf.cdo.security.SecurityPackage;
import org.eclipse.emf.cdo.security.User;
import org.eclipse.emf.cdo.security.UserPassword;
+import org.eclipse.net4j.util.security.IPasswordCredentials;
+
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -412,6 +414,14 @@ public class RealmImpl extends SecurityElementImpl implements Realm
}
/**
+ * @since 4.3
+ */
+ public User addUser(IPasswordCredentials credentials)
+ {
+ return addUser(credentials.getUserID(), new String(credentials.getPassword()));
+ }
+
+ /**
* @since 4.2
*/
protected User addUser(User user)
diff --git a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java
index 72c4ddd507..97a7a7d1c3 100644
--- a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java
@@ -63,6 +63,7 @@ import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
import org.eclipse.net4j.util.security.IAuthenticator;
+import org.eclipse.net4j.util.security.IPasswordCredentials;
import org.eclipse.emf.common.util.EList;
@@ -258,6 +259,11 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage
return result[0];
}
+ public User addUser(IPasswordCredentials credentials)
+ {
+ return addUser(credentials.getUserID(), new String(credentials.getPassword()));
+ }
+
public User setPassword(final String id, final String password)
{
final User[] result = { null };
@@ -532,11 +538,12 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage
// Create roles
Role allReaderRole = realm.addRole("All Objects Reader");
- allReaderRole.getPermissions().add(factory.createFilterPermission(Access.READ, factory.createResourceFilter(".*")));
+ allReaderRole.getPermissions().add(
+ factory.createFilterPermission(Access.READ, factory.createResourceFilter(".*", Inclusion.REGEX)));
Role allWriterRole = realm.addRole("All Objects Writer");
- allWriterRole.getPermissions()
- .add(factory.createFilterPermission(Access.WRITE, factory.createResourceFilter(".*")));
+ allWriterRole.getPermissions().add(
+ factory.createFilterPermission(Access.WRITE, factory.createResourceFilter(".*", Inclusion.REGEX)));
Role treeReaderRole = realm.addRole("Resource Tree Reader");
treeReaderRole.getPermissions().add(
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/PasswordCredentials.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/PasswordCredentials.java
index 7dcbea0065..8eb098e2f4 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/PasswordCredentials.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/PasswordCredentials.java
@@ -23,6 +23,22 @@ public class PasswordCredentials extends Credentials implements IPasswordCredent
this.password = password;
}
+ /**
+ * @since 3.4
+ */
+ public PasswordCredentials(String userID, String password)
+ {
+ this(userID, password.toCharArray());
+ }
+
+ /**
+ * @since 3.4
+ */
+ public PasswordCredentials(String userID)
+ {
+ super(userID);
+ }
+
public char[] getPassword()
{
return password;

Back to the top