syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject syncope git commit: SYNCOPE-1119 - Support specifying the admin password using the installer
Date Mon, 26 Jun 2017 16:13:26 GMT
Repository: syncope
Updated Branches:
  refs/heads/master 2deb36904 -> cca472be5


SYNCOPE-1119 - Support specifying the admin password using the installer


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/cca472be
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/cca472be
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/cca472be

Branch: refs/heads/master
Commit: cca472be51fd9d882e4bd8aa8f1e03a4c16112d6
Parents: 2deb369
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Mon Jun 26 17:12:57 2017 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Mon Jun 26 17:13:21 2017 +0100

----------------------------------------------------------------------
 .../META-INF/maven/archetype-metadata.xml       |  3 +++
 archetype/src/main/resources/meta-pom.xml       |  1 +
 .../src/main/resources/security.properties      |  2 +-
 .../syncope/installer/utilities/MavenUtils.java | 21 ++++++++++++++++++--
 .../validators/ArchetypeValidator.java          |  5 +++++
 .../src/main/resources/izpack/userInputSpec.xml |  4 ++++
 pom.xml                                         |  1 +
 7 files changed, 34 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/cca472be/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
----------------------------------------------------------------------
diff --git a/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
index db55592..f3ba98c 100644
--- a/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
+++ b/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -24,6 +24,9 @@ under the License.
     <requiredProperty key="secretKey"/>
     <requiredProperty key="anonymousKey"/>
     <requiredProperty key="jwsKey"/>
+    <requiredProperty key="adminPassword">
+        <defaultValue>5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8</defaultValue>
+    </requiredProperty>
   </requiredProperties>
   
   <modules>

http://git-wip-us.apache.org/repos/asf/syncope/blob/cca472be/archetype/src/main/resources/meta-pom.xml
----------------------------------------------------------------------
diff --git a/archetype/src/main/resources/meta-pom.xml b/archetype/src/main/resources/meta-pom.xml
index 3ee57a1..a322758 100644
--- a/archetype/src/main/resources/meta-pom.xml
+++ b/archetype/src/main/resources/meta-pom.xml
@@ -34,6 +34,7 @@ under the License.
     <secretKey>${secretKey}</secretKey>
     <anonymousKey>${anonymousKey}</anonymousKey>
     <jwsKey>${jwsKey}</jwsKey>
+    <adminPassword>${adminPassword}</adminPassword>
     
     <rat.skip>true</rat.skip>
     <checkstyle.skip>true</checkstyle.skip>

http://git-wip-us.apache.org/repos/asf/syncope/blob/cca472be/core/spring/src/main/resources/security.properties
----------------------------------------------------------------------
diff --git a/core/spring/src/main/resources/security.properties b/core/spring/src/main/resources/security.properties
index 9e59a96..5c39d1e 100644
--- a/core/spring/src/main/resources/security.properties
+++ b/core/spring/src/main/resources/security.properties
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 adminUser=${adminUser}
-adminPassword=5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8
+adminPassword=${adminPassword}
 adminPasswordAlgorithm=SHA1
 
 anonymousUser=${anonymousUser}

http://git-wip-us.apache.org/repos/asf/syncope/blob/cca472be/installer/src/main/java/org/apache/syncope/installer/utilities/MavenUtils.java
----------------------------------------------------------------------
diff --git a/installer/src/main/java/org/apache/syncope/installer/utilities/MavenUtils.java
b/installer/src/main/java/org/apache/syncope/installer/utilities/MavenUtils.java
index cd773a8..59ee898 100644
--- a/installer/src/main/java/org/apache/syncope/installer/utilities/MavenUtils.java
+++ b/installer/src/main/java/org/apache/syncope/installer/utilities/MavenUtils.java
@@ -23,15 +23,23 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.TransformerException;
+
+import org.apache.commons.codec.binary.Hex;
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.shared.invoker.DefaultInvocationRequest;
 import org.apache.maven.shared.invoker.DefaultInvoker;
@@ -110,8 +118,17 @@ public class MavenUtils {
         properties.setProperty("anonymousKey", anonymousKey);
         properties.setProperty("jwsKey", jwsKey);
 
-        //String encodedPassword = PasswordGenerator.password(adminPassword, "SHA-1");
-        //properties.setProperty("adminPassword", encodedPassword);
+        if (adminPassword != null) {
+            try {
+                final MessageDigest cript = MessageDigest.getInstance("SHA-1");
+                String encodedPassword =
+                    new String(Hex.encodeHex(cript.digest(adminPassword.getBytes(StandardCharsets.UTF_8))));
+                properties.setProperty("adminPassword", encodedPassword);
+            } catch (final NoSuchAlgorithmException ex) {
+                Logger.getLogger(MavenUtils.class.getName()).log(Level.SEVERE, "NoSuchAlgorithmException",
ex);
+
+            }
+        }
         properties.setProperty("version", "1.0-SNAPSHOT");
         return properties;
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/cca472be/installer/src/main/java/org/apache/syncope/installer/validators/ArchetypeValidator.java
----------------------------------------------------------------------
diff --git a/installer/src/main/java/org/apache/syncope/installer/validators/ArchetypeValidator.java
b/installer/src/main/java/org/apache/syncope/installer/validators/ArchetypeValidator.java
index 39836d85..35181e3 100644
--- a/installer/src/main/java/org/apache/syncope/installer/validators/ArchetypeValidator.java
+++ b/installer/src/main/java/org/apache/syncope/installer/validators/ArchetypeValidator.java
@@ -34,6 +34,7 @@ public class ArchetypeValidator extends AbstractValidator {
         final String mavenSecretKey = StringUtils.trim(installData.getVariable("mvn.secretkey"));
         final String mavenAnonymousKey = StringUtils.trim(installData.getVariable("mvn.anonymous.key"));
         final String mavenJwsKey = StringUtils.trim(installData.getVariable("mvn.jws.key"));
+        final String mavenAdminPassword = StringUtils.trim(installData.getVariable("mvn.syncope.admin.password"));
         final String mavenLogDirectory = StringUtils.trim(installData.getVariable("mvn.log.directory"));
         final String mavenBundleDirectory = StringUtils.trim(installData.getVariable("mvn.bundle.directory"));
 
@@ -66,6 +67,10 @@ public class ArchetypeValidator extends AbstractValidator {
             error.append("JwsKey\n");
             verified = false;
         }
+        if (StringUtils.isBlank(mavenAdminPassword)) {
+            error.append("AdminPassword\n");
+            verified = false;
+        }
         if (StringUtils.isBlank(mavenLogDirectory)) {
             error.append("Logs directory\n");
             verified = false;

http://git-wip-us.apache.org/repos/asf/syncope/blob/cca472be/installer/src/main/resources/izpack/userInputSpec.xml
----------------------------------------------------------------------
diff --git a/installer/src/main/resources/izpack/userInputSpec.xml b/installer/src/main/resources/izpack/userInputSpec.xml
index 7e2a287..51a4b42 100644
--- a/installer/src/main/resources/izpack/userInputSpec.xml
+++ b/installer/src/main/resources/izpack/userInputSpec.xml
@@ -53,6 +53,10 @@ under the License.
       <spec id="mvn.jws.key.id" size="20" set="ZW7pRixehFuNUtnY5Se47IemgMryTzazPPJ9CGX5LTCmsOJpOgHAQEuPQeV9A28f"/>
     </field>
     <field type="space"/>
+    <field type="text" variable="mvn.syncope.admin.password">
+      <spec id="mvn.syncope.admin.password.id" size="20" set="password"/>
+    </field>
+    <field type="space"/>
     <field type="dir" variable="mvn.conf.directory">
       <spec id="archetype.mvn.conf.directory" size="20" set="/var/tmp/syncope/conf" mustExist="false"
create="true"/>
     </field>

http://git-wip-us.apache.org/repos/asf/syncope/blob/cca472be/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 681b447..198152c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -480,6 +480,7 @@ under the License.
 
     <adminUser>admin</adminUser>
     <anonymousUser>anonymous</anonymousUser>
+    <adminPassword>5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8</adminPassword>
     <!-- static keys, only used for build: generated overlays will override during archetype:generate
-->
     <anonymousKey>anonymousKey</anonymousKey>
     <secretKey>1abcdefghilmnopqrstuvz2!</secretKey>


Mime
View raw message