From: masensio Date: Mon, 20 Jan 2014 10:36:10 +0000 (+0100) Subject: Merge branch 'develop' into share_link_show_shared_files X-Git-Tag: oc-android-1.5.5~35^2~61 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/2da9af38711adf0f69913a8e011ac4e7f5220668?hp=8587f644e71522fc594d8192ad48e308cf93dd6e Merge branch 'develop' into share_link_show_shared_files --- diff --git a/oc_framework/src/com/owncloud/android/oc_framework/accounts/AccountUtils.java b/oc_framework/src/com/owncloud/android/oc_framework/accounts/AccountUtils.java index 810f3eba..72946dcb 100644 --- a/oc_framework/src/com/owncloud/android/oc_framework/accounts/AccountUtils.java +++ b/oc_framework/src/com/owncloud/android/oc_framework/accounts/AccountUtils.java @@ -111,8 +111,8 @@ public class AccountUtils { public static class AccountNotFoundException extends AccountsException { - /** Generated - should be refreshed every time the class changes!! */ - private static final long serialVersionUID = -9013287181793186830L; + /** Generated - should be refreshed every time the class changes!! */ + private static final long serialVersionUID = -1684392454798508693L; private Account mFailedAccount; @@ -125,5 +125,4 @@ public class AccountUtils { return mFailedAccount; } } - } diff --git a/oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteOperationResult.java b/oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteOperationResult.java index 58accf9f..a5f5a39f 100644 --- a/oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteOperationResult.java +++ b/oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteOperationResult.java @@ -33,6 +33,7 @@ import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpStatus; import org.apache.jackrabbit.webdav.DavException; +import org.json.JSONException; import com.owncloud.android.oc_framework.accounts.AccountUtils.AccountNotFoundException; import com.owncloud.android.oc_framework.network.CertificateCombinedException; @@ -51,9 +52,9 @@ import android.util.Log; * @author David A. Velasco */ public class RemoteOperationResult implements Serializable { - + /** Generated - should be refreshed every time the class changes!! */ - private static final long serialVersionUID = -2469951225222759283L; + private static final long serialVersionUID = -8257349554488668693L; private static final String TAG = "RemoteOperationResult"; @@ -294,6 +295,9 @@ public class RemoteOperationResult implements Serializable { } else if (mException instanceof AccountsException) { return "Exception while using account"; + } else if (mException instanceof JSONException) { + return "JSON exception"; + } else { return "Unexpected exception"; } diff --git a/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/GetUserNameRemoteOperation.java b/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/GetUserNameRemoteOperation.java new file mode 100644 index 00000000..717fae22 --- /dev/null +++ b/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/GetUserNameRemoteOperation.java @@ -0,0 +1,127 @@ + +/* ownCloud Android client application + * 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 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +package com.owncloud.android.oc_framework.operations.remote; + +import java.io.IOException; + +import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.http.HttpStatus; +import org.json.JSONException; +import org.json.JSONObject; + +import android.util.Log; + +import com.owncloud.android.oc_framework.network.webdav.WebdavClient; +import com.owncloud.android.oc_framework.operations.RemoteOperation; +import com.owncloud.android.oc_framework.operations.RemoteOperationResult; + + +/** + * @author masensio + * + * Get the UserName for a SAML connection, from a JSON with the format: + * id + * display-name + * email + */ + +public class GetUserNameRemoteOperation extends RemoteOperation { + + private static final String TAG = GetUserNameRemoteOperation.class.getSimpleName(); + + // HEADER + private static final String HEADER_OCS_API = "OCS-APIREQUEST"; + private static final String HEADER_OCS_API_VALUE = "true"; + + // OCS Route + private static final String OCS_ROUTE ="/index.php/ocs/cloud/user?format=json"; + + // JSON Node names + private static final String NODE_OCS = "ocs"; + private static final String NODE_DATA = "data"; + private static final String NODE_ID = "id"; + private static final String NODE_DISPLAY_NAME= "display-name"; + private static final String NODE_EMAIL= "email"; + + private String mUserName; + + public String getUserName() { + return mUserName; + } + + + public GetUserNameRemoteOperation() { + } + + @Override + protected RemoteOperationResult run(WebdavClient client) { + RemoteOperationResult result = null; + int status = -1; + + // Get Method + GetMethod get = new GetMethod(client.getBaseUri() + OCS_ROUTE); + Log.d(TAG, "URL ------> " + client.getBaseUri() + OCS_ROUTE); + // Add the Header + get.addRequestHeader(HEADER_OCS_API, HEADER_OCS_API_VALUE); + + //Get the user + try { + status = client.executeMethod(get); + if(isSuccess(status)) { + Log.d(TAG, "Obtain RESPONSE"); + String response = get.getResponseBodyAsString(); + + Log.d(TAG, "GET RESPONSE.................... " + response); + + // Parse the response + JSONObject respJSON = new JSONObject(response); + JSONObject respOCS = respJSON.getJSONObject(NODE_OCS); + JSONObject respData = respOCS.getJSONObject(NODE_DATA); + String id = respData.getString(NODE_ID); + String displayName = respData.getString(NODE_DISPLAY_NAME); + String email = respData.getString(NODE_EMAIL); + + // Result + result = new RemoteOperationResult(isSuccess(status), status, (get != null ? get.getResponseHeaders() : null)); + mUserName = displayName; + + Log.d(TAG, "Response: " + id + " - " + displayName + " - " + email); + + } + } catch (HttpException e) { + result = new RemoteOperationResult(e); + e.printStackTrace(); + } catch (IOException e) { + result = new RemoteOperationResult(e); + e.printStackTrace(); + } catch (JSONException e) { + result = new RemoteOperationResult(e); + e.printStackTrace(); + } finally { + get.releaseConnection(); + } + + return result; + } + + private boolean isSuccess(int status) { + return (status == HttpStatus.SC_OK); + } + +} diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index b8188011..b8e445e2 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -1,6 +1,6 @@ - App Android %1$s + %1$s para Android versión %1$s Actualizar cuenta Subir @@ -16,7 +16,7 @@ Gestionar cuentas PIN de aplicación Proteja su cliente - Habilitar la subida instantánea + Activar la subida instantánea Subir instantáneamente las fotos tomadas por la cámara Habilitar registro Esto es usado para registrar problemas @@ -78,7 +78,7 @@ Error en la subida La subida de %1$s no se pudo completar Descargando ... - %1$s Descargada de %2$s + %1$d%% Descargado de %2$s Descarga completa %1$s se ha descargado con éxito Falló la descarga @@ -178,7 +178,7 @@ Carácteres ilegales: / \\ < > : \" | ? * Espere un momento Problema inesperado; por favor, prueba otra app para seleccionar el archivo - No fué seleccionado ningún archivo + No hay ficheros seleccionados. Ingresar con oAuth2 Conectando al servidor oAuth2... La identidad del sitio no puede ser verificada @@ -209,7 +209,7 @@ 389 KB 2012/05/18 12:23 PM 12:23:45 - Subir imágenes sólo via WiFi + Subir imágenes sólo cuando hay WiFi /SubidasInstantáneas Conflicto en la actualización El archivo remoto %s no está sincronizado con el archivo local. Si continúa, se reemplazará el contenido del archivo en el servidor. diff --git a/res/values-ku-rIQ/strings.xml b/res/values-ku-rIQ/strings.xml index 5e87456f..09c1c8c5 100644 --- a/res/values-ku-rIQ/strings.xml +++ b/res/values-ku-rIQ/strings.xml @@ -1,11 +1,30 @@ بارکردن + په‌ڕگەکان + درووستکردنى بوخچە ده‌ستكاری + گشتی + هەژمارەکان یارمەتی ناوی به‌کارهێنه‌ر وشەی تێپەربو + په‌ڕگەکان + بەستنەوە بارکردن + هیچ هەژمارێک نه‌دۆزرایه‌وه‌ + جێگیرکردن + دەرچوون + بارکردن + قەبارە: + جۆر: + درووستبووە: + گۆردراو: داگرتن + بەڵێ + نەخێر + باشە + لابردن + پاشکەوتکردن & دەرچوون هه‌ڵه diff --git a/res/values-sq/strings.xml b/res/values-sq/strings.xml index 03b08ac0..c460e82b 100644 --- a/res/values-sq/strings.xml +++ b/res/values-sq/strings.xml @@ -2,21 +2,53 @@ Ngarko Skedarët + Krijo kartelë Parametrat Përgjithshme Më tepër + Llogarit Ndihmë + Stampoj Përdoruesi Kodi Skedarët + Lidhu Ngarko + Nuk u gjend asnjë llogari + Nuk ka %1$s llogari në pajisjen tuaj. Ju lutemi të krijojnë një llogari të parë. + Ndërto + Dil + Ngarko + Trokitje e lehtë në një dokument për të shfaqur informacion shtesë. + Dimensioni: + Tipi: + Krijuar: + Modifikuar: Shkarko Po Jo + Ok Anulo ngarkimin Anulo Veprim i gabuar + Gabim panjohur + Rreth Ndrysho fjalëkalimin + Fshi llogarin + Krijo llogari + Ngarko nga... + Ngarkim... + %1$d%% Ngarkim %2$s + Ngarkimi me sukses. + %1$s u ngarkua me sukses Ngarkimi dështoi + Ngarkimi i %1$s nuk mund te behej + Shkarkimi... + %1$d%% Shkarkimi %2$s + Shkarkimi me sukses + %1$s u shkarkua me sukses + Shkarkimi dështoj + Lidhja e Sigurt vendos Riemërto + Hiq diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index 2334d654..868c564b 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -24,7 +24,13 @@ Hiển thị các nhật trình đã được ghi nhận lại Xóa lịch sử Giúp đỡ + Giới thiệu đến bạn bè + Phản hồi + Đánh dấu + Thử %1$s trên smartphone của bạn! + Tôi muốn mời bạn sử dụng %1$s trên smartphone của bạn!\nTải về tại đây: %2$s Kiểm tra máy chủ + Địa chỉ máy chủ https://… Tên người dùng Mật khẩu Lần đầu mới đến %1$s? @@ -40,7 +46,7 @@ Không có nội dung được nhận. Không có gì để tải lên. %1$s không cho phép truy cập vào các nội dung chia sẻ Đang tải lên - Không có các tập tin trong thư mục này ⏎ tập tin mới có thể được thêm vào với tùy chọn trình đơn \"Tải lên\". + Không có tập tin trong thư mục này. tập tin mới có thể được thêm vào với tùy chọn \"Tải lên\". Tap vào một tập tin để hiển thị thêm thông tin Kích thước: Loại: @@ -88,6 +94,8 @@ Nội dung tập tin %1$d không thể đồng bộ (%2$d xung đột) Một số tập tin cục bộ bị quên Các tập tin %1$d ở ngoài thư mục %2$s không thể được chép vào + \"Từ phiên bản 1.3.16, các tập tin tải lên từ thiết bị này được chép vào thư mục cục bộ %1$s để đề phòng mất dữ liệu khi một tập tin được đồng bộ với nhiều tài khoản.\n\nDo thay đổi này, tất cả các tập tin được tải lên ở phiên bản trước của ứng dụng này được chép vào thư mục %2$s. Tuy nhiên, đã có lỗi ngăn cản việc này trong lúc đồng bộ tài khoản. Bạn có thể để (các) tập tin như vậy và xóa liên kết đến %3$s, hoặc di chuyển (các) tập tin vào thư mục %1$s và giữ lại liên kết tới %4$s.\n\nDanh sách bên dưới là (các) tập tin cục bộ và (các) tập tin ở xa trong %5$s mà chúng được liên kết tới. + Thư mục %1$s không còn tồn tại Di chuyển tất cả Tất cả tập tin đã được chuyển đi Một vài tập tin không thể chuyển đi @@ -113,6 +121,7 @@ Codec của media không được hỗ trợ Không thể đọc dữ liệu từ tập tin media Tập tin media không được mã hóa đúng quy định + Tạm ngừng trong khi đang cố gắng chạy Không thể phân luồng dữ liệu tập tin media Tập tin media không thể được phát với trình phát media của stock Lỗi bảo mật khi cố phát %1$s @@ -127,12 +136,15 @@ Kết nối đã thiết lập Đang kiểm tra kết nối... Thay đổi cấu hình máy chủ + Một tài khoản với cùng tên người dùng và máy chủ đã tồn tại trong thiết bị + Tên người dùng đã nhập không đúng với tên người dùng của tài khoản này Không xác định được lỗi! Không thể tìm thấy máy chủ Phiên bản máy chủ không tìm thấy Máy chủ đã quá dài để đáp ứng Thay đổi URL SSL khởi tạo thất bại + không thể xác minh danh tính của máy chủ SSL Không chấp nhận phiên bản máy chủ Không thể thiết lập kết nối Kết nối an toàn đã được thiết lập @@ -140,7 +152,12 @@ Xác nhận không thành công Từ chối truy cập vì xác nhận từ phía máy chủ Trạng thái không rõ, vui lòng điền lại đường dẫn liên kết một lần nữa + Hạn xác nhận của bạn đã hết. Vui lòng, xác nhận lại Vui lòng điền vào mật khẩu hiện tại của bạn + Phiên làm việc của bạn đã kết thúc. Vui lòng kết nối lại + Đang kết nối đến máy chủ xác thực... + Máy chủ không hổ trợ phương thức xác thực này + %1$s không hỗ trợ nhiều tài khoản Giữ tập tin cập nhật Sửa tên Xóa @@ -158,9 +175,11 @@ Tập tin từ xa không được kiểm tra Nội dung tập tin đã đồng bộ Thư mục không thể được tạo + Những kí tự không được dùng: / \\ < > : \" | ? * Chờ một lúc Vấn đề bất ngờ ; hãy thử ứng dụng khác để chọn tập tin Không có tập tin nào được chọn + Đăng nhập bằng oAuth2. Đang kết nối đến máy chủ oAuth2... Không thể xác minh danh tính của site Chứng chỉ này không đáng tin cậy @@ -200,6 +219,7 @@ Xem trước hình ảnh Không thể hiển thị hình ảnh %1$s không thể sao chép vào %2$s thư mục cục bộ + Tải lên nhanh bị lỗi Tải lên nhanh bị lỗi Tóm tắt tất cả các tải lên nhanh bị lỗi chọn tất cả diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index 456e284b..ad40a066 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -64,6 +64,7 @@ import com.owncloud.android.oc_framework.operations.RemoteOperation; import com.owncloud.android.oc_framework.operations.RemoteOperationResult; import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.oc_framework.operations.remote.ExistenceCheckRemoteOperation; +import com.owncloud.android.oc_framework.operations.remote.GetUserNameRemoteOperation; import com.owncloud.android.ui.dialog.SamlWebViewDialog; import com.owncloud.android.ui.dialog.SslValidatorDialog; import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener; @@ -102,8 +103,6 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList 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_OC_USERNAME_EQUALS = "oc_username="; private static final String AUTH_ON = "on"; private static final String AUTH_OFF = "off"; @@ -792,10 +791,41 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList } else { onAuthorizationCheckFinish((ExistenceCheckRemoteOperation)operation, result); } + } else if (operation instanceof GetUserNameRemoteOperation) { + onGetUserNameFinish((GetUserNameRemoteOperation) operation, result); + } + } - - + + private void onGetUserNameFinish(GetUserNameRemoteOperation operation, RemoteOperationResult result) { + if (result.isSuccess()) { + boolean success = false; + String username = operation.getUserName(); + + if ( mAction == ACTION_CREATE) { + mUsernameInput.setText(username); + success = createAccount(); + } else { + + if (!mUsernameInput.getText().toString().equals(username)) { + // fail - not a new account, but an existing one; disallow + result = new RemoteOperationResult(ResultCode.ACCOUNT_NOT_THE_SAME); + updateAuthStatusIconAndText(result); + showAuthStatus(); + Log_OC.d(TAG, result.getLogMessage()); + } else { + updateToken(); + success = true; + } + } + + if (success) + finish(); + } + + } + private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperation operation, RemoteOperationResult result) { try { dismissDialog(DIALOG_LOGIN_PROGRESS); @@ -1120,7 +1150,8 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList success = createAccount(); } else { - success = updateToken(); + updateToken(); + success = true; } if (success) { @@ -1166,7 +1197,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList * Sets the proper response to get that the Account Authenticator that started this activity saves * a new authorization token for mAccount. */ - private boolean updateToken() { + private void updateToken() { Bundle response = new Bundle(); response.putString(AccountManager.KEY_ACCOUNT_NAME, mAccount.name); response.putString(AccountManager.KEY_ACCOUNT_TYPE, mAccount.type); @@ -1177,16 +1208,6 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken); } else if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) { - String username = getUserNameForSamlSso(); - if (!mUsernameInput.getText().toString().equals(username)) { - // fail - not a new account, but an existing one; disallow - RemoteOperationResult result = new RemoteOperationResult(ResultCode.ACCOUNT_NOT_THE_SAME); - updateAuthStatusIconAndText(result); - showAuthStatus(); - Log_OC.d(TAG, result.getLogMessage()); - - return false; - } response.putString(AccountManager.KEY_AUTHTOKEN, mAuthToken); // the next line is necessary; by now, notifications are calling directly to the AuthenticatorActivity to update, without AccountManager intervention @@ -1198,7 +1219,6 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList } setAccountAuthenticatorResult(response); - return true; } @@ -1216,10 +1236,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList Uri uri = Uri.parse(mHostBaseUrl); String username = mUsernameInput.getText().toString().trim(); - if (isSaml) { - username = getUserNameForSamlSso(); - - } else if (isOAuth) { + if (isOAuth) { username = "OAuth_user" + (new java.util.Random(System.currentTimeMillis())).nextLong(); } String accountName = username + "@" + uri.getHost(); @@ -1279,20 +1296,6 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList } } - - private String getUserNameForSamlSso() { - if (mAuthToken != null) { - String [] cookies = mAuthToken.split(";"); - for (int i=0; i 0) { mAuthToken = sessionCookie; - boolean success = false; - if (mAction == ACTION_CREATE) { - success = createAccount(); - - } else { - success = updateToken(); - } - if (success) { - finish(); - } + + GetUserNameRemoteOperation getUserOperation = new GetUserNameRemoteOperation(); + WebdavClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl), getApplicationContext(), true); + client.setSsoSessionCookie(mAuthToken); + getUserOperation.execute(client, this, mHandler); } @@ -1652,4 +1650,5 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList } return super.onTouchEvent(event); } + } diff --git a/src/com/owncloud/android/authentication/SsoWebViewClient.java b/src/com/owncloud/android/authentication/SsoWebViewClient.java index 8d80e9b7..442ec73d 100644 --- a/src/com/owncloud/android/authentication/SsoWebViewClient.java +++ b/src/com/owncloud/android/authentication/SsoWebViewClient.java @@ -21,12 +21,16 @@ import java.lang.ref.WeakReference; import com.owncloud.android.utils.Log_OC; - import android.graphics.Bitmap; +import android.net.http.SslError; import android.os.Handler; import android.os.Message; +import android.view.KeyEvent; import android.view.View; import android.webkit.CookieManager; +import android.webkit.HttpAuthHandler; +import android.webkit.SslErrorHandler; +import android.webkit.WebResourceResponse; import android.webkit.WebView; import android.webkit.WebViewClient; @@ -107,7 +111,7 @@ public class SsoWebViewClient extends WebViewClient { view.setVisibility(View.GONE); CookieManager cookieManager = CookieManager.getInstance(); final String cookies = cookieManager.getCookie(url); - //Log_OC.d(TAG, "Cookies: " + cookies); + Log_OC.d(TAG, "Cookies: " + cookies); if (mListenerHandler != null && mListenerRef != null) { // this is good idea because onPageFinished is not running in the UI thread mListenerHandler.post(new Runnable() { @@ -115,16 +119,16 @@ public class SsoWebViewClient extends WebViewClient { public void run() { SsoWebViewClientListener listener = mListenerRef.get(); if (listener != null) { + // Send Cookies to the listener listener.onSsoFinished(cookies); } } }); } - } - + } } - /* + @Override public void doUpdateVisitedHistory (WebView view, String url, boolean isReload) { Log_OC.d(TAG, "doUpdateVisitedHistory : " + url); @@ -133,6 +137,7 @@ public class SsoWebViewClient extends WebViewClient { @Override public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) { Log_OC.d(TAG, "onReceivedSslError : " + error); + handler.proceed(); } @Override @@ -172,5 +177,5 @@ public class SsoWebViewClient extends WebViewClient { Log_OC.d(TAG, "shouldOverrideKeyEvent : " + event); return false; } - */ + }