/** * Store a cookie string associated with a url. * * @param url The url to be used as a key for the cookie. * @param value The cookie string to be stored. */ @DSComment("Private Method") @DSBan(DSCat.PRIVATE_METHOD) @DSGenerator( tool_name = "Doppelganger", tool_version = "2.0", generated_on = "2013-12-30 12:32:41.967 -0500", hash_original_method = "D5A9FC7DDB356B7F9D175C82B50A2AF1", hash_generated_method = "24C7574FF957618A543446AAAEE4BC4D") private void setCookies(String url, String value) { if (value.contains("\r") || value.contains("\n")) { // for security reason, filter out '\r' and '\n' from the cookie int size = value.length(); StringBuilder buffer = new StringBuilder(size); int i = 0; while (i != -1 && i < size) { int ir = value.indexOf('\r', i); int in = value.indexOf('\n', i); int newi = (ir == -1) ? in : (in == -1 ? ir : (ir < in ? ir : in)); if (newi > i) { buffer.append(value.subSequence(i, newi)); } else if (newi == -1) { buffer.append(value.subSequence(i, size)); break; } i = newi + 1; } value = buffer.toString(); } CookieManager.getInstance().setCookie(url, value); }
/** Returns whether cookies are enabled or not. */ @DSComment("Private Method") @DSBan(DSCat.PRIVATE_METHOD) @DSGenerator( tool_name = "Doppelganger", tool_version = "2.0", generated_on = "2013-12-30 12:32:41.972 -0500", hash_original_method = "E9376C130584FE2146C1CFB7A84FB471", hash_generated_method = "FA6BBF0A4D9665939C38DB115FB61EFF") private boolean cookiesEnabled() { return CookieManager.getInstance().acceptCookie(); }
/** * Retrieve the cookie string for the given url. * * @param url The resource's url. * @return A String representing the cookies for the given resource url. */ @DSComment("Private Method") @DSBan(DSCat.PRIVATE_METHOD) @DSGenerator( tool_name = "Doppelganger", tool_version = "2.0", generated_on = "2013-12-30 12:32:41.970 -0500", hash_original_method = "E3D7D6931554145E868760CB2C4A26A3", hash_generated_method = "EE86FFF77F12F6E87C0C4F0204A00383") private String cookies(String url) { return CookieManager.getInstance().getCookie(url); }