aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/model/User.java
diff options
context:
space:
mode:
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;
}