X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/69d6d821ec1311e6804d1398140ccf9e2d8d0e5c..52bd01bcedf1b8f13c49b67ee40a848bae1a9d40:/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 9b2dd851..ef5c21b5 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -3,9 +3,8 @@ * Copyright (C) 2012-2013 ownCloud Inc. * * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,6 +19,7 @@ package com.owncloud.android.authentication; import com.owncloud.android.AccountUtils; +import com.owncloud.android.Log_OC; import com.owncloud.android.ui.dialog.SslValidatorDialog; import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener; import com.owncloud.android.utils.OwnCloudVersion; @@ -47,7 +47,6 @@ import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; import android.text.InputType; -import android.util.Log; import android.view.View; import android.view.View.OnFocusChangeListener; import android.view.Window; @@ -87,6 +86,10 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity private static final String KEY_IS_SSL_CONN = "IS_SSL_CONN"; private static final String KEY_OAUTH2_STATUS_TEXT = "OAUTH2_STATUS_TEXT"; private static final String KEY_OAUTH2_STATUS_ICON = "OAUTH2_STATUS_ICON"; + + private static final String OAUTH_MODE_ON = "on"; + private static final String OAUTH_MODE_OFF = "off"; + private static final String OAUTH_MODE_OPTIONAL = "optional"; private static final int DIALOG_LOGIN_PROGRESS = 0; private static final int DIALOG_SSL_VALIDATOR = 1; @@ -154,7 +157,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity mOkButton = findViewById(R.id.buttonOK); mAuthStatusLayout = (TextView) findViewById(R.id.auth_status_text); - /// complete label for 'register account' button Button b = (Button) findViewById(R.id.account_register); if (b != null) { @@ -179,7 +181,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity /// retrieve extras from intent String tokenType = getIntent().getExtras().getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE); - boolean oAuthRequired = AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(tokenType); + boolean oAuthRequired = AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(tokenType) || OAUTH_MODE_ON.equals(getString(R.string.oauth2_mode)); mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT); if (mAccount != null) { @@ -201,6 +203,10 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity loadSavedInstanceState(savedInstanceState); } + if (!OAUTH_MODE_OPTIONAL.equals(getString(R.string.oauth2_mode))) { + mOAuth2Check.setVisibility(View.GONE); + } + if (mAction == ACTION_UPDATE_TOKEN) { /// lock things that should not change mHostUrlInput.setEnabled(false); @@ -295,7 +301,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity */ @Override protected void onNewIntent (Intent intent) { - Log.d(TAG, "onNewIntent()"); + Log_OC.d(TAG, "onNewIntent()"); Uri data = intent.getData(); if (data != null && data.toString().startsWith(getString(R.string.oauth2_redirect_uri))) { mNewCapturedUriFromOAuth2Redirection = data; @@ -344,7 +350,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity getString(R.string.oauth2_redirect_uri), // TODO check - necessary here? getString(R.string.oauth2_grant_type), queryParameters); - WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(getString(R.string.oauth2_url_endpoint_access)), getApplicationContext()); + //WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(getString(R.string.oauth2_url_endpoint_access)), getApplicationContext()); + WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mOAuthTokenEndpointText.getText().toString().trim()), getApplicationContext()); operation.execute(client, this, mHandler); } @@ -469,7 +476,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity mStatusText = R.string.auth_wtf_reenter_URL; updateConnStatus(); mOkButton.setEnabled(false); - Log.wtf(TAG, "The user was allowed to click 'connect' to an unchecked server!!"); + Log_OC.wtf(TAG, "The user was allowed to click 'connect' to an unchecked server!!"); return; } @@ -516,7 +523,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity updateAuthStatus(); // GET AUTHORIZATION request - Uri uri = Uri.parse(getString(R.string.oauth2_url_endpoint_auth)); + //Uri uri = Uri.parse(getString(R.string.oauth2_url_endpoint_auth)); + Uri uri = Uri.parse(mOAuthAuthEndpointText.getText().toString().trim()); Uri.Builder uriBuilder = uri.buildUpon(); uriBuilder.appendQueryParameter(OAuth2Constants.KEY_RESPONSE_TYPE, getString(R.string.oauth2_response_type)); uriBuilder.appendQueryParameter(OAuth2Constants.KEY_REDIRECT_URI, getString(R.string.oauth2_redirect_uri)); @@ -524,7 +532,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity uriBuilder.appendQueryParameter(OAuth2Constants.KEY_SCOPE, getString(R.string.oauth2_scope)); //uriBuilder.appendQueryParameter(OAuth2Constants.KEY_STATE, whateverwewant); uri = uriBuilder.build(); - Log.d(TAG, "Starting browser to view " + uri.toString()); + Log_OC.d(TAG, "Starting browser to view " + uri.toString()); Intent i = new Intent(Intent.ACTION_VIEW, uri); startActivity(i); } @@ -713,7 +721,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity /// time to test the retrieved access token on the ownCloud server mOAuthAccessToken = ((OAuth2GetAccessToken)operation).getResultTokenMap().get(OAuth2Constants.KEY_ACCESS_TOKEN); - Log.d(TAG, "Got ACCESS TOKEN: " + mOAuthAccessToken); + Log_OC.d(TAG, "Got ACCESS TOKEN: " + mOAuthAccessToken); mAuthCheckOperation = new ExistenceCheckOperation("", this, false); WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this); client.setBearerCredentials(mOAuthAccessToken); @@ -722,7 +730,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity } else { updateStatusIconAndText(result); updateAuthStatus(); - Log.d(TAG, "Access failed: " + result.getLogMessage()); + Log_OC.d(TAG, "Access failed: " + result.getLogMessage()); } } @@ -743,7 +751,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity } if (result.isSuccess()) { - Log.d(TAG, "Successful access - time to save the account"); + Log_OC.d(TAG, "Successful access - time to save the account"); if (mAction == ACTION_CREATE) { createAccount(); @@ -757,7 +765,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity } else { updateStatusIconAndText(result); updateAuthStatus(); - Log.d(TAG, "Access failed: " + result.getLogMessage()); + Log_OC.d(TAG, "Access failed: " + result.getLogMessage()); } } @@ -865,7 +873,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity break; } default: - Log.e(TAG, "Incorrect dialog called with id = " + id); + Log_OC.e(TAG, "Incorrect dialog called with id = " + id); } } @@ -888,7 +896,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity @Override public void onCancel(DialogInterface dialog) { /// TODO study if this is enough - Log.i(TAG, "Login canceled"); + Log_OC.i(TAG, "Login canceled"); if (mOperationThread != null) { mOperationThread.interrupt(); finish(); @@ -907,7 +915,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity .setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { - Log.i(TAG, "Login canceled"); + Log_OC.i(TAG, "Login canceled"); finish(); } }); @@ -933,7 +941,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity break; } default: - Log.e(TAG, "Incorrect dialog called with id = " + id); + Log_OC.e(TAG, "Incorrect dialog called with id = " + id); } return dialog; }