aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/model/User.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-11-18 16:05:35 +0500
committerAbyss777 <abyss@fox5.ru>2016-11-18 16:05:35 +0500
commitc9b67d19132b687bea9130f39f13a5515b120e5e (patch)
tree5890f28c060777ecb6be32b18daaa2d555496be6 /src/org/traccar/model/User.java
parent3eca9acd6e6a160df8f7b86150429c3d7c09b0c3 (diff)
downloadtrackermap-server-c9b67d19132b687bea9130f39f13a5515b120e5e.tar.gz
trackermap-server-c9b67d19132b687bea9130f39f13a5515b120e5e.tar.bz2
trackermap-server-c9b67d19132b687bea9130f39f13a5515b120e5e.zip
Implement users tokens
Diffstat (limited to 'src/org/traccar/model/User.java')
-rw-r--r--src/org/traccar/model/User.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/org/traccar/model/User.java b/src/org/traccar/model/User.java
index a36fa0e31..816f49da9 100644
--- a/src/org/traccar/model/User.java
+++ b/src/org/traccar/model/User.java
@@ -180,6 +180,31 @@ public class User extends Extensible {
this.deviceLimit = deviceLimit;
}
+ private String token;
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ if (token != null && !token.isEmpty()) {
+ if (validateToken(token)) {
+ this.token = token;
+ } else {
+ throw new IllegalArgumentException("Bad token");
+ }
+ } else {
+ this.token = null;
+ }
+ }
+
+ public static boolean validateToken(String token) {
+ if (token.length() < 16 || !token.matches("^[a-zA-Z0-9]+$")) {
+ return false;
+ }
+ return true;
+ }
+
public String getPassword() {
return null;
}