+\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, UNTRUSTED_CERT_DIALOG_TAG);\r
+ }\r
+\r
+ /**\r
+ * Show untrusted cert dialog \r
+ */\r
+ private 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, UNTRUSTED_CERT_DIALOG_TAG);\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(SAML_DIALOG_TAG);\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
+ dismissDialog(SAML_DIALOG_TAG);\r
+ Toast.makeText(this, R.string.ssl_validator_not_saved, Toast.LENGTH_LONG).show();\r
+ }\r
+\r
+ @Override\r
+ public void onCancelCertificate() {\r
+ dismissDialog(SAML_DIALOG_TAG);\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
+ \r
+ \r
+ if (mGetServerInfoOpId != -1) {\r
+ RemoteOperationResult result = \r
+ mOperationsServiceBinder.getOperationResultIfFinished(mGetServerInfoOpId);\r
+ if (result != null) {\r
+ //Log_OC.wtf(TAG, "found result of operation finished while rotating");\r
+ onGetServerInfoFinish(result);\r
+ }\r
+ \r
+ } else if (mOauth2GetAccessTokenOpId != -1) {\r
+ RemoteOperationResult result = \r
+ mOperationsServiceBinder.getOperationResultIfFinished(\r
+ mOauth2GetAccessTokenOpId);\r
+ if (result != null) {\r
+ //Log_OC.wtf(TAG, "found result of operation finished while rotating");\r
+ onGetOAuthAccessTokenFinish(result);\r
+ }\r
+ \r
+ } else if (mExistenceCheckOpId != -1) {\r
+ RemoteOperationResult result = \r
+ mOperationsServiceBinder.getOperationResultIfFinished(mExistenceCheckOpId);\r
+ if (result != null) {\r
+ //Log_OC.wtf(TAG, "found result of operation finished while rotating");\r
+ if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(\r
+ MainApp.getAccountType()).equals(mAuthTokenType)) {\r
+ onSamlBasedFederatedSingleSignOnAuthorizationStart(result);\r
+\r
+ } else {\r
+ onAuthorizationCheckFinish(result);\r
+ }\r
+ }\r
+ }if (mGetUserNameOpId != -1) {\r
+ RemoteOperationResult result = \r
+ mOperationsServiceBinder.getOperationResultIfFinished(mGetUserNameOpId);\r
+ if (result != null) {\r
+ //Log_OC.wtf(TAG, "found result of operation finished while rotating");\r
+ onGetUserNameFinish(result);\r
+ }\r
+ \r
+ } \r
+ \r
+ }\r
+\r
+ \r
+ private void dismissDialog(String dialogTag){\r
+ Fragment frag = getSupportFragmentManager().findFragmentByTag(dialogTag);\r
+ if (frag != null && frag instanceof SherlockDialogFragment) {\r
+ SherlockDialogFragment dialog = (SherlockDialogFragment) frag;\r
+ dialog.dismiss();\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