List of usage examples for android.webkit SslErrorHandler proceed
public void proceed()
From source file:nya.miku.wishmaster.http.recaptcha.RecaptchaAjax.java
private static String getChallengeInternal(final String address, final String data, CancellableTask task, final HttpHost proxy) throws Exception { Logger.d(TAG, "not intercepting; proxy: " + (proxy == null ? "disabled" : "enabled")); if (proxy != null) { Logger.d(TAG, "AJAX recaptcha not using (proxy and old API)"); throw new Exception("proxy && old API"); //? ? ? ? reflection ???, .. js-antiddos, ? ( noscript ) }// w w w . j ava 2 s. c o m final Context context = MainApplication.getInstance(); final Holder holder = new Holder(); sHandler.post(new Runnable() { @SuppressLint("SetJavaScriptEnabled") @Override public void run() { holder.webView = new WebView(context); holder.webView.setWebViewClient(new WebViewClient() { @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } @Override public void onLoadResource(WebView view, String url) { String challenge = getChallengeFromImageUrl(url); if (challenge != null) holder.challenge = challenge; super.onLoadResource(view, url); } }); holder.webView.getSettings().setUserAgentString(CUSTOM_UA); holder.webView.getSettings().setJavaScriptEnabled(true); holder.webView.loadDataWithBaseURL(address, data, "text/html", "UTF-8", null); } }); long startTime = System.currentTimeMillis(); while (holder.challenge == null) { long time = System.currentTimeMillis() - startTime; if ((task != null && task.isCancelled()) || time > TIMEOUT) break; Thread.yield(); } sHandler.post(new Runnable() { @Override public void run() { try { holder.webView.stopLoading(); holder.webView.clearCache(true); holder.webView.destroy(); } catch (Exception e) { Logger.e(TAG, e); } } }); if (holder.challenge == null) throw new RecaptchaException("couldn't get Recaptcha Challenge (AJAX)"); return holder.challenge; }
From source file:com.todoroo.astrid.taskrabbit.TaskRabbitOAuthLoginActivity.java
@SuppressWarnings("nls") @Override/*from w ww . ja va 2s . co m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); DependencyInjectionService.getInstance().inject(this); setContentView(R.layout.oauth_login_activity); getSupportActionBar().setTitle(R.string.actfm_OLA_prompt); final String urlParam = getIntent().getStringExtra(URL_TOKEN); final WebView webView = (WebView) findViewById(R.id.browser); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setSavePassword(false); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setSupportZoom(true); webView.setWebViewClient(new WebViewClient() { @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { System.err.println("hey error. " + errorCode + ": " + description); } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.contains("?client_id=") && (url.lastIndexOf("?client_id=") != url.indexOf("?client_id="))) { String redirectUrl = url.substring(0, url.lastIndexOf("?client_id=")); webView.loadUrl(redirectUrl); return true; } return super.shouldOverrideUrlLoading(view, url); } @Override public void onLoadResource(WebView view, String url) { super.onLoadResource(view, url); } @Override public void onPageFinished(WebView view, final String url) { super.onPageFinished(view, url); pd.dismiss(); if (url.contains("access_token=")) { String token = url.substring(url.indexOf("access_token="), url.length()); Intent intent = new Intent(); intent.putExtra(DATA_RESPONSE, token); setResult(RESULT_OK, intent); finish(); } } }); pd = DialogUtilities.progressDialog(this, getString(R.string.DLG_wait)); webView.loadUrl(urlParam); }
From source file:jlelse.simplewebwrapper.SimpleWebWrapperActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // FAB/*from w w w . j a va 2s . c om*/ enableFabChanges(); //WebView webView = new WebView(this); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setAppCacheEnabled(true); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (isOnlyOwnPagesAllowed()) { if (Uri.parse(url).getHost().equals(Uri.parse(getStartUrl()).getHost())) { loadUrl(url); return false; } Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); return true; } else { return false; } } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } }); addContentView(webView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); }
From source file:nya.miku.wishmaster.http.cloudflare.InterceptingAntiDDOS.java
/** anti-DDOS , ? ? ?? webview httpclient (? ?? ? ?-? API >= 11) */ Cookie check(final CloudflareException exception, final ExtendedHttpClient httpClient, final CancellableTask task, final Activity activity) { synchronized (lock) { if (processing) return null; processing = true;/*w w w . jav a2s . c om*/ } processing2 = true; currentCookie = null; final HttpRequestModel rqModel = HttpRequestModel.builder().setGET().build(); final CookieStore cookieStore = httpClient.getCookieStore(); CloudflareChecker.removeCookie(cookieStore, exception.getRequiredCookieName()); final ViewGroup layout = (ViewGroup) activity.getWindow().getDecorView().getRootView(); final WebViewClient client = new WebViewClient() { @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } @Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { HttpResponseModel responseModel = null; try { responseModel = HttpStreamer.getInstance().getFromUrl(url, rqModel, httpClient, null, task); for (int i = 0; i < 3 && responseModel.statusCode == 400; ++i) { Logger.d(TAG, "HTTP 400"); responseModel.release(); responseModel = HttpStreamer.getInstance().getFromUrl(url, rqModel, httpClient, null, task); } for (Cookie cookie : cookieStore.getCookies()) { if (CloudflareChecker.isClearanceCookie(cookie, url, exception.getRequiredCookieName())) { Logger.d(TAG, "Cookie found: " + cookie.getValue()); currentCookie = cookie; processing2 = false; return new WebResourceResponse("text/html", "UTF-8", new ByteArrayInputStream("cookie received".getBytes())); } } BufOutputStream output = new BufOutputStream(); IOUtils.copyStream(responseModel.stream, output); return new WebResourceResponse(null, null, output.toInputStream()); } catch (Exception e) { Logger.e(TAG, e); } finally { if (responseModel != null) responseModel.release(); } return new WebResourceResponse("text/html", "UTF-8", new ByteArrayInputStream("something wrong".getBytes())); } }; activity.runOnUiThread(new Runnable() { @SuppressLint("SetJavaScriptEnabled") @Override public void run() { webView = new WebView(activity); webView.setVisibility(View.GONE); layout.addView(webView); webView.setWebViewClient(client); webView.getSettings().setUserAgentString(HttpConstants.USER_AGENT_STRING); webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl(exception.getCheckUrl()); } }); long startTime = System.currentTimeMillis(); while (processing2) { long time = System.currentTimeMillis() - startTime; if ((task != null && task.isCancelled()) || time > CloudflareChecker.TIMEOUT) { processing2 = false; } } activity.runOnUiThread(new Runnable() { @Override public void run() { try { layout.removeView(webView); webView.stopLoading(); webView.clearCache(true); webView.destroy(); webView = null; } finally { processing = false; } } }); return currentCookie; }
From source file:li.klass.fhem.fragments.AbstractWebViewFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override/*from w w w.ja v a 2 s. co m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); if (view != null) return view; view = inflater.inflate(R.layout.webview, container, false); assert view != null; final WebView webView = (WebView) view.findViewById(R.id.webView); WebSettings settings = webView.getSettings(); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); settings.setJavaScriptEnabled(true); settings.setBuiltInZoomControls(true); final ProgressDialog progressDialog = new ProgressDialog(getActivity()); progressDialog.setMessage(getResources().getString(R.string.loading)); webView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); if (newProgress < 100) { progressDialog.setProgress(newProgress); progressDialog.show(); } else { progressDialog.hide(); } } }); webView.setWebViewClient(new WebViewClient() { @Override public void onReceivedSslError(WebView view, @NotNull SslErrorHandler handler, SslError error) { handler.proceed(); } @SuppressWarnings("ConstantConditions") @Override public void onReceivedHttpAuthRequest(WebView view, @NotNull HttpAuthHandler handler, String host, String realm) { FHEMServerSpec currentServer = connectionService.getCurrentServer(getActivity()); String url = currentServer.getUrl(); String alternativeUrl = trimToNull(currentServer.getAlternateUrl()); try { String fhemUrlHost = new URL(url).getHost(); String alternativeUrlHost = alternativeUrl == null ? null : new URL(alternativeUrl).getHost(); String username = currentServer.getUsername(); String password = currentServer.getPassword(); if (host.startsWith(fhemUrlHost) || (alternativeUrlHost != null && host.startsWith(alternativeUrlHost))) { handler.proceed(username, password); } else { handler.cancel(); Intent intent = new Intent(Actions.SHOW_TOAST); intent.putExtra(BundleExtraKeys.STRING_ID, R.string.error_authentication); getActivity().sendBroadcast(intent); } } catch (MalformedURLException e) { Intent intent = new Intent(Actions.SHOW_TOAST); intent.putExtra(BundleExtraKeys.STRING_ID, R.string.error_host_connection); getActivity().sendBroadcast(intent); LOG.error("malformed URL: " + url, e); handler.cancel(); } } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if ("about:blank".equalsIgnoreCase(url)) { Optional<String> alternativeUrl = getAlternateLoadUrl(); if (alternativeUrl.isPresent()) { webView.loadUrl(alternativeUrl.get()); } } else { onPageLoadFinishedCallback(view, url); } } }); return view; }
From source file:com.polyvi.xface.view.XWebViewClient.java
/** * ????CA?SslError proceed()?SSL/*from w w w . ja va 2 s. c o m*/ */ @TargetApi(8) @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); }
From source file:org.geometerplus.android.fbreader.network.auth.WebAuthorisationScreen.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); requestWindowFeature(Window.FEATURE_PROGRESS); SQLiteCookieDatabase.init(this); CookieSyncManager.createInstance(getApplicationContext()); CookieManager.getInstance().removeAllCookie(); final Intent intent = getIntent(); final Uri data = intent.getData(); if (data == null || data.getHost() == null) { finish();/* w w w . ja v a2 s . c o m*/ return; } final String completeUrl = intent.getStringExtra(COMPLETE_URL_KEY); OrientationUtil.setOrientation(this, intent); final WebView view = new WebView(this); view.getSettings().setJavaScriptEnabled(true); view.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int progress) { setProgress(progress * 100); } }); view.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { setTitle(url); if (url != null && url.startsWith(completeUrl)) { final HashMap<String, String> cookies = new HashMap<String, String>(); final String cookieString = CookieManager.getInstance().getCookie(url); if (cookieString != null) { // cookieString is a string like NAME=VALUE [; NAME=VALUE] for (String pair : cookieString.split(";")) { final String[] parts = pair.split("=", 2); if (parts.length != 2) { continue; } cookies.put(parts[0].trim(), parts[1].trim()); } } storeCookies(data.getHost(), cookies); WebAuthorisationScreen.this.setResult(RESULT_OK); finish(); } } public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.ECLAIR_MR1) { // hack for auth problem in android 2.1 handler.proceed(); } else { super.onReceivedSslError(view, handler, error); } } }); setContentView(view); view.loadUrl(intent.getDataString()); }
From source file:nya.miku.wishmaster.http.cloudflare.CloudflareChecker.java
private Cookie checkAntiDDOS(final CloudflareException exception, final HttpHost proxy, CancellableTask task, final Activity activity) { synchronized (lock) { if (processing) return null; processing = true;/*from ww w. ja v a2 s . co m*/ } processing2 = true; currentCookie = null; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { CookieSyncManager.createInstance(activity); CookieManager.getInstance().removeAllCookie(); } else { CompatibilityImpl.clearCookies(CookieManager.getInstance()); } final ViewGroup layout = (ViewGroup) activity.getWindow().getDecorView().getRootView(); final WebViewClient client = new WebViewClient() { @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } @Override public void onPageFinished(WebView webView, String url) { super.onPageFinished(webView, url); Logger.d(TAG, "Got Page: " + url); String value = null; try { String[] cookies = CookieManager.getInstance().getCookie(url).split("[;]"); for (String cookie : cookies) { if ((cookie != null) && (!cookie.trim().equals("")) && (cookie.startsWith(" " + exception.getRequiredCookieName() + "="))) { value = cookie.substring(exception.getRequiredCookieName().length() + 2); } } } catch (NullPointerException e) { Logger.e(TAG, e); } if (value != null) { BasicClientCookieHC4 cf_cookie = new BasicClientCookieHC4(exception.getRequiredCookieName(), value); cf_cookie.setDomain("." + Uri.parse(url).getHost()); cf_cookie.setPath("/"); currentCookie = cf_cookie; Logger.d(TAG, "Cookie found: " + value); processing2 = false; } else { Logger.d(TAG, "Cookie is not found"); } } }; activity.runOnUiThread(new Runnable() { @SuppressLint("SetJavaScriptEnabled") @Override public void run() { webView = new WebView(activity); webView.setVisibility(View.GONE); layout.addView(webView); webView.setWebViewClient(client); webView.getSettings().setUserAgentString(HttpConstants.USER_AGENT_STRING); webView.getSettings().setJavaScriptEnabled(true); webViewContext = webView.getContext(); if (proxy != null) WebViewProxy.setProxy(webViewContext, proxy.getHostName(), proxy.getPort()); webView.loadUrl(exception.getCheckUrl()); } }); long startTime = System.currentTimeMillis(); while (processing2) { long time = System.currentTimeMillis() - startTime; if ((task != null && task.isCancelled()) || time > TIMEOUT) { processing2 = false; } } activity.runOnUiThread(new Runnable() { @Override public void run() { try { layout.removeView(webView); webView.stopLoading(); webView.clearCache(true); webView.destroy(); webView = null; } finally { if (proxy != null) WebViewProxy.setProxy(webViewContext, null, 0); processing = false; } } }); return currentCookie; }
From source file:com.webileapps.fragments.CordovaFragment.java
protected void init() { appView = makeWebView();/*from w ww . ja v a 2 s. c o m*/ createViews(); if (!appView.isInitialized()) { appView.init(cordovaInterface, pluginEntries, preferences); } cordovaInterface.onCordovaInit(appView.getPluginManager()); // Wire the hardware volume controls to control media if desired. String volumePref = preferences.getString("DefaultVolumeStream", ""); if ("media".equals(volumePref.toLowerCase(Locale.ENGLISH))) { getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC); } if (BuildConfig.DEBUG) { ((WebView) appView.getView()) .setWebViewClient(new SystemWebViewClient((SystemWebViewEngine) appView.getEngine()) { @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } }); } }
From source file:system.info.reader.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); resolutions = Properties.resolution(dm); Properties.resolution = resolutions[0] + "*" + resolutions[1]; int tabHeight = 30, tabWidth = 80; if (dm.widthPixels >= 480) { tabHeight = 40;// w ww. ja v a 2s . c o m tabWidth = 120; } tabHost = getTabHost(); LayoutInflater.from(this).inflate(R.layout.main, tabHost.getTabContentView(), true); tabHost.addTab( tabHost.newTabSpec("tab1").setIndicator(getString(R.string.brief)).setContent(R.id.PropertyList)); tabHost.addTab( tabHost.newTabSpec("tab2").setIndicator(getString(R.string.online)).setContent(R.id.ViewServer)); tabHost.addTab( tabHost.newTabSpec("tab3").setIndicator(getString(R.string.apps)).setContent(R.id.sViewApps)); tabHost.addTab( tabHost.newTabSpec("tab4").setIndicator(getString(R.string.process)).setContent(R.id.sViewProcess)); tabHost.addTab(tabHost.newTabSpec("tab5").setIndicator("Services").setContent(R.id.sViewCpu)); tabHost.addTab(tabHost.newTabSpec("tab6").setIndicator("Tasks").setContent(R.id.sViewMem)); //tabHost.addTab(tabHost.newTabSpec("tab7") // .setIndicator("Vending") // .setContent(R.id.sViewDisk)); AppsText = (TextView) findViewById(R.id.TextViewApps); ProcessText = (TextView) findViewById(R.id.TextViewProcess); ServiceText = (TextView) findViewById(R.id.TextViewCpu); TaskText = (TextView) findViewById(R.id.TextViewMem); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(tabWidth, tabHeight); for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) tabHost.getTabWidget().getChildAt(i).setLayoutParams(lp); properList = (ListView) findViewById(R.id.PropertyList); Properties.properListItem = new ArrayList<HashMap<String, Object>>(); properListItemAdapter = new SimpleAdapter(this, Properties.properListItem, R.layout.property_list, new String[] { "ItemTitle", "ItemText" }, new int[] { R.id.ItemTitle, R.id.ItemText }); properList.setAdapter(properListItemAdapter); properList.setOnItemClickListener(mpropertyCL); //will support app list later //appList = (ListView)findViewById(R.id.AppList); //Properties.appListItem = new ArrayList<HashMap<String, Object>>(); //SimpleAdapter appListItemAdapter = new SimpleAdapter(this, Properties.appListItem, // R.layout.app_list, // new String[] {"ItemTitle", "ItemText"}, // new int[] {R.id.ItemTitle, R.id.ItemText} // ); //appList.setAdapter(appListItemAdapter); serverWeb = (WebView) findViewById(R.id.ViewServer); WebSettings webSettings = serverWeb.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setUserAgentString("sys.info.trial" + versionCode); webSettings.setTextSize(WebSettings.TextSize.SMALLER); serverWeb.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return false;//this will not launch browser when redirect. } public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } }); PackageManager pm = getPackageManager(); try { PackageInfo pi = pm.getPackageInfo("sys.info.trial", 0); version = "v" + pi.versionName; versionCode = pi.versionCode; List<PackageInfo> apps = getPackageManager().getInstalledPackages(0); nApk = Integer.toString(apps.size()); apklist = ""; for (PackageInfo app : apps) { apklist += app.packageName + "\t(" + app.versionName + ")\n"; } } catch (NameNotFoundException e) { e.printStackTrace(); } showDialog(0); initPropList(); //refresh(); PageTask task = new PageTask(); task.execute(""); }