salt creation and password hash comparison service api 73/72073/6
authorRyan Goulding <ryandgoulding@gmail.com>
Thu, 17 May 2018 20:13:26 +0000 (16:13 -0400)
committerRyan Goulding <ryandgoulding@gmail.com>
Thu, 17 May 2018 20:59:17 +0000 (16:59 -0400)
A generic one-way password comparison (hash equality) and salt generation
API.  This is not meant to cover Password criteria satisfaction.

Change-Id: I6c8cb72a5cf83108b29232b6c1a8b8ae1cee21e8
Signed-off-by: Ryan Goulding <ryandgoulding@gmail.com>
aaa-password-service/api/pom.xml [new file with mode: 0644]
aaa-password-service/api/src/main/java/org/opendaylight/aaa/api/password/service/PasswordHash.java [new file with mode: 0644]
aaa-password-service/api/src/main/java/org/opendaylight/aaa/api/password/service/PasswordHashService.java [new file with mode: 0644]
aaa-password-service/pom.xml [new file with mode: 0644]
artifacts/pom.xml
pom.xml

diff --git a/aaa-password-service/api/pom.xml b/aaa-password-service/api/pom.xml
new file mode 100644 (file)
index 0000000..4f9c2d9
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright © 2018 Inocybe Technologies and others. All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.opendaylight.aaa</groupId>
+    <artifactId>aaa-parent</artifactId>
+    <version>0.8.0-SNAPSHOT</version>
+    <relativePath>../../parent</relativePath>
+  </parent>
+
+  <groupId>org.opendaylight.aaa</groupId>
+  <artifactId>aaa-password-service-api</artifactId>
+  <version>0.8.0-SNAPSHOT</version>
+  <name>ODL :: aaa :: ${project.artifactId}</name>
+  <packaging>bundle</packaging>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Export-Package>
+              org.opendaylight.aaa.api.password.service
+            </Export-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/aaa-password-service/api/src/main/java/org/opendaylight/aaa/api/password/service/PasswordHash.java b/aaa-password-service/api/src/main/java/org/opendaylight/aaa/api/password/service/PasswordHash.java
new file mode 100644 (file)
index 0000000..afe67fc
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright © 2018 Inocybe Technologies and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.aaa.api.password.service;
+
+/**
+ * Four-tuple representing a <code>PasswordHash</code>.
+ */
+public interface PasswordHash {
+
+    /**
+     * The algorithm name used to generate this hash.
+     *
+     * @return algorithm name used to generate this hash
+     */
+    String getAlgorithmName();
+
+    /**
+     * The salt used to generate this hash.
+     *
+     * @return salt used to generate this hash
+     */
+    String getSalt();
+
+    /**
+     * The number of iterations used to generate this hash.
+     *
+     * @return number of iterations used to generate this hash
+     */
+    int getIterations();
+
+    /**
+     * The hashed password.
+     *
+     * @return hashed password
+     */
+    String getHashedPassword();
+}
diff --git a/aaa-password-service/api/src/main/java/org/opendaylight/aaa/api/password/service/PasswordHashService.java b/aaa-password-service/api/src/main/java/org/opendaylight/aaa/api/password/service/PasswordHashService.java
new file mode 100644 (file)
index 0000000..1b3da92
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright © 2018 Inocybe Technologies and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.aaa.api.password.service;
+
+/**
+ * Service responsible for generating salts and comparing passwords.  This service is designed for one-way hashing only.
+ */
+public interface PasswordHashService {
+
+    /**
+     * Extract a hashed password using a randomly generated salt.
+     *
+     * @param password a plaintext password
+     * @return the result of hashing the password
+     */
+    PasswordHash getHashedPassword(String password);
+
+    /**
+     * Extract a hashed password using an input salt.
+     *
+     * @param password a plaintext password
+     * @param salt the hash for <code>password</code>
+     * @return the result of hashing the password
+     */
+    PasswordHash getHashedPassword(String password, String salt);
+
+    /**
+     * Password comparison.
+     *
+     * @param plaintext the &quot;input&quot; password in plaintext
+     * @param stored the Base64-encoded stored password
+     * @param salt the salt used to originally encode <code>stored</code>
+     * @return whether or not the passwords match
+     */
+    boolean passwordsMatch(String plaintext, String stored, String salt);
+}
diff --git a/aaa-password-service/pom.xml b/aaa-password-service/pom.xml
new file mode 100644 (file)
index 0000000..786654e
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright © 2018 Inocybe Technologies and others. All rights reserved.
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
+-->
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.opendaylight.odlparent</groupId>
+    <artifactId>odlparent</artifactId>
+    <version>3.1.0</version>
+    <relativePath/>
+  </parent>
+
+  <groupId>org.opendaylight.aaa</groupId>
+  <artifactId>aaa-password-service-aggregator</artifactId>
+  <version>0.8.0-SNAPSHOT</version>
+  <name>ODL :: aaa :: ${project.artifactId}</name>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>api</module>
+    <!--<module>impl</module>-->
+  </modules>
+
+</project>
index f1c40b63491a7736c1411da332517ebd337d4a1a..2003872df76d439fc585f8407685e976cb0ff792 100644 (file)
                 <artifactId>servlet-jersey2</artifactId>
                 <version>${project.version}</version>
             </dependency>
-
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>aaa-password-service-api</artifactId>
+                <version>${project.version}</version>
+            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>features-aaa</artifactId>
diff --git a/pom.xml b/pom.xml
index d3a6909e8a186b4b733bafd51863e46267249c82..b0709f44baccd6c077e25d5352ca97f96d74f35e 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -28,6 +28,7 @@
     <module>aaa-cli</module>
     <module>aaa-cli-jar</module>
     <module>aaa-filterchain</module>
+    <module>aaa-password-service</module>
     <module>artifacts</module>
     <module>features</module>
     <module>parent</module>