Exemplo 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);
    }
  }
Exemplo 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);
    }
  }
Exemplo 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;
  }
Exemplo 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();
  }
Exemplo n.º 5
0
 public static String getCsrf() {
   if (csrf != null) {
     return csrf;
   }
   return SharedData.getInstance().get(Default.CsrfName);
 }
Exemplo n.º 6
0
 /** 清除用户数据 */
 public static void clearUser() {
   SharedData.getInstance().pop(USER_INFO);
 }
Exemplo n.º 7
0
 /**
  * 保存登陆用户信息
  *
  * @param response
  */
 public static void saveUser(JSONObject response) {
   SharedData.getInstance().push(USER_INFO, response.toString());
 }