Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngel Avila2015-04-29 01:52:34 +0000
committerjmisinco2015-04-29 01:52:34 +0000
commitfb09ba693042ccb53707b05f07afeb23bfccb16e (patch)
treecd17d70c91f012948caf8edb36604a9f0c8f9f0b /plugins/org.eclipse.osee.orcs.authorization
parent4ca21719d44791d7ca25cf665c00cb69bbb34a74 (diff)
downloadorg.eclipse.osee-fb09ba693042ccb53707b05f07afeb23bfccb16e.tar.gz
org.eclipse.osee-fb09ba693042ccb53707b05f07afeb23bfccb16e.tar.xz
org.eclipse.osee-fb09ba693042ccb53707b05f07afeb23bfccb16e.zip
bug: Move orcs dependencies out of xcore
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.authorization')
-rw-r--r--plugins/org.eclipse.osee.orcs.authorization/.classpath7
-rw-r--r--plugins/org.eclipse.osee.orcs.authorization/.project33
-rw-r--r--plugins/org.eclipse.osee.orcs.authorization/META-INF/MANIFEST.MF17
-rw-r--r--plugins/org.eclipse.osee.orcs.authorization/OSGI-INF/osee.authorization.provider.xml8
-rw-r--r--plugins/org.eclipse.osee.orcs.authorization/build.properties5
-rw-r--r--plugins/org.eclipse.osee.orcs.authorization/pom.xml34
-rw-r--r--plugins/org.eclipse.osee.orcs.authorization/src/org/eclipse/osee/orcs/authorization/OseeAuthorizationProvider.java136
7 files changed, 240 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.orcs.authorization/.classpath b/plugins/org.eclipse.osee.orcs.authorization/.classpath
new file mode 100644
index 0000000000..ad32c83a78
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.authorization/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.orcs.authorization/.project b/plugins/org.eclipse.osee.orcs.authorization/.project
new file mode 100644
index 0000000000..c8b8845b8c
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.authorization/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.orcs.authorization</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.orcs.authorization/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.authorization/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..f26922e16c
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.authorization/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ORCS Authorization (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.orcs.authorization
+Bundle-Version: 0.22.0.qualifier
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Service-Component: OSGI-INF/*.xml
+Export-Package: org.eclipse.osee.orcs.authorization
+Import-Package: org.eclipse.osee.authorization.admin,
+ org.eclipse.osee.framework.core.data,
+ org.eclipse.osee.framework.core.enums,
+ org.eclipse.osee.framework.jdk.core.type,
+ org.eclipse.osee.orcs,
+ org.eclipse.osee.orcs.data,
+ org.eclipse.osee.orcs.search
+Bundle-ActivationPolicy: lazy
diff --git a/plugins/org.eclipse.osee.orcs.authorization/OSGI-INF/osee.authorization.provider.xml b/plugins/org.eclipse.osee.orcs.authorization/OSGI-INF/osee.authorization.provider.xml
new file mode 100644
index 0000000000..6212286824
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.authorization/OSGI-INF/osee.authorization.provider.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
+ <implementation class="org.eclipse.osee.orcs.authorization.OseeAuthorizationProvider"/>
+ <service>
+ <provide interface="org.eclipse.osee.authorization.admin.AuthorizationProvider"/>
+ </service>
+ <reference bind="setOrcsApi" cardinality="1..1" interface="org.eclipse.osee.orcs.OrcsApi" name="OrcsApi" policy="static"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.orcs.authorization/build.properties b/plugins/org.eclipse.osee.orcs.authorization/build.properties
new file mode 100644
index 0000000000..c58ea2178c
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.authorization/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/
diff --git a/plugins/org.eclipse.osee.orcs.authorization/pom.xml b/plugins/org.eclipse.osee.orcs.authorization/pom.xml
new file mode 100644
index 0000000000..f97259e41b
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.authorization/pom.xml
@@ -0,0 +1,34 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.osee</groupId>
+ <artifactId>org.eclipse.osee.orcs.parent</artifactId>
+ <version>0.22.0-SNAPSHOT</version>
+ <relativePath>../../plugins/org.eclipse.osee.orcs.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.osee.orcs.authorization</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>ORCS Authorization - (Incubation)</name>
+
+ <build>
+ <!-- workaround for https://issues.sonatype.org/browse/TYCHO-168 -->
+ <resources>
+ <resource>
+ <directory>src</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-source-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.authorization/src/org/eclipse/osee/orcs/authorization/OseeAuthorizationProvider.java b/plugins/org.eclipse.osee.orcs.authorization/src/org/eclipse/osee/orcs/authorization/OseeAuthorizationProvider.java
new file mode 100644
index 0000000000..7674df4ee0
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.authorization/src/org/eclipse/osee/orcs/authorization/OseeAuthorizationProvider.java
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.authorization;
+
+import java.security.Principal;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+import org.eclipse.osee.authorization.admin.Authority;
+import org.eclipse.osee.authorization.admin.AuthorizationConstants;
+import org.eclipse.osee.authorization.admin.AuthorizationData;
+import org.eclipse.osee.authorization.admin.AuthorizationProvider;
+import org.eclipse.osee.authorization.admin.AuthorizationRequest;
+import org.eclipse.osee.authorization.admin.AuthorizationUser;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.jdk.core.type.ResultSet;
+import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.search.QueryFactory;
+
+/**
+ * @author Angel Avila
+ */
+public class OseeAuthorizationProvider implements AuthorizationProvider, AuthorizationData, Authority {
+ private OrcsApi orcsApi;
+
+ Principal principal;
+
+ public void setOrcsApi(OrcsApi orcsApi) {
+ this.orcsApi = orcsApi;
+ }
+
+ @Override
+ public String getScheme() {
+ return AuthorizationConstants.OSEE_AUTHORIZATION_PROVIDER;
+ }
+
+ @Override
+ public Principal getPrincipal() {
+ return principal;
+ }
+
+ @Override
+ public Authority getAuthority() {
+ return this;
+ }
+
+ @Override
+ public AuthorizationData authorize(AuthorizationRequest request) {
+ Set<String> rolesFromStore = getRolesFromStore(request.getIdentifier());
+ principal = newAuthorization(rolesFromStore);
+ return this;
+ }
+
+ private IOseeBranch getAdminBranch() {
+ return CoreBranches.COMMON;
+ }
+
+ private QueryFactory getQuery() {
+ return orcsApi.getQueryFactory();
+ }
+
+ private Set<String> getRolesFromStore(long identifier) {
+ Set<String> roles = new HashSet<String>();
+ ArtifactReadable oseeUser =
+ getQuery().fromBranch(getAdminBranch()).andUuid(identifier).getResults().getExactlyOne();
+ ResultSet<ArtifactReadable> groups = oseeUser.getRelated(CoreRelationTypes.Universal_Grouping__Group);
+ for (ArtifactReadable group : groups) {
+ roles.add(group.getName());
+ }
+
+ return roles;
+ }
+
+ @Override
+ public boolean isInRole(String role) {
+ return true;
+ }
+
+ private AuthorizationUser newAuthorization(final Set<String> roles) {
+ return new AuthorizationUser() {
+
+ @Override
+ public Iterable<String> getRoles() {
+ return roles;
+ }
+
+ @Override
+ public boolean isAuthenticated() {
+ return true;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public Date getCreationDate() {
+ return null;
+ }
+
+ @Override
+ public boolean isSecure() {
+ return false;
+ }
+
+ @Override
+ public Principal getPrincipal() {
+ return null;
+ }
+
+ @Override
+ public String getScheme() {
+ return null;
+ }
+
+ @Override
+ public boolean isInRole(String role) {
+ return false;
+ }
+
+ };
+ }
+
+}

Back to the top