List of usage examples for org.apache.http.impl.cookie BasicClientCookie getValue
public String getValue()
From source file:com.game.sns.volley.MyVolley.java
public static String getCookie() { String value = null;/*from w ww. j av a2 s. c o m*/ if (mHttpClient != null) { CookieStore cs = mHttpClient.getCookieStore(); BasicClientCookie c = (BasicClientCookie) getCookies(cs, "PHPSESSID"); if (c != null) { value = c.getValue(); } } return value; }
From source file:it.evilsocket.dsploit.core.System.java
public static String saveHijackerSession(String sessionName, Session session) throws IOException { StringBuilder builder = new StringBuilder(); String filename = mStoragePath + '/' + sessionName + ".dhs", buffer = null; builder.append(SESSION_MAGIC + "\n"); builder.append((session.mUserName == null ? "null" : session.mUserName) + "\n"); builder.append(session.mHTTPS + "\n"); builder.append(session.mAddress + "\n"); builder.append(session.mDomain + "\n"); builder.append(session.mUserAgent + "\n"); builder.append(session.mCookies.size() + "\n"); for (BasicClientCookie cookie : session.mCookies.values()) { builder.append(cookie.getName() + "=" + cookie.getValue() + "; domain=" + cookie.getDomain() + "; path=/" + (session.mHTTPS ? ";secure" : "") + "\n"); }/* w w w.j ava 2 s . co m*/ buffer = builder.toString(); FileOutputStream ostream = new FileOutputStream(filename); GZIPOutputStream gzip = new GZIPOutputStream(ostream); gzip.write(buffer.getBytes()); gzip.close(); mSessionName = sessionName; return filename; }
From source file:com.github.irib_examples.Act_Cookies.java
private Response.Listener<String> createMyReqSuccessListener() { return new Response.Listener<String>() { @Override/*from w w w . jav a2s . c om*/ public void onResponse(String response) { CookieStore cs = mHttpClient.getCookieStore(); BasicClientCookie c = (BasicClientCookie) getCookie(cs, "my_cookie"); if (c != null) { setTvCookieText(c.getValue()); } mBtnSetCookie.setEnabled(true); } }; }
From source file:com.jaeksoft.searchlib.crawler.web.database.CookieItem.java
public CookieItem(BasicClientCookie basicClientCookie) { this.pattern = null; this.name = basicClientCookie.getName(); this.value = basicClientCookie.getValue(); this.basicClientCookie = basicClientCookie; }
From source file:it.evilsocket.dsploit.plugins.mitm.hijacker.HijackerWebView.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); requestWindowFeature(Window.FEATURE_PROGRESS); setTitle(System.getCurrentTarget() + " > MITM > Session Hijacker"); setContentView(R.layout.plugin_mitm_hijacker_webview); getSupportActionBar().setDisplayHomeAsUpEnabled(true); setSupportProgressBarIndeterminateVisibility(false); mWebView = (WebView) findViewById(R.id.webView); mSettings = mWebView.getSettings();/* w ww.ja v a2s. c o m*/ mSettings.setJavaScriptEnabled(true); mSettings.setBuiltInZoomControls(true); mSettings.setAppCacheEnabled(false); mSettings.setUserAgentString(DEFAULT_USER_AGENT); mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); mWebView.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { if (mWebView != null) getSupportActionBar().setSubtitle(mWebView.getUrl()); setSupportProgressBarIndeterminateVisibility(true); // Normalize our progress along the progress bar's scale int mmprogress = (Window.PROGRESS_END - Window.PROGRESS_START) / 100 * progress; setSupportProgress(mmprogress); if (progress == 100) setSupportProgressBarIndeterminateVisibility(false); } }); CookieSyncManager.createInstance(this); CookieManager.getInstance().removeAllCookie(); Session session = (Session) System.getCustomData(); if (session != null) { String domain = null, rawcookie = null; for (BasicClientCookie cookie : session.mCookies.values()) { domain = cookie.getDomain(); rawcookie = cookie.getName() + "=" + cookie.getValue() + "; domain=" + domain + "; path=/" + (session.mHTTPS ? ";secure" : ""); CookieManager.getInstance().setCookie(domain, rawcookie); } CookieSyncManager.getInstance().sync(); if (session.mUserAgent != null && session.mUserAgent.isEmpty() == false) mSettings.setUserAgentString(session.mUserAgent); mWebView.loadUrl((session.mHTTPS ? "https" : "http") + "://www." + domain); } }
From source file:com.feigdev.webcom.PersistentCookieStore.java
public void addCookie(String rawCookie, String url) throws Exception { ArrayList<BasicClientCookie> cookies = parseRawCookie(rawCookie, url); for (BasicClientCookie cookie : cookies) { if (Constants.VERBOSE) { Log.d("PersistentCookieStore", "adding cookie: " + cookie.getName() + "=" + cookie.getValue()); }/*from www.j av a 2 s . c o m*/ addCookie(cookie); } }
From source file:ti.modules.titanium.network.NetworkModule.java
/** * Adds a cookie to the system cookie store. Any existing cookie with the same domain, path and name will be replaced with * the new cookie. The cookie being set must not have expired, otherwise it will be ignored. * @param cookieProxy the cookie to add// w w w . j av a 2 s . c om */ @Kroll.method public void addSystemCookie(CookieProxy cookieProxy) { BasicClientCookie cookie = cookieProxy.getHTTPCookie(); String cookieString = cookie.getName() + "=" + cookie.getValue(); String domain = cookie.getDomain(); if (domain == null) { Log.w(TAG, "Unable to add system cookie. Need to provide domain."); return; } cookieString += "; domain=" + domain; String path = cookie.getPath(); Date expiryDate = cookie.getExpiryDate(); boolean secure = cookie.isSecure(); boolean httponly = TiConvert.toBoolean(cookieProxy.getProperty(TiC.PROPERTY_HTTP_ONLY), false); if (path != null) { cookieString += "; path=" + path; } if (expiryDate != null) { cookieString += "; expires=" + CookieProxy.systemExpiryDateFormatter.format(expiryDate); } if (secure) { cookieString += "; secure"; } if (httponly) { cookieString += " httponly"; } CookieSyncManager.createInstance(TiApplication.getInstance().getRootOrCurrentActivity()); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setCookie(domain, cookieString); CookieSyncManager.getInstance().sync(); }
From source file:immf.StatusManager.java
public void load() throws IOException { Properties prop = new Properties(); FileInputStream fis = null;// w w w.j a va 2 s. com try { fis = new FileInputStream(this.f); prop.load(fis); this.lastMailId = prop.getProperty("lastmailid"); this.pushCredentials = prop.getProperty("push_credentials"); String nc = prop.getProperty("needconnect"); if (this.needConnect == null) { this.needConnect = nc; } if (this.needConnect != null && !this.needConnect.equals("1")) { this.needConnect = nc; } Enumeration<Object> enu = prop.keys(); List<Cookie> list = new ArrayList<Cookie>(); while (enu.hasMoreElements()) { String key = (String) enu.nextElement(); if (key.startsWith("cookie_")) { String cookieName = key.substring(7); String val = prop.getProperty(key); String[] params = val.split(";"); BasicClientCookie c = new BasicClientCookie(cookieName, params[0]); for (int i = 1; i < params.length; i++) { String[] nameval = params[i].split("="); if (nameval[0].equalsIgnoreCase("path")) { c.setPath(nameval[1]); } else if (nameval[0].equalsIgnoreCase("domain")) { c.setDomain(nameval[1]); } } c.setSecure(true); log.debug("Load Cookie [" + c.getName() + "]=[" + c.getValue() + "]"); list.add(c); } } this.cookies = list; } finally { Util.safeclose(fis); } }
From source file:br.com.autonomiccs.apacheCloudStack.client.ApacheCloudStackClientTest.java
@Test public void createCookieForHeaderElementTest() { String cookiePath = "/client/api"; String paramName = "paramName1"; String paramValue = "paramVale1"; NameValuePair[] parameters = new NameValuePair[1]; parameters[0] = new BasicNameValuePair(paramName, paramValue); String headerName = "headerElementName"; String headerValue = "headerElementValue"; HeaderElement headerElement = new BasicHeaderElement(headerName, headerValue, parameters); Mockito.doNothing().when(apacheCloudStackClient) .configureDomainForCookie(Mockito.any(BasicClientCookie.class)); BasicClientCookie cookieForHeaderElement = apacheCloudStackClient .createCookieForHeaderElement(headerElement); Assert.assertNotNull(cookieForHeaderElement); Assert.assertEquals(headerName, cookieForHeaderElement.getName()); Assert.assertEquals(headerValue, cookieForHeaderElement.getValue()); Assert.assertEquals(paramValue, cookieForHeaderElement.getAttribute(paramName)); Assert.assertEquals(cookiePath, cookieForHeaderElement.getPath()); Mockito.verify(apacheCloudStackClient).configureDomainForCookie(Mockito.eq(cookieForHeaderElement)); }
From source file:nl.esciencecenter.ptk.web.WebClient.java
protected void initJSession(boolean deletePrevious) throws WebException { logger.debugPrintf("initJSession(). Using JESSION URI init string:%s\n", config.jsessionInitPart); if (deletePrevious) { this.jsessionID = null; }/* www. j a v a 2 s . c om*/ String uri = null; // re-use JSESSIONID: if (this.jsessionID != null) { BasicClientCookie cookie = new BasicClientCookie(WebConst.COOKIE_JSESSIONID, jsessionID); cookie.setPath(config.servicePath); cookie.setDomain(config.serverHostname); logger.infoPrintf(" - Using JSessionID = %s\n", jsessionID); logger.debugPrintf(" - Cookie Domain/Path = %s/%s\n", cookie.getDomain(), cookie.getPath()); this.httpClient.getCookieStore().addCookie(cookie); return; } else { logger.debugPrintf("initJSession():NO JSESSIONID\n"); } try { uri = getServerURI().toString(); // put slash between parts: if ((uri.endsWith("/") == false) && (config.servicePath.startsWith("/") == false)) { uri = uri + "/"; } uri = uri + config.servicePath + "/" + config.jsessionInitPart; HttpPost postMethod = new HttpPost(uri); // get.setFollowRedirects(true); int result = executeAuthenticatedPut(postMethod, null, null); List<Cookie> cookies = this.httpClient.getCookieStore().getCookies(); for (Cookie cookie : cookies) { if (cookie.getName().equals(WebConst.COOKIE_JSESSIONID)) { this.jsessionID = cookie.getValue(); logger.infoPrintf(" - new JSessionID = %s\n", jsessionID); logger.debugPrintf(" - Cookie Domain/Path = '%s','%s'\n", cookie.getDomain(), cookie.getPath()); } } checkHttpStatus(result, "initJSession(): Couldn't initialize JSessionID.", null, null); // all ok here. } catch (WebException e) { Reason reason = e.getReason(); if (reason == Reason.FORBIDDEN) { throw new WebException(reason, "Failed to authenticate: Forbidden.\n" + e.getMessage(), e); } else if (reason == Reason.UNAUTHORIZED) { if (this.config.useAuthentication() == false) { throw new WebException(reason, "Need proper authentication for this service, but authentication is disabled for:" + this.getServiceURI() + ".\n" + e.getMessage(), e); } throw new WebException(reason, "Failed to authenticate: User or password wrong for URI:" + this.getServiceURI() + ".\n" + e.getMessage(), e); } else { throw new WebException(reason, "Failed to initialize JSession to: " + this.getServiceURI() + "\n" + e.getMessage(), e); } } }