aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/model/User.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-07-01 12:07:09 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-07-01 12:07:09 +1200
commite2df061ec7d8e4ff21c9a033985d9ca56118556e (patch)
tree68f7dfd7bf2e40545606e52fdc97dbbb56351f6e /src/org/traccar/model/User.java
parent200ef5bb3fd4f194c47518e0633d7e8bb6ab6d79 (diff)
downloadtrackermap-server-e2df061ec7d8e4ff21c9a033985d9ca56118556e.tar.gz
trackermap-server-e2df061ec7d8e4ff21c9a033985d9ca56118556e.tar.bz2
trackermap-server-e2df061ec7d8e4ff21c9a033985d9ca56118556e.zip
Minor changes to password management
Diffstat (limited to 'src/org/traccar/model/User.java')
-rw-r--r--src/org/traccar/model/User.java39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/org/traccar/model/User.java b/src/org/traccar/model/User.java
index bcb03804c..dccb4851e 100644
--- a/src/org/traccar/model/User.java
+++ b/src/org/traccar/model/User.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2013 - 2015 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
package org.traccar.model;
import org.traccar.helper.Hashing;
-import org.traccar.helper.IgnoreOnSerialization;
+import org.traccar.http.JsonIgnore;
public class User implements Factory {
@@ -37,15 +37,6 @@ public class User implements Factory {
public String getEmail() { return email; }
public void setEmail(String email) { this.email = email; }
- private String hashedPassword;
- @IgnoreOnSerialization
- public String getHashedPassword() { return hashedPassword; }
- public void setHashedPassword(String hashedPassword) { this.hashedPassword = hashedPassword; }
-
- private String salt;
- @IgnoreOnSerialization
- public String getSalt() { return salt; }
- public void setSalt(String salt) { this.salt = salt; }
private boolean readonly;
private boolean admin;
@@ -70,19 +61,25 @@ public class User implements Factory {
public String getPassword() { return password; }
public void setPassword(String password) {
this.password = password;
- if(this.password != null && !this.password.trim().equals("")) {
- this.hashPassword(password);
+ if (password != null && !password.isEmpty()) {
+ Hashing.HashingResult hashingResult = Hashing.createHash(password);
+ hashedPassword = hashingResult.hash;
+ salt = hashingResult.salt;
}
}
- public boolean isPasswordValid(String inputPassword) {
- return Hashing.validatePassword(inputPassword, this.hashedPassword, this.salt);
- }
-
- public void hashPassword(String password) {
- Hashing.HashingResult hashingResult = Hashing.createHash(password);
- this.hashedPassword = hashingResult.hash;
- this.salt = hashingResult.salt;
+ private String hashedPassword;
+ @JsonIgnore
+ public String getHashedPassword() { return hashedPassword; }
+ public void setHashedPassword(String hashedPassword) { this.hashedPassword = hashedPassword; }
+
+ private String salt;
+ @JsonIgnore
+ public String getSalt() { return salt; }
+ public void setSalt(String salt) { this.salt = salt; }
+
+ public boolean isPasswordValid(String password) {
+ return Hashing.validatePassword(password, hashedPassword, salt);
}
}