<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">
<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}"/>
-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
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=**
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
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}
<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>
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;
/**
// 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;
+ }
}