Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2013-12-18 13:47:12 -0500
committerRyan D. Brooks2013-12-18 13:47:12 -0500
commitef5e93647692f868f2f1daf614831471430a181d (patch)
tree53fdf9323aadbf3e943251e1d07bf0fcc7a71862 /plugins
parentf2607d5e4cde9196ecfffbe9bea9d565587148a5 (diff)
downloadorg.eclipse.osee-ef5e93647692f868f2f1daf614831471430a181d.tar.gz
org.eclipse.osee-ef5e93647692f868f2f1daf614831471430a181d.tar.xz
org.eclipse.osee-ef5e93647692f868f2f1daf614831471430a181d.zip
feature[ats_ATS8937]: Create AuthenticationAdmin
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/.classpath (renamed from plugins/org.eclipse.osee.authentication/.classpath)0
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/.project (renamed from plugins/org.eclipse.osee.authentication/.project)2
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/META-INF/MANIFEST.MF15
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/build.properties (renamed from plugins/org.eclipse.osee.authentication/build.properties)0
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/pom.xml30
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/AuthAdminTestSuite.java24
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AnonymousUserTest.java49
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationAdminImplTest.java263
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationConfigurationBuilderTest.java88
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/InternalTestSuite.java27
-rw-r--r--plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/NoneAuthenticationProviderTest.java87
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/.classpath7
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/.project33
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/META-INF/MANIFEST.MF15
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/OSGI-INF/authentication.admin.xml9
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/OSGI-INF/none.authentication.provider.xml7
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/build.properties5
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/pom.xml34
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticatedUser.java32
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationAdmin.java30
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationConfiguration.java20
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationConfigurationBuilder.java112
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationConstants.java34
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationProvider.java23
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationRequest.java25
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationRequestBuilder.java83
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AnonymousUser.java88
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AuthenticationAdminImpl.java119
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AuthenticationImpl.java51
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AuthenticationUtil.java44
-rw-r--r--plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/NoneAuthenticationProvider.java81
-rw-r--r--plugins/org.eclipse.osee.authentication/META-INF/MANIFEST.MF8
-rw-r--r--plugins/org.eclipse.osee.authentication/src/org/eclipse/osee/authentication/placeholder.txt0
-rw-r--r--plugins/org.eclipse.osee.x.core.parent/pom.xml3
34 files changed, 1439 insertions, 9 deletions
diff --git a/plugins/org.eclipse.osee.authentication/.classpath b/plugins/org.eclipse.osee.authentication.admin.test/.classpath
index ad32c83a788..ad32c83a788 100644
--- a/plugins/org.eclipse.osee.authentication/.classpath
+++ b/plugins/org.eclipse.osee.authentication.admin.test/.classpath
diff --git a/plugins/org.eclipse.osee.authentication/.project b/plugins/org.eclipse.osee.authentication.admin.test/.project
index 0eb2e566ecd..318c92d86c0 100644
--- a/plugins/org.eclipse.osee.authentication/.project
+++ b/plugins/org.eclipse.osee.authentication.admin.test/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>org.eclipse.osee.authentication</name>
+ <name>org.eclipse.osee.authentication.admin.test</name>
<comment></comment>
<projects>
</projects>
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.authentication.admin.test/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..12ac3486b8c
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE Authentication Admin Test (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.authentication.admin.test
+Bundle-Version: 0.17.0.qualifier
+Fragment-Host: org.eclipse.osee.authentication.admin
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Import-Package: org.hamcrest.core,
+ org.junit,
+ org.junit.rules,
+ org.junit.runner,
+ org.junit.runners,
+ org.mockito,
+ org.mockito.stubbing
diff --git a/plugins/org.eclipse.osee.authentication/build.properties b/plugins/org.eclipse.osee.authentication.admin.test/build.properties
index 34d2e4d2dad..34d2e4d2dad 100644
--- a/plugins/org.eclipse.osee.authentication/build.properties
+++ b/plugins/org.eclipse.osee.authentication.admin.test/build.properties
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/pom.xml b/plugins/org.eclipse.osee.authentication.admin.test/pom.xml
new file mode 100644
index 00000000000..a6307ba38db
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/pom.xml
@@ -0,0 +1,30 @@
+<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.17.0-SNAPSHOT</version>
+ <relativePath>../../plugins/org.eclipse.osee.orcs.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.osee.authentication.admin.test</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+ <name>OSEE Authentication Admin Test - (Incubation)</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <testSuite>org.eclipse.osee.authentication.admin.test</testSuite>
+ <testClass>org.eclipse.osee.authentication.admin.AuthAdminTestSuite</testClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/AuthAdminTestSuite.java b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/AuthAdminTestSuite.java
new file mode 100644
index 00000000000..7a4308929ab
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/AuthAdminTestSuite.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin;
+
+import org.eclipse.osee.authentication.admin.internal.InternalTestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({InternalTestSuite.class})
+public class AuthAdminTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AnonymousUserTest.java b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AnonymousUserTest.java
new file mode 100644
index 00000000000..d4f898c8aec
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AnonymousUserTest.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.MockitoAnnotations.initMocks;
+import org.eclipse.osee.authentication.admin.AuthenticatedUser;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test Case for {@link AnonymousUser}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AnonymousUserTest {
+
+ private static final String NAME = AnonymousUser.ANONYMOUS_NAME;
+ private AuthenticatedUser actual;
+
+ @Before
+ public void testSetup() {
+ initMocks(this);
+
+ actual = new AnonymousUser();
+ }
+
+ @Test
+ public void testUser() {
+ assertEquals(NAME, actual.getName());
+ assertEquals(NAME, actual.getDisplayName());
+
+ assertEquals("", actual.getUserName());
+ assertEquals("", actual.getEmailAddress());
+
+ assertEquals(false, actual.getRoles().iterator().hasNext());
+ assertEquals(true, actual.isActive());
+ assertEquals(false, actual.isAuthenticated());
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationAdminImplTest.java b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationAdminImplTest.java
new file mode 100644
index 00000000000..6ab99f1cc6a
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationAdminImplTest.java
@@ -0,0 +1,263 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.eclipse.osee.authentication.admin.AuthenticatedUser;
+import org.eclipse.osee.authentication.admin.AuthenticationConstants;
+import org.eclipse.osee.authentication.admin.AuthenticationProvider;
+import org.eclipse.osee.authentication.admin.AuthenticationRequest;
+import org.eclipse.osee.authentication.admin.AuthenticationRequestBuilder;
+import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
+import org.eclipse.osee.logger.Log;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.Mock;
+
+/**
+ * Test Case for {@link AuthenticationAdminImpl}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AuthenticationAdminImplTest {
+
+ private static final String SCHEME_1 = "scheme1";
+ private static final String SCHEME_2 = "scheme2";
+
+ private static final String USERNAME = "my username";
+ private static final String PASSWORD = "my password";
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ // @formatter:off
+ @Mock private Log logger;
+
+ @Mock private AuthenticationProvider provider1;
+ @Mock private AuthenticationProvider provider2;
+
+ @Mock private AuthenticatedUser authenticatedUser;
+ // @formatter:on
+
+ private AuthenticationAdminImpl admin;
+
+ @Before
+ public void testSetup() {
+ initMocks(this);
+
+ admin = new AuthenticationAdminImpl();
+ admin.setLogger(logger);
+ admin.start(Collections.<String, Object> emptyMap());
+
+ when(provider1.getAuthenticationScheme()).thenReturn(SCHEME_1);
+ when(provider2.getAuthenticationScheme()).thenReturn(SCHEME_2);
+ }
+
+ @Test
+ public void testAddRemoveProvider() {
+ Iterable<String> iterable = admin.getAvailableSchemes();
+ assertEquals(false, iterable.iterator().hasNext());
+
+ admin.addAuthenticationProvider(provider1);
+ admin.addAuthenticationProvider(provider2);
+
+ iterable = admin.getAvailableSchemes();
+ Iterator<String> iterator = iterable.iterator();
+ assertEquals(SCHEME_1, iterator.next());
+ assertEquals(SCHEME_2, iterator.next());
+
+ admin.removeAuthenticationProvider(provider1);
+
+ iterable = admin.getAvailableSchemes();
+ iterator = iterable.iterator();
+ assertEquals(SCHEME_2, iterator.next());
+
+ admin.removeAuthenticationProvider(provider2);
+ iterable = admin.getAvailableSchemes();
+ assertEquals(false, iterable.iterator().hasNext());
+ }
+
+ @Test
+ public void testAuthenticateExceptionNoSchemeAvailable() {
+ AuthenticationRequest request = AuthenticationRequestBuilder.newBuilder()//
+ .scheme(SCHEME_1) //
+ .userName(USERNAME)//
+ .password(PASSWORD)//
+ .build();
+
+ thrown.expect(OseeArgumentException.class);
+ thrown.expectMessage("Authentication Error - scheme [" + SCHEME_1 + "] is not allowed. Schemes available [].");
+ admin.authenticate(request);
+ }
+
+ @Test
+ public void testAuthenticateSchemeAvailableButNotAllowed() {
+ admin.addAuthenticationProvider(provider1);
+
+ Iterable<String> iterable = admin.getAvailableSchemes();
+ assertEquals(SCHEME_1, iterable.iterator().next());
+
+ iterable = admin.getAllowedSchemes();
+ assertEquals(false, iterable.iterator().hasNext());
+
+ AuthenticationRequest request = AuthenticationRequestBuilder.newBuilder()//
+ .scheme(SCHEME_1) //
+ .userName(USERNAME)//
+ .password(PASSWORD)//
+ .build();
+
+ thrown.expect(OseeArgumentException.class);
+ thrown.expectMessage("Authentication Error - scheme [" + SCHEME_1 + "] is not allowed. Schemes available [].");
+ admin.authenticate(request);
+ }
+
+ @Test
+ public void testAuthenticateExceptionProviderReturnsNull() {
+ admin.addAuthenticationProvider(provider1);
+
+ Iterable<String> iterable = admin.getAvailableSchemes();
+ assertEquals(SCHEME_1, iterable.iterator().next());
+
+ iterable = admin.getAllowedSchemes();
+ assertEquals(false, iterable.iterator().hasNext());
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED, SCHEME_1);
+ admin.update(properties);
+
+ iterable = admin.getAllowedSchemes();
+ assertEquals(SCHEME_1, iterable.iterator().next());
+
+ AuthenticationRequest request = AuthenticationRequestBuilder.newBuilder()//
+ .scheme(SCHEME_1) //
+ .userName(USERNAME)//
+ .password(PASSWORD)//
+ .build();
+
+ thrown.expect(OseeArgumentException.class);
+ thrown.expectMessage("Authentication Error - scheme [" + SCHEME_1 + "] returned null principal");
+ admin.authenticate(request);
+ }
+
+ @Test
+ public void testAuthenticate() {
+ admin.addAuthenticationProvider(provider1);
+
+ Iterable<String> iterable = admin.getAvailableSchemes();
+ assertEquals(SCHEME_1, iterable.iterator().next());
+
+ iterable = admin.getAllowedSchemes();
+ assertEquals(false, iterable.iterator().hasNext());
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED, SCHEME_1);
+ admin.update(properties);
+
+ iterable = admin.getAllowedSchemes();
+ assertEquals(SCHEME_1, iterable.iterator().next());
+
+ AuthenticationRequest request = AuthenticationRequestBuilder.newBuilder()//
+ .scheme(SCHEME_1) //
+ .userName(USERNAME)//
+ .password(PASSWORD)//
+ .build();
+
+ when(provider1.authenticate(request)).thenReturn(authenticatedUser);
+
+ AuthenticatedUser actual = admin.authenticate(request);
+
+ verify(provider1).authenticate(request);
+ assertEquals(authenticatedUser, actual);
+ }
+
+ @Test
+ public void testGetAllowedSchemes() {
+ admin.addAuthenticationProvider(provider1);
+
+ Iterable<String> iterable = admin.getAvailableSchemes();
+ assertEquals(SCHEME_1, iterable.iterator().next());
+
+ iterable = admin.getAllowedSchemes();
+ assertEquals(false, iterable.iterator().hasNext());
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED, SCHEME_1);
+ admin.update(properties);
+
+ iterable = admin.getAllowedSchemes();
+ assertEquals(SCHEME_1, iterable.iterator().next());
+ }
+
+ @Test
+ public void testIsSchemeAllowed() {
+ admin.addAuthenticationProvider(provider1);
+ admin.addAuthenticationProvider(provider2);
+
+ Iterable<String> iterable = admin.getAvailableSchemes();
+ Iterator<String> iterator = iterable.iterator();
+ assertEquals(SCHEME_1, iterator.next());
+ assertEquals(SCHEME_2, iterator.next());
+
+ boolean actual = admin.isSchemeAllowed(SCHEME_1);
+ assertEquals(false, actual);
+
+ actual = admin.isSchemeAllowed(SCHEME_2);
+ assertEquals(false, actual);
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED, SCHEME_1);
+ admin.update(properties);
+
+ actual = admin.isSchemeAllowed(SCHEME_1);
+ assertEquals(true, actual);
+
+ actual = admin.isSchemeAllowed(SCHEME_2);
+ assertEquals(false, actual);
+
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED, SCHEME_1 + "," + SCHEME_2);
+ admin.update(properties);
+
+ actual = admin.isSchemeAllowed(SCHEME_1);
+ assertEquals(true, actual);
+
+ actual = admin.isSchemeAllowed(SCHEME_2);
+ assertEquals(true, actual);
+ }
+
+ @Test
+ public void testConfigUpdate() {
+ Iterator<String> iterator = admin.getAllowedSchemes().iterator();
+ assertEquals(false, iterator.hasNext());
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+ admin.update(properties);
+
+ iterator = admin.getAllowedSchemes().iterator();
+ assertEquals(false, iterator.hasNext());
+
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED, SCHEME_1 + "," + SCHEME_2);
+ admin.update(properties);
+
+ iterator = admin.getAllowedSchemes().iterator();
+ assertEquals(SCHEME_1, iterator.next());
+ assertEquals(SCHEME_2, iterator.next());
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationConfigurationBuilderTest.java b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationConfigurationBuilderTest.java
new file mode 100644
index 00000000000..5a9c7a1b734
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/AuthenticationConfigurationBuilderTest.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.MockitoAnnotations.initMocks;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.eclipse.osee.authentication.admin.AuthenticationConfiguration;
+import org.eclipse.osee.authentication.admin.AuthenticationConfigurationBuilder;
+import org.eclipse.osee.authentication.admin.AuthenticationConstants;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+/**
+ * Test Case for {@link AuthenticationConfigurationBuilder}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AuthenticationConfigurationBuilderTest {
+
+ private static final String SCHEME_1 = "scheme1";
+ private static final String SCHEME_2 = "scheme2";
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private AuthenticationConfigurationBuilder builder;
+
+ @Before
+ public void testSetup() {
+ initMocks(this);
+
+ builder = AuthenticationConfigurationBuilder.newBuilder();
+ }
+
+ @Test
+ public void testAddSchemes() {
+ builder.scheme(SCHEME_1);
+ builder.scheme(SCHEME_2);
+
+ AuthenticationConfiguration actual = builder.build();
+
+ Iterator<String> iterator = actual.getAllowedSchemes().iterator();
+ assertEquals(SCHEME_1, iterator.next());
+ assertEquals(SCHEME_2, iterator.next());
+ }
+
+ @Test
+ public void testConfigProperties() {
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED, SCHEME_2);
+ builder.properties(properties);
+
+ AuthenticationConfiguration actual = builder.build();
+
+ Iterator<String> iterator = actual.getAllowedSchemes().iterator();
+ assertEquals(SCHEME_2, iterator.next());
+ }
+
+ @Test
+ public void testNoChangeAfterBuild() {
+ builder.scheme(SCHEME_1);
+
+ AuthenticationConfiguration actual = builder.build();
+
+ Iterator<String> iterator = actual.getAllowedSchemes().iterator();
+ assertEquals(SCHEME_1, iterator.next());
+ assertEquals(false, iterator.hasNext());
+
+ builder.scheme(SCHEME_2);
+
+ iterator = actual.getAllowedSchemes().iterator();
+ assertEquals(SCHEME_1, iterator.next());
+ assertEquals(false, iterator.hasNext());
+ }
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/InternalTestSuite.java b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/InternalTestSuite.java
new file mode 100644
index 00000000000..849b7c5d229
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/InternalTestSuite.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin.internal;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ AnonymousUserTest.class,
+ AuthenticationAdminImplTest.class,
+ AuthenticationConfigurationBuilderTest.class,
+ NoneAuthenticationProviderTest.class})
+public class InternalTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/NoneAuthenticationProviderTest.java b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/NoneAuthenticationProviderTest.java
new file mode 100644
index 00000000000..afef6b238a9
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin.test/src/org/eclipse/osee/authentication/admin/internal/NoneAuthenticationProviderTest.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.MockitoAnnotations.initMocks;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.osee.authentication.admin.AuthenticatedUser;
+import org.eclipse.osee.authentication.admin.AuthenticationConstants;
+import org.eclipse.osee.authentication.admin.AuthenticationRequest;
+import org.eclipse.osee.authentication.admin.AuthenticationRequestBuilder;
+import org.eclipse.osee.logger.Log;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+
+/**
+ * Test Case for {@link NoneAuthenticationProvider}
+ *
+ * @author Roberto E. Escobar
+ */
+public class NoneAuthenticationProviderTest {
+
+ private static final String NONE_SCHEME = "none";
+ private static final String USERNAME = "my username";
+ private static final String PASSWORD = "my password";
+
+ // @formatter:off
+ @Mock private Log logger;
+ // @formatter:on
+
+ private AuthenticationAdminImpl admin;
+
+ @Before
+ public void testSetup() {
+ initMocks(this);
+
+ admin = new AuthenticationAdminImpl();
+ admin.setLogger(logger);
+
+ NoneAuthenticationProvider provider = new NoneAuthenticationProvider();
+ admin.addAuthenticationProvider(provider);
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED,
+ NoneAuthenticationProvider.AUTHENTICATION_TYPE);
+
+ admin.start(properties);
+ }
+
+ @Test
+ public void testAuthenticate() {
+ Iterable<String> iterable = admin.getAllowedSchemes();
+ assertEquals(NONE_SCHEME, iterable.iterator().next());
+
+ AuthenticationRequest request = AuthenticationRequestBuilder.newBuilder()//
+ .scheme(NONE_SCHEME) //
+ .userName(USERNAME)//
+ .password(PASSWORD)//
+ .build();
+
+ AuthenticatedUser actual = admin.authenticate(request);
+
+ assertNotNull(actual);
+
+ assertEquals(USERNAME, actual.getName());
+ assertEquals(USERNAME, actual.getUserName());
+ assertEquals(USERNAME, actual.getDisplayName());
+
+ assertEquals("", actual.getEmailAddress());
+
+ assertEquals(false, actual.getRoles().iterator().hasNext());
+ assertEquals(true, actual.isActive());
+ assertEquals(true, actual.isAuthenticated());
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin/.classpath b/plugins/org.eclipse.osee.authentication.admin/.classpath
new file mode 100644
index 00000000000..ad32c83a788
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/.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.authentication.admin/.project b/plugins/org.eclipse.osee.authentication.admin/.project
new file mode 100644
index 00000000000..f8d6f2ccadd
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.authentication.admin</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.authentication.admin/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.authentication.admin/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..effb218bf1e
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE Authentication Admin (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.authentication.admin
+Bundle-Version: 0.17.0.qualifier
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.eclipse.osee.framework.core.exception,
+ org.eclipse.osee.framework.jdk.core.type,
+ org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.logger,
+ org.osgi.framework
+Service-Component: OSGI-INF/*.xml
+Export-Package: org.eclipse.osee.authentication.admin
+Bundle-ActivationPolicy: lazy
diff --git a/plugins/org.eclipse.osee.authentication.admin/OSGI-INF/authentication.admin.xml b/plugins/org.eclipse.osee.authentication.admin/OSGI-INF/authentication.admin.xml
new file mode 100644
index 00000000000..c50418227c3
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/OSGI-INF/authentication.admin.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" configuration-policy="optional" deactivate="stop" modified="update">
+ <implementation class="org.eclipse.osee.authentication.admin.internal.AuthenticationAdminImpl"/>
+ <service>
+ <provide interface="org.eclipse.osee.authentication.admin.AuthenticationAdmin"/>
+ </service>
+ <reference bind="setLogger" cardinality="1..1" interface="org.eclipse.osee.logger.Log" name="Log" policy="static"/>
+ <reference bind="addAuthenticationProvider" cardinality="0..n" interface="org.eclipse.osee.authentication.admin.AuthenticationProvider" name="AuthenticationProvider" policy="dynamic" unbind="removeAuthenticationProvider"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.authentication.admin/OSGI-INF/none.authentication.provider.xml b/plugins/org.eclipse.osee.authentication.admin/OSGI-INF/none.authentication.provider.xml
new file mode 100644
index 00000000000..af961d4ac26
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/OSGI-INF/none.authentication.provider.xml
@@ -0,0 +1,7 @@
+<?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.authentication.admin.internal.NoneAuthenticationProvider"/>
+ <service>
+ <provide interface="org.eclipse.osee.authentication.admin.AuthenticationProvider"/>
+ </service>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.authentication.admin/build.properties b/plugins/org.eclipse.osee.authentication.admin/build.properties
new file mode 100644
index 00000000000..6210e849b59
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/build.properties
@@ -0,0 +1,5 @@
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/
+source.. = src/
diff --git a/plugins/org.eclipse.osee.authentication.admin/pom.xml b/plugins/org.eclipse.osee.authentication.admin/pom.xml
new file mode 100644
index 00000000000..f8e5e59f862
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/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.x.core.parent</artifactId>
+ <version>0.17.0-SNAPSHOT</version>
+ <relativePath>../../plugins/org.eclipse.osee.x.core.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.osee.authentication.admin</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>OSEE Authentication Admin - (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.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticatedUser.java b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticatedUser.java
new file mode 100644
index 00000000000..263c4935b03
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticatedUser.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin;
+
+import java.security.Principal;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface AuthenticatedUser extends Principal {
+
+ String getDisplayName();
+
+ String getUserName();
+
+ String getEmailAddress();
+
+ boolean isActive();
+
+ Iterable<String> getRoles();
+
+ boolean isAuthenticated();
+
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationAdmin.java b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationAdmin.java
new file mode 100644
index 00000000000..362a8317c0f
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationAdmin.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin;
+
+import org.eclipse.osee.authentication.admin.internal.AuthenticationUtil;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface AuthenticationAdmin {
+
+ public static final AuthenticatedUser ANONYMOUS_USER = AuthenticationUtil.newAnonymousUser();
+
+ AuthenticatedUser authenticate(AuthenticationRequest authenticationRequest);
+
+ boolean isSchemeAllowed(String scheme);
+
+ Iterable<String> getAllowedSchemes();
+
+ Iterable<String> getAvailableSchemes();
+
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationConfiguration.java b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationConfiguration.java
new file mode 100644
index 00000000000..66cb956d520
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationConfiguration.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface AuthenticationConfiguration {
+
+ Iterable<String> getAllowedSchemes();
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationConfigurationBuilder.java b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationConfigurationBuilder.java
new file mode 100644
index 00000000000..424a2e1696f
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationConfigurationBuilder.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin;
+
+import static org.eclipse.osee.authentication.admin.AuthenticationConstants.AUTHENTICATION_SCHEME_ALLOWED;
+import static org.eclipse.osee.authentication.admin.AuthenticationConstants.DEFAULT_AUTHENTICATION_SCHEME;
+import static org.eclipse.osee.authentication.admin.internal.AuthenticationUtil.normalize;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.osee.authentication.admin.internal.AuthenticationUtil;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AuthenticationConfigurationBuilder {
+
+ private final AuthenticationConfigurationImpl config = new AuthenticationConfigurationImpl();
+
+ private AuthenticationConfigurationBuilder() {
+ //Builder class
+ }
+
+ public static AuthenticationConfigurationBuilder newBuilder() {
+ return new AuthenticationConfigurationBuilder();
+ }
+
+ public AuthenticationConfigurationBuilder scheme(String scheme) {
+ config.addScheme(scheme);
+ return this;
+ }
+
+ public AuthenticationConfigurationBuilder properties(Map<String, Object> props) {
+ config.loadProperties(props);
+ return this;
+ }
+
+ public AuthenticationConfiguration build() {
+ return config.clone();
+ }
+
+ private static final class AuthenticationConfigurationImpl implements AuthenticationConfiguration, Cloneable {
+
+ private final Set<String> schemes = new HashSet<String>();
+
+ @Override
+ public Iterable<String> getAllowedSchemes() {
+ return AuthenticationUtil.unmodifiableSortedIterable(schemes);
+ }
+
+ public void addSchemes(Collection<String> toAdd) {
+ if (toAdd != null && !toAdd.isEmpty()) {
+ schemes.addAll(toAdd);
+ }
+ }
+
+ public void addScheme(String scheme) {
+ if (Strings.isValid(scheme)) {
+ schemes.add(scheme);
+ }
+ }
+
+ @Override
+ public synchronized AuthenticationConfigurationImpl clone() {
+ AuthenticationConfigurationImpl cloned = new AuthenticationConfigurationImpl();
+ cloned.addSchemes(this.schemes);
+ return cloned;
+ }
+
+ public void loadProperties(Map<String, Object> props) {
+ if (props != null && !props.isEmpty()) {
+ addSchemes(getSet(props, AUTHENTICATION_SCHEME_ALLOWED, DEFAULT_AUTHENTICATION_SCHEME));
+ }
+ }
+
+ public Collection<String> getSet(Map<String, Object> props, String key, String defaultValue) {
+ Set<String> toReturn = new HashSet<String>();
+ String joinedArray = get(props, key, "");
+ if (Strings.isValid(joinedArray)) {
+ String[] split = joinedArray.split(",");
+ for (String value : split) {
+ String toAdd = normalize(value);
+ if (Strings.isValid(toAdd)) {
+ toReturn.add(toAdd);
+ }
+ }
+ } else {
+ toReturn.add(defaultValue);
+ }
+ return toReturn;
+ }
+
+ private String get(Map<String, Object> props, String key, String defaultValue) {
+ String toReturn = defaultValue;
+ Object object = props.get(key);
+ if (object != null) {
+ toReturn = String.valueOf(object);
+ }
+ return toReturn;
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationConstants.java b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationConstants.java
new file mode 100644
index 00000000000..e758469df43
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationConstants.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class AuthenticationConstants {
+
+ private AuthenticationConstants() {
+ // Utility class
+ }
+
+ public static final String NAMESPACE = "authentication";
+
+ private static String qualify(String value) {
+ return String.format("%s.%s", NAMESPACE, value);
+ }
+
+ public static final String NO_AUTHENTICATION = "None";
+
+ public static final String DEFAULT_AUTHENTICATION_SCHEME = NO_AUTHENTICATION;
+
+ public static final String AUTHENTICATION_SCHEME_ALLOWED = qualify("scheme.allowed");
+
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationProvider.java b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationProvider.java
new file mode 100644
index 00000000000..a7a63892e91
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationProvider.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin;
+
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface AuthenticationProvider {
+
+ String getAuthenticationScheme();
+
+ AuthenticatedUser authenticate(AuthenticationRequest request);
+
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationRequest.java b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationRequest.java
new file mode 100644
index 00000000000..ca6ce54e7fc
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationRequest.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin;
+
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface AuthenticationRequest {
+
+ String getScheme();
+
+ String getUserName();
+
+ String getPassword();
+
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationRequestBuilder.java b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationRequestBuilder.java
new file mode 100644
index 00000000000..d21f43ad0a3
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/AuthenticationRequestBuilder.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class AuthenticationRequestBuilder {
+
+ private String scheme;
+ private String userName;
+ private String password;
+
+ private AuthenticationRequestBuilder() {
+ //
+ }
+
+ public static AuthenticationRequestBuilder newBuilder() {
+ return new AuthenticationRequestBuilder();
+ }
+
+ public AuthenticationRequestBuilder scheme(String scheme) {
+ this.scheme = scheme;
+ return this;
+ }
+
+ public AuthenticationRequestBuilder userName(String userName) {
+ this.userName = userName;
+ return this;
+ }
+
+ public AuthenticationRequestBuilder password(String password) {
+ this.password = password;
+ return this;
+ }
+
+ public AuthenticationRequest build() {
+ return new AuthenticationRequestImpl(scheme, userName, password);
+ }
+
+ private static final class AuthenticationRequestImpl implements AuthenticationRequest {
+
+ private final String userName;
+ private final String password;
+ private final String scheme;
+
+ public AuthenticationRequestImpl(String scheme, String userName, String password) {
+ super();
+ this.scheme = scheme;
+ this.userName = userName;
+ this.password = password;
+ }
+
+ @Override
+ public String getScheme() {
+ return scheme;
+ }
+
+ @Override
+ public String getUserName() {
+ return userName;
+ }
+
+ @Override
+ public String getPassword() {
+ return password;
+ }
+
+ @Override
+ public String toString() {
+ return "AuthenticationRequestImpl [scheme=" + scheme + ", userName=" + userName + ", password=[*****]]";
+ }
+
+ }
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AnonymousUser.java b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AnonymousUser.java
new file mode 100644
index 00000000000..b5fa533e0aa
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AnonymousUser.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin.internal;
+
+import java.util.Collections;
+import org.eclipse.osee.authentication.admin.AuthenticatedUser;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AnonymousUser implements AuthenticatedUser {
+
+ protected static final String ANONYMOUS_NAME = "Anonymous";
+
+ @Override
+ public String getName() {
+ return ANONYMOUS_NAME;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return getName();
+ }
+
+ @Override
+ public String getUserName() {
+ return Strings.emptyString();
+ }
+
+ @Override
+ public String getEmailAddress() {
+ return Strings.emptyString();
+ }
+
+ @Override
+ public boolean isActive() {
+ return true;
+ }
+
+ @Override
+ public Iterable<String> getRoles() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public boolean isAuthenticated() {
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ AnonymousUser other = (AnonymousUser) obj;
+ if (getName() == null) {
+ if (other.getName() != null) {
+ return false;
+ }
+ } else if (!getName().equals(other.getName())) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AuthenticationAdminImpl.java b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AuthenticationAdminImpl.java
new file mode 100644
index 00000000000..8bc0ef72513
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AuthenticationAdminImpl.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin.internal;
+
+import static org.eclipse.osee.authentication.admin.internal.AuthenticationUtil.normalize;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.eclipse.osee.authentication.admin.AuthenticatedUser;
+import org.eclipse.osee.authentication.admin.AuthenticationAdmin;
+import org.eclipse.osee.authentication.admin.AuthenticationConfiguration;
+import org.eclipse.osee.authentication.admin.AuthenticationConfigurationBuilder;
+import org.eclipse.osee.authentication.admin.AuthenticationProvider;
+import org.eclipse.osee.authentication.admin.AuthenticationRequest;
+import org.eclipse.osee.framework.jdk.core.util.Conditions;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.logger.Log;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AuthenticationAdminImpl implements AuthenticationAdmin {
+
+ private final Map<String, AuthenticationProvider> authenticationProviders =
+ new ConcurrentHashMap<String, AuthenticationProvider>();
+
+ private Log logger;
+ private AuthenticationConfiguration config;
+
+ public void setLogger(Log logger) {
+ this.logger = logger;
+ }
+
+ public void start(Map<String, Object> properties) {
+ logger.trace("Starting AuthenticationAdminImpl...");
+ update(properties);
+ }
+
+ public void stop() {
+ logger.trace("Stopping AuthenticationAdminImpl...");
+ config = null;
+ }
+
+ public void update(Map<String, Object> properties) {
+ logger.trace("Updating AuthenticationAdmin Config...");
+
+ config = AuthenticationConfigurationBuilder.newBuilder()//
+ .properties(properties)//
+ .build();
+ }
+
+ public void addAuthenticationProvider(AuthenticationProvider authenticationProvider) {
+ String providerId = authenticationProvider.getAuthenticationScheme();
+ providerId = normalize(providerId);
+ authenticationProviders.put(providerId, authenticationProvider);
+ }
+
+ public void removeAuthenticationProvider(AuthenticationProvider authenticationProvider) {
+ String providerId = authenticationProvider.getAuthenticationScheme();
+ providerId = normalize(providerId);
+ authenticationProviders.remove(providerId);
+ }
+
+ @Override
+ public Iterable<String> getAvailableSchemes() {
+ return AuthenticationUtil.unmodifiableSortedIterable(authenticationProviders.keySet());
+ }
+
+ @Override
+ public Iterable<String> getAllowedSchemes() {
+ return config.getAllowedSchemes();
+ }
+
+ private AuthenticationProvider getAuthenticator(String schemeType) {
+ String toMatch = normalize(schemeType);
+ return authenticationProviders.get(toMatch);
+ }
+
+ @Override
+ public AuthenticatedUser authenticate(AuthenticationRequest authenticationRequest) {
+ String schemeType = authenticationRequest.getScheme();
+ checkSchemeAllowed(schemeType);
+
+ AuthenticationProvider provider = getAuthenticator(schemeType);
+ AuthenticatedUser principal = provider.authenticate(authenticationRequest);
+
+ Conditions.checkExpressionFailOnTrue(principal == null,
+ "Authentication Error - scheme [%s] returned null principal", schemeType);
+
+ return principal;
+ }
+
+ @Override
+ public boolean isSchemeAllowed(String schemeType) {
+ boolean isAllowed = false;
+ if (Strings.isValid(schemeType)) {
+ String toMatch = normalize(schemeType);
+ for (String scheme : getAllowedSchemes()) {
+ isAllowed = scheme.equals(toMatch);
+ if (isAllowed) {
+ break;
+ }
+ }
+ }
+ return isAllowed;
+ }
+
+ private void checkSchemeAllowed(String schemeType) {
+ Conditions.checkExpressionFailOnTrue(!isSchemeAllowed(schemeType),
+ "Authentication Error - scheme [%s] is not allowed. Schemes available %s.", schemeType, getAllowedSchemes());
+ }
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AuthenticationImpl.java b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AuthenticationImpl.java
new file mode 100644
index 00000000000..b2d7b233115
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AuthenticationImpl.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin.internal;
+
+import org.eclipse.osee.authentication.admin.AuthenticationRequest;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AuthenticationImpl implements AuthenticationRequest {
+
+ private final String scheme;
+ private final String userName;
+ private final String password;
+
+ public AuthenticationImpl(String scheme, String userName, String password) {
+ super();
+ this.scheme = scheme;
+ this.userName = userName;
+ this.password = password;
+ }
+
+ @Override
+ public String getUserName() {
+ return userName;
+ }
+
+ @Override
+ public String getPassword() {
+ return password;
+ }
+
+ @Override
+ public String getScheme() {
+ return scheme;
+ }
+
+ @Override
+ public String toString() {
+ return "AuthenticationImpl [scheme=" + scheme + ", userName=" + userName + ", password=[********]]";
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AuthenticationUtil.java b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AuthenticationUtil.java
new file mode 100644
index 00000000000..1ba2b16a4f8
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/AuthenticationUtil.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin.internal;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.eclipse.osee.authentication.admin.AuthenticatedUser;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class AuthenticationUtil {
+
+ private AuthenticationUtil() {
+ //
+ }
+
+ public static AuthenticatedUser newAnonymousUser() {
+ return new AnonymousUser();
+ }
+
+ public static String normalize(String value) {
+ return Strings.isValid(value) ? value.toLowerCase().trim() : value;
+ }
+
+ public static Iterable<String> unmodifiableSortedIterable(Collection<String> source) {
+ List<String> list = new ArrayList<String>();
+ list.addAll(source);
+ Collections.sort(list);
+ return Collections.unmodifiableList(list);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/NoneAuthenticationProvider.java b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/NoneAuthenticationProvider.java
new file mode 100644
index 00000000000..e86253510ab
--- /dev/null
+++ b/plugins/org.eclipse.osee.authentication.admin/src/org/eclipse/osee/authentication/admin/internal/NoneAuthenticationProvider.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.authentication.admin.internal;
+
+import java.util.Collections;
+import org.eclipse.osee.authentication.admin.AuthenticatedUser;
+import org.eclipse.osee.authentication.admin.AuthenticationProvider;
+import org.eclipse.osee.authentication.admin.AuthenticationRequest;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class NoneAuthenticationProvider implements AuthenticationProvider {
+
+ protected static final String AUTHENTICATION_TYPE = "None";
+
+ @Override
+ public String getAuthenticationScheme() {
+ return AUTHENTICATION_TYPE;
+ }
+
+ @Override
+ public AuthenticatedUser authenticate(AuthenticationRequest request) {
+ String username = request.getUserName();
+ return new AssumeAnyUser(username);
+ }
+
+ private static final class AssumeAnyUser implements AuthenticatedUser {
+
+ private final String username;
+
+ public AssumeAnyUser(String username) {
+ super();
+ this.username = username;
+ }
+
+ @Override
+ public String getName() {
+ return username;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return username;
+ }
+
+ @Override
+ public String getUserName() {
+ return username;
+ }
+
+ @Override
+ public String getEmailAddress() {
+ return Strings.emptyString();
+ }
+
+ @Override
+ public boolean isActive() {
+ return true;
+ }
+
+ @Override
+ public boolean isAuthenticated() {
+ return true;
+ }
+
+ @Override
+ public Iterable<String> getRoles() {
+ return Collections.emptyList();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.authentication/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.authentication/META-INF/MANIFEST.MF
deleted file mode 100644
index 1048a2169fd..00000000000
--- a/plugins/org.eclipse.osee.authentication/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,8 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: OSEE Authentication
-Bundle-SymbolicName: org.eclipse.osee.authentication
-Bundle-Version: 0.17.0.qualifier
-Bundle-Vendor: Eclipse Open System Engineering Environment
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Import-Package: org.osgi.framework;version="1.3.0"
diff --git a/plugins/org.eclipse.osee.authentication/src/org/eclipse/osee/authentication/placeholder.txt b/plugins/org.eclipse.osee.authentication/src/org/eclipse/osee/authentication/placeholder.txt
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/plugins/org.eclipse.osee.authentication/src/org/eclipse/osee/authentication/placeholder.txt
+++ /dev/null
diff --git a/plugins/org.eclipse.osee.x.core.parent/pom.xml b/plugins/org.eclipse.osee.x.core.parent/pom.xml
index 02df270547e..15abc218dc0 100644
--- a/plugins/org.eclipse.osee.x.core.parent/pom.xml
+++ b/plugins/org.eclipse.osee.x.core.parent/pom.xml
@@ -36,6 +36,9 @@
<module>../../plugins/org.eclipse.osee.framework.jdk.core</module>
<module>../../plugins/org.eclipse.osee.framework.jdk.core.test</module>
+ <module>../../plugins/org.eclipse.osee.authentication.admin</module>
+ <module>../../plugins/org.eclipse.osee.authentication.admin.test</module>
+
<module>../../plugins/org.eclipse.osee.account.admin</module>
<module>../../plugins/org.eclipse.osee.account.admin.test</module>

Back to the top