+ }\r
+\r
+ \r
+ /**\r
+ * The redirection triggered by the OAuth authentication server as response to the GET AUTHORIZATION, and \r
+ * deferred in {@link #onNewIntent(Intent)}, is processed here.\r
+ */\r
+ @Override\r
+ protected void onResume() {\r
+ super.onResume();\r
+ /* LEAVE OLD OAUTH FLOW ; \r
+ // (old oauth code) Registering token receiver. We must listening to the service that is pooling to the oAuth server for a token.\r
+ if (tokenReceiver == null) {\r
+ IntentFilter tokenFilter = new IntentFilter(OAuth2GetTokenService.TOKEN_RECEIVED_MESSAGE); \r
+ tokenReceiver = new TokenReceiver();\r
+ this.registerReceiver(tokenReceiver,tokenFilter);\r
+ } */\r
+ // (new oauth code)\r
+ if (mNewCapturedUriFromOAuth2Redirection != null) {\r
+ getOAuth2AccessTokenFromCapturedRedirection(); \r
+ }\r
+ }\r
+ \r
+ \r
+ @Override protected void onDestroy() { \r
+ super.onDestroy();\r
+\r
+ /* LEAVE OLD OAUTH FLOW\r
+ // We must stop the service thats it's pooling to oAuth2 server for a token.\r
+ Intent tokenService = new Intent(this, OAuth2GetTokenService.class);\r
+ stopService(tokenService);\r
+ \r
+ // We stop listening the result of the pooling service.\r
+ if (tokenReceiver != null) {\r
+ unregisterReceiver(tokenReceiver);\r
+ tokenReceiver = null;\r
+ }*/\r
+\r
+ } \r
+ \r
+ \r
+ /**\r
+ * Parses the redirection with the response to the GET AUTHORIZATION request to the \r
+ * oAuth server and requests for the access token (GET ACCESS TOKEN)\r
+ */\r
+ private void getOAuth2AccessTokenFromCapturedRedirection() {\r
+ /// Parse data from OAuth redirection\r
+ Map<String, String> responseValues = new HashMap<String, String>();\r
+ String queryParameters = mNewCapturedUriFromOAuth2Redirection.getQuery();\r
+ mNewCapturedUriFromOAuth2Redirection = null;\r
+ String[] pairs = queryParameters.split("&");\r
+ int i = 0;\r
+ String key = "";\r
+ String value = "";\r
+ StringBuilder sb = new StringBuilder();\r
+ while (pairs.length > i) {\r
+ int j = 0;\r
+ String[] part = pairs[i].split("=");\r
+ while (part.length > j) {\r
+ String p = part[j];\r
+ if (j == 0) {\r
+ key = p;\r
+ sb.append(key + " = ");\r
+ } else if (j == 1) {\r
+ value = p;\r
+ responseValues.put(key, value);\r
+ sb.append(value + "\n");\r
+ }\r
+\r
+ Log.v(TAG, "[" + i + "," + j + "] = " + p);\r
+ j++;\r
+ }\r
+ i++;\r
+ }\r
+ \r
+ /// Updating status widget to OK.\r
+ updateOAuth2IconAndText(R.drawable.ic_ok, R.string.auth_connection_established);\r
+ \r
+ /// Showing the dialog with instructions for the user.\r
+ showDialog(DIALOG_OAUTH2_LOGIN_PROGRESS);\r
+\r
+ /// GET ACCESS TOKEN to the oAuth server \r
+ RemoteOperation operation = new OAuth2GetAccessToken(responseValues);\r
+ WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(getString(R.string.oauth_url_endpoint_access)), getApplicationContext());\r
+ operation.execute(client, this, mHandler);\r
+ }\r
+ \r
+\r
+ \r
+ /**\r
+ * Handles the change of focus on the text inputs for the server URL and the password\r
+ */\r
+ public void onFocusChange(View view, boolean hasFocus) {\r
+ if (view.getId() == R.id.hostUrlInput) {\r
+ onUrlInputFocusChanged((TextView) view, hasFocus);\r
+ \r
+ } else if (view.getId() == R.id.account_password) {\r
+ onPasswordFocusChanged((TextView) view, hasFocus);\r
+ }\r
+ }\r
+ \r
+\r
+ /**\r
+ * Handles changes in focus on the text input for the server URL.\r
+ * \r
+ * IMPORTANT ENTRY POINT 2: When (!hasFocus), user wrote the server URL and changed to \r
+ * other field. The operation to check the existence of the server in the entered URL is\r
+ * started. \r
+ * \r
+ * When hasFocus: user 'comes back' to write again the server URL.\r
+ * \r
+ * @param hostInput TextView with the URL input field receiving the change of focus.\r
+ * @param hasFocus 'True' if focus is received, 'false' if is lost\r
+ */\r
+ private void onUrlInputFocusChanged(TextView hostInput, boolean hasFocus) {\r
+ if (!hasFocus) {\r
+ String uri = hostInput.getText().toString().trim();\r
+ if (uri.length() != 0) {\r
+ mStatusText = R.string.auth_testing_connection;\r
+ mStatusIcon = R.drawable.progress_small;\r
+ updateOcServerCheckIconAndText();\r
+ /** TODO cancel previous connection check if the user tries to ammend a wrong URL \r
+ if(mConnChkOperation != null) {\r
+ mConnChkOperation.cancel();\r
+ } */\r
+ mOcServerChkOperation = new OwnCloudServerCheckOperation(uri, this);\r
+ WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(uri), this);\r
+ mHostBaseUrl = "";\r
+ mDiscoveredVersion = null;\r
+ mOperationThread = mOcServerChkOperation.execute(client, this, mHandler);\r
+ } else {\r
+ mRefreshButton.setVisibility(View.INVISIBLE);\r
+ mStatusText = 0;\r
+ mStatusIcon = 0;\r
+ updateOcServerCheckIconAndText();\r
+ }\r
+ } else {\r
+ // avoids that the 'connect' button can be clicked if the test was previously passed\r
+ mOkButton.setEnabled(false); \r
+ }\r
+ }\r
+\r
+\r
+ /**\r
+ * Handles changes in focus on the text input for the password (basic authorization).\r
+ * \r
+ * When (hasFocus), the button to toggle password visibility is shown.\r
+ * \r
+ * When (!hasFocus), the button is made invisible and the password is hidden.\r
+ * \r
+ * @param passwordInput TextView with the password input field receiving the change of focus.\r
+ * @param hasFocus 'True' if focus is received, 'false' if is lost\r
+ */\r
+ private void onPasswordFocusChanged(TextView passwordInput, boolean hasFocus) {\r
+ if (hasFocus) {\r
+ mViewPasswordButton.setVisibility(View.VISIBLE);\r
+ } else {\r
+ int input_type = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;\r
+ passwordInput.setInputType(input_type);\r
+ mViewPasswordButton.setVisibility(View.INVISIBLE);\r
+ }\r
+ }\r
+\r
+\r
+ \r
+ /**\r
+ * Cancels the authenticator activity\r
+ * \r
+ * IMPORTANT ENTRY POINT 3: Never underestimate the importance of cancellation\r
+ * \r
+ * This method is bound in the layout/acceoun_setup.xml resource file.\r
+ * \r
+ * @param view Cancel button\r
+ */\r
+ public void onCancelClick(View view) {\r
+ setResult(RESULT_CANCELED); // TODO review how is this related to AccountAuthenticator\r
+ finish();\r
+ }\r
+ \r
+ \r
+ \r
+ /**\r
+ * Checks the credentials of the user in the root of the ownCloud server\r
+ * before creating a new local account.\r
+ * \r
+ * For basic authorization, a check of existence of the root folder is\r
+ * performed.\r
+ * \r
+ * For OAuth, starts the flow to get an access token; the credentials test \r
+ * is postponed until it is available.\r
+ * \r
+ * IMPORTANT ENTRY POINT 4\r
+ * \r
+ * @param view OK button\r
+ */\r
+ public void onOkClick(View view) {\r
+ // this check should be unnecessary\r
+ if (mDiscoveredVersion == null || !mDiscoveredVersion.isVersionValid() || mHostBaseUrl == null || mHostBaseUrl.length() == 0) {\r
+ mStatusIcon = R.drawable.common_error;\r
+ mStatusText = R.string.auth_wtf_reenter_URL;\r
+ updateOcServerCheckIconAndText();\r
+ mOkButton.setEnabled(false);\r
+ Log.wtf(TAG, "The user was allowed to click 'connect' to an unchecked server!!");\r
+ return;\r
+ }\r
+ \r
+ if (mOAuth2Check.isChecked()) {\r
+ startOauthorization();\r
+ \r
+ } else {\r
+ checkBasicAuthorization();\r
+ }\r
+ }\r
+ \r
+ \r
+ /**\r
+ * Tests the credentials entered by the user performing a check of existence on \r
+ * the root folder of the ownCloud server.\r
+ */\r
+ private void checkBasicAuthorization() {\r
+ /// get the path to the root folder through WebDAV from the version server\r
+ String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, false);\r
+ \r
+ /// get basic credentials entered by user\r
+ String username = mUsernameInput.getText().toString();\r
+ String password = mPasswordInput.getText().toString();\r
+ \r
+ /// be gentle with the user\r
+ showDialog(DIALOG_LOGIN_PROGRESS);\r
+ \r
+ /// test credentials accessing the root folder\r
+ mAuthCheckOperation = new ExistenceCheckOperation("", this, false);\r
+ WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this);\r
+ client.setBasicCredentials(username, password);\r
+ mOperationThread = mAuthCheckOperation.execute(client, this, mHandler);\r
+ }\r
+\r
+\r
+ /**\r
+ * Starts the OAuth 'grant type' flow to get an access token, with \r
+ * a GET AUTHORIZATION request to the BUILT-IN authorization server. \r
+ */\r
+ private void startOauthorization() {\r
+ // be gentle with the user\r
+ updateOAuth2IconAndText(R.drawable.progress_small, R.string.oauth_login_connection);\r
+ \r
+ // GET AUTHORIZATION request\r
+ /*\r
+ mOAuth2GetCodeRunnable = new OAuth2GetAuthorizationToken(, this);\r
+ mOAuth2GetCodeRunnable.setListener(this, mHandler);\r
+ mOAuth2GetCodeThread = new Thread(mOAuth2GetCodeRunnable);\r
+ mOAuth2GetCodeThread.start();\r
+ */\r
+ \r
+ //if (mGrantType.equals(OAuth2Context.OAUTH2_AUTH_CODE_GRANT_TYPE)) {\r
+ Uri uri = Uri.parse(getString(R.string.oauth_url_endpoint_auth));\r
+ Uri.Builder uriBuilder = uri.buildUpon();\r
+ uriBuilder.appendQueryParameter(OAuth2Context.CODE_RESPONSE_TYPE, OAuth2Context.OAUTH2_CODE_RESPONSE_TYPE);\r
+ uriBuilder.appendQueryParameter(OAuth2Context.CODE_REDIRECT_URI, OAuth2Context.MY_REDIRECT_URI); \r
+ uriBuilder.appendQueryParameter(OAuth2Context.CODE_CLIENT_ID, OAuth2Context.OAUTH2_F_CLIENT_ID);\r
+ uriBuilder.appendQueryParameter(OAuth2Context.CODE_SCOPE, OAuth2Context.OAUTH2_F_SCOPE);\r
+ //uriBuilder.appendQueryParameter(OAuth2Context.CODE_STATE, whateverwewant);\r
+ uri = uriBuilder.build();\r
+ Log.d(TAG, "Starting browser to view " + uri.toString());\r
+ Intent i = new Intent(Intent.ACTION_VIEW, uri);\r
+ startActivity(i);\r
+ //}\r
+ }\r
+\r
+ \r
+ /**\r
+ * Callback method invoked when a RemoteOperation executed by this Activity finishes.\r
+ * \r
+ * Dispatches the operation flow to the right method.\r
+ */\r
+ @Override\r
+ public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {\r
+\r
+ if (operation instanceof OwnCloudServerCheckOperation) {\r
+ onOcServerCheckFinish((OwnCloudServerCheckOperation) operation, result);\r
+ \r
+ } else if (operation instanceof OAuth2GetAccessToken) {\r
+ onGetOAuthAccessTokenFinish((OAuth2GetAccessToken)operation, result);\r
+ \r
+ } else if (operation instanceof ExistenceCheckOperation) {\r
+ onAuthorizationCheckFinish((ExistenceCheckOperation)operation, result);\r
+ \r
+ }\r
+ }\r
+ \r
+\r
+ /**\r
+ * Processes the result of the server check performed when the user finishes the enter of the\r
+ * server URL.\r
+ * \r
+ * @param operation Server check performed.\r
+ * @param result Result of the check.\r
+ */\r
+ private void onOcServerCheckFinish(OwnCloudServerCheckOperation operation, RemoteOperationResult result) {\r
+ /// update status connection icon and text\r
+ mStatusText = mStatusIcon = 0;\r
+ mStatusCorrect = false;\r
+ \r
+ switch (result.getCode()) {\r
+ case OK_SSL:\r
+ mIsSslConn = true;\r
+ mStatusIcon = android.R.drawable.ic_secure;\r
+ mStatusText = R.string.auth_secure_connection;\r
+ mStatusCorrect = true;\r
+ break;\r
+ \r
+ case OK_NO_SSL:\r
+ case OK:\r
+ mIsSslConn = false;\r
+ mStatusCorrect = true;\r
+ if (mHostUrlInput.getText().toString().trim().toLowerCase().startsWith("http://") ) {\r
+ mStatusText = R.string.auth_connection_established;\r
+ mStatusIcon = R.drawable.ic_ok;\r
+ } else {\r
+ mStatusText = R.string.auth_nossl_plain_ok_title;\r
+ mStatusIcon = android.R.drawable.ic_partial_secure;\r
+ }\r
+ break;\r
+ \r
+ /// very special case (TODO: move to a common place for all the remote operations)\r
+ case SSL_RECOVERABLE_PEER_UNVERIFIED:\r
+ mStatusIcon = R.drawable.common_error;\r
+ mStatusText = R.string.auth_ssl_unverified_server_title;\r
+ mLastSslUntrustedServerResult = result;\r
+ showDialog(DIALOG_SSL_VALIDATOR); \r
+ break;\r
+ \r
+ case BAD_OC_VERSION:\r
+ mStatusIcon = R.drawable.common_error;\r
+ mStatusText = R.string.auth_bad_oc_version_title;\r
+ break;\r
+ case WRONG_CONNECTION:\r
+ mStatusIcon = R.drawable.common_error;\r
+ mStatusText = R.string.auth_wrong_connection_title;\r
+ break;\r
+ case TIMEOUT:\r
+ mStatusIcon = R.drawable.common_error;\r
+ mStatusText = R.string.auth_timeout_title;\r
+ break;\r
+ case INCORRECT_ADDRESS:\r
+ mStatusIcon = R.drawable.common_error;\r
+ mStatusText = R.string.auth_incorrect_address_title;\r
+ break;\r
+ \r
+ case SSL_ERROR:\r
+ mStatusIcon = R.drawable.common_error;\r
+ mStatusText = R.string.auth_ssl_general_error_title;\r
+ break;\r
+ \r
+ case HOST_NOT_AVAILABLE:\r
+ mStatusIcon = R.drawable.common_error;\r
+ mStatusText = R.string.auth_unknown_host_title;\r
+ break;\r
+ case NO_NETWORK_CONNECTION:\r
+ mStatusIcon = R.drawable.no_network;\r
+ mStatusText = R.string.auth_no_net_conn_title;\r
+ break;\r
+ case INSTANCE_NOT_CONFIGURED:\r
+ mStatusIcon = R.drawable.common_error;\r
+ mStatusText = R.string.auth_not_configured_title;\r
+ break;\r
+ case FILE_NOT_FOUND:\r
+ mStatusIcon = R.drawable.common_error;\r
+ mStatusText = R.string.auth_incorrect_path_title;\r
+ break;\r
+ case UNHANDLED_HTTP_CODE:\r
+ case UNKNOWN_ERROR:\r
+ mStatusIcon = R.drawable.common_error;\r
+ mStatusText = R.string.auth_unknown_error_title;\r
+ break;\r
+ default:\r
+ Log.e(TAG, "Incorrect connection checker result type: " + result.getHttpCode());\r
+ }\r
+ updateOcServerCheckIconAndText();\r
+ \r
+ /// update the visibility of the 'retry connection' button\r
+ if (!mStatusCorrect)\r
+ mRefreshButton.setVisibility(View.VISIBLE);\r
+ else\r
+ mRefreshButton.setVisibility(View.INVISIBLE);\r
+ \r
+ /// retrieve discovered version and normalize server URL\r
+ mDiscoveredVersion = operation.getDiscoveredVersion();\r
+ mHostBaseUrl = mHostUrlInput.getText().toString().trim();\r
+ if (!mHostBaseUrl.toLowerCase().startsWith("http://") &&\r
+ !mHostBaseUrl.toLowerCase().startsWith("https://")) {\r
+ \r
+ if (mIsSslConn) {\r
+ mHostBaseUrl = "https://" + mHostBaseUrl;\r
+ } else {\r
+ mHostBaseUrl = "http://" + mHostBaseUrl;\r
+ }\r
+ \r
+ }\r
+ if (mHostBaseUrl.endsWith("/"))\r
+ mHostBaseUrl = mHostBaseUrl.substring(0, mHostBaseUrl.length() - 1);\r
+ \r
+ /// allow or not the user try to access the server\r
+ mOkButton.setEnabled(mStatusCorrect);\r
+ }\r
+\r
+\r
+ /**\r
+ * Processes the result of the request for and access token send \r
+ * to an OAuth authorization server.\r
+ * \r
+ * @param operation Operation performed requesting the access token.\r
+ * @param result Result of the operation.\r
+ */\r
+ private void onGetOAuthAccessTokenFinish(OAuth2GetAccessToken operation, RemoteOperationResult result) {\r
+ try {\r
+ dismissDialog(DIALOG_OAUTH2_LOGIN_PROGRESS);\r
+ } catch (IllegalArgumentException e) {\r
+ // NOTHING TO DO ; can't find out what situation that leads to the exception in this code, but user logs signal that it happens\r
+ }\r
+\r
+ String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, false);\r
+ if (result.isSuccess() && webdav_path != null) {\r
+ /// be gentle with the user\r
+ showDialog(DIALOG_LOGIN_PROGRESS);\r
+ \r
+ /// time to test the retrieved access token on the ownCloud server\r
+ mOAuthAccessToken = ((OAuth2GetAccessToken)operation).getResultTokenMap().get(OAuth2Context.KEY_ACCESS_TOKEN);\r
+ Log.d(TAG, "Got ACCESS TOKEN: " + mOAuthAccessToken);\r
+ mAuthCheckOperation = new ExistenceCheckOperation("", this, false);\r
+ WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this);\r
+ client.setBearerCredentials(mOAuthAccessToken);\r
+ mAuthCheckOperation.execute(client, this, mHandler);\r
+ \r
+ } else {\r
+ if (webdav_path != null) {\r
+ mOAuthAuthEndpointText.setError("A valid authorization could not be obtained");\r
+ } else {\r
+ mOAuthAuthEndpointText.setError(getString(R.string.auth_bad_oc_version_title)); // should never happen \r
+ }\r
+ }\r
+ }\r
+\r
+ \r
+ /**\r
+ * Processes the result of the access check performed to try the user credentials.\r
+ * \r
+ * Creates a new account through the AccountManager.\r
+ * \r
+ * @param operation Access check performed.\r
+ * @param result Result of the operation.\r
+ */\r
+ private void onAuthorizationCheckFinish(ExistenceCheckOperation operation, RemoteOperationResult result) {\r
+ try {\r
+ dismissDialog(DIALOG_LOGIN_PROGRESS);\r
+ } catch (IllegalArgumentException e) {\r
+ // NOTHING TO DO ; can't find out what situation that leads to the exception in this code, but user logs signal that it happens\r
+ }\r
+ \r
+ boolean isOAuth = mOAuth2Check.isChecked();\r
+\r
+ if (result.isSuccess()) {\r
+ Log.d(TAG, "Successful access - time to save the account");\r
+\r
+ /// create and save new ownCloud account\r
+ Uri uri = Uri.parse(mHostBaseUrl);\r
+ String username = isOAuth ?\r
+ "OAuth_user" + (new java.util.Random(System.currentTimeMillis())).nextLong() :\r
+ mUsernameInput.getText().toString().trim();\r
+ // TODO a better way to set an account name\r
+ String accountName = username + "@" + uri.getHost();\r
+ if (uri.getPort() >= 0) {\r
+ accountName += ":" + uri.getPort();\r
+ }\r
+ Account account = new Account(accountName, AccountAuthenticator.ACCOUNT_TYPE);\r
+ AccountManager accManager = AccountManager.get(this);\r
+ if (isOAuth) {\r
+ accManager.addAccountExplicitly(account, "", null); // with our implementation, the password is never input in the app\r
+ } else {\r
+ accManager.addAccountExplicitly(account, mPasswordInput.getText().toString(), null);\r
+ }\r
+\r
+ /// add the new account as default in preferences, if there is none already\r
+ Account defaultAccount = AccountUtils.getCurrentOwnCloudAccount(this);\r
+ if (defaultAccount == null) {\r
+ SharedPreferences.Editor editor = PreferenceManager\r
+ .getDefaultSharedPreferences(this).edit();\r
+ editor.putString("select_oc_account", accountName);\r
+ editor.commit();\r
+ }\r
+\r
+\r
+ /// prepare result to return to the Authenticator\r
+ // TODO check again what the Authenticator makes with it; probably has the same effect as addAccountExplicitly, but it's not well done\r
+ final Intent intent = new Intent(); // TODO check if the intent can be retrieved from getIntent(), passed from AccountAuthenticator \r
+ intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, AccountAuthenticator.ACCOUNT_TYPE);\r
+ intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, account.name);\r
+ if (!isOAuth)\r
+ intent.putExtra(AccountManager.KEY_AUTHTOKEN, AccountAuthenticator.ACCOUNT_TYPE); // TODO check this; not sure it's right; maybe\r
+ intent.putExtra(AccountManager.KEY_USERDATA, username);\r
+ if (isOAuth) {\r
+ accManager.setAuthToken(account, AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN, mOAuthAccessToken);\r
+ }\r
+ /// add user data to the new account; TODO probably can be done in the last parameter addAccountExplicitly, or in KEY_USERDATA\r
+ accManager.setUserData(account, AccountAuthenticator.KEY_OC_VERSION, mDiscoveredVersion.toString());\r
+ accManager.setUserData(account, AccountAuthenticator.KEY_OC_BASE_URL, mHostBaseUrl);\r
+ if (isOAuth)\r
+ accManager.setUserData(account, AccountAuthenticator.KEY_SUPPORTS_OAUTH2, "TRUE"); // TODO this flag should be unnecessary\r
+\r
+ setAccountAuthenticatorResult(intent.getExtras());\r
+ setResult(RESULT_OK, intent);\r
+ \r
+ /// immediately request for the synchronization of the new account\r
+ Bundle bundle = new Bundle();\r
+ bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);\r
+ ContentResolver.requestSync(account, AccountAuthenticator.AUTHORITY, bundle);\r
+\r
+ finish();\r
+ \r
+ } else {\r
+ if (!isOAuth) {\r
+ mUsernameInput.setError(result.getLogMessage() + " "); \r
+ // the extra spaces are a workaround for an ugly bug: \r
+ // 1. insert wrong credentials and connect\r
+ // 2. put the focus on the user name field with using hardware controls (don't touch the screen); the error is shown UNDER the field\r
+ // 3. touch the user name field; the software keyboard appears; the error popup is moved OVER the field and SHRINKED in width, losing the last word\r
+ // Seen, at least, in Android 2.x devices \r
+ \r
+ } else {\r
+ mOAuthAuthEndpointText.setError(result.getLogMessage() + " ");\r
+ }\r
+ Log.d(TAG, "Access failed: " + result.getLogMessage());\r
+ }\r
+ }\r
+\r
+ \r
+ \r
+ /**\r
+ * {@inheritDoc}\r
+ * \r
+ * Necessary to update the contents of the SSL Dialog\r
+ * \r
+ * TODO move to some common place for all possible untrusted SSL failures\r
+ */\r
+ @Override\r
+ protected void onPrepareDialog(int id, Dialog dialog, Bundle args) {\r
+ switch (id) {\r
+ case DIALOG_LOGIN_PROGRESS:\r
+ case DIALOG_CERT_NOT_SAVED:\r
+ case DIALOG_OAUTH2_LOGIN_PROGRESS:\r
+ break;\r
+ case DIALOG_SSL_VALIDATOR: {\r
+ ((SslValidatorDialog)dialog).updateResult(mLastSslUntrustedServerResult);\r
+ break;\r
+ }\r
+ default:\r
+ Log.e(TAG, "Incorrect dialog called with id = " + id);\r