This repository has been archived by the owner on Mar 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from junkerm/develop
Release 0.1.6
- Loading branch information
Showing
125 changed files
with
2,308 additions
and
4,091 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.8"/> | ||
<classpathentry kind="con" path="aQute.bnd.classpath.container"/> | ||
<classpathentry kind="src" output="bin" path="src"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/bin/ | ||
/generated/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>specmate-auth-test</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>bndtools.core.bndbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>bndtools.core.bndnature</nature> | ||
</natures> | ||
</projectDescription> |
2 changes: 2 additions & 0 deletions
2
bundles/specmate-auth-test/.settings/org.eclipse.core.resources.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
eclipse.preferences.version=1 | ||
encoding/bnd.bnd=UTF-8 |
11 changes: 11 additions & 0 deletions
11
bundles/specmate-auth-test/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
Test-Cases: \ | ||
com.specmate.auth.test.InMemorySessionServiceTest | ||
-buildpath: \ | ||
org.apache.servicemix.bundles.junit,\ | ||
specmate-model-gen;version=latest,\ | ||
specmate-auth;version=latest,\ | ||
specmate-common;version=latest,\ | ||
specmate-config-api;version=latest,\ | ||
osgi.core,\ | ||
specmate-config;version=latest,\ | ||
specmate-logging;version=latest,\ | ||
specmate-logging-slf4j;version=latest,\ | ||
specmate-logging-slf4j-julbridge;version=latest,\ | ||
specmate-migration-api;version=latest,\ | ||
specmate-persistency-cdo;version=latest | ||
-runfw: org.eclipse.osgi;version='[3.10.2.v20150203-1939,3.10.2.v20150203-1939]' | ||
-runee: JavaSE-1.8 | ||
-runproperties:\ | ||
jetty.http.port=8088,\ | ||
jetty.etc.config.urls='etc/jetty.xml,etc/jetty-http.xml,etc/jetty-deployer.xml,etc/jetty-rewrite.xml',\ | ||
osgi.console=,\ | ||
jetty.home.bundle=specmate-jettystarter,\ | ||
osgi.compatibility.bootdelegation=true,\ | ||
tester.trace=true,\ | ||
tester.continuous=true,\ | ||
tester.dir=testdir | ||
-runvm: -ea | ||
-runrequires: \ | ||
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)',\ | ||
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\ | ||
osgi.identity;filter:='(osgi.identity=org.eclipse.equinox.log)',\ | ||
osgi.identity;filter:='(osgi.identity=jul.to.slf4j)',\ | ||
osgi.identity;filter:='(osgi.identity=log4j.over.slf4j)',\ | ||
osgi.identity;filter:='(osgi.identity=specmate-common)',\ | ||
osgi.identity;filter:='(osgi.identity=specmate-logging)',\ | ||
osgi.identity;filter:='(osgi.identity=specmate-logging-slf4j)',\ | ||
osgi.identity;filter:='(osgi.identity=org.json)',\ | ||
osgi.identity;filter:='(osgi.identity=specmate-logging-slf4j-julbridge)',\ | ||
osgi.identity;filter:='(osgi.identity=specmate-persistency-api)',\ | ||
osgi.identity;filter:='(osgi.identity=org.eclipse.equinox.event)',\ | ||
osgi.identity;filter:='(osgi.identity=org.eclipse.equinox.cm)',\ | ||
osgi.identity;filter:='(osgi.identity=org.eclipse.equinox.metatype)',\ | ||
osgi.identity;filter:='(osgi.identity=specmate-config)',\ | ||
osgi.identity;filter:='(osgi.identity=specmate-model-gen)',\ | ||
osgi.identity;filter:='(osgi.identity=specmate-model-support)',\ | ||
osgi.identity;filter:='(osgi.identity=org.eclipse.emf.cdo.server.ocl)',\ | ||
osgi.identity;filter:='(osgi.identity=org.apache.servicemix.bundles.junit)',\ | ||
osgi.identity;filter:='(osgi.identity=specmate-auth)',\ | ||
osgi.identity;filter:='(osgi.identity=specmate-persistency-cdo)' | ||
-runbundles: \ | ||
javax.annotation-api;version='[1.2.0,1.2.1)',\ | ||
javax.validation.api;version='[1.1.0,1.1.1)',\ | ||
javax.ws.rs-api;version='[2.0.1,2.0.2)',\ | ||
jul.to.slf4j;version='[1.7.12,1.7.13)',\ | ||
log4j.over.slf4j;version='[1.7.12,1.7.13)',\ | ||
lpg.runtime.java;version='[2.0.17,2.0.18)',\ | ||
org.apache.commons.lang;version='[2.6.0,2.6.1)',\ | ||
org.apache.commons.lang3;version='[3.3.2,3.3.3)',\ | ||
org.apache.felix.gogo.command;version='[0.10.0,0.10.1)',\ | ||
org.apache.felix.gogo.runtime;version='[0.10.0,0.10.1)',\ | ||
org.apache.felix.gogo.shell;version='[0.10.0,0.10.1)',\ | ||
org.apache.felix.scr;version='[2.0.8,2.0.9)',\ | ||
org.apache.servicemix.bundles.junit;version='[4.12.0,4.12.1)',\ | ||
org.eclipse.core.contenttype;version='[3.4.200,3.4.201)',\ | ||
org.eclipse.core.jobs;version='[3.6.1,3.6.2)',\ | ||
org.eclipse.core.runtime;version='[3.10.0,3.10.1)',\ | ||
org.eclipse.emf.cdo;version='[4.5.0,4.5.1)',\ | ||
org.eclipse.emf.cdo.common;version='[4.5.0,4.5.1)',\ | ||
org.eclipse.emf.cdo.ecore.retrofit;version='[4.2.300,4.2.301)',\ | ||
org.eclipse.emf.cdo.server;version='[4.5.0,4.5.1)',\ | ||
org.eclipse.emf.cdo.server.ocl;version='[4.2.100,4.2.101)',\ | ||
org.eclipse.emf.common;version='[2.12.0,2.12.1)',\ | ||
org.eclipse.emf.ecore;version='[2.12.0,2.12.1)',\ | ||
org.eclipse.emf.ecore.change;version='[2.11.0,2.11.1)',\ | ||
org.eclipse.emf.ecore.xmi;version='[2.12.0,2.12.1)',\ | ||
org.eclipse.equinox.app;version='[1.3.200,1.3.201)',\ | ||
org.eclipse.equinox.cm;version='[1.1.0,1.1.1)',\ | ||
org.eclipse.equinox.common;version='[3.6.200,3.6.201)',\ | ||
org.eclipse.equinox.event;version='[1.3.100,1.3.101)',\ | ||
org.eclipse.equinox.log;version='[1.2.300,1.2.301)',\ | ||
org.eclipse.equinox.metatype;version='[1.4.0,1.4.1)',\ | ||
org.eclipse.equinox.preferences;version='[3.5.200,3.5.201)',\ | ||
org.eclipse.equinox.registry;version='[3.5.400,3.5.401)',\ | ||
org.eclipse.net4j.util;version='[3.6.0,3.6.1)',\ | ||
org.eclipse.ocl;version='[3.6.200,3.6.201)',\ | ||
org.eclipse.ocl.common;version='[1.4.200,1.4.201)',\ | ||
org.eclipse.ocl.ecore;version='[3.6.200,3.6.201)',\ | ||
org.eclipse.osgi.services;version='[3.4.0,3.4.1)',\ | ||
org.glassfish.hk2.api;version='[2.4.0,2.4.1)',\ | ||
org.glassfish.hk2.external.aopalliance-repackaged;version='[2.4.0,2.4.1)',\ | ||
org.glassfish.hk2.external.javax.inject;version='[2.4.0,2.4.1)',\ | ||
org.glassfish.hk2.osgi-resource-locator;version='[1.0.1,1.0.2)',\ | ||
org.glassfish.hk2.utils;version='[2.4.0,2.4.1)',\ | ||
org.glassfish.jersey.bundles.repackaged.jersey-guava;version='[2.17.0,2.17.1)',\ | ||
org.glassfish.jersey.core.jersey-client;version='[2.17.0,2.17.1)',\ | ||
org.glassfish.jersey.core.jersey-common;version='[2.17.0,2.17.1)',\ | ||
org.glassfish.jersey.core.jersey-server;version='[2.17.0,2.17.1)',\ | ||
org.glassfish.jersey.media.jersey-media-sse;version='[2.17.0,2.17.1)',\ | ||
org.json;version=snapshot,\ | ||
org.slf4j.api;version='[1.7.2,1.7.3)',\ | ||
slf4j.api;version='[1.7.12,1.7.13)',\ | ||
specmate-common;version=snapshot,\ | ||
specmate-config;version=snapshot,\ | ||
specmate-config-api;version=snapshot,\ | ||
specmate-logging;version=snapshot,\ | ||
specmate-logging-slf4j;version=snapshot,\ | ||
specmate-logging-slf4j-julbridge;version=snapshot,\ | ||
specmate-model-gen;version=snapshot,\ | ||
specmate-model-support;version=snapshot,\ | ||
specmate-persistency-api;version=snapshot,\ | ||
specmate-auth;version=snapshot,\ | ||
org.eclipse.emf.cdo.net4j;version='[4.1.400,4.1.401)',\ | ||
org.eclipse.emf.cdo.server.db;version='[4.4.0,4.4.1)',\ | ||
org.eclipse.emf.cdo.server.net4j;version='[4.1.300,4.1.301)',\ | ||
org.eclipse.net4j;version='[4.5.0,4.5.1)',\ | ||
org.eclipse.net4j.db;version='[4.5.0,4.5.1)',\ | ||
org.eclipse.net4j.db.h2;version='[4.2.300,4.2.301)',\ | ||
org.eclipse.net4j.db.jdbc;version='[4.3.100,4.3.101)',\ | ||
org.eclipse.net4j.jvm;version='[4.1.400,4.1.401)',\ | ||
org.eclipse.net4j.tcp;version='[4.1.400,4.1.401)',\ | ||
org.h2;version='[1.4.186,1.4.187)',\ | ||
specmate-administration;version=snapshot,\ | ||
specmate-emfrest-api;version=snapshot,\ | ||
specmate-migration-api;version=snapshot,\ | ||
specmate-persistency-cdo;version=snapshot,\ | ||
specmate-connectors;version=snapshot |
94 changes: 94 additions & 0 deletions
94
bundles/specmate-auth-test/src/com/specmate/auth/test/InMemorySessionServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.specmate.auth.test; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.osgi.framework.BundleContext; | ||
import org.osgi.framework.Filter; | ||
import org.osgi.framework.FrameworkUtil; | ||
import org.osgi.util.tracker.ServiceTracker; | ||
|
||
import com.specmate.auth.api.ISessionService; | ||
import com.specmate.common.SpecmateException; | ||
import com.specmate.usermodel.AccessRights; | ||
|
||
public class InMemorySessionServiceTest { | ||
private static ISessionService sessionService; | ||
private static BundleContext context; | ||
private String baseURL = "localhost/services/rest/"; | ||
|
||
@BeforeClass | ||
public static void init() throws Exception { | ||
context = FrameworkUtil.getBundle(InMemorySessionServiceTest.class).getBundleContext(); | ||
sessionService = getSessionService(); | ||
} | ||
|
||
@Test | ||
public void testIsAuthorized() throws SpecmateException { | ||
String projectName = "testIsAuthorized"; | ||
String token = sessionService.create(AccessRights.ALL, AccessRights.ALL, projectName); | ||
assertTrue(sessionService.isAuthorized(token, baseURL + projectName + "/resource1")); | ||
assertTrue(sessionService.isAuthorized(token, baseURL + projectName + "/resource1/resource2")); | ||
assertTrue(sessionService.isAuthorized(token, baseURL + projectName + "/")); | ||
assertFalse(sessionService.isAuthorized(token, baseURL + projectName)); | ||
assertFalse(sessionService.isAuthorized(token, baseURL)); | ||
assertFalse(sessionService.isAuthorized(token, baseURL.substring(0, baseURL.length() - 1))); | ||
} | ||
|
||
@Test | ||
public void testRegexInjection() throws SpecmateException { | ||
String token = sessionService.create(AccessRights.ALL, AccessRights.ALL, "testRegexInjection"); | ||
assertFalse(sessionService.isAuthorized(token, baseURL + "project/resource1")); | ||
assertFalse(sessionService.isAuthorized(token, baseURL + "project/")); | ||
assertFalse(sessionService.isAuthorized(token, baseURL + "project")); | ||
|
||
token = sessionService.create(AccessRights.ALL, AccessRights.ALL, ""); | ||
assertFalse(sessionService.isAuthorized(token, baseURL + "pro/resource1")); | ||
sessionService.delete(token); | ||
|
||
token = sessionService.create(AccessRights.ALL, AccessRights.ALL, "?"); | ||
assertFalse(sessionService.isAuthorized(token, baseURL + "p/resource1")); | ||
sessionService.delete(token); | ||
|
||
token = sessionService.create(AccessRights.ALL, AccessRights.ALL, ".*"); | ||
assertFalse(sessionService.isAuthorized(token, baseURL + "pr/resource1")); | ||
sessionService.delete(token); | ||
|
||
token = sessionService.create(AccessRights.ALL, AccessRights.ALL, ".+"); | ||
assertFalse(sessionService.isAuthorized(token, baseURL + "pro/resource1")); | ||
} | ||
|
||
@Test | ||
public void testDeleteSession() throws SpecmateException { | ||
boolean thrown = false; | ||
String projectName = "testDeleteSession"; | ||
String token = sessionService.create(AccessRights.ALL, AccessRights.ALL, projectName); | ||
assertTrue(sessionService.isAuthorized(token, baseURL + projectName + "/resource1")); | ||
sessionService.delete(token); | ||
try { | ||
assertFalse(sessionService.isAuthorized(token, baseURL + projectName + "/resource1")); | ||
} catch (SpecmateException e) { | ||
thrown = true; | ||
} | ||
|
||
assertTrue(thrown); | ||
} | ||
|
||
private static ISessionService getSessionService() throws Exception { | ||
Filter sessionFilter = context.createFilter("(impl=volatile)"); | ||
ServiceTracker<ISessionService, ISessionService> sessionTracker = new ServiceTracker<>(context, | ||
sessionFilter, null); | ||
sessionTracker.open(); | ||
ISessionService sessionService; | ||
try { | ||
sessionService = sessionTracker.waitForService(10000); | ||
} catch (InterruptedException e) { | ||
throw new SpecmateException(e); | ||
} | ||
Assert.assertNotNull(sessionService); | ||
return sessionService; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
bundles/specmate-auth/src/com/specmate/auth/api/IAuthenticationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
package com.specmate.auth.api; | ||
|
||
import com.specmate.common.SpecmateException; | ||
import com.specmate.usermodel.AccessRights; | ||
|
||
public interface IAuthenticationService { | ||
public String authenticate(String username, String password, String projectname) throws SpecmateException; | ||
public String authenticate(String username, String password) throws SpecmateException; | ||
public void deauthenticate(String token) throws SpecmateException; | ||
public void validateToken(String token, String path, boolean refresh) throws SpecmateException; | ||
public AccessRights getSourceAccessRights(String token) throws SpecmateException; | ||
public AccessRights getTargetAccessRights(String token) throws SpecmateException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.