[seam-commits] Seam SVN: r10163 - trunk/src/gen/org/jboss/seam/tool.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Sat Mar 14 03:33:00 EDT 2009
Author: dan.j.allen
Date: 2009-03-14 03:33:00 -0400 (Sat, 14 Mar 2009)
New Revision: 10163
Added:
trunk/src/gen/org/jboss/seam/tool/EncodePasswordTask.java
trunk/src/gen/org/jboss/seam/tool/RandomUUIDTask.java
Log:
Add Ant tasks that are used to create values needed for the IDEA project file
Added: trunk/src/gen/org/jboss/seam/tool/EncodePasswordTask.java
===================================================================
--- trunk/src/gen/org/jboss/seam/tool/EncodePasswordTask.java (rev 0)
+++ trunk/src/gen/org/jboss/seam/tool/EncodePasswordTask.java 2009-03-14 07:33:00 UTC (rev 10163)
@@ -0,0 +1,49 @@
+package org.jboss.seam.tool;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+/**
+ * Encode the password provided using the same algorithm that IntelliJ IDEA uses
+ * to encode a JDBC database password before storing it in the project file,
+ * then assign it to the property.
+ */
+public class EncodePasswordTask extends Task
+{
+ private String property;
+ private String password;
+
+ @Override
+ public void execute() throws BuildException
+ {
+ getProject().setProperty(property, encode(password));
+ }
+
+ protected String encode(String value)
+ {
+ if (value == null)
+ {
+ return "";
+ }
+
+ String result = "";
+ for (int i = 0; i < value.length(); i++)
+ {
+ int c = value.charAt(i);
+ c ^= 0xdfaa;
+ result += Integer.toHexString(c);
+ }
+
+ return result;
+ }
+
+ public void setProperty(String property)
+ {
+ this.property = property;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+}
Added: trunk/src/gen/org/jboss/seam/tool/RandomUUIDTask.java
===================================================================
--- trunk/src/gen/org/jboss/seam/tool/RandomUUIDTask.java (rev 0)
+++ trunk/src/gen/org/jboss/seam/tool/RandomUUIDTask.java 2009-03-14 07:33:00 UTC (rev 10163)
@@ -0,0 +1,31 @@
+package org.jboss.seam.tool;
+
+import java.util.UUID;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+/**
+ * Creates a random UUID using {@link java.util.UUID#randomUUID()} and
+ * assigns it to the property.
+ */
+public class RandomUUIDTask extends Task
+{
+ private String property;
+
+ @Override
+ public void execute() throws BuildException
+ {
+ getProject().setProperty(property, generateRandomUUID());
+ }
+
+ protected String generateRandomUUID()
+ {
+ return UUID.randomUUID().toString();
+ }
+
+ public void setProperty(String property)
+ {
+ this.property = property;
+ }
+}
More information about the seam-commits
mailing list