+\r
+\r
+ /**\r
+ * Show untrusted cert dialog \r
+ */\r
+ public void showUntrustedCertDialog(X509Certificate x509Certificate, SslError error, SslErrorHandler handler) {\r
+ // Show a dialog with the certificate info\r
+ SslUntrustedCertDialog dialog = null;\r
+ if (x509Certificate == null) {\r
+ dialog = SslUntrustedCertDialog.newInstanceForEmptySslError(error, handler);\r
+ } else {\r
+ dialog = SslUntrustedCertDialog.newInstanceForFullSslError(x509Certificate, error, handler);\r
+ }\r
+ FragmentManager fm = getSupportFragmentManager();\r
+ FragmentTransaction ft = fm.beginTransaction();\r
+ ft.addToBackStack(null);\r
+ dialog.show(ft, DIALOG_UNTRUSTED_CERT);\r
+ }\r
+\r
+ /**\r
+ * Show untrusted cert dialog \r
+ */\r
+ public void showUntrustedCertDialog(RemoteOperationResult result) {\r
+ // Show a dialog with the certificate info\r
+ SslUntrustedCertDialog dialog = SslUntrustedCertDialog.newInstanceForFullSslError((CertificateCombinedException)result.getException());\r
+ FragmentManager fm = getSupportFragmentManager();\r
+ FragmentTransaction ft = fm.beginTransaction();\r
+ ft.addToBackStack(null);\r
+ dialog.show(ft, DIALOG_UNTRUSTED_CERT);\r
+\r
+ }\r
+\r
+ /**\r
+ * Dismiss untrusted cert dialog\r
+ */\r
+ public void dismissUntrustedCertDialog(){\r
+ /*Fragment frag = getSupportFragmentManager().findFragmentByTag(DIALOG_UNTRUSTED_CERT);\r
+ if (frag != null) {\r
+ SslErrorViewAdapter dialog = (SslErrorViewAdapter) frag;\r
+ dialog.dismiss();\r
+ }\r
+ */\r
+ }\r
+\r
+ /**\r
+ * Called from SslValidatorDialog when a new server certificate was correctly saved.\r
+ */\r
+ public void onSavedCertificate() {\r
+ Fragment fd = getSupportFragmentManager().findFragmentByTag(TAG_SAML_DIALOG);\r
+ if (fd == null) {\r
+ // if SAML dialog is not shown, the SslDialog was shown due to an SSL error in the server check\r
+ checkOcServer();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Called from SslValidatorDialog when a new server certificate could not be saved \r
+ * when the user requested it.\r
+ */\r
+ @Override\r
+ public void onFailedSavingCertificate() {\r
+ showDialog(DIALOG_CERT_NOT_SAVED);\r
+ cancelWebView();\r
+ }\r
+\r
+ @Override\r
+ public void onCancelCertificate() {\r
+ cancelWebView();\r
+ }\r
+\r
+\r
+ public void cancelWebView() {\r
+ Fragment fd = getSupportFragmentManager().findFragmentByTag(TAG_SAML_DIALOG);\r
+ if (fd != null && fd instanceof SherlockDialogFragment) {\r
+ Dialog d = ((SherlockDialogFragment)fd).getDialog();\r
+ if (d != null && d.isShowing()) {\r
+ d.dismiss();\r
+ }\r
+ }\r
+\r
+ }\r
+ \r
+ \r
+ private void doOnResumeAndBound() {\r
+ //Log.wtf(TAG, "registering to listen for operation callbacks" );\r
+ mOperationsServiceBinder.addOperationListener(AuthenticatorActivity.this, mHandler);\r
+ \r
+ if (mGetServerInfoOpId != -1) {\r
+ RemoteOperationResult result = \r
+ mOperationsServiceBinder.getOperationResultIfFinished(mGetServerInfoOpId);\r
+ if (result != null) {\r
+ //Log.wtf(TAG, "found result of operation finished while rotating");\r
+ onGetServerInfoFinish(result);\r
+ }\r
+ }\r
+ }\r
+ \r
+ /** \r
+ * Implements callback methods for service binding. \r
+ */\r
+ private class OperationsServiceConnection implements ServiceConnection {\r
+\r
+ @Override\r
+ public void onServiceConnected(ComponentName component, IBinder service) {\r
+ if (component.equals(new ComponentName(AuthenticatorActivity.this, OperationsService.class))) {\r
+ //Log_OC.wtf(TAG, "Operations service connected");\r
+ mOperationsServiceBinder = (OperationsServiceBinder) service;\r
+ \r
+ doOnResumeAndBound();\r
+ \r
+ } else {\r
+ return;\r
+ }\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void onServiceDisconnected(ComponentName component) {\r
+ if (component.equals(new ComponentName(AuthenticatorActivity.this, OperationsService.class))) {\r
+ Log_OC.e(TAG, "Operations service crashed");\r
+ mOperationsServiceBinder = null;\r
+ }\r
+ }\r
+ \r
+ }\r
+ \r