summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2011-05-26 13:44:48 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-05-26 13:44:48 -0700
commitb3deaf8371a649770e472408475b6201def060f3 (patch)
tree3772d3d7ebb950d4edc3e17d7cc0a3e05041ec38
parent43e00f2e7f13800d2cf0185e4342222e0de90705 (diff)
parent5379cd3f586062b9e0a2f31058326097dc727bfe (diff)
downloadGallery3D-b3deaf8371a649770e472408475b6201def060f3.tar.gz
am 5379cd3f: Merge "Fix 4442284 Android Picasa sync over HTTP - data and credentials sent in clear text. DO NOT MERGE." into gingerbread
* commit '5379cd3f586062b9e0a2f31058326097dc727bfe': Fix 4442284 Android Picasa sync over HTTP - data and credentials sent in clear text. DO NOT MERGE.
-rw-r--r--src/com/cooliris/picasa/GDataClient.java2
-rw-r--r--src/com/cooliris/picasa/PicasaApi.java17
-rw-r--r--src/com/cooliris/picasa/PicasaContentProvider.java2
3 files changed, 16 insertions, 5 deletions
diff --git a/src/com/cooliris/picasa/GDataClient.java b/src/com/cooliris/picasa/GDataClient.java
index a2e2be2..b156347 100644
--- a/src/com/cooliris/picasa/GDataClient.java
+++ b/src/com/cooliris/picasa/GDataClient.java
@@ -32,6 +32,7 @@ import org.apache.http.client.params.HttpClientParams;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.impl.client.DefaultHttpClient;
@@ -70,6 +71,7 @@ public final class GDataClient {
// Register HTTP protocol.
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
+ schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
// Create the connection manager.
HTTP_CONNECTION_MANAGER = new ThreadSafeClientConnManager(params, schemeRegistry);
diff --git a/src/com/cooliris/picasa/PicasaApi.java b/src/com/cooliris/picasa/PicasaApi.java
index 90f3db1..d7f214a 100644
--- a/src/com/cooliris/picasa/PicasaApi.java
+++ b/src/com/cooliris/picasa/PicasaApi.java
@@ -28,10 +28,12 @@ import android.accounts.AccountManager;
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.app.Activity;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.SyncResult;
import android.net.Uri;
import android.os.Bundle;
+import android.provider.Settings;
import android.util.Log;
import android.util.Xml;
@@ -41,7 +43,8 @@ public final class PicasaApi {
public static final int RESULT_ERROR = 2;
private static final String TAG = "PicasaAPI";
- private static final String BASE_URL = "http://picasaweb.google.com/data/feed/api/";
+ private static final String SETTINGS_PICASA_GDATA_BASE_URL_KEY = "picasa_gdata_base_url";
+ private static final String DEFAULT_BASE_URL = "https://picasaweb.google.com/data/feed/api/";
private static final String BASE_QUERY_STRING;
static {
@@ -54,6 +57,7 @@ public final class PicasaApi {
BASE_QUERY_STRING = query.toString() + "&visibility=visible";
}
+ private final ContentResolver mContentResolver;
private final GDataClient mClient;
private final GDataClient.Operation mOperation = new GDataClient.Operation();
private final GDataParser mParser = new GDataParser();
@@ -151,7 +155,8 @@ public final class PicasaApi {
return username;
}
- public PicasaApi() {
+ public PicasaApi(ContentResolver cr) {
+ mContentResolver = cr;
mClient = new GDataClient();
}
@@ -164,7 +169,9 @@ public final class PicasaApi {
public int getAlbums(AccountManager accountManager, SyncResult syncResult, UserEntry user, GDataParser.EntryHandler handler) {
// Construct the query URL for user albums.
- StringBuilder builder = new StringBuilder(BASE_URL);
+ String baseUrl = Settings.Secure.getString(mContentResolver,
+ SETTINGS_PICASA_GDATA_BASE_URL_KEY);
+ StringBuilder builder = new StringBuilder(baseUrl != null ? baseUrl : DEFAULT_BASE_URL);
builder.append("user/");
builder.append(Uri.encode(mAuth.user));
builder.append(BASE_QUERY_STRING);
@@ -237,7 +244,9 @@ public final class PicasaApi {
public int getAlbumPhotos(AccountManager accountManager, SyncResult syncResult, AlbumEntry album,
GDataParser.EntryHandler handler) {
// Construct the query URL for user albums.
- StringBuilder builder = new StringBuilder(BASE_URL);
+ String baseUrl = Settings.Secure.getString(mContentResolver,
+ SETTINGS_PICASA_GDATA_BASE_URL_KEY);
+ StringBuilder builder = new StringBuilder(baseUrl != null ? baseUrl : DEFAULT_BASE_URL);
builder.append("user/");
builder.append(Uri.encode(mAuth.user));
builder.append("/albumid/");
diff --git a/src/com/cooliris/picasa/PicasaContentProvider.java b/src/com/cooliris/picasa/PicasaContentProvider.java
index 870c7f1..4211fcf 100644
--- a/src/com/cooliris/picasa/PicasaContentProvider.java
+++ b/src/com/cooliris/picasa/PicasaContentProvider.java
@@ -516,7 +516,7 @@ public final class PicasaContentProvider extends TableContentProvider {
// A connection to the Picasa API for a specific user account. Initially
// null.
- public PicasaApi api = new PicasaApi();
+ public PicasaApi api = new PicasaApi(getContext().getContentResolver());
// A handle to the Picasa databse.
public SQLiteDatabase db;