Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.authentication.admin')
-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
20 files changed, 852 insertions, 0 deletions
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();
+ }
+ }
+}

Back to the top