Merge branch 'saml_based_federated_single_sign_on' into saml_based_federated_single_s...
authorDavid A. Velasco <dvelasco@solidgear.es>
Fri, 23 Aug 2013 12:37:14 +0000 (14:37 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Fri, 23 Aug 2013 12:37:14 +0000 (14:37 +0200)
1  2 
res/layout-land/account_setup.xml
res/layout/account_setup.xml
src/com/owncloud/android/authentication/AuthenticatorActivity.java

Simple merge
Simple merge
@@@ -457,16 -453,10 +469,16 @@@ implements  OnRemoteOperationListener, 
      protected void onResume() {\r
          super.onResume();\r
          if (mAction == ACTION_UPDATE_TOKEN && mJustCreated && getIntent().getBooleanExtra(EXTRA_ENFORCED_UPDATE, false)) {\r
-             if (AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mCurrentAuthTokenType)) {\r
 -            if (mOAuth2Check.isChecked())\r
 -                Toast.makeText(this, R.string.auth_expired_oauth_token_toast, Toast.LENGTH_LONG).show();\r
 -            else\r
 -                Toast.makeText(this, R.string.auth_expired_basic_auth_toast, Toast.LENGTH_LONG).show();\r
++            if (AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mAuthTokenType)) {\r
 +                //Toast.makeText(this, R.string.auth_expired_oauth_token_toast, Toast.LENGTH_LONG).show();\r
 +                showAuthMessage(getString(R.string.auth_expired_oauth_token_toast));\r
-             } else if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mCurrentAuthTokenType)) {\r
++            } else if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType)) {\r
 +                //Toast.makeText(this, R.string.auth_expired_saml_sso_token_toast, Toast.LENGTH_LONG).show();\r
 +                showAuthMessage(getString(R.string.auth_expired_saml_sso_token_toast));\r
 +            } else {\r
 +                //Toast.makeText(this, R.string.auth_expired_basic_auth_toast, Toast.LENGTH_LONG).show();\r
 +                showAuthMessage(getString(R.string.auth_expired_basic_auth_toast));\r
 +            }\r
          }\r
  \r
          if (mNewCapturedUriFromOAuth2Redirection != null) {\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() || result.isIdPRedirection()) {\r
 +        if (result.isTemporalRedirection() && result.isIdPRedirection()) {\r
              String url = result.getRedirectedLocation();\r
-             String targetUrl = mHostBaseUrl + AccountUtils.getWebdavPath(mDiscoveredVersion, mCurrentAuthTokenType);\r
+             String targetUrl = mHostBaseUrl + AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType);\r
              \r
              // Show dialog\r
              mSamlDialog = SamlWebViewDialog.newInstance(url, targetUrl);            \r
          response.putString(AccountManager.KEY_ACCOUNT_NAME, mAccount.name);\r
          response.putString(AccountManager.KEY_ACCOUNT_TYPE, mAccount.type);\r
          \r
-         if (AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mCurrentAuthTokenType)) { \r
+         if (AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mAuthTokenType)) { \r
              response.putString(AccountManager.KEY_AUTHTOKEN, mAuthToken);\r
              // the next line is necessary; by now, notifications are calling directly to the AuthenticatorActivity to update, without AccountManager intervention\r
-             mAccountMgr.setAuthToken(mAccount, mCurrentAuthTokenType, mAuthToken);\r
+             mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);\r
              \r
-         } else if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mCurrentAuthTokenType)) {\r
+         } else if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType)) {\r
 +            String username = getUserNameForSamlSso();\r
 +            if (!mUsernameInput.getText().toString().equals(username)) {\r
 +                // fail - not a new account, but an existing one; disallow\r
 +                RemoteOperationResult result = new RemoteOperationResult(ResultCode.ACCOUNT_NOT_THE_SAME); \r
 +                updateAuthStatusIconAndText(result);\r
 +                showAuthStatus();\r
 +                Log_OC.d(TAG, result.getLogMessage());\r
 +                \r
 +                return false;\r
 +            }\r
 +            \r
              response.putString(AccountManager.KEY_AUTHTOKEN, mAuthToken);\r
              // the next line is necessary; by now, notifications are calling directly to the AuthenticatorActivity to update, without AccountManager intervention\r
-             mAccountMgr.setAuthToken(mAccount, mCurrentAuthTokenType, mAuthToken);\r
+             mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);\r
              \r
          } else {\r
              response.putString(AccountManager.KEY_AUTHTOKEN, mPasswordInput.getText().toString());\r
          mAuthToken = sessionCookie;\r
          \r
          if (sessionCookie != null && sessionCookie.length() > 0) {\r
-             Log_OC.d(TAG, "Successful SSO - time to save the account");\r
              mAuthToken = sessionCookie;\r
 -            boolean success = true;\r
 +            boolean success = false;\r
              if (mAction == ACTION_CREATE) {\r
                  success = createAccount();\r
          \r
      \r
      }\r
      \r
 +    /** Show auth_message \r
 +     * \r
 +     * @param message\r
 +     */\r
 +    private void showAuthMessage(String message) {\r
 +       mAuthMessage.setVisibility(View.VISIBLE);\r
 +       mAuthMessage.setText(message);\r
 +    }\r
 +    \r
 +    private void hideAuthMessage() {\r
 +        mAuthMessage.setVisibility(View.GONE);\r
 +    }\r
  \r
-     \r
      private void syncAccount(){\r
          /// immediately request for the synchronization of the new account\r
          Bundle bundle = new Bundle();\r