List of usage examples for android.webkit CookieManager removeAllCookie
@Deprecated public abstract void removeAllCookie();
From source file:com.zbrown.droidsteal.activities.HijackActivity.java
private void setupCookies() { Log.i(APPLICATION_TAG, "######################## COOKIE SETUP ###############################"); CookieManager manager = CookieManager.getInstance(); Log.i(APPLICATION_TAG, "Cookiemanager has cookies: " + (manager.hasCookies() ? "YES" : "NO")); if (manager.hasCookies()) { manager.removeAllCookie(); try {// www .java2 s . c o m Thread.sleep(3000); } catch (InterruptedException e) { Log.e(APPLICATION_TAG, "Error with Thread.sleep(3000)", e); } Log.i(APPLICATION_TAG, "Cookiemanager has still cookies: " + (manager.hasCookies() ? "YES" : "NO")); } Log.i(APPLICATION_TAG, "######################## COOKIE SETUP START ###############################"); for (CookieWrapper cookieWrapper : authToHijack.getCookies()) { Cookie cookie = cookieWrapper.getCookie(); String cookieString = cookie.getName() + "=" + cookie.getValue() + "; domain=" + cookie.getDomain() + "; Path=" + cookie.getPath(); Log.i(APPLICATION_TAG, "Setting up cookie: " + cookieString); manager.setCookie(cookie.getDomain(), cookieString); } CookieSyncManager.getInstance().sync(); Log.i(APPLICATION_TAG, "######################## COOKIE SETUP DONE ###############################"); }
From source file:de.trier.infsec.koch.droidsheep.activities.HijackActivity.java
private void setupCookies() { Log.i(APPLICATION_TAG, "######################## COOKIE SETUP ###############################"); CookieManager manager = CookieManager.getInstance(); Log.i(APPLICATION_TAG, "Cookiemanager has cookies: " + (manager.hasCookies() ? "YES" : "NO")); if (manager.hasCookies()) { manager.removeAllCookie(); try {/*from w ww . j a va2s . c o m*/ Thread.sleep(3000); } catch (InterruptedException e) { } Log.i(APPLICATION_TAG, "Cookiemanager has still cookies: " + (manager.hasCookies() ? "YES" : "NO")); } Log.i(APPLICATION_TAG, "######################## COOKIE SETUP START ###############################"); for (CookieWrapper cookieWrapper : authToHijack.getCookies()) { Cookie cookie = cookieWrapper.getCookie(); String cookieString = cookie.getName() + "=" + cookie.getValue() + "; domain=" + cookie.getDomain() + "; Path=" + cookie.getPath(); Log.i(APPLICATION_TAG, "Setting up cookie: " + cookieString); manager.setCookie(cookie.getDomain(), cookieString); } CookieSyncManager.getInstance().sync(); Log.i(APPLICATION_TAG, "######################## COOKIE SETUP DONE ###############################"); }
From source file:com.microsoft.firstapp.AuthService.java
/** * Handles logging the user out including: -deleting cookies so their login * with a provider won't be cached in the web view -removing the userdata * from the shared preferences -setting the current user object on the * client to logged out -optionally redirects to the login page if requested * // w ww . ja v a2s . com * @param shouldRedirectToLogin */ public void logout(boolean shouldRedirectToLogin) { // Clear the cookies so they won't auto login to a provider again CookieSyncManager.createInstance(mContext); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); // Clear the user id and token from the shared preferences SharedPreferences settings = mContext.getSharedPreferences("UserData", 0); SharedPreferences.Editor preferencesEditor = settings.edit(); preferencesEditor.clear(); preferencesEditor.commit(); // Clear the user and return to the auth activity mClient.logout(); // Take the user back to the auth activity to relogin if requested if (shouldRedirectToLogin) { Intent logoutIntent = new Intent(mContext, LogInActivity.class); logoutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(logoutIntent); } }
From source file:com.owncloud.android.ui.dialog.LoginWebViewDialog.java
@SuppressWarnings("deprecation") @SuppressLint("SetJavaScriptEnabled") @Override/* w w w .ja v a2 s .com*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log_OC.v(TAG, "onCreateView, savedInsanceState is " + savedInstanceState); // Inflate layout of the dialog RelativeLayout ssoRootView = (RelativeLayout) inflater.inflate(R.layout.webview_dialog, container, false); // null parent view because it will go in the dialog layout if (mWebView == null) { // initialize the WebView mWebView = new SsoWebView(getActivity().getApplicationContext()); mWebView.setFocusable(true); mWebView.setFocusableInTouchMode(true); mWebView.setClickable(true); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setSavePassword(false); webSettings.setUserAgentString(MainApp.getUserAgent()); webSettings.setSaveFormData(false); // next two settings grant that non-responsive webs are zoomed out when loaded webSettings.setUseWideViewPort(true); webSettings.setLoadWithOverviewMode(true); // next three settings allow the user use pinch gesture to zoom in / out webSettings.setSupportZoom(true); webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false); webSettings.setAllowFileAccess(false); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setAcceptCookie(true); cookieManager.removeAllCookie(); mWebView.loadUrl(mInitialUrl); } mWebViewClient.addTargetUrls(mTargetUrls); mWebView.setWebViewClient(mWebViewClient); // add the webview into the layout RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); ssoRootView.addView(mWebView, layoutParams); ssoRootView.requestLayout(); return ssoRootView; }
From source file:com.tdispatch.passenger.fragment.OAuthFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override// ww w .ja va 2 s . co m protected void onPostCreateView() { View v = mFragmentView.findViewById(R.id.button_cancel); v.setOnClickListener(mOnClickListener); ProgressBar pb = (ProgressBar) mFragmentView.findViewById(R.id.progressbar); pb.setVisibility(View.GONE); mWebView = (WebView) mFragmentView.findViewById(R.id.webview); if (mWebView != null) { mWebView.setWebViewClient(new MyWebViewClient()); mWebView.setWebChromeClient(new MyWebchromeClient()); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { mWebView.setOnTouchListener(mOnTouchListener); } WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); webSettings.setAppCacheEnabled(false); webSettings.setSavePassword(false); webSettings.setSaveFormData(false); CookieSyncManager.createInstance(mContext); CookieManager cm = CookieManager.getInstance(); cm.setAcceptCookie(true); cm.removeAllCookie(); try { ApiRequest req = new ApiRequest(Const.Api.OauthAuthUrl); req.addGetParam("key", Const.getApiKey()); req.addGetParam("scope", ""); req.addGetParam("response_type", "code"); req.addGetParam("client_id", Const.getOAuthClientId()); req.addGetParam("redirect_uri", mOAuthRedirectUrl); req.buildRequest(); String url = req.getUrl(); mWebView.loadUrl(url); } catch (Exception e) { WebnetLog.e("Failed to load oauth launch page..."); } } else { WebnetLog.e("Failed to init WebView. Aborting"); mHostActivity.oAuthCancelled(); } }
From source file:net.niyonkuru.koodroid.service.SessionService.java
private void logout() { final ContentResolver cr = getContentResolver(); final String email = mSettings.email(); /* clear application settings */ cr.delete(Settings.CONTENT_URI, null, null); try {//from w w w . j a v a 2 s. c om /* allow a 5 second window for batch operations to finish */ Thread.sleep(5 * DateUtils.SECOND_IN_MILLIS); } catch (InterruptedException ignored) { } /* clear database data */ cr.delete(Subscribers.CONTENT_URI, Subscribers.SUBSCRIBER_EMAIL + "='" + email + "'", null); CookieManager cookieManager = CookieManager.getInstance(); if (cookieManager != null) { cookieManager.removeAllCookie(); } stopSelf(); }
From source file:org.schabi.newpipe.ReCaptchaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_recaptcha); // Set return to Cancel by default setResult(RESULT_CANCELED);/* ww w.j ava 2 s.c om*/ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(R.string.reCaptcha_title); actionBar.setDisplayShowTitleEnabled(true); } WebView myWebView = (WebView) findViewById(R.id.reCaptchaWebView); // Enable Javascript WebSettings webSettings = myWebView.getSettings(); webSettings.setJavaScriptEnabled(true); ReCaptchaWebViewClient webClient = new ReCaptchaWebViewClient(this); myWebView.setWebViewClient(webClient); // Cleaning cache, history and cookies from webView myWebView.clearCache(true); myWebView.clearHistory(); android.webkit.CookieManager cookieManager = CookieManager.getInstance(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { cookieManager.removeAllCookies(new ValueCallback<Boolean>() { @Override public void onReceiveValue(Boolean aBoolean) { } }); } else { cookieManager.removeAllCookie(); } myWebView.loadUrl(YT_URL); }
From source file:com.microsoft.aad.adal.testapp.MainActivity.java
private void removeCookies() { // Clear browser cookies CookieSyncManager.createInstance(MainActivity.this); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); CookieSyncManager.getInstance().sync(); }
From source file:thiru.in.basicauthwebview.ShowWebViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_show_web_view); // Initialize the Cookie Manager CookieSyncManager.createInstance(this); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setAcceptCookie(true); String url = "http://auth.thiru.in/"; // Call the REST Service to Authenticate // This is sample app, the app can have a login form, accept input, encode the // id and passowrd using Base64 for Validating AsyncTask<String, Void, CookieStore> cookieStoreTask = new Authenticate(this).execute(url + "app-auth", "ZGVtbzpkZW1v"); //Base64 Encoded for demo:demo try {/*from w ww . j a va2 s .c o m*/ cookieManager.removeAllCookie(); CookieStore cookieStore = cookieStoreTask.get(); List<Cookie> cookies = cookieStore.getCookies(); // If the User id and password is wrong, the cookie store will not have any cookies // And the page will display 403 Access Denied for (Cookie cookie : cookies) { Log.i("Cookie", cookie.getName() + " ==> " + cookie.getValue()); // Add the REST Service Cookie Responses to Cookie Manager to make it // Available for the WebViewClient cookieManager.setCookie(url, cookie.getName() + "=" + cookie.getValue()); } } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } mWebView = (WebView) findViewById(R.id.activity_main_webview); mWebView.setWebViewClient(new WebViewClient()); mWebView.loadUrl(url); }
From source file:ti.modules.titanium.network.NetworkModule.java
/** * Removes all the cookies in the system cookie store. *///from w w w . j a va2 s . c o m @Kroll.method public void removeAllSystemCookies() { CookieSyncManager.createInstance(TiApplication.getInstance().getRootOrCurrentActivity()); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); CookieSyncManager.getInstance().sync(); }