Esempio n. 1
0
  public static void setCsrf(String csrf) {
    if (csrf == null) {
      return;
    }

    if (SessionManager.csrf == null || !SessionManager.csrf.equals(csrf)) {
      SessionManager.csrf = csrf;
      SharedData.getInstance().push(Default.CsrfName, csrf);
    }
  }
Esempio n. 2
0
  public static void setCookie(String cookie) {
    if (cookie == null) {
      return;
    }

    if (SessionManager.cookie == null || !SessionManager.cookie.equals(cookie)) {
      SessionManager.cookie = cookie;
      SharedData.getInstance().push(Default.CookieName, cookie);
    }
  }
Esempio n. 3
0
  public static String getCookie() {
    if (cookie != null) {
      return cookie;
    }

    // load cookie from SharedData
    cookie = SharedData.getInstance().get(Default.CookieName);
    if (cookie != null) {
      return cookie;
    }

    return cookie;
  }
Esempio n. 4
0
  public static <T> T getModUser(TypeToken token) {

    // 获取保存的用户数据
    String json = SharedData.getInstance().get(USER_INFO);
    if (json == null) {
      return null;
    }

    JSONObject user;
    try {
      user = new JSONObject(json);
    } catch (JSONException e) {
      return null;
    }

    GsonParser<T> modUser = GsonParser.fromJson(user, token);
    return modUser.getDetail();
  }
Esempio n. 5
0
 public static String getCsrf() {
   if (csrf != null) {
     return csrf;
   }
   return SharedData.getInstance().get(Default.CsrfName);
 }
Esempio n. 6
0
 /** 清除用户数据 */
 public static void clearUser() {
   SharedData.getInstance().pop(USER_INFO);
 }
Esempio n. 7
0
 /**
  * 保存登陆用户信息
  *
  * @param response
  */
 public static void saveUser(JSONObject response) {
   SharedData.getInstance().push(USER_INFO, response.toString());
 }