X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/022c555aca2ff13ebe57558c15a4167d5bf17ac0..b017073e960ad2039a823740b5f1ca1771d23278:/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 dd20d48a..fb55c147 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -19,6 +19,7 @@ package com.owncloud.android.authentication; import java.security.cert.X509Certificate; +import java.util.Map; import android.accounts.Account; import android.accounts.AccountManager; @@ -45,7 +46,6 @@ import android.support.v4.app.FragmentTransaction; import android.text.Editable; import android.text.InputType; import android.text.TextWatcher; -import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; @@ -67,9 +67,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; import com.owncloud.android.operations.DetectAuthenticationMethodOperation.AuthenticationMethod; import com.owncloud.android.operations.GetServerInfoOperation; import com.owncloud.android.operations.OAuth2GetAccessToken; @@ -112,7 +109,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"; @@ -149,17 +145,20 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private int mAuthMessageVisibility, mServerStatusText, mServerStatusIcon; private boolean mServerIsChecked, mServerIsValid, mIsSslConn; private AuthenticationMethod mServerAuthMethod = AuthenticationMethod.UNKNOWN; - private int mDetectAuthOpId = -1; + + private int mGetServerInfoOpId = -1; + private int mOauth2GetAccessTokenOpId = -1; private int mAuthStatusText, mAuthStatusIcon; 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; @@ -280,10 +279,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); @@ -316,9 +314,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); @@ -341,7 +338,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mServerAuthMethod = AuthenticationMethod.valueOf( savedInstanceState.getString(KEY_SERVER_AUTH_METHOD)); - mDetectAuthOpId = savedInstanceState.getInt(KEY_DETECT_AUTH_OP_ID); + mGetServerInfoOpId = savedInstanceState.getInt(KEY_DETECT_AUTH_OP_ID); } @@ -364,7 +361,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mOAuth2Check.setVisibility(View.GONE); } - //showRefreshButton(mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled); showRefreshButton(mServerIsChecked && !mServerIsValid && refreshButtonEnabled); mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes @@ -500,7 +496,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); @@ -514,7 +509,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, (mRefreshButton.getVisibility() == View.VISIBLE)); outState.putString(KEY_SERVER_AUTH_METHOD, mServerAuthMethod.name()); - outState.putInt(KEY_DETECT_AUTH_OP_ID, mDetectAuthOpId); + outState.putInt(KEY_DETECT_AUTH_OP_ID, mGetServerInfoOpId); //Log.wtf(TAG, "onSaveInstanceState end" ); } @@ -605,7 +600,24 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { /// Showing the dialog with instructions for the user. showDialog(DIALOG_OAUTH2_LOGIN_PROGRESS); - /// GET ACCESS TOKEN to the oAuth server + /// GET ACCESS TOKEN to the oAuth server + Intent getServerInfoIntent = new Intent(); + getServerInfoIntent.setAction(OperationsService.ACTION_OAUTH2_GET_ACCESS_TOKEN); + + getServerInfoIntent.putExtra( + OperationsService.EXTRA_SERVER_URL, + mOAuthTokenEndpointText.getText().toString().trim()); + + getServerInfoIntent.putExtra( + OperationsService.EXTRA_OAUTH2_QUERY_PARAMETERS, + queryParameters); + + if (mOperationsServiceBinder != null) { + //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), @@ -613,6 +625,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { //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); + */ + } @@ -674,21 +688,15 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mServerStatusText = R.string.auth_testing_connection; mServerStatusIcon = R.drawable.progress_small; showServerStatus(); - mServerInfoOperation = new GetServerInfoOperation(uri, mAuthTokenType, this); - OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(uri), this, true); - mServerInfoOperation.execute(client, this, mHandler); - /* - * TODO start joint operation in OperationsService - Intent detectAuthIntent = new Intent(); - detectAuthIntent.setAction(OperationsService.ACTION_DETECT_AUTHENTICATION_METHOD); - detectAuthIntent.putExtra(OperationsService.EXTRA_SERVER_URL, mBaseUrl); - detectAuthIntent.putExtra(OperationsService.EXTRA_WEBDAV_PATH, webdav_path); + Intent getServerInfoIntent = new Intent(); + getServerInfoIntent.setAction(OperationsService.ACTION_GET_SERVER_INFO); + getServerInfoIntent.putExtra(OperationsService.EXTRA_SERVER_URL, uri); + getServerInfoIntent.putExtra(OperationsService.EXTRA_AUTH_TOKEN_TYPE, mAuthTokenType); if (mOperationsServiceBinder != null) { - //Log.wtf(TAG, "starting detection..." ); - mDetectAuthOpId = mOperationsServiceBinder.newOperation(detectAuthIntent); + //Log.wtf(TAG, "checking server..." ); + mGetServerInfoOpId = mOperationsServiceBinder.newOperation(getServerInfoIntent); } - */ } else { mServerStatusText = 0; @@ -814,12 +822,32 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { showDialog(DIALOG_LOGIN_PROGRESS); /// 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 @@ -831,7 +859,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mAuthStatusText = R.string.oauth_login_connection; showAuthStatus(); - // GET AUTHORIZATION request //Uri uri = Uri.parse(getString(R.string.oauth2_url_endpoint_auth)); Uri uri = Uri.parse(mOAuthAuthEndpointText.getText().toString().trim()); @@ -863,9 +890,10 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { 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); } @@ -878,68 +906,33 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) { if (operation instanceof GetServerInfoOperation) { - if (operation.equals(mServerInfoOperation)) { + if (operation.hashCode() == mGetServerInfoOpId) { onGetServerInfoFinish(result); } // else nothing ; only the last check operation is considered; - // multiple can be triggered if the user amends a URL before a previous check - // can be triggered + // multiple can be started if the user amends a URL quickly } else if (operation instanceof OAuth2GetAccessToken) { - onGetOAuthAccessTokenFinish((OAuth2GetAccessToken)operation, result); + 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); - - } else if (operation instanceof DetectAuthenticationMethodOperation) { - Log.wtf(TAG, "received detection response through callback" ); - onDetectAuthenticationFinish(result); + onGetUserNameFinish(result); } } - private void onDetectAuthenticationFinish(RemoteOperationResult result) { - // Read authentication method - mDetectAuthOpId = -1; - if (result.getData().size() > 0) { - AuthenticationMethod authMethod = (AuthenticationMethod) result.getData().get(0); - String basic = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType()); - String oAuth = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()); - String saml = AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()); - - if ( ( mAuthTokenType.equals(basic) && !authMethod.equals(AuthenticationMethod.BASIC_HTTP_AUTH) ) || - ( mAuthTokenType.equals(oAuth) && !authMethod.equals(AuthenticationMethod.BEARER_TOKEN) ) || - ( mAuthTokenType.equals(saml) && !authMethod.equals(AuthenticationMethod.SAML_WEB_SSO) ) ) { - - mOkButton.setEnabled(false); - mServerIsValid = false; - //show an alert message ( Server Status ) - updateServerStatusIconNoRegularAuth(); - showServerStatus(); - - } else { - mOkButton.setEnabled(true); - - // Show server status - showServerStatus(); - } - - } - } - - - - 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); @@ -968,7 +961,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { } - private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperation operation, RemoteOperationResult result) { + private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperationResult result) { + mExistenceCheckOpId = -1; try { dismissDialog(DIALOG_LOGIN_PROGRESS); } catch (IllegalArgumentException e) { @@ -1008,7 +1002,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mServerIsChecked = true; mIsSslConn = (result.getCode() == ResultCode.OK_SSL); mServerInfoOperation = null; - mDetectAuthOpId = -1; + mGetServerInfoOpId = -1; // update server status, but don't show it yet updateServerStatusIconAndText(result); @@ -1022,8 +1016,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mServerInfo = (GetServerInfoOperation.ServerInfo) (result.getData().get(0)); mDiscoveredVersion = mServerInfo.mVersion; mHostBaseUrl = mServerInfo.mBaseUrl; + mServerAuthMethod = mServerInfo.mAuthMethod; - if (!authSupported(mServerInfo.mAuthMethod)) { + if (!authSupported(mServerAuthMethod)) { updateServerStatusIconNoRegularAuth(); // overrides updateServerStatusIconAndText() mServerIsValid = false; @@ -1063,32 +1058,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { } - /** - * Try to access with user/pass ""/"", to know if it is a regular server - */ - private void detectAuthorizationMethod() { - - Log_OC.d(TAG, "Trying empty authorization to detect authentication method"); - - String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType); - - /// test credentials - //Intent detectAuthIntent = new Intent(this, OperationsService.class); - Intent detectAuthIntent = new Intent(); - detectAuthIntent.setAction(OperationsService.ACTION_DETECT_AUTHENTICATION_METHOD); - detectAuthIntent.putExtra(OperationsService.EXTRA_SERVER_URL, mHostBaseUrl); - detectAuthIntent.putExtra(OperationsService.EXTRA_WEBDAV_PATH, webdav_path); - - //if (mOperationsBinder != null) { // let's let it crash to detect if is really possible - mServerAuthMethod = AuthenticationMethod.UNKNOWN; - if (mOperationsServiceBinder != null) { - //Log.wtf(TAG, "starting detection..." ); - mDetectAuthOpId = mOperationsServiceBinder.newOperation(detectAuthIntent); - } - //} - } - - // TODO remove, if possible private String normalizeUrl(String url) { if (url != null && url.length() > 0) { @@ -1101,8 +1070,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { url = "http://" + url; } } - - // OC-208: Add suffix remote.php/webdav to normalize (OC-34) + url = trimUrlWebdav(url); if (url.endsWith("/")) { @@ -1301,10 +1269,10 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { * Processes the result of the request for and access token send * to an OAuth authorization server. * - * @param operation Operation performed requesting the access token. * @param result Result of the operation. */ - private void onGetOAuthAccessTokenFinish(OAuth2GetAccessToken operation, RemoteOperationResult result) { + private void onGetOAuthAccessTokenFinish(RemoteOperationResult result) { + mOauth2GetAccessTokenOpId = -1; try { dismissDialog(DIALOG_OAUTH2_LOGIN_PROGRESS); } catch (IllegalArgumentException e) { @@ -1317,12 +1285,16 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { showDialog(DIALOG_LOGIN_PROGRESS); /// time to test the retrieved access token on the ownCloud server - mAuthToken = ((OAuth2GetAccessToken)operation).getResultTokenMap().get(OAuth2Constants.KEY_ACCESS_TOKEN); + @SuppressWarnings("unchecked") + Map tokens = (Map)(result.getData().get(0)); + 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); @@ -1340,7 +1312,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { * @param operation Access check performed. * @param result Result of the operation. */ - private void onAuthorizationCheckFinish(ExistenceCheckRemoteOperation operation, RemoteOperationResult result) { + private void onAuthorizationCheckFinish(RemoteOperationResult result) { + mExistenceCheckOpId = -1; try { dismissDialog(DIALOG_LOGIN_PROGRESS); } catch (IllegalArgumentException e) { @@ -1487,7 +1460,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) { @@ -1778,13 +1750,27 @@ 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); +// 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); } - - } @@ -1918,14 +1904,46 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { //Log.wtf(TAG, "registering to listen for operation callbacks" ); mOperationsServiceBinder.addOperationListener(AuthenticatorActivity.this, mHandler); - if (mDetectAuthOpId != -1) { + if (mGetServerInfoOpId != -1) { RemoteOperationResult result = - mOperationsServiceBinder.getOperationResultIfFinished(mDetectAuthOpId); + mOperationsServiceBinder.getOperationResultIfFinished(mGetServerInfoOpId); if (result != null) { - //Log.wtf(TAG, "found result of operation finished while rotating"); - onDetectAuthenticationFinish(result); + //Log_OC.wtf(TAG, "found result of operation finished while rotating"); + onGetServerInfoFinish(result); } - } + + } else if (mOauth2GetAccessTokenOpId != -1) { + RemoteOperationResult result = + mOperationsServiceBinder.getOperationResultIfFinished( + mOauth2GetAccessTokenOpId); + if (result != null) { + //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); + } + + } + } /**