aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-03-24 16:41:01 +0100
committerVincent Breitmoser <valodim@mugenguild.com>2015-03-24 16:41:01 +0100
commite573cd774a4a41234c229d9c49ef7a5656445f93 (patch)
tree3efd104d6d8e1ec4feeaa9ca351cd13cdf3261b4 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain
parentf9ef1160ca764d508dafcb45fbf65f18911fff9c (diff)
downloadopen-keychain-e573cd774a4a41234c229d9c49ef7a5656445f93.tar.gz
open-keychain-e573cd774a4a41234c229d9c49ef7a5656445f93.tar.bz2
open-keychain-e573cd774a4a41234c229d9c49ef7a5656445f93.zip
work on cookie scanning during creation
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java10
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/LinkedCookieResource.java26
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java49
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GithubResource.java73
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/TwitterResource.java107
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateDnsStep2Fragment.java3
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateFinalFragment.java20
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubStep2Fragment.java5
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateHttpsStep2Fragment.java3
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep2Fragment.java5
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdViewFragment.java2
11 files changed, 150 insertions, 153 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java
index 616b6f062..3270d12d5 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java
@@ -771,6 +771,12 @@ public abstract class OperationResult implements Parcelable {
MSG_LV_FP_OK (LogLevel.DEBUG, R.string.msg_lv_fp_ok),
MSG_LV_FP_ERROR (LogLevel.ERROR, R.string.msg_lv_fp_error),
+ MSG_LV_ERROR_TWITTER_AUTH (LogLevel.ERROR, R.string.msg_lv_error_twitter_auth),
+ MSG_LV_ERROR_TWITTER_HANDLE (LogLevel.ERROR, R.string.msg_lv_error_twitter_handle),
+ MSG_LV_ERROR_TWITTER_RESPONSE (LogLevel.ERROR, R.string.msg_lv_error_twitter_response),
+ MSG_LV_ERROR_GITHUB_HANDLE (LogLevel.ERROR, R.string.msg_lv_error_github_handle),
+ MSG_LV_ERROR_GITHUB_NOT_FOUND (LogLevel.ERROR, R.string.msg_lv_error_github_not_found),
+
MSG_LV_FETCH (LogLevel.DEBUG, R.string.msg_lv_fetch),
MSG_LV_FETCH_REDIR (LogLevel.DEBUG, R.string.msg_lv_fetch_redir),
MSG_LV_FETCH_OK (LogLevel.DEBUG, R.string.msg_lv_fetch_ok),
@@ -778,14 +784,14 @@ public abstract class OperationResult implements Parcelable {
MSG_LV_FETCH_ERROR_URL (LogLevel.ERROR, R.string.msg_lv_fetch_error_url),
MSG_LV_FETCH_ERROR_IO (LogLevel.ERROR, R.string.msg_lv_fetch_error_io),
MSG_LV_FETCH_ERROR_FORMAT(LogLevel.ERROR, R.string.msg_lv_fetch_error_format),
+ MSG_LV_FETCH_ERROR_NOTHING (LogLevel.ERROR, R.string.msg_lv_fetch_error_nothing),
//export log
MSG_EXPORT_LOG(LogLevel.START,R.string.msg_export_log_start),
MSG_EXPORT_LOG_EXPORT_ERROR_NO_FILE(LogLevel.ERROR,R.string.msg_export_log_error_no_file),
MSG_EXPORT_LOG_EXPORT_ERROR_FOPEN(LogLevel.ERROR,R.string.msg_export_log_error_fopen),
MSG_EXPORT_LOG_EXPORT_ERROR_WRITING(LogLevel.ERROR,R.string.msg_export_log_error_writing),
- MSG_EXPORT_LOG_EXPORT_SUCCESS (LogLevel.OK, R.string.msg_export_log_success),
- ;
+ MSG_EXPORT_LOG_EXPORT_SUCCESS (LogLevel.OK, R.string.msg_export_log_success);
public final int mMsgId;
public final LogLevel mLevel;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/LinkedCookieResource.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/LinkedCookieResource.java
index 940e0f7eb..606c951b8 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/LinkedCookieResource.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/LinkedCookieResource.java
@@ -4,10 +4,10 @@ import android.content.Context;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
+import org.json.JSONException;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.operations.results.LinkedVerifyResult;
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
@@ -19,6 +19,7 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.net.MalformedURLException;
import java.net.URI;
import java.util.HashMap;
import java.util.Map.Entry;
@@ -86,7 +87,23 @@ public abstract class LinkedCookieResource extends LinkedResource {
log.add(LogType.MSG_LV, 0);
// Try to fetch resource. Logs for itself
- String res = fetchResource(log, 1);
+ String res = null;
+ try {
+ res = fetchResource(log, 1);
+ } catch (HttpStatusException e) {
+ // log verbose output to logcat
+ Log.e(Constants.TAG, "http error (" + e.getStatus() + "): " + e.getReason());
+ log.add(LogType.MSG_LV_FETCH_ERROR, 2, Integer.toString(e.getStatus()));
+ } catch (MalformedURLException e) {
+ log.add(LogType.MSG_LV_FETCH_ERROR_URL, 2);
+ } catch (IOException e) {
+ Log.e(Constants.TAG, "io error", e);
+ log.add(LogType.MSG_LV_FETCH_ERROR_IO, 2);
+ } catch (JSONException e) {
+ Log.e(Constants.TAG, "json error", e);
+ log.add(LogType.MSG_LV_FETCH_ERROR_FORMAT, 2);
+ }
+
if (res == null) {
// if this is null, an error was recorded in fetchResource above
return new LinkedVerifyResult(LinkedVerifyResult.RESULT_ERROR, log);
@@ -98,7 +115,8 @@ public abstract class LinkedCookieResource extends LinkedResource {
}
- protected abstract String fetchResource (OperationLog log, int indent);
+ protected abstract String fetchResource (OperationLog log, int indent) throws HttpStatusException, IOException,
+ JSONException;
protected Matcher matchResource (OperationLog log, int indent, String res) {
return magicPattern.matcher(res);
@@ -130,6 +148,8 @@ public abstract class LinkedCookieResource extends LinkedResource {
public static String getResponseBody(HttpRequestBase request) throws IOException, HttpStatusException {
StringBuilder sb = new StringBuilder();
+ request.setHeader("User-Agent", "Open Keychain");
+
DefaultHttpClient httpClient = new DefaultHttpClient(new BasicHttpParams());
HttpResponse response = httpClient.execute(request);
int statusCode = response.getStatusLine().getStatusCode();
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java
index c6d5883ee..4cf56fe67 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java
@@ -8,6 +8,7 @@ import android.support.annotation.StringRes;
import com.textuality.keybase.lib.Search;
+import org.apache.http.client.methods.HttpGet;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
@@ -40,53 +41,15 @@ public class GenericHttpsResource extends LinkedCookieResource {
}
@Override
- protected String fetchResource (OperationLog log, int indent) {
+ protected String fetchResource (OperationLog log, int indent) throws HttpStatusException, IOException {
log.add(LogType.MSG_LV_FETCH, indent, mSubUri.toString());
indent += 1;
- try {
-
- HttpsURLConnection conn = null;
- URL url = mSubUri.toURL();
- int status = 0;
- int redirects = 0;
-
- while (redirects < 5) {
- conn = (HttpsURLConnection) url.openConnection();
- conn.addRequestProperty("User-Agent", "OpenKeychain");
- conn.setConnectTimeout(5000);
- conn.setReadTimeout(25000);
- conn.connect();
- status = conn.getResponseCode();
- if (status == 301) {
- redirects++;
- url = new URL(conn.getHeaderFields().get("Location").get(0));
- log.add(LogType.MSG_LV_FETCH_REDIR, indent, url.toString());
- } else {
- break;
- }
- }
-
- if (status >= 200 && status < 300) {
- log.add(LogType.MSG_LV_FETCH_OK, indent, Integer.toString(status));
- return Search.snarf(conn.getInputStream());
- } else {
- // log verbose output to logcat
- Log.e(Constants.TAG, Search.snarf(conn.getErrorStream()));
- log.add(LogType.MSG_LV_FETCH_ERROR, indent, Integer.toString(status));
- return null;
- }
-
- } catch (MalformedURLException e) {
- log.add(LogType.MSG_LV_FETCH_ERROR_URL, indent);
- return null;
- } catch (IOException e) {
- Log.e(Constants.TAG, "io error", e);
- e.printStackTrace();
- log.add(LogType.MSG_LV_FETCH_ERROR_IO, indent);
- return null;
- }
+ HttpGet httpGet = new HttpGet(mSubUri);
+ return getResponseBody(httpGet);
+
+ // log.add(LogType.MSG_LV_FETCH_REDIR, indent, url.toString());
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GithubResource.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GithubResource.java
index 400a0a678..9300b67e7 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GithubResource.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GithubResource.java
@@ -48,58 +48,43 @@ public class GithubResource extends LinkedCookieResource {
}
@Override
- protected String fetchResource (OperationLog log, int indent) {
+ protected String fetchResource (OperationLog log, int indent)
+ throws HttpStatusException, IOException, JSONException {
log.add(LogType.MSG_LV_FETCH, indent, mSubUri.toString());
indent += 1;
- try {
-
- HttpGet httpGet = new HttpGet("https://api.github.com/gists/" + mGistId);
- httpGet.setHeader("User-Agent", "OpenKeychain");
+ HttpGet httpGet = new HttpGet("https://api.github.com/gists/" + mGistId);
+ String response = getResponseBody(httpGet);
- String response = getResponseBody(httpGet);
+ JSONObject obj = new JSONObject(response);
- JSONObject obj = new JSONObject(response);
-
- JSONObject owner = obj.getJSONObject("owner");
- if (!mHandle.equals(owner.getString("login"))) {
- log.add(LogType.MSG_LV_FETCH_ERROR_FORMAT, indent);
- return null;
- }
-
- JSONObject files = obj.getJSONObject("files");
- Iterator<String> it = files.keys();
- if (it.hasNext()) {
- // TODO can there be multiple candidates?
- JSONObject file = files.getJSONObject(it.next());
- return file.getString("content");
- }
+ JSONObject owner = obj.getJSONObject("owner");
+ if (!mHandle.equals(owner.getString("login"))) {
+ log.add(LogType.MSG_LV_ERROR_GITHUB_HANDLE, indent);
+ return null;
+ }
- } catch (HttpStatusException e) {
- // log verbose output to logcat
- Log.e(Constants.TAG, "http error (" + e.getStatus() + "): " + e.getReason());
- log.add(LogType.MSG_LV_FETCH_ERROR, indent, Integer.toString(e.getStatus()));
- } catch (MalformedURLException e) {
- log.add(LogType.MSG_LV_FETCH_ERROR_URL, indent);
- } catch (IOException e) {
- Log.e(Constants.TAG, "io error", e);
- log.add(LogType.MSG_LV_FETCH_ERROR_IO, indent);
- } catch (JSONException e) {
- Log.e(Constants.TAG, "json error", e);
- log.add(LogType.MSG_LV_FETCH_ERROR_FORMAT, indent);
+ JSONObject files = obj.getJSONObject("files");
+ Iterator<String> it = files.keys();
+ if (it.hasNext()) {
+ // TODO can there be multiple candidates?
+ JSONObject file = files.getJSONObject(it.next());
+ return file.getString("content");
}
+
+ log.add(LogType.MSG_LV_ERROR_GITHUB_NOT_FOUND, indent);
return null;
}
- public static GithubResource searchInGithubStream(String screenName, String needle) {
+ public static GithubResource searchInGithubStream(String screenName, String needle,
+ OperationLog log) {
// narrow the needle down to important part
Matcher matcher = magicPattern.matcher(needle);
if (!matcher.find()) {
- Log.e(Constants.TAG, "needle didn't contain cookie!");
- return null;
+ throw new AssertionError("Needle must contain cookie pattern! This is a programming error, please report.");
}
needle = matcher.group();
@@ -150,9 +135,21 @@ public class GithubResource extends LinkedCookieResource {
}
// update the results with the body of the response
+ log.add(LogType.MSG_LV_FETCH_ERROR_NOTHING, 2);
return null;
- } catch (JSONException | HttpStatusException | IOException e) {
- Log.e(Constants.TAG, "exception parsing stream", e);
+
+ } catch (HttpStatusException e) {
+ // log verbose output to logcat
+ Log.e(Constants.TAG, "http error (" + e.getStatus() + "): " + e.getReason());
+ log.add(LogType.MSG_LV_FETCH_ERROR, 2, Integer.toString(e.getStatus()));
+ } catch (MalformedURLException e) {
+ log.add(LogType.MSG_LV_FETCH_ERROR_URL, 2);
+ } catch (IOException e) {
+ Log.e(Constants.TAG, "io error", e);
+ log.add(LogType.MSG_LV_FETCH_ERROR_IO, 2);
+ } catch (JSONException e) {
+ Log.e(Constants.TAG, "json error", e);
+ log.add(LogType.MSG_LV_FETCH_ERROR_FORMAT, 2);
}
return null;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/TwitterResource.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/TwitterResource.java
index 136d87d03..e56d281b7 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/TwitterResource.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/TwitterResource.java
@@ -22,6 +22,7 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.Operat
import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URI;
import java.util.HashMap;
import java.util.HashSet;
@@ -66,11 +67,14 @@ public class TwitterResource extends LinkedCookieResource {
}
@Override
- protected String fetchResource(OperationLog log, int indent) {
+ protected String fetchResource(OperationLog log, int indent) throws IOException, HttpStatusException,
+ JSONException {
- String authToken = getAuthToken();
-
- if (authToken == null) {
+ String authToken;
+ try {
+ authToken = getAuthToken();
+ } catch (IOException | HttpStatusException | JSONException e) {
+ log.add(LogType.MSG_LV_ERROR_TWITTER_AUTH, indent);
return null;
}
@@ -87,32 +91,19 @@ public class TwitterResource extends LinkedCookieResource {
try {
String response = getResponseBody(httpGet);
JSONObject obj = new JSONObject(response);
-
- if (!obj.has("text")) {
- return null;
- }
-
JSONObject user = obj.getJSONObject("user");
if (!mHandle.equalsIgnoreCase(user.getString("screen_name"))) {
- log.add(LogType.MSG_LV_FETCH_ERROR_FORMAT, indent);
+ log.add(LogType.MSG_LV_ERROR_TWITTER_HANDLE, indent);
return null;
}
// update the results with the body of the response
return obj.getString("text");
- } catch (HttpStatusException e) {
- // log verbose output to logcat
- Log.e(Constants.TAG, "http error (" + e.getStatus() + "): " + e.getReason());
- log.add(LogType.MSG_LV_FETCH_ERROR, indent, Integer.toString(e.getStatus()));
- } catch (IOException e) {
- Log.e(Constants.TAG, "io error", e);
- log.add(LogType.MSG_LV_FETCH_ERROR_IO, indent);
} catch (JSONException e) {
- Log.e(Constants.TAG, "json error", e);
- log.add(LogType.MSG_LV_FETCH_ERROR_FORMAT, indent);
+ log.add(LogType.MSG_LV_ERROR_TWITTER_RESPONSE, indent);
+ return null;
}
- return null;
}
@Override
@@ -148,11 +139,14 @@ public class TwitterResource extends LinkedCookieResource {
return intent;
}
- public static TwitterResource searchInTwitterStream(String screenName, String needle) {
-
- String authToken = getAuthToken();
+ public static TwitterResource searchInTwitterStream(
+ String screenName, String needle, OperationLog log) {
- if (authToken == null) {
+ String authToken;
+ try {
+ authToken = getAuthToken();
+ } catch (IOException | HttpStatusException | JSONException e) {
+ log.add(LogType.MSG_LV_ERROR_TWITTER_AUTH, 1);
return null;
}
@@ -184,46 +178,51 @@ public class TwitterResource extends LinkedCookieResource {
}
// update the results with the body of the response
+ log.add(LogType.MSG_LV_FETCH_ERROR_NOTHING, 1);
return null;
- } catch (JSONException | HttpStatusException | IOException e) {
- Log.e(Constants.TAG, "exception parsing stream", e);
+
+ } catch (HttpStatusException e) {
+ // log verbose output to logcat
+ Log.e(Constants.TAG, "http error (" + e.getStatus() + "): " + e.getReason());
+ log.add(LogType.MSG_LV_FETCH_ERROR, 1, Integer.toString(e.getStatus()));
+ } catch (MalformedURLException e) {
+ log.add(LogType.MSG_LV_FETCH_ERROR_URL, 1);
+ } catch (IOException e) {
+ Log.e(Constants.TAG, "io error", e);
+ log.add(LogType.MSG_LV_FETCH_ERROR_IO, 1);
+ } catch (JSONException e) {
+ Log.e(Constants.TAG, "json error", e);
+ log.add(LogType.MSG_LV_FETCH_ERROR_FORMAT, 1);
}
return null;
}
- private static String authToken;
+ private static String cachedAuthToken;
- private static String getAuthToken() {
- if (authToken != null) {
- return authToken;
+ private static String getAuthToken() throws IOException, HttpStatusException, JSONException {
+ if (cachedAuthToken != null) {
+ return cachedAuthToken;
}
- try {
-
- String base64Encoded = rot13("D293FQqanH0jH29KIaWJER5DomqSGRE2Ewc1LJACn3cbD1c"
- + "Fq1bmqSAQAz5MI2cIHKOuo3cPoRAQI1OyqmIVFJS6LHMXq2g6MRLkIj") + "==";
-
- // Step 2: Obtain a bearer token
- HttpPost httpPost = new HttpPost("https://api.twitter.com/oauth2/token");
- httpPost.setHeader("Authorization", "Basic " + base64Encoded);
- httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
- httpPost.setEntity(new StringEntity("grant_type=client_credentials"));
- JSONObject rawAuthorization = new JSONObject(getResponseBody(httpPost));
-
- // Applications should verify that the value associated with the
- // token_type key of the returned object is bearer
- if (!"bearer".equals(JWalk.getString(rawAuthorization, "token_type"))) {
- return null;
- }
-
- authToken = JWalk.getString(rawAuthorization, "access_token");
- return authToken;
-
- } catch (JSONException | IllegalStateException | HttpStatusException | IOException ex) {
- Log.e(Constants.TAG, "exception fetching auth token", ex);
- return null;
+ String base64Encoded = rot13("D293FQqanH0jH29KIaWJER5DomqSGRE2Ewc1LJACn3cbD1c"
+ + "Fq1bmqSAQAz5MI2cIHKOuo3cPoRAQI1OyqmIVFJS6LHMXq2g6MRLkIj") + "==";
+
+ // Step 2: Obtain a bearer token
+ HttpPost httpPost = new HttpPost("https://api.twitter.com/oauth2/token");
+ httpPost.setHeader("Authorization", "Basic " + base64Encoded);
+ httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
+ httpPost.setEntity(new StringEntity("grant_type=client_credentials"));
+ JSONObject rawAuthorization = new JSONObject(getResponseBody(httpPost));
+
+ // Applications should verify that the value associated with the
+ // token_type key of the returned object is bearer
+ if (!"bearer".equals(JWalk.getString(rawAuthorization, "token_type"))) {
+ throw new JSONException("Expected bearer token in response!");
}
+ cachedAuthToken = rawAuthorization.getString("access_token");
+ return cachedAuthToken;
+
}
public static String rot13(String input) {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateDnsStep2Fragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateDnsStep2Fragment.java
index c0e2fd29c..e8668dc90 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateDnsStep2Fragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateDnsStep2Fragment.java
@@ -31,6 +31,7 @@ import android.widget.TextView;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
+import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource;
import org.sufficientlysecure.keychain.pgp.linked.resources.DnsResource;
import org.sufficientlysecure.keychain.ui.util.Notify;
@@ -104,7 +105,7 @@ public class LinkedIdCreateDnsStep2Fragment extends LinkedIdCreateFinalFragment
}
@Override
- LinkedCookieResource getResource() {
+ LinkedCookieResource getResource(OperationLog log) {
return DnsResource.createNew(mResourceDomain);
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateFinalFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateFinalFragment.java
index 99e770857..4f10102ae 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateFinalFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateFinalFragment.java
@@ -20,6 +20,7 @@ import android.widget.ViewAnimator;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.operations.results.LinkedVerifyResult;
import org.sufficientlysecure.keychain.operations.results.OperationResult;
+import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute;
import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource;
import org.sufficientlysecure.keychain.pgp.linked.LinkedIdentity;
@@ -28,6 +29,8 @@ import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
import org.sufficientlysecure.keychain.ui.PassphraseDialogActivity;
import org.sufficientlysecure.keychain.ui.util.Notify;
+import org.sufficientlysecure.keychain.util.Passphrase;
+
public abstract class LinkedIdCreateFinalFragment extends Fragment {
@@ -95,7 +98,7 @@ public abstract class LinkedIdCreateFinalFragment extends Fragment {
return view;
}
- abstract LinkedCookieResource getResource();
+ abstract LinkedCookieResource getResource(OperationLog log);
private void setVerifyProgress(boolean on, Boolean success) {
if (success == null) {
@@ -133,7 +136,12 @@ public abstract class LinkedIdCreateFinalFragment extends Fragment {
protected LinkedVerifyResult doInBackground(Void... params) {
long timer = System.currentTimeMillis();
- LinkedCookieResource resource = getResource();
+ OperationLog log = new OperationLog();
+ LinkedCookieResource resource = getResource(log);
+ if (resource == null) {
+ return new LinkedVerifyResult(LinkedVerifyResult.RESULT_ERROR, log);
+ }
+
LinkedVerifyResult result = resource.verify(mLinkedIdWizard.mFingerprint);
// ux flow: this operation should take at last a second
@@ -178,7 +186,7 @@ public abstract class LinkedIdCreateFinalFragment extends Fragment {
}
- private void certifyLinkedIdentity (String passphrase) {
+ private void certifyLinkedIdentity (Passphrase passphrase) {
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(
getActivity(),
getString(R.string.progress_saving),
@@ -227,7 +235,7 @@ public abstract class LinkedIdCreateFinalFragment extends Fragment {
// fill values for this action
Bundle data = new Bundle();
- data.putString(KeychainIntentService.EDIT_KEYRING_PASSPHRASE, passphrase);
+ data.putParcelable(KeychainIntentService.EDIT_KEYRING_PASSPHRASE, passphrase);
data.putParcelable(KeychainIntentService.EDIT_KEYRING_PARCEL, skp);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
@@ -249,8 +257,8 @@ public abstract class LinkedIdCreateFinalFragment extends Fragment {
switch (requestCode) {
case REQUEST_CODE_PASSPHRASE:
if (resultCode == Activity.RESULT_OK && data != null) {
- String passphrase =
- data.getStringExtra(PassphraseDialogActivity.MESSAGE_DATA_PASSPHRASE);
+ Passphrase passphrase =
+ data.getParcelableExtra(PassphraseDialogActivity.MESSAGE_DATA_PASSPHRASE);
certifyLinkedIdentity(passphrase);
}
break;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubStep2Fragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubStep2Fragment.java
index 05bdf89a4..cc1052b1f 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubStep2Fragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubStep2Fragment.java
@@ -26,6 +26,7 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource;
import org.sufficientlysecure.keychain.pgp.linked.resources.GithubResource;
@@ -82,8 +83,8 @@ public class LinkedIdCreateGithubStep2Fragment extends LinkedIdCreateFinalFragme
}
@Override
- LinkedCookieResource getResource() {
- return GithubResource.searchInGithubStream(mResourceHandle, mResourceString);
+ LinkedCookieResource getResource(OperationLog log) {
+ return GithubResource.searchInGithubStream(mResourceHandle, mResourceString, log);
}
@Override
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateHttpsStep2Fragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateHttpsStep2Fragment.java
index 5559c0daf..6bb555105 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateHttpsStep2Fragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateHttpsStep2Fragment.java
@@ -30,6 +30,7 @@ import android.widget.EditText;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
import org.sufficientlysecure.keychain.pgp.linked.resources.GenericHttpsResource;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
@@ -66,7 +67,7 @@ public class LinkedIdCreateHttpsStep2Fragment extends LinkedIdCreateFinalFragmen
}
@Override
- GenericHttpsResource getResource() {
+ GenericHttpsResource getResource(OperationLog log) {
return GenericHttpsResource.createNew(mResourceUri);
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep2Fragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep2Fragment.java
index 2de9b54c9..66e86f7d4 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep2Fragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateTwitterStep2Fragment.java
@@ -27,6 +27,7 @@ import android.view.ViewGroup;
import android.widget.EditText;
import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource;
import org.sufficientlysecure.keychain.pgp.linked.resources.TwitterResource;
@@ -82,8 +83,8 @@ public class LinkedIdCreateTwitterStep2Fragment extends LinkedIdCreateFinalFragm
}
@Override
- LinkedCookieResource getResource() {
- return TwitterResource.searchInTwitterStream(mResourceHandle, mResourceString);
+ LinkedCookieResource getResource(OperationLog log) {
+ return TwitterResource.searchInTwitterStream(mResourceHandle, mResourceString, log);
}
@Override
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdViewFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdViewFragment.java
index 41d0178a3..4a3c6f4d0 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdViewFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdViewFragment.java
@@ -133,7 +133,7 @@ public class LinkedIdViewFragment extends Fragment implements
case LOADER_ID_LINKED_ID:
if (!cursor.moveToFirst()) {
- Notify.createNotify(getActivity(), "Error loading identity!",
+ Notify.create(getActivity(), "Error loading identity!",
Notify.LENGTH_LONG, Style.ERROR).show();
finishFragment();
break;