There would have been a powerful tool for generating token validation JWT, but sometimes taking into account the actual requirements of the project, Guid/uuid will be used to generate token, of course, Guid/uuid can generate a lot of unique validation results, so here is the main record of the use of Guid/uuid
public string createtkn (string account,string pin,string imei) {
Savetodb st = new Savetodb ();
Create GUID object
uuid uuid = Uuid.randomuuid ();
Get the object generated ID
String token = uuid.tostring ();
Convert to uppercase
token = Token.touppercase ();
Replace "-" into space
token = Token.replaceall ("-", "");
SYSTEM.OUT.PRINTLN (token);
Save token and user information to the database
map<string, object> params = new hashmap<> ();
Params.put ("St_sid", token);
Params.put ("St_account", account);
String tablename = "table name";
Here is a mybaits method to save data to the database, specifically http://blog.csdn.net/suresand/article/details/52540684
st.save (tablename, params);
Save the next time you can use the user's token in the database to do a validation return
"token";
/** * Verify that the user's token value is correct * @param account * @param tokenvalue * @return correct--1, error
--0 */public string checktkn (string account, String tokenvalue) {Savetodb st = new Savetodb ();
Map<string, object> params=new hashmap<> ();
Query the database to see if the user's token exists params.put ("St_sid", Tokenvalue);
String tablename = "T_hy_logintkn_i";
Use a list set to accept the map collection, so you need to convert the list rs = new arraylist<> () later;
The same mybaits Query method rs = st.select (tablename, params);
Map<string, object> map=new hashmap<> ();
Map = (map<string, object>) rs.get (0);
Check if the token belongs to the user if (Account.equals (Map.get ("St_account"). ToString ()) {return "1";
}else{return "0"; }
}