You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2013/01/11 17:00:20 UTC

svn commit: r1432115 - in /syncope/trunk: ./ archetype/ archetype/src/main/resources/META-INF/maven/ archetype/src/main/resources/archetype-resources/console/src/main/resources/ archetype/src/main/resources/archetype-resources/core/src/main/resources/ ...

Author: ilgrosso
Date: Fri Jan 11 16:00:20 2013
New Revision: 1432115

URL: http://svn.apache.org/viewvc?rev=1432115&view=rev
Log:
[SYNCOPE-269] Merge from 1_0_X

Removed:
    syncope/trunk/archetype/src/main/resources/archetype-resources/core/src/main/resources/security.properties
Modified:
    syncope/trunk/   (props changed)
    syncope/trunk/archetype/pom.xml
    syncope/trunk/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
    syncope/trunk/archetype/src/main/resources/archetype-resources/console/src/main/resources/configuration.properties
    syncope/trunk/core/pom.xml
    syncope/trunk/core/src/main/java/org/apache/syncope/core/util/PasswordEncoder.java
    syncope/trunk/core/src/main/resources/security.properties
    syncope/trunk/pom.xml

Propchange: syncope/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Jan 11 16:00:20 2013
@@ -2,3 +2,4 @@ target
 .subversion
 .pom.xml.swp
 .CHANGES.swp
+.vi.swp

Propchange: syncope/trunk/
------------------------------------------------------------------------------
  Merged /syncope/branches/1_0_X:r1431994-1432096

Modified: syncope/trunk/archetype/pom.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/archetype/pom.xml?rev=1432115&r1=1432114&r2=1432115&view=diff
==============================================================================
--- syncope/trunk/archetype/pom.xml (original)
+++ syncope/trunk/archetype/pom.xml Fri Jan 11 16:00:20 2013
@@ -154,13 +154,13 @@ under the License.
                   <else>
                     <get src="${SVNRepoURL}/core/src/test/resources/persistence.properties" dest="${basedir}/src/main/resources/archetype-resources/core/src/test/resources/persistence.properties" />
                     <get src="${SVNRepoURL}/core/src/test/resources/workflow.properties" dest="${basedir}/src/main/resources/archetype-resources/core/src/test/resources/workflow.properties" />
-                    <get src="${SVNRepoURL}/core/src/test/resources/security.properties" dest="${basedir}/src/main/resources/archetype-resources/core/src/test/resources/security.properties" />
                     <get src="${SVNRepoURL}/core/src/test/resources/content.xml" dest="${basedir}/src/main/resources/archetype-resources/core/src/test/resources/content.xml" />
                     <get src="${SVNRepoURL}/core/src/test/resources/test.csv" dest="${basedir}/src/main/resources/archetype-resources/core/src/test/resources/test.csv" />
                     <get src="${SVNRepoURL}/core/src/test/resources/db.jsp" dest="${basedir}/src/main/resources/archetype-resources/core/src/test/resources/db.jsp" />
 
                     <get src="${SVNRepoURL}/core/src/main/resources/persistence.properties" dest="${basedir}/src/main/resources/archetype-resources/core/src/main/resources/persistence.properties" />
                     <get src="${SVNRepoURL}/core/src/main/resources/workflow.properties" dest="${basedir}/src/main/resources/archetype-resources/core/src/main/resources/workflow.properties" />
+                    <get src="${SVNRepoURL}/core/src/main/resources/security.properties" dest="${basedir}/src/main/resources/archetype-resources/core/src/main/resources/security.properties" />
                     <get src="${SVNRepoURL}/core/src/main/resources/content.xml" dest="${basedir}/src/main/resources/archetype-resources/core/src/main/resources/content.xml" />
                     <get src="${SVNRepoURL}/core/src/main/resources/logback.xml" dest="${basedir}/src/main/resources/archetype-resources/core/src/main/resources/logback.xml" />
                     <get src="${SVNRepoURL}/core/src/main/resources/META-INF/spring-persistence.xml" dest="${basedir}/src/main/resources/archetype-resources/core/src/main/resources/META-INF/spring-persistence.xml" />

Modified: syncope/trunk/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml?rev=1432115&r1=1432114&r2=1432115&view=diff
==============================================================================
--- syncope/trunk/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml (original)
+++ syncope/trunk/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml Fri Jan 11 16:00:20 2013
@@ -16,11 +16,14 @@ software distributed under the License i
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
-
 -->
 <archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="syncope-sample"
                       xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <requiredProperties>
+    <requiredProperty key="secretKey"/>
+  </requiredProperties>
+  
   <modules>
     <module id="core" dir="core" name="core">
       <fileSets>

Modified: syncope/trunk/archetype/src/main/resources/archetype-resources/console/src/main/resources/configuration.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/archetype/src/main/resources/archetype-resources/console/src/main/resources/configuration.properties?rev=1432115&r1=1432114&r2=1432115&view=diff
==============================================================================
--- syncope/trunk/archetype/src/main/resources/archetype-resources/console/src/main/resources/configuration.properties (original)
+++ syncope/trunk/archetype/src/main/resources/archetype-resources/console/src/main/resources/configuration.properties Fri Jan 11 16:00:20 2013
@@ -17,4 +17,4 @@
 scheme=http
 host=localhost
 port=8080
-path=/syncope/rest/
+rootPath=/syncope/rest/

Modified: syncope/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/pom.xml?rev=1432115&r1=1432114&r2=1432115&view=diff
==============================================================================
--- syncope/trunk/core/pom.xml (original)
+++ syncope/trunk/core/pom.xml Fri Jan 11 16:00:20 2013
@@ -734,7 +734,6 @@ under the License.
                     <excludes>
                       <exclude>content.xml</exclude>
                       <exclude>persistence.properties</exclude>
-                      <exclude>security.properties</exclude>
                       <exclude>workflow.properties</exclude>
                     </excludes>
                   </resource>

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/util/PasswordEncoder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/PasswordEncoder.java?rev=1432115&r1=1432114&r2=1432115&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/util/PasswordEncoder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/util/PasswordEncoder.java Fri Jan 11 16:00:20 2013
@@ -18,9 +18,12 @@
  */
 package org.apache.syncope.core.util;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
+import java.util.Properties;
 import javax.crypto.BadPaddingException;
 import javax.crypto.Cipher;
 import javax.crypto.IllegalBlockSizeException;
@@ -41,8 +44,41 @@ public final class PasswordEncoder {
     private static SecretKeySpec keySpec;
 
     static {
+        String secretKey = null;
+
+        InputStream propStream = null;
+        try {
+            propStream = PasswordEncoder.class.getResourceAsStream("/security.properties");
+            Properties props = new Properties();
+            props.load(propStream);
+            secretKey = props.getProperty("secretKey");
+        } catch (Exception e) {
+            LOG.error("Could not read secretKey", e);
+        } finally {
+            if (propStream != null) {
+                try {
+                    propStream.close();
+                } catch (IOException e) {
+                    LOG.error("While closing property stream", e);
+                }
+            }
+        }
+
+        if (secretKey == null) {
+            secretKey = "1abcdefghilmnopqrstuvz2!";
+            LOG.debug("secretKey not found, reverting to default");
+        }
+        if (secretKey.length() < 16) {
+            StringBuilder secretKeyPadding = new StringBuilder(secretKey);
+            for (int i = 0; i < 16 - secretKey.length(); i++) {
+                secretKeyPadding.append('0');
+            }
+            secretKey = secretKeyPadding.toString();
+            LOG.debug("secretKey too short, adding some random characters");
+        }
+
         try {
-            keySpec = new SecretKeySpec(ArrayUtils.subarray("1abcdefghilmnopqrstuvz2!".getBytes("UTF8"), 0, 16), "AES");
+            keySpec = new SecretKeySpec(ArrayUtils.subarray(secretKey.getBytes("UTF8"), 0, 16), "AES");
         } catch (Exception e) {
             LOG.error("Error during key specification", e);
         }
@@ -67,7 +103,6 @@ public final class PasswordEncoder {
                 encodedPassword = BCrypt.hashpw(password, BCrypt.gensalt());
             } else {
                 encodedPassword = getDigester(cipherAlgorithm).digest(password);
-
             }
         }
 

Modified: syncope/trunk/core/src/main/resources/security.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/security.properties?rev=1432115&r1=1432114&r2=1432115&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/security.properties (original)
+++ syncope/trunk/core/src/main/resources/security.properties Fri Jan 11 16:00:20 2013
@@ -17,3 +17,4 @@
 adminUser=admin
 adminPassword=5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8
 adminPasswordAlgorithm=SHA1
+secretKey=${secretKey}

Modified: syncope/trunk/pom.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/pom.xml?rev=1432115&r1=1432114&r2=1432115&view=diff
==============================================================================
--- syncope/trunk/pom.xml (original)
+++ syncope/trunk/pom.xml Fri Jan 11 16:00:20 2013
@@ -322,6 +322,9 @@ under the License.
     <test.csvdir.path>${project.build.directory}/test-csvdir</test.csvdir.path>
         
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    
+    <!-- static secret key, only used for build: generated overlays will override this during archetype:generate -->
+    <secretKey>1abcdefghilmnopqrstuvz2!</secretKey>
   </properties>
 
   <dependencyManagement>
@@ -363,11 +366,11 @@ under the License.
         <version>${commons-jexl.version}</version>
       </dependency>
 
-	  <dependency>
-		<groupId>javax.ws.rs</groupId>
-    	<artifactId>javax.ws.rs-api</artifactId>
-    	<version>2.0-m10</version>
-    </dependency>
+      <dependency>
+        <groupId>javax.ws.rs</groupId>
+        <artifactId>javax.ws.rs-api</artifactId>
+        <version>2.0-m10</version>
+      </dependency>
       <dependency>
         <groupId>commons-lang</groupId>
         <artifactId>commons-lang</artifactId>