X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/0addc90ae5082de926dc9c5bbb8092d6efe123a8..5611205f1d5bc06bc89a73ac27f70098a09bd9ae:/src/com/owncloud/android/authentication/AuthenticatorActivity.java diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index 84362ba9..ac71a59a 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -23,12 +23,9 @@ import java.util.Map; import android.accounts.Account; import android.accounts.AccountManager; -import android.app.AlertDialog; import android.app.Dialog; -import android.app.ProgressDialog; import android.content.ComponentName; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; @@ -67,8 +64,6 @@ import com.owncloud.android.R; import com.owncloud.android.authentication.SsoWebViewClient.SsoWebViewClientListener; import com.owncloud.android.lib.common.accounts.AccountTypeUtils; import com.owncloud.android.lib.common.accounts.AccountUtils.Constants; -import com.owncloud.android.lib.common.OwnCloudClientFactory; -import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.operations.DetectAuthenticationMethodOperation.AuthenticationMethod; import com.owncloud.android.operations.GetServerInfoOperation; import com.owncloud.android.operations.OAuth2GetAccessToken; @@ -83,6 +78,7 @@ import com.owncloud.android.lib.resources.users.GetRemoteUserNameOperation; import com.owncloud.android.services.OperationsService; import com.owncloud.android.services.OperationsService.OperationsServiceBinder; +import com.owncloud.android.ui.dialog.IndeterminateProgressDialog; import com.owncloud.android.ui.dialog.SamlWebViewDialog; import com.owncloud.android.ui.dialog.SslUntrustedCertDialog; import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.OnSslUntrustedCertListener; @@ -94,6 +90,7 @@ import com.owncloud.android.lib.resources.status.OwnCloudVersion; * * @author Bartek Przybylski * @author David A. Velasco + * @author masensio */ public class AuthenticatorActivity extends AccountAuthenticatorActivity implements OnRemoteOperationListener, OnFocusChangeListener, OnEditorActionListener, @@ -111,7 +108,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private static final String KEY_AUTH_MESSAGE_TEXT = "AUTH_MESSAGE_TEXT"; private static final String KEY_HOST_URL_TEXT = "HOST_URL_TEXT"; private static final String KEY_OC_VERSION = "OC_VERSION"; - private static final String KEY_OC_VERSION_STRING = "OC_VERSION_STRING"; private static final String KEY_ACCOUNT = "ACCOUNT"; private static final String KEY_SERVER_VALID = "SERVER_VALID"; private static final String KEY_SERVER_CHECKED = "SERVER_CHECKED"; @@ -123,23 +119,18 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private static final String KEY_AUTH_STATUS_TEXT = "AUTH_STATUS_TEXT"; private static final String KEY_AUTH_STATUS_ICON = "AUTH_STATUS_ICON"; private static final String KEY_REFRESH_BUTTON_ENABLED = "KEY_REFRESH_BUTTON_ENABLED"; - //private static final String KEY_IS_SHARED_SUPPORTED = "KEY_IS_SHARE_SUPPORTED"; private static final String KEY_SERVER_AUTH_METHOD = "KEY_SERVER_AUTH_METHOD"; private static final String KEY_DETECT_AUTH_OP_ID = "KEY_DETECT_AUTH_OP_ID"; - private static final String AUTH_ON = "on"; - private static final String AUTH_OFF = "off"; + //private static final String AUTH_OFF = "off"; private static final String AUTH_OPTIONAL = "optional"; - private static final int DIALOG_LOGIN_PROGRESS = 0; - private static final int DIALOG_CERT_NOT_SAVED = 1; - private static final int DIALOG_OAUTH2_LOGIN_PROGRESS = 2; - public static final byte ACTION_CREATE = 0; public static final byte ACTION_UPDATE_TOKEN = 1; - private static final String TAG_SAML_DIALOG = "samlWebViewDialog"; + private static final String SAML_DIALOG_TAG = "SAML_DIALOG"; + private static final String WAIT_DIALOG_TAG = "WAIT_DIALOG"; private String mHostBaseUrl; // TODO remove private OwnCloudVersion mDiscoveredVersion; // TODO remove @@ -156,11 +147,11 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private TextView mAuthStatusLayout; private final Handler mHandler = new Handler(); - private Thread mOperationThread; - //private GetRemoteStatusOperation mOcServerChkOperation; private GetServerInfoOperation mServerInfoOperation; - private ExistenceCheckRemoteOperation mAuthCheckOperation; + private int mExistenceCheckOpId = -1; + private int mGetUserNameOpId = -1; + private Uri mNewCapturedUriFromOAuth2Redirection; private AccountManager mAccountMgr; @@ -281,10 +272,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { /// retrieve extras from intent mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT); if (mAccount != null) { - String ocVersion = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION); - String ocVersionString = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION_STRING); + String ocVersion = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION); if (ocVersion != null) { - mDiscoveredVersion = new OwnCloudVersion(ocVersion, ocVersionString); + mDiscoveredVersion = new OwnCloudVersion(ocVersion); } mHostBaseUrl = normalizeUrl(mAccountMgr.getUserData(mAccount, Constants.KEY_OC_BASE_URL)); mHostUrlInput.setText(mHostBaseUrl); @@ -317,9 +307,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { /// server data String ocVersion = savedInstanceState.getString(KEY_OC_VERSION); - String ocVersionString = savedInstanceState.getString(KEY_OC_VERSION_STRING); if (ocVersion != null) { - mDiscoveredVersion = new OwnCloudVersion(ocVersion, ocVersionString); + mDiscoveredVersion = new OwnCloudVersion(ocVersion); } mHostBaseUrl = savedInstanceState.getString(KEY_HOST_URL_TEXT); @@ -500,7 +489,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { /// server data if (mDiscoveredVersion != null) { outState.putString(KEY_OC_VERSION, mDiscoveredVersion.getVersion()); - outState.putString(KEY_OC_VERSION_STRING, mDiscoveredVersion.getVersionString()); } outState.putString(KEY_HOST_URL_TEXT, mHostBaseUrl); @@ -603,7 +591,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mNewCapturedUriFromOAuth2Redirection = null; /// Showing the dialog with instructions for the user. - showDialog(DIALOG_OAUTH2_LOGIN_PROGRESS); + IndeterminateProgressDialog dialog = + IndeterminateProgressDialog.newInstance(R.string.auth_getting_authorization, true); + dialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG); /// GET ACCESS TOKEN to the oAuth server Intent getServerInfoIntent = new Intent(); @@ -621,17 +611,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { //Log.wtf(TAG, "getting access token..." ); mOauth2GetAccessTokenOpId = mOperationsServiceBinder.newOperation(getServerInfoIntent); } - - /* - RemoteOperation operation = new OAuth2GetAccessToken( getString(R.string.oauth2_client_id), - getString(R.string.oauth2_redirect_uri), - getString(R.string.oauth2_grant_type), - queryParameters); - //OwnCloudClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(getString(R.string.oauth2_url_endpoint_access)), getApplicationContext()); - OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mOAuthTokenEndpointText.getText().toString().trim()), getApplicationContext(), true); - operation.execute(client, this, mHandler); - */ - } @@ -759,23 +738,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { showViewPasswordButton(); } - - /** - * Cancels the authenticator activity - * - * IMPORTANT ENTRY POINT 3: Never underestimate the importance of cancellation - * - * This method is bound in the layout/acceoun_setup.xml resource file. - * - * @param view Cancel button - */ - public void onCancelClick(View view) { - setResult(RESULT_CANCELED); // TODO review how is this related to AccountAuthenticator (debugging) - finish(); - } - - - /** * Checks the credentials of the user in the root of the ownCloud server * before creating a new local account. @@ -824,15 +786,37 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { String password = mPasswordInput.getText().toString(); /// be gentle with the user - showDialog(DIALOG_LOGIN_PROGRESS); + IndeterminateProgressDialog dialog = + IndeterminateProgressDialog.newInstance(R.string.auth_trying_to_login, true); + dialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG); /// test credentials accessing the root folder - mAuthCheckOperation = new ExistenceCheckRemoteOperation("", this, false); - OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true); - client.setBasicCredentials(username, password); - mOperationThread = mAuthCheckOperation.execute(client, this, mHandler); + String remotePath =""; + boolean successIfAbsent = false; + boolean followRedirects = true; + startExistenceCheckRemoteOperation(remotePath, this, successIfAbsent, webdav_path, username, password, followRedirects); + } + private void startExistenceCheckRemoteOperation(String remotePath, Context context, boolean successIfAbsent, String webdav_path, + String username, String password, boolean followRedirects) { + + Intent existenceCheckIntent = new Intent(); + existenceCheckIntent.setAction(OperationsService.ACTION_EXISTENCE_CHECK); + existenceCheckIntent.putExtra(OperationsService.EXTRA_SERVER_URL, mHostBaseUrl); + existenceCheckIntent.putExtra(OperationsService.EXTRA_REMOTE_PATH, remotePath); + existenceCheckIntent.putExtra(OperationsService.EXTRA_SUCCESS_IF_ABSENT, successIfAbsent); + existenceCheckIntent.putExtra(OperationsService.EXTRA_WEBDAV_PATH, webdav_path); + existenceCheckIntent.putExtra(OperationsService.EXTRA_USERNAME, username); + existenceCheckIntent.putExtra(OperationsService.EXTRA_PASSWORD, password); + existenceCheckIntent.putExtra(OperationsService.EXTRA_AUTH_TOKEN, mAuthToken); + existenceCheckIntent.putExtra(OperationsService.EXTRA_FOLLOW_REDIRECTS, followRedirects); + + if (mOperationsServiceBinder != null) { + Log_OC.wtf(TAG, "starting existenceCheckRemoteOperation..." ); + mExistenceCheckOpId = mOperationsServiceBinder.newOperation(existenceCheckIntent); + } + } /** * Starts the OAuth 'grant type' flow to get an access token, with @@ -869,15 +853,18 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mAuthStatusIcon = R.drawable.progress_small; mAuthStatusText = R.string.auth_connecting_auth_server; showAuthStatus(); - showDialog(DIALOG_LOGIN_PROGRESS); + IndeterminateProgressDialog dialog = + IndeterminateProgressDialog.newInstance(R.string.auth_trying_to_login, true); + dialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG); /// get the path to the root folder through WebDAV from the version server String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType); /// test credentials accessing the root folder - mAuthCheckOperation = new ExistenceCheckRemoteOperation("", this, false); - OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, false); - mOperationThread = mAuthCheckOperation.execute(client, this, mHandler); + String remotePath =""; + boolean successIfAbsent = false; + boolean followRedirections = false; + startExistenceCheckRemoteOperation(remotePath, this, successIfAbsent, webdav_path, "", "", followRedirections); } @@ -899,24 +886,24 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { onGetOAuthAccessTokenFinish(result); } else if (operation instanceof ExistenceCheckRemoteOperation) { + Log_OC.wtf(TAG, "received detection response through callback" ); if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) { - onSamlBasedFederatedSingleSignOnAuthorizationStart(operation, result); + onSamlBasedFederatedSingleSignOnAuthorizationStart(result); } else { - onAuthorizationCheckFinish((ExistenceCheckRemoteOperation)operation, result); + onAuthorizationCheckFinish(result); } } else if (operation instanceof GetRemoteUserNameOperation) { - onGetUserNameFinish((GetRemoteUserNameOperation) operation, result); - + onGetUserNameFinish(result); } } - private void onGetUserNameFinish(GetRemoteUserNameOperation operation, RemoteOperationResult result) { - + private void onGetUserNameFinish(RemoteOperationResult result) { + mGetUserNameOpId = -1; if (result.isSuccess()) { boolean success = false; - String username = operation.getUserName(); + String username = (String) result.getData().get(0); if ( mAction == ACTION_CREATE) { mUsernameInput.setText(username); @@ -945,12 +932,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { } - private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperation operation, RemoteOperationResult result) { - try { - dismissDialog(DIALOG_LOGIN_PROGRESS); - } catch (IllegalArgumentException e) { - // NOTHING TO DO ; can't find out what situation that leads to the exception in this code, but user logs signal that it happens - } + private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperationResult result) { + mExistenceCheckOpId = -1; + dismissDialog(WAIT_DIALOG_TAG); //if (result.isTemporalRedirection() && result.isIdPRedirection()) { if (result.isIdPRedirection()) { @@ -959,7 +943,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { // Show dialog mSamlDialog = SamlWebViewDialog.newInstance(url, targetUrl); - mSamlDialog.show(getSupportFragmentManager(), TAG_SAML_DIALOG); + mSamlDialog.show(getSupportFragmentManager(), SAML_DIALOG_TAG); mAuthStatusIcon = 0; mAuthStatusText = 0; @@ -1053,8 +1037,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { url = "http://" + url; } } - - // OC-208: Add suffix remote.php/webdav to normalize (OC-34) + url = trimUrlWebdav(url); if (url.endsWith("/")) { @@ -1257,16 +1240,14 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { */ private void onGetOAuthAccessTokenFinish(RemoteOperationResult result) { mOauth2GetAccessTokenOpId = -1; - try { - dismissDialog(DIALOG_OAUTH2_LOGIN_PROGRESS); - } catch (IllegalArgumentException e) { - // NOTHING TO DO ; can't find out what situation that leads to the exception in this code, but user logs signal that it happens - } + dismissDialog(WAIT_DIALOG_TAG); String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType); if (result.isSuccess() && webdav_path != null) { /// be gentle with the user - showDialog(DIALOG_LOGIN_PROGRESS); + IndeterminateProgressDialog dialog = + IndeterminateProgressDialog.newInstance(R.string.auth_trying_to_login, true); + dialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG); /// time to test the retrieved access token on the ownCloud server @SuppressWarnings("unchecked") @@ -1274,10 +1255,11 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mAuthToken = tokens.get(OAuth2Constants.KEY_ACCESS_TOKEN); //mAuthToken = ((OAuth2GetAccessToken)operation).getResultTokenMap().get(OAuth2Constants.KEY_ACCESS_TOKEN); Log_OC.d(TAG, "Got ACCESS TOKEN: " + mAuthToken); - mAuthCheckOperation = new ExistenceCheckRemoteOperation("", this, false); - OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true); - client.setBearerCredentials(mAuthToken); - mAuthCheckOperation.execute(client, this, mHandler); + + String remotePath =""; + boolean successIfAbsent = false; + boolean followRedirects = true; + startExistenceCheckRemoteOperation(remotePath, this, successIfAbsent, webdav_path, "", "", followRedirects); } else { updateAuthStatusIconAndText(result); @@ -1295,12 +1277,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { * @param operation Access check performed. * @param result Result of the operation. */ - private void onAuthorizationCheckFinish(ExistenceCheckRemoteOperation operation, RemoteOperationResult result) { - try { - dismissDialog(DIALOG_LOGIN_PROGRESS); - } catch (IllegalArgumentException e) { - // NOTHING TO DO ; can't find out what situation that leads to the exception in this code, but user logs signal that it happens - } + private void onAuthorizationCheckFinish(RemoteOperationResult result) { + mExistenceCheckOpId = -1; + dismissDialog(WAIT_DIALOG_TAG); if (result.isSuccess()) { Log_OC.d(TAG, "Successful access - time to save the account"); @@ -1442,7 +1421,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { } /// add user data to the new account; TODO probably can be done in the last parameter addAccountExplicitly, or in KEY_USERDATA mAccountMgr.setUserData(mAccount, Constants.KEY_OC_VERSION, mDiscoveredVersion.getVersion()); - mAccountMgr.setUserData(mAccount, Constants.KEY_OC_VERSION_STRING, mDiscoveredVersion.getVersionString()); mAccountMgr.setUserData(mAccount, Constants.KEY_OC_BASE_URL, mHostBaseUrl); if (isSaml) { @@ -1460,90 +1438,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { /** - * {@inheritDoc} - * - * Necessary to update the contents of the SSL Dialog - * - * TODO move to some common place for all possible untrusted SSL failures - */ - @Override - protected void onPrepareDialog(int id, Dialog dialog, Bundle args) { - switch (id) { - case DIALOG_LOGIN_PROGRESS: - case DIALOG_CERT_NOT_SAVED: - case DIALOG_OAUTH2_LOGIN_PROGRESS: - break; - default: - Log_OC.e(TAG, "Incorrect dialog called with id = " + id); - } - } - - - /** - * {@inheritDoc} - */ - @Override - protected Dialog onCreateDialog(int id) { - Dialog dialog = null; - switch (id) { - case DIALOG_LOGIN_PROGRESS: { - /// simple progress dialog - ProgressDialog working_dialog = new ProgressDialog(this); - working_dialog.setMessage(getResources().getString(R.string.auth_trying_to_login)); - working_dialog.setIndeterminate(true); - working_dialog.setCancelable(true); - working_dialog - .setOnCancelListener(new DialogInterface.OnCancelListener() { - @Override - public void onCancel(DialogInterface dialog) { - /// TODO study if this is enough - Log_OC.i(TAG, "Login canceled"); - if (mOperationThread != null) { - mOperationThread.interrupt(); - finish(); - } - } - }); - dialog = working_dialog; - break; - } - case DIALOG_OAUTH2_LOGIN_PROGRESS: { - ProgressDialog working_dialog = new ProgressDialog(this); - working_dialog.setMessage(String.format("Getting authorization")); - working_dialog.setIndeterminate(true); - working_dialog.setCancelable(true); - working_dialog - .setOnCancelListener(new DialogInterface.OnCancelListener() { - @Override - public void onCancel(DialogInterface dialog) { - Log_OC.i(TAG, "Login canceled"); - finish(); - } - }); - dialog = working_dialog; - break; - } - case DIALOG_CERT_NOT_SAVED: { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage(getResources().getString(R.string.ssl_validator_not_saved)); - builder.setCancelable(false); - builder.setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - }; - }); - dialog = builder.create(); - break; - } - default: - Log_OC.e(TAG, "Incorrect dialog called with id = " + id); - } - return dialog; - } - - - /** * Starts and activity to open the 'new account' page in the ownCloud web site * * @param view 'Account register' button @@ -1732,25 +1626,32 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { if (sessionCookie != null && sessionCookie.length() > 0) { mAuthToken = sessionCookie; - - GetRemoteUserNameOperation getUserOperation = new GetRemoteUserNameOperation(); - OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl), getApplicationContext(), true); - client.setSsoSessionCookie(mAuthToken); - getUserOperation.execute(client, this, mHandler); + boolean followRedirects = true; + getRemoteUserNameOperation(sessionCookie, followRedirects); + } + } + + private void getRemoteUserNameOperation(String sessionCookie, boolean followRedirects) { + + Intent getUserNameIntent = new Intent(); + getUserNameIntent.setAction(OperationsService.ACTION_GET_USER_NAME); + getUserNameIntent.putExtra(OperationsService.EXTRA_SERVER_URL, mHostBaseUrl); + getUserNameIntent.putExtra(OperationsService.EXTRA_COOKIE, sessionCookie); + getUserNameIntent.putExtra(OperationsService.EXTRA_FOLLOW_REDIRECTS, followRedirects); + + if (mOperationsServiceBinder != null) { + //Log_OC.wtf(TAG, "starting getRemoteUserNameOperation..." ); + mGetUserNameOpId = mOperationsServiceBinder.newOperation(getUserNameIntent); } - - } @Override public void onSsoFinished(String sessionCookies) { - //Toast.makeText(this, "got cookies: " + sessionCookie, Toast.LENGTH_LONG).show(); - if (sessionCookies != null && sessionCookies.length() > 0) { Log_OC.d(TAG, "Successful SSO - time to save the account"); onSamlDialogSuccess(sessionCookies); - Fragment fd = getSupportFragmentManager().findFragmentByTag(TAG_SAML_DIALOG); + Fragment fd = getSupportFragmentManager().findFragmentByTag(SAML_DIALOG_TAG); if (fd != null && fd instanceof SherlockDialogFragment) { Dialog d = ((SherlockDialogFragment)fd).getDialog(); if (d != null && d.isShowing()) { @@ -1819,22 +1720,10 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { } /** - * Dismiss untrusted cert dialog - */ - public void dismissUntrustedCertDialog(){ - /*Fragment frag = getSupportFragmentManager().findFragmentByTag(DIALOG_UNTRUSTED_CERT); - if (frag != null) { - SslErrorViewAdapter dialog = (SslErrorViewAdapter) frag; - dialog.dismiss(); - } - */ - } - - /** * Called from SslValidatorDialog when a new server certificate was correctly saved. */ public void onSavedCertificate() { - Fragment fd = getSupportFragmentManager().findFragmentByTag(TAG_SAML_DIALOG); + Fragment fd = getSupportFragmentManager().findFragmentByTag(SAML_DIALOG_TAG); if (fd == null) { // if SAML dialog is not shown, the SslDialog was shown due to an SSL error in the server check checkOcServer(); @@ -1847,28 +1736,16 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { */ @Override public void onFailedSavingCertificate() { - showDialog(DIALOG_CERT_NOT_SAVED); - cancelWebView(); + dismissDialog(SAML_DIALOG_TAG); + Toast.makeText(this, R.string.ssl_validator_not_saved, Toast.LENGTH_LONG).show(); } @Override public void onCancelCertificate() { - cancelWebView(); + dismissDialog(SAML_DIALOG_TAG); } - public void cancelWebView() { - Fragment fd = getSupportFragmentManager().findFragmentByTag(TAG_SAML_DIALOG); - if (fd != null && fd instanceof SherlockDialogFragment) { - Dialog d = ((SherlockDialogFragment)fd).getDialog(); - if (d != null && d.isShowing()) { - d.dismiss(); - } - } - - } - - private void doOnResumeAndBound() { //Log.wtf(TAG, "registering to listen for operation callbacks" ); mOperationsServiceBinder.addOperationListener(AuthenticatorActivity.this, mHandler); @@ -1877,7 +1754,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { RemoteOperationResult result = mOperationsServiceBinder.getOperationResultIfFinished(mGetServerInfoOpId); if (result != null) { - //Log.wtf(TAG, "found result of operation finished while rotating"); + //Log_OC.wtf(TAG, "found result of operation finished while rotating"); onGetServerInfoFinish(result); } @@ -1886,12 +1763,45 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mOperationsServiceBinder.getOperationResultIfFinished( mOauth2GetAccessTokenOpId); if (result != null) { - //Log.wtf(TAG, "found result of operation finished while rotating"); + //Log_OC.wtf(TAG, "found result of operation finished while rotating"); onGetOAuthAccessTokenFinish(result); } + + } else if (mExistenceCheckOpId != -1) { + RemoteOperationResult result = + mOperationsServiceBinder.getOperationResultIfFinished(mExistenceCheckOpId); + if (result != null) { + //Log_OC.wtf(TAG, "found result of operation finished while rotating"); + if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie( + MainApp.getAccountType()).equals(mAuthTokenType)) { + onSamlBasedFederatedSingleSignOnAuthorizationStart(result); + + } else { + onAuthorizationCheckFinish(result); + } + } + }if (mGetUserNameOpId != -1) { + RemoteOperationResult result = + mOperationsServiceBinder.getOperationResultIfFinished(mGetUserNameOpId); + if (result != null) { + //Log_OC.wtf(TAG, "found result of operation finished while rotating"); + onGetUserNameFinish(result); + } + + } + + } + + + private void dismissDialog(String dialogTag){ + Fragment frag = getSupportFragmentManager().findFragmentByTag(dialogTag); + if (frag != null && frag instanceof SherlockDialogFragment) { + SherlockDialogFragment dialog = (SherlockDialogFragment) frag; + dialog.dismiss(); } } + /** * Implements callback methods for service binding. */