use of com.firenio.codec.http11.Cookie in project MiMangaNu by raulhaag.
the class BatoTo method testLogin.
// just log in batoto to store the cookie if all ok
@Override
public boolean testLogin(String user, String password) throws Exception {
Navigator nav = getNavigatorAndFlushParameters();
CookieJar ccj = nav.getHttpClient().cookieJar();
VolatileCookieJar cj = new VolatileCookieJar();
nav.setCookieJar(cj);
String data = nav.get(HOST + "/forums/index.php?app=core&module=global&section=login");
HashMap<String, String> params = Navigator.getFormParamsFromSource(data);
nav = getNavigatorAndFlushParameters();
nav.addPost("auth_key", params.get("auth_key"));
nav.addPost("ips_password", password);
nav.addPost("ips_username", user);
nav.addPost("referer", "https://bato.to/forums/");
nav.addPost("rememberMe", "1");
nav.post(HOST + "/forums/index.php?app=core&module=global§ion=login&do=process");
List<Cookie> cookies = Navigator.getCookieJar().loadForRequest(HttpUrl.parse("https://bato.to"));
nav.setCookieJar(ccj);
return cj.contain("member_id");
}
use of com.firenio.codec.http11.Cookie in project MVPFrames by RockyQu.
the class SerializableCookie method decode.
public Cookie decode(String encodedCookie) {
byte[] bytes = hexStringToByteArray(encodedCookie);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
Cookie cookie = null;
ObjectInputStream objectInputStream = null;
try {
objectInputStream = new ObjectInputStream(byteArrayInputStream);
cookie = ((SerializableCookie) objectInputStream.readObject()).cookie;
} catch (IOException e) {
Log.d(TAG, "IOException in decodeCookie", e);
} catch (ClassNotFoundException e) {
Log.d(TAG, "ClassNotFoundException in decodeCookie", e);
} finally {
if (objectInputStream != null) {
try {
objectInputStream.close();
} catch (IOException e) {
Log.d(TAG, "Stream not closed in decodeCookie", e);
}
}
}
return cookie;
}
use of com.firenio.codec.http11.Cookie in project MVPFrames by RockyQu.
the class SharedPrefsCookiePersistor method saveAll.
@Override
public void saveAll(Collection<Cookie> cookies) {
SharedPreferences.Editor editor = sharedPreferences.edit();
for (Cookie cookie : cookies) {
editor.putString(createCookieKey(cookie), new SerializableCookie().encode(cookie));
}
editor.commit();
}
use of com.firenio.codec.http11.Cookie in project JustAndroid by chinaltz.
the class PersistentCookieStore method decodeCookie.
/**
* 将字符串反序列化成cookies
*
* @param cookieString cookies string
* @return cookie object
*/
protected Cookie decodeCookie(String cookieString) {
byte[] bytes = hexStringToByteArray(cookieString);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
Cookie cookie = null;
try {
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
cookie = ((SerializableOkHttpCookies) objectInputStream.readObject()).getCookies();
} catch (IOException e) {
Log.d(LOG_TAG, "IOException in decodeCookie", e);
} catch (ClassNotFoundException e) {
Log.d(LOG_TAG, "ClassNotFoundException in decodeCookie", e);
}
return cookie;
}
use of com.firenio.codec.http11.Cookie in project apps-android-wikipedia by wikimedia.
the class SharedPreferenceCookieManager method buildCookieList.
private void buildCookieList(@NonNull List<Cookie> outList, @NonNull List<Cookie> inList, @Nullable String prefix) {
Iterator<Cookie> i = inList.iterator();
boolean cookieJarModified = false;
while (i.hasNext()) {
Cookie cookie = i.next();
if (prefix != null && !cookie.name().startsWith(prefix)) {
continue;
}
// But wait, is the cookie expired?
if (cookie.expiresAt() < System.currentTimeMillis()) {
i.remove();
cookieJarModified = true;
} else {
outList.add(cookie);
}
}
if (cookieJarModified) {
persistCookies();
}
}
Aggregations