]> git.mxchange.org Git - jshop-core.git/commitdiff
added missing Apache Commons library for BASE64-encoding + removed jcore-ee-logger...
authorRoland Haeder <roland@mxchange.org>
Mon, 21 Sep 2015 10:04:08 +0000 (12:04 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 21 Sep 2015 10:04:08 +0000 (12:04 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

lib/commons-codec-1.10.jar [new file with mode: 0644]
lib/jcore-ee-logger.jar [deleted file]
lib/jcoreee.jar
nbproject/build-impl.xml
nbproject/genfiles.properties
nbproject/project.properties
nbproject/project.xml
src/org/mxchange/jshopcore/model/customer/CustomerUtils.java

diff --git a/lib/commons-codec-1.10.jar b/lib/commons-codec-1.10.jar
new file mode 100644 (file)
index 0000000..1d7417c
Binary files /dev/null and b/lib/commons-codec-1.10.jar differ
diff --git a/lib/jcore-ee-logger.jar b/lib/jcore-ee-logger.jar
deleted file mode 100644 (file)
index 903d016..0000000
Binary files a/lib/jcore-ee-logger.jar and /dev/null differ
index 42674a26cdfe924a0f1bbc181451a5e055c6db1b..6061f285cd719c267ee2f1a5e8a526abc4202328 100644 (file)
Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ
index b9b81340a3a403fe9685ca9760dd85be06c110c8..e841dc3782f5a9583e718448cbbff54022be6802 100644 (file)
@@ -921,14 +921,6 @@ is divided into following sections:
         <propertyfile file="${built-jar.properties}">
             <entry key="${basedir}" value=""/>
         </propertyfile>
-        <antcall target="-maybe-call-dep">
-            <param name="call.built.properties" value="${built-jar.properties}"/>
-            <param location="${project.jcore-ee-logger}" name="call.subproject"/>
-            <param location="${project.jcore-ee-logger}/build.xml" name="call.script"/>
-            <param name="call.target" value="dist"/>
-            <param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
-            <param name="transfer.not.archive.disabled" value="true"/>
-        </antcall>
     </target>
     <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
     <target depends="init" name="-check-automatic-build">
@@ -1414,14 +1406,6 @@ is divided into following sections:
         <propertyfile file="${built-clean.properties}">
             <entry key="${basedir}" value=""/>
         </propertyfile>
-        <antcall target="-maybe-call-dep">
-            <param name="call.built.properties" value="${built-clean.properties}"/>
-            <param location="${project.jcore-ee-logger}" name="call.subproject"/>
-            <param location="${project.jcore-ee-logger}/build.xml" name="call.script"/>
-            <param name="call.target" value="clean"/>
-            <param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
-            <param name="transfer.not.archive.disabled" value="true"/>
-        </antcall>
     </target>
     <target depends="init" name="-do-clean">
         <delete dir="${build.dir}"/>
index e80406ee9f8a8c041775390dc91ce30b9e942f29..6cfed580dc55958d184eb4903b1be3f4c5dbcf20 100644 (file)
@@ -1,8 +1,8 @@
-build.xml.data.CRC32=1c4c32e3
+build.xml.data.CRC32=9ef4aaf1
 build.xml.script.CRC32=fa35cacf
 build.xml.stylesheet.CRC32=8064a381@1.75.2.48
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=1c4c32e3
-nbproject/build-impl.xml.script.CRC32=33c1ce19
+nbproject/build-impl.xml.data.CRC32=9ef4aaf1
+nbproject/build-impl.xml.script.CRC32=40bf9247
 nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
index feebabc9f7d93bb29704ef22d9172bd441d078d9..4776cf1014251389ab2a3b7e2e8a72c762f8303d 100644 (file)
@@ -30,6 +30,7 @@ dist.jar=${dist.dir}/jshop-core.jar
 dist.javadoc.dir=${dist.dir}/javadoc
 endorsed.classpath=
 excludes=
+file.reference.commons-codec-1.10.jar=lib\\commons-codec-1.10.jar
 file.reference.jcore.jar=lib/jcore.jar
 file.reference.jcoreee.jar=lib/jcoreee.jar
 includes=**
@@ -38,9 +39,9 @@ jar.compress=false
 jar.index=${jnlp.enabled}
 javac.classpath=\
     ${file.reference.jcore.jar}:\
-    ${reference.jcore-ee-logger.dist}:\
     ${file.reference.jcoreee.jar}:\
-    ${libs.javaee-api-7.0.classpath}
+    ${libs.javaee-api-7.0.classpath}:\
+    ${file.reference.commons-codec-1.10.jar}
 # Space-separated list of extra javac options
 javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
 javac.deprecation=true
@@ -80,9 +81,7 @@ manifest.custom.permissions=
 meta.inf.dir=${src.dir}/META-INF
 mkdist.disabled=true
 platform.active=default_platform
-project.jcore-ee-logger=../jcore-ee-logger
 project.license=gpl30
-reference.jcore-ee-logger.dist=${project.jcore-ee-logger}/dist/jcore-ee-logger.jar
 run.classpath=\
     ${javac.classpath}:\
     ${build.classes.dir}
index c4336b248a3678b4b8e6dc97700da901fe2a70fd..feaeefa52575a75b0b9130d131d45e16dad2b60a 100644 (file)
         <libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
             <definitions>./lib/nblibraries.properties</definitions>
         </libraries>
-        <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
-            <reference>
-                <foreign-project>jcore-ee-logger</foreign-project>
-                <artifact-type>jar</artifact-type>
-                <script>build.xml</script>
-                <target>dist</target>
-                <clean-target>clean</clean-target>
-                <id>dist</id>
-            </reference>
-        </references>
+        <references xmlns="http://www.netbeans.org/ns/ant-project-references/1"/>
     </configuration>
 </project>
index 72e024e35c294d975162ff48664e0a4bab2f378a..0a58bd431a64136504a0585fbbb53630fb66d288 100644 (file)
@@ -20,6 +20,8 @@ import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.digest.Sha2Crypt;
 import org.mxchange.jcore.BaseFrameworkSystem;
 
 /**
@@ -91,4 +93,59 @@ public class CustomerUtils extends BaseFrameworkSystem {
                // Found one
                return customerNumber;
        }
+
+       /**
+        * Generates an unique access key.
+        *
+        * @param connection Connection instance
+        * @param customer Customer instance
+        * @return An unique access key
+        * @throws java.sql.SQLException If any SQL error occured
+        */
+       public static String generateAccessKey (final Connection connection, final Customer customer) throws SQLException {
+               // Trace message
+               // TODO: utils.getLogger().logTrace(MessageFormat.format("generateAccessKey: connection={0} - CALLED!", connection));
+               // connection cannot be null
+               if (null == connection) {
+                       // Abort here
+                       throw new NullPointerException("connection is null"); //NOI18N
+               }
+
+               // Prepare statement
+               PreparedStatement statement = connection.prepareStatement("SELECT `id` FROM `orders` WHERE `access_key` = ? LIMIT 1"); //NOI18N
+
+               // Generate access keyy
+               String accessKey = null;
+
+               // Default is found
+               boolean isFound = true;
+
+               // Is the number used?
+               while (isFound) {
+                       // Both number parts
+                       String randString = String.format("%s:%s:%s", Long.toHexString(Math.round(Math.random() * 1000000)), connection, customer.getCustomerNumber());
+
+                       // Generate new number
+                       accessKey = Base64.encodeBase64String(Sha2Crypt.sha512Crypt(randString.getBytes()).getBytes()).substring(0, 100);
+
+                       // Debug message
+                       // TODO: utils.getLogger().logDebug(MessageFormat.format("generateAccessKey: accessKey={0}", accessKey));
+                       // Insert customer number
+                       statement.setString(1, accessKey);
+
+                       // Find it
+                       statement.execute();
+
+                       // Get result
+                       ResultSet result = statement.getResultSet();
+
+                       // Try to get next result
+                       isFound = result.next();
+               }
+
+               // Trace message
+               // TODO: utils.getLogger().logTrace(MessageFormat.format("generateAccessKey: accessKey={0} - EXIT!", accessKey));
+               // Found one
+               return accessKey;
+       }
 }