/** * This will parse the info byte array and take the 1-30 bytes off and convert that to a string * and search the database for the user that owns this token. * * @param info the byte array of size 31 that contains the user token * @return the {@link User} that owns the token. */ private User getUserForToken(byte[] info) { User user = null; String token = new String(info).substring(1); Vector<String[]> query = sql.runQuery( sql.getPreparedStatement( "select u.id,u.username,u.name,u.email,u.permission from user_connection c left join user u on u.id=c.user where c.token=?", token)); if (query.size() > 0) { String[] userInfo = query.get(0); user = new User(userInfo[2], userInfo[3], userInfo[1], Integer.parseInt(userInfo[4])); user.setId(Integer.parseInt(userInfo[0])); } return user; }