Improved status messages for authentication through SAML-based federated SSO
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / AuthenticatorActivity.java
index d1f79cf..f648b6e 100644 (file)
@@ -34,6 +34,7 @@ import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
 import android.accounts.Account;\r
 import android.accounts.AccountAuthenticatorActivity;\r
 import android.accounts.AccountManager;\r
+import android.annotation.SuppressLint;\r
 import android.app.AlertDialog;\r
 import android.app.Dialog;\r
 import android.app.ProgressDialog;\r
@@ -57,6 +58,8 @@ import android.view.View.OnFocusChangeListener;
 import android.view.View.OnTouchListener;\r
 import android.view.Window;\r
 import android.view.inputmethod.EditorInfo;\r
+import android.webkit.CookieManager;\r
+import android.webkit.WebSettings;\r
 import android.webkit.WebView;\r
 import android.widget.CheckBox;\r
 import android.widget.EditText;\r
@@ -96,7 +99,6 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     private static final String KEY_SERVER_STATUS_ICON = "SERVER_STATUS_ICON";\r
     private static final String KEY_IS_SSL_CONN = "IS_SSL_CONN";\r
     private static final String KEY_PASSWORD_VISIBLE = "PASSWORD_VISIBLE";\r
-    private static final String KEY_AUTH_METHOD = "AUTH_METHOD";\r
     private static final String KEY_AUTH_STATUS_TEXT = "AUTH_STATUS_TEXT";\r
     private static final String KEY_AUTH_STATUS_ICON = "AUTH_STATUS_ICON";\r
     private static final String KEY_REFRESH_BUTTON_ENABLED = "KEY_REFRESH_BUTTON_ENABLED";\r
@@ -105,10 +107,6 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     private static final String AUTH_OFF = "off";\r
     private static final String AUTH_OPTIONAL = "optional";\r
     \r
-    private static final int AUTH_METHOD_BASIC_HTTP = 0;\r
-    private static final int AUTH_METHOD_OAUTH2 = 1;\r
-    private static final int AUTH_METHOD_SAML_WEB_SSO = 2;\r
-\r
     private static final int DIALOG_LOGIN_PROGRESS = 0;\r
     private static final int DIALOG_SSL_VALIDATOR = 1;\r
     private static final int DIALOG_CERT_NOT_SAVED = 2;\r
@@ -142,7 +140,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     private boolean mHostUrlInputEnabled;\r
     private View mRefreshButton;\r
 \r
-    private int mCurrentAuthorizationMethod;  \r
+    private String mCurrentAuthTokenType;\r
     \r
     private EditText mUsernameInput;\r
     private EditText mPasswordInput;\r
@@ -154,7 +152,8 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     private TextView mOAuthTokenEndpointText;\r
     \r
     private TextView mAccountNameInput;\r
-    private WebView mWebSsoView;\r
+    private WebView mSsoWebView;\r
+    private SsoWebViewClient mWebViewClient;\r
     \r
     private View mOkButton;\r
 \r
@@ -179,7 +178,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         mOAuthTokenEndpointText = (TextView)findViewById(R.id.oAuthEntryPoint_2);\r
         mOAuth2Check = (CheckBox) findViewById(R.id.oauth_onOff_check);\r
         mAccountNameInput = (EditText) findViewById(R.id.account_name);\r
-        mWebSsoView = (WebView) findViewById(R.id.web_sso_view);\r
+        mSsoWebView = (WebView) findViewById(R.id.web_sso_view);\r
         mOkButton = findViewById(R.id.buttonOK);\r
         mAuthStatusLayout = (TextView) findViewById(R.id.auth_status_text); \r
         \r
@@ -230,13 +229,13 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
                 mHostUrlInput.setText(mHostBaseUrl);\r
             }\r
             initAuthorizationMethod();  // checks intent and setup.xml to determine mCurrentAuthorizationMethod\r
-            mOAuth2Check.setChecked(mCurrentAuthorizationMethod == AUTH_METHOD_OAUTH2);\r
+            mOAuth2Check.setChecked(mCurrentAuthTokenType == AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN);\r
             mJustCreated = true;\r
             \r
             if (mAction == ACTION_UPDATE_TOKEN || !mHostUrlInputEnabled) {\r
                 checkOcServer(); \r
             }\r
-\r
+            \r
         } else {\r
             /// connection state and info\r
             mServerIsValid = savedInstanceState.getBoolean(KEY_SERVER_VALID);\r
@@ -259,7 +258,10 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 \r
             // account data, if updating\r
             mAccount = savedInstanceState.getParcelable(KEY_ACCOUNT);\r
-            mCurrentAuthorizationMethod = savedInstanceState.getInt(KEY_AUTH_METHOD, AUTH_METHOD_BASIC_HTTP);\r
+            mCurrentAuthTokenType = savedInstanceState.getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE);\r
+            if (mCurrentAuthTokenType == null) {\r
+                mCurrentAuthTokenType =  AccountAuthenticator.AUTH_TOKEN_TYPE_PASSWORD;\r
+            }\r
 \r
             // check if server check was interrupted by a configuration change\r
             if (savedInstanceState.getBoolean(KEY_SERVER_CHECK_IN_PROGRESS, false)) {\r
@@ -289,13 +291,14 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         if (mServerIsChecked && !mServerIsValid && refreshButtonEnabled) showRefreshButton();\r
         mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes\r
 \r
-        if (mCurrentAuthorizationMethod == AUTH_METHOD_SAML_WEB_SSO || !AUTH_OPTIONAL.equals(getString(R.string.auth_method_oauth2))) {\r
+        if (mCurrentAuthTokenType == AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE || \r
+                !AUTH_OPTIONAL.equals(getString(R.string.auth_method_oauth2))) {\r
             mOAuth2Check.setVisibility(View.GONE);\r
         }\r
 \r
         mPasswordInput.setText("");     // clean password to avoid social hacking (disadvantage: password in removed if the device is turned aside)\r
 \r
-        /// bind view elements to listeners\r
+        /// bind view elements to listeners and other friends\r
         mHostUrlInput.setOnFocusChangeListener(this);\r
         mHostUrlInput.addTextChangedListener(new TextWatcher() {\r
 \r
@@ -324,40 +327,55 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
                 }\r
                 return true;\r
             }\r
-        });
+        });\r
+        \r
+    }\r
+    \r
+    @SuppressLint("SetJavaScriptEnabled")\r
+       private void initWebView() {\r
+        CookieManager cookieManager = CookieManager.getInstance();\r
+        cookieManager.setAcceptCookie(true);\r
+        //cookieManager.removeSessionCookie();        \r
+\r
+        mWebViewClient = new SsoWebViewClient(this);\r
+        mSsoWebView.setWebViewClient(mWebViewClient);\r
+        WebSettings webSettings = mSsoWebView.getSettings();\r
+        webSettings.setJavaScriptEnabled(true);\r
+        webSettings.setBuiltInZoomControls(true);\r
+        webSettings.setLoadWithOverviewMode(false);\r
+        webSettings.setSavePassword(false);\r
+        webSettings.setUserAgentString(WebdavClient.USER_AGENT);\r
     }\r
 \r
     private void initAuthorizationMethod() {\r
         boolean oAuthRequired = false;\r
         boolean samlWebSsoRequired = false;\r
 \r
-        String tokenType = getIntent().getExtras().getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE);\r
+        mCurrentAuthTokenType = getIntent().getExtras().getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE);\r
         mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT);\r
         \r
-        if (tokenType != null) {\r
-            /// use the authentication method requested by caller \r
-            oAuthRequired = AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(tokenType);\r
-            samlWebSsoRequired = AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(tokenType);\r
-            \r
-        } else if (mAccount != null) {\r
-            /// same authentication method than the one used to create the account to update\r
-            oAuthRequired = (mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_OAUTH2) != null);\r
-            samlWebSsoRequired = (mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_SAML_WEB_SSO) != null);\r
-            \r
-        } else {\r
-            /// use the one set in setup.xml\r
-            oAuthRequired = AUTH_ON.equals(getString(R.string.auth_method_oauth2));\r
-            samlWebSsoRequired = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));            \r
-        }\r
+        // TODO could be a good moment to validate the received token type, if not null\r
         \r
-        if (oAuthRequired) {\r
-            mCurrentAuthorizationMethod = AUTH_METHOD_OAUTH2; \r
-        } else if (samlWebSsoRequired) {\r
-            mCurrentAuthorizationMethod = AUTH_METHOD_SAML_WEB_SSO;\r
-        } else {\r
-            mCurrentAuthorizationMethod = AUTH_METHOD_BASIC_HTTP;\r
+        if (mCurrentAuthTokenType == null) {    \r
+            if (mAccount != null) {\r
+                /// same authentication method than the one used to create the account to update\r
+                oAuthRequired = (mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_OAUTH2) != null);\r
+                samlWebSsoRequired = (mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_SAML_WEB_SSO) != null);\r
+            \r
+            } else {\r
+                /// use the one set in setup.xml\r
+                oAuthRequired = AUTH_ON.equals(getString(R.string.auth_method_oauth2));\r
+                samlWebSsoRequired = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));            \r
+            }\r
+            if (oAuthRequired) {\r
+                mCurrentAuthTokenType = AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN;\r
+            } else if (samlWebSsoRequired) {\r
+                mCurrentAuthTokenType = AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE;\r
+            } else {\r
+                mCurrentAuthTokenType = AccountAuthenticator.AUTH_TOKEN_TYPE_PASSWORD;\r
+            }\r
         }\r
-\r
+    \r
         if (mAccount != null) {\r
             String userName = mAccount.name.substring(0, mAccount.name.lastIndexOf('@'));\r
             mUsernameInput.setText(userName);\r
@@ -397,7 +415,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         if (mAccount != null) {\r
             outState.putParcelable(KEY_ACCOUNT, mAccount);\r
         }\r
-        outState.putInt(KEY_AUTH_METHOD, mCurrentAuthorizationMethod);\r
+        outState.putString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE, mCurrentAuthTokenType);\r
         \r
         // refresh button enabled\r
         outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, (mRefreshButton.getVisibility() == View.VISIBLE));\r
@@ -462,7 +480,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
                 getString(R.string.oauth2_grant_type),\r
                 queryParameters);\r
         //WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(getString(R.string.oauth2_url_endpoint_access)), getApplicationContext());\r
-        WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mOAuthTokenEndpointText.getText().toString().trim()), getApplicationContext());\r
+        WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mOAuthTokenEndpointText.getText().toString().trim()), getApplicationContext(), true);\r
         operation.execute(client, this, mHandler);\r
     }\r
 \r
@@ -526,7 +544,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             mServerStatusIcon = R.drawable.progress_small;\r
             showServerStatus();\r
             mOcServerChkOperation = new  OwnCloudServerCheckOperation(uri, this);\r
-            WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(uri), this);\r
+            WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(uri), this, true);\r
             mOperationThread = mOcServerChkOperation.execute(client, this, mHandler);\r
         } else {\r
             mServerStatusText = 0;\r
@@ -626,9 +644,10 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             return;\r
         }\r
 \r
-        if (mOAuth2Check.isChecked()) {\r
+        if (AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mCurrentAuthTokenType)) {\r
             startOauthorization();\r
-\r
+        } else if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mCurrentAuthTokenType)) { \r
+            startSamlBasedFederatedSingleSignOnAuthorization();\r
         } else {\r
             checkBasicAuthorization();\r
         }\r
@@ -641,7 +660,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
      */\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
+        String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mCurrentAuthTokenType);\r
 \r
         /// get basic credentials entered by user\r
         String username = mUsernameInput.getText().toString();\r
@@ -652,7 +671,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 \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
+        WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true);\r
         client.setBasicCredentials(username, password);\r
         mOperationThread = mAuthCheckOperation.execute(client, this, mHandler);\r
     }\r
@@ -667,6 +686,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         mAuthStatusIcon = R.drawable.progress_small;\r
         mAuthStatusText = R.string.oauth_login_connection;\r
         showAuthStatus();\r
+        \r
 \r
         // GET AUTHORIZATION request\r
         //Uri uri = Uri.parse(getString(R.string.oauth2_url_endpoint_auth));\r
@@ -685,6 +705,26 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 \r
 \r
     /**\r
+     * Starts the Web Single Sign On flow to get access to the root folder\r
+     * in the server.\r
+     */\r
+    private void startSamlBasedFederatedSingleSignOnAuthorization() {\r
+        // be gentle with the user\r
+        mAuthStatusIcon = R.drawable.progress_small;\r
+        mAuthStatusText = R.string.auth_connecting_auth_server;\r
+        showAuthStatus();\r
+        showDialog(DIALOG_LOGIN_PROGRESS);\r
+        \r
+        /// get the path to the root folder through WebDAV from the version server\r
+        String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mCurrentAuthTokenType);\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, false);\r
+        mOperationThread = mAuthCheckOperation.execute(client, this, mHandler);\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
@@ -699,9 +739,37 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             onGetOAuthAccessTokenFinish((OAuth2GetAccessToken)operation, result);\r
 \r
         } else if (operation instanceof ExistenceCheckOperation)  {\r
-            onAuthorizationCheckFinish((ExistenceCheckOperation)operation, result);\r
+            if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mCurrentAuthTokenType)) {\r
+                onSamlBasedFederatedSingleSignOnAuthorizationStart(operation, result);\r
+                \r
+            } else {\r
+                onAuthorizationCheckFinish((ExistenceCheckOperation)operation, result);\r
+            }\r
+        }\r
+    }\r
+    \r
+    \r
+    private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperation 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
+        if (result.isTemporalRedirection()) {\r
+            String url = result.getRedirectedLocation();\r
+            mWebViewClient.setTargetUrl(mHostBaseUrl + AccountUtils.getWebdavPath(mDiscoveredVersion, mCurrentAuthTokenType));\r
+            mSsoWebView.loadUrl(url);\r
+            \r
+            mAuthStatusIcon = android.R.drawable.ic_secure;\r
+            mAuthStatusText = R.string.auth_follow_auth_server;\r
+            \r
+        } else {\r
+            mAuthStatusIcon = R.drawable.common_error;\r
+            mAuthStatusText = R.string.auth_unsupported_auth_method;\r
+            \r
         }\r
+        showAuthStatus();\r
     }\r
 \r
 \r
@@ -952,7 +1020,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             // 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, true);\r
+        String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mCurrentAuthTokenType);\r
         if (result.isSuccess() && webdav_path != null) {\r
             /// be gentle with the user\r
             showDialog(DIALOG_LOGIN_PROGRESS);\r
@@ -961,7 +1029,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             mOAuthAccessToken = ((OAuth2GetAccessToken)operation).getResultTokenMap().get(OAuth2Constants.KEY_ACCESS_TOKEN);\r
             Log_OC.d(TAG, "Got ACCESS TOKEN: " + mOAuthAccessToken);\r
             mAuthCheckOperation = new ExistenceCheckOperation("", this, false);\r
-            WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this);\r
+            WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true);\r
             client.setBearerCredentials(mOAuthAccessToken);\r
             mAuthCheckOperation.execute(client, this, mHandler);\r
 \r
@@ -1305,9 +1373,9 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     public void onCheckClick(View view) {\r
         CheckBox oAuth2Check = (CheckBox)view;\r
         if (oAuth2Check.isChecked()) {\r
-            mCurrentAuthorizationMethod = AUTH_METHOD_OAUTH2;\r
+            mCurrentAuthTokenType = AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN;\r
         } else {\r
-            mCurrentAuthorizationMethod = AUTH_METHOD_BASIC_HTTP;\r
+            mCurrentAuthTokenType = AccountAuthenticator.AUTH_TOKEN_TYPE_PASSWORD;\r
         }\r
         adaptViewAccordingToAuthenticationMethod();\r
     }\r
@@ -1318,37 +1386,34 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
      * the current authorization method.\r
      */\r
     private void adaptViewAccordingToAuthenticationMethod () {\r
-        switch (mCurrentAuthorizationMethod) { \r
-            case AUTH_METHOD_OAUTH2:\r
-                // OAuth 2 authorization\r
-                mOAuthAuthEndpointText.setVisibility(View.VISIBLE);\r
-                mOAuthTokenEndpointText.setVisibility(View.VISIBLE);\r
-                mUsernameInput.setVisibility(View.GONE);\r
-                mPasswordInput.setVisibility(View.GONE);\r
-                mAccountNameInput.setVisibility(View.GONE);\r
-                mWebSsoView.setVisibility(View.GONE);\r
-                break;\r
-                \r
-            case AUTH_METHOD_SAML_WEB_SSO:\r
-                // SAML-based web Single Sign On\r
-                mOAuthAuthEndpointText.setVisibility(View.GONE);\r
-                mOAuthTokenEndpointText.setVisibility(View.GONE);\r
-                mUsernameInput.setVisibility(View.GONE);\r
-                mPasswordInput.setVisibility(View.GONE);\r
-                mAccountNameInput.setVisibility(View.VISIBLE);\r
-                mWebSsoView.setVisibility(View.VISIBLE);\r
-                break;\r
-                \r
-            case AUTH_METHOD_BASIC_HTTP:\r
-            default:\r
-                // basic HTTP authorization\r
-                mOAuthAuthEndpointText.setVisibility(View.GONE);\r
-                mOAuthTokenEndpointText.setVisibility(View.GONE);\r
-                mUsernameInput.setVisibility(View.VISIBLE);\r
-                mPasswordInput.setVisibility(View.VISIBLE);\r
-                mAccountNameInput.setVisibility(View.GONE);\r
-                mWebSsoView.setVisibility(View.GONE);\r
-            }\r
+        if (AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mCurrentAuthTokenType)) {\r
+            // OAuth 2 authorization\r
+            mOAuthAuthEndpointText.setVisibility(View.VISIBLE);\r
+            mOAuthTokenEndpointText.setVisibility(View.VISIBLE);\r
+            mUsernameInput.setVisibility(View.GONE);\r
+            mPasswordInput.setVisibility(View.GONE);\r
+            mAccountNameInput.setVisibility(View.GONE);\r
+            mSsoWebView.setVisibility(View.GONE);\r
+            \r
+        } else if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mCurrentAuthTokenType)) {\r
+            // SAML-based web Single Sign On\r
+            mOAuthAuthEndpointText.setVisibility(View.GONE);\r
+            mOAuthTokenEndpointText.setVisibility(View.GONE);\r
+            mUsernameInput.setVisibility(View.GONE);\r
+            mPasswordInput.setVisibility(View.GONE);\r
+            mAccountNameInput.setVisibility(View.VISIBLE);\r
+            mSsoWebView.setVisibility(View.VISIBLE);\r
+            initWebView();\r
+            \r
+        } else {\r
+            // basic HTTP authorization\r
+            mOAuthAuthEndpointText.setVisibility(View.GONE);\r
+            mOAuthTokenEndpointText.setVisibility(View.GONE);\r
+            mUsernameInput.setVisibility(View.VISIBLE);\r
+            mPasswordInput.setVisibility(View.VISIBLE);\r
+            mAccountNameInput.setVisibility(View.GONE);\r
+            mSsoWebView.setVisibility(View.GONE);\r
+        }\r
     }\r
     \r
     /**\r