aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/model
diff options
context:
space:
mode:
authorDemian <demianalonso@gmail.com>2015-06-09 16:29:27 -0300
committerDemian <demianalonso@gmail.com>2015-06-09 16:29:27 -0300
commitc4f3d8958caf55f99e383553980d8c2eea968243 (patch)
tree79b949864639eda7016fe6686da2733e1e52f27c /src/org/traccar/model
parentb70876b7a3b852d0f0b9aade30d6a9405c054ac5 (diff)
downloadtrackermap-server-c4f3d8958caf55f99e383553980d8c2eea968243.tar.gz
trackermap-server-c4f3d8958caf55f99e383553980d8c2eea968243.tar.bz2
trackermap-server-c4f3d8958caf55f99e383553980d8c2eea968243.zip
Added compatibility for MySQL on all queries. Moved the sha256 logic to java to make it compatible across all databases
Diffstat (limited to 'src/org/traccar/model')
-rw-r--r--src/org/traccar/model/User.java24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/org/traccar/model/User.java b/src/org/traccar/model/User.java
index 2df5f276d..70a4498f5 100644
--- a/src/org/traccar/model/User.java
+++ b/src/org/traccar/model/User.java
@@ -15,6 +15,10 @@
*/
package org.traccar.model;
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
public class User implements Factory {
@Override
@@ -34,9 +38,9 @@ public class User implements Factory {
public String getEmail() { return email; }
public void setEmail(String email) { this.email = email; }
- private String password;
- public String getPassword() { return password; }
- public void setPassword(String password) { this.password = password; }
+ private byte[] password;
+ public byte[] getPassword() { return password; }
+ public void setPassword(String password) { this.password = sha256(password); }
private boolean readonly;
@@ -58,4 +62,18 @@ public class User implements Factory {
private int zoom;
+
+ public static byte[] sha256(String text) {
+ try {
+ MessageDigest md = MessageDigest.getInstance("SHA-256");
+
+ md.update(text.getBytes("UTF-8"));
+ byte[] digest = md.digest();
+ return digest;
+ } catch (NoSuchAlgorithmException e) {
+ throw new RuntimeException(e);
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ }
}