Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.examples')
-rw-r--r--plugins/org.eclipse.emf.cdo.examples/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.emf.cdo.examples/build.properties3
-rw-r--r--plugins/org.eclipse.emf.cdo.examples/plugin.xml23
-rw-r--r--plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/server/UserRolesQueryHandlerFactory.java66
4 files changed, 94 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.examples/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.examples/META-INF/MANIFEST.MF
index 1937cef3cd..dafdd53703 100644
--- a/plugins/org.eclipse.emf.cdo.examples/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.examples/META-INF/MANIFEST.MF
@@ -19,7 +19,9 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)";resoluti
org.eclipse.emf.cdo.server.embedded;bundle-version="[4.0.0,5.0.0)",
org.eclipse.net4j.jvm;bundle-version="[4.0.0,5.0.0)",
org.eclipse.net4j.tcp;bundle-version="[4.0.0,5.0.0)",
- org.eclipse.net4j.db.h2;bundle-version="[4.0.0,5.0.0)"
+ org.eclipse.net4j.db.h2;bundle-version="[4.0.0,5.0.0)",
+ org.eclipse.emf.cdo.security;bundle-version="[4.0.0,5.0.0)",
+ org.eclipse.emf.cdo.server.security;bundle-version="[4.0.0,5.0.0)"
Import-Package: org.h2.jdbcx;version="[1.0.0,2.0.0)"
Export-Package: org.eclipse.emf.cdo.examples;version="4.0.800";x-internal:=true,
org.eclipse.emf.cdo.examples.embedded;version="4.0.800",
diff --git a/plugins/org.eclipse.emf.cdo.examples/build.properties b/plugins/org.eclipse.emf.cdo.examples/build.properties
index 0618dd7116..23ed73cb27 100644
--- a/plugins/org.eclipse.emf.cdo.examples/build.properties
+++ b/plugins/org.eclipse.emf.cdo.examples/build.properties
@@ -19,7 +19,8 @@ bin.includes = META-INF/,\
about.properties,\
modeling32.png,\
.,\
- sslKey/
+ sslKey/,\
+ plugin.xml
source.. = src/
jars.compile.order = .
src.includes = about.html,\
diff --git a/plugins/org.eclipse.emf.cdo.examples/plugin.xml b/plugins/org.eclipse.emf.cdo.examples/plugin.xml
new file mode 100644
index 0000000000..e9d7066626
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.examples/plugin.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<!--
+ Copyright (c) 2012, 2013 Eike Stepper (Loehne, 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
+-->
+
+<plugin>
+
+ <extension point="org.eclipse.net4j.util.factories">
+ <factory
+ productGroup="org.eclipse.emf.cdo.server.queryHandlerFactories"
+ type="user_roles"
+ class="org.eclipse.emf.cdo.examples.server.UserRolesQueryHandlerFactory"/>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/server/UserRolesQueryHandlerFactory.java b/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/server/UserRolesQueryHandlerFactory.java
new file mode 100644
index 0000000000..4fe7310ac9
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/server/UserRolesQueryHandlerFactory.java
@@ -0,0 +1,66 @@
+package org.eclipse.emf.cdo.examples.server;
+
+import org.eclipse.emf.cdo.common.util.CDOQueryInfo;
+import org.eclipse.emf.cdo.security.Realm;
+import org.eclipse.emf.cdo.security.Role;
+import org.eclipse.emf.cdo.security.User;
+import org.eclipse.emf.cdo.server.IQueryContext;
+import org.eclipse.emf.cdo.server.IQueryHandler;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.ISession;
+import org.eclipse.emf.cdo.server.security.ISecurityManager;
+import org.eclipse.emf.cdo.server.security.ISecurityManager.RealmOperation;
+import org.eclipse.emf.cdo.server.security.SecurityManagerUtil;
+import org.eclipse.emf.cdo.spi.server.QueryHandlerFactory;
+
+import org.eclipse.net4j.util.factory.ProductCreationException;
+
+/**
+ * @author Eike Stepper
+ */
+public class UserRolesQueryHandlerFactory extends QueryHandlerFactory
+{
+ public static final String LANGUAGE = "user_roles";
+
+ public UserRolesQueryHandlerFactory()
+ {
+ super(LANGUAGE);
+ }
+
+ @Override
+ public IQueryHandler create(String description) throws ProductCreationException
+ {
+ return new IQueryHandler()
+ {
+ public void executeQuery(CDOQueryInfo info, final IQueryContext context)
+ {
+ ISession session = context.getView().getSession();
+ IRepository repository = session.getManager().getRepository();
+ ISecurityManager securityManager = SecurityManagerUtil.getSecurityManager(repository);
+
+ if (securityManager != null)
+ {
+ final String userID = session.getUserID();
+
+ securityManager.read(new RealmOperation()
+ {
+ public void execute(Realm realm)
+ {
+ User user = realm.getUser(userID);
+
+ for (Role role : user.getAllRoles())
+ {
+ String roleID = role.getId();
+ if (!context.addResult(roleID))
+ {
+ // maxResults has been reached.
+ break;
+ }
+ }
+ }
+ });
+ }
+ }
+ };
+ }
+}

Back to the top