mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
ensuring code style is preserved
This commit is contained in:
parent
7fd3ccd332
commit
66350d7be3
@ -63,11 +63,11 @@ public class CloudSearch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// wait for either all the searches to come back, or 10 seconds. If using proxy, wait 30 seconds.
|
// wait for either all the searches to come back, or 10 seconds. If using proxy, wait 30 seconds.
|
||||||
synchronized(results) {
|
synchronized (results) {
|
||||||
try {
|
try {
|
||||||
if (proxy != null) {
|
if (proxy != null) {
|
||||||
results.wait(30 * SECONDS);
|
results.wait(30 * SECONDS);
|
||||||
} else{
|
} else {
|
||||||
results.wait(10 * SECONDS);
|
results.wait(10 * SECONDS);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@ -75,7 +75,7 @@ public class CloudSearch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (results.outstandingSuppliers() > 0) {
|
if (results.outstandingSuppliers() > 0) {
|
||||||
String message = "Launched " + servers.size() + " cloud searchers, but " +
|
String message = "Launched " + servers.size() + " cloud searchers, but " +
|
||||||
results.outstandingSuppliers() + " failed to complete.";
|
results.outstandingSuppliers() + " failed to complete.";
|
||||||
problems.add(new Keyserver.QueryFailedException(message));
|
problems.add(new Keyserver.QueryFailedException(message));
|
||||||
}
|
}
|
||||||
|
@ -18,20 +18,23 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.keyimport;
|
package org.sufficientlysecure.keychain.keyimport;
|
||||||
|
|
||||||
import com.squareup.okhttp.*;
|
import com.squareup.okhttp.MediaType;
|
||||||
import okio.BufferedSink;
|
import com.squareup.okhttp.OkHttpClient;
|
||||||
|
import com.squareup.okhttp.Request;
|
||||||
|
import com.squareup.okhttp.RequestBody;
|
||||||
|
import com.squareup.okhttp.Response;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.sufficientlysecure.keychain.util.TlsHelper;
|
import org.sufficientlysecure.keychain.util.TlsHelper;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.*;
|
import java.net.Proxy;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -197,7 +200,7 @@ public class HkpKeyserver extends Keyserver {
|
|||||||
* @param proxy
|
* @param proxy
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static OkHttpClient getClient(URL url, Proxy proxy) throws IOException {
|
public static OkHttpClient getClient(URL url, Proxy proxy) throws IOException {
|
||||||
OkHttpClient client = new OkHttpClient();
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -222,8 +225,6 @@ public class HkpKeyserver extends Keyserver {
|
|||||||
OkHttpClient client = getClient(url, proxy);
|
OkHttpClient client = getClient(url, proxy);
|
||||||
Response response = client.newCall(new Request.Builder().url(url).build()).execute();
|
Response response = client.newCall(new Request.Builder().url(url).build()).execute();
|
||||||
|
|
||||||
tempIpTest(proxy);
|
|
||||||
|
|
||||||
String responseBody = response.body().string();// contains body both in case of success or failure
|
String responseBody = response.body().string();// contains body both in case of success or failure
|
||||||
|
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
@ -237,12 +238,6 @@ public class HkpKeyserver extends Keyserver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tempIpTest(Proxy proxy) throws IOException {
|
|
||||||
URL url = new URL("https://wtfismyip.com/text");
|
|
||||||
Response response = getClient(url, proxy).newCall(new Request.Builder().url(url).build()).execute();
|
|
||||||
Log.e("PHILIP", "proxy Test: " + response.body().string());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Results are sorted by creation date of key!
|
* Results are sorted by creation date of key!
|
||||||
*
|
*
|
||||||
@ -388,8 +383,6 @@ public class HkpKeyserver extends Keyserver {
|
|||||||
|
|
||||||
RequestBody body = RequestBody.create(MediaType.parse("application/x-www-form-urlencoded"), params);
|
RequestBody body = RequestBody.create(MediaType.parse("application/x-www-form-urlencoded"), params);
|
||||||
|
|
||||||
Log.e("PHILIP", "Media Type charset: "+body.contentType().charset());
|
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.addHeader("Content-Type", "application/x-www-form-urlencoded")
|
.addHeader("Content-Type", "application/x-www-form-urlencoded")
|
||||||
@ -397,12 +390,11 @@ public class HkpKeyserver extends Keyserver {
|
|||||||
.post(body)
|
.post(body)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Response response = getClient(url, proxy).newCall(request).execute();
|
Response response = getClient(url, proxy).newCall(request).execute();
|
||||||
|
|
||||||
Log.d(Constants.TAG, "response code: " + response.code());
|
Log.d(Constants.TAG, "response code: " + response.code());
|
||||||
Log.d(Constants.TAG, "answer: " + response.body().string());
|
Log.d(Constants.TAG, "answer: " + response.body().string());
|
||||||
|
|
||||||
tempIpTest(proxy);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(Constants.TAG, "IOException", e);
|
Log.e(Constants.TAG, "IOException", e);
|
||||||
throw new AddKeyException();
|
throw new AddKeyException();
|
||||||
|
@ -32,6 +32,7 @@ public abstract class Keyserver {
|
|||||||
public CloudSearchFailureException(String message) {
|
public CloudSearchFailureException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CloudSearchFailureException() {
|
public CloudSearchFailureException() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,9 @@ package org.sufficientlysecure.keychain.operations;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
|
||||||
import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
|
import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
|
||||||
import org.sufficientlysecure.keychain.keyimport.Keyserver.AddKeyException;
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.CertifyResult;
|
import org.sufficientlysecure.keychain.operations.results.CertifyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.ExportResult;
|
import org.sufficientlysecure.keychain.operations.results.ExportResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
|
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
|
||||||
@ -45,26 +42,25 @@ import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
|||||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.NfcSignOperationsBuilder;
|
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.NfcSignOperationsBuilder;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
|
||||||
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
||||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||||
|
|
||||||
import java.net.Proxy;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
/** An operation which implements a high level user id certification operation.
|
/**
|
||||||
*
|
* An operation which implements a high level user id certification operation.
|
||||||
|
* <p/>
|
||||||
* This operation takes a specific CertifyActionsParcel as its input. These
|
* This operation takes a specific CertifyActionsParcel as its input. These
|
||||||
* contain a masterKeyId to be used for certification, and a list of
|
* contain a masterKeyId to be used for certification, and a list of
|
||||||
* masterKeyIds and related user ids to certify.
|
* masterKeyIds and related user ids to certify.
|
||||||
*
|
*
|
||||||
* @see CertifyActionsParcel
|
* @see CertifyActionsParcel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class CertifyOperation extends BaseOperation {
|
public class CertifyOperation extends BaseOperation {
|
||||||
|
|
||||||
public CertifyOperation(Context context, ProviderHelper providerHelper, Progressable progressable, AtomicBoolean cancelled) {
|
public CertifyOperation(Context context, ProviderHelper providerHelper, Progressable progressable, AtomicBoolean
|
||||||
|
cancelled) {
|
||||||
super(context, providerHelper, progressable, cancelled);
|
super(context, providerHelper, progressable, cancelled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +171,7 @@ public class CertifyOperation extends BaseOperation {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! allRequiredInput.isEmpty()) {
|
if (!allRequiredInput.isEmpty()) {
|
||||||
log.add(LogType.MSG_CRT_NFC_RETURN, 1);
|
log.add(LogType.MSG_CRT_NFC_RETURN, 1);
|
||||||
return new CertifyResult(log, allRequiredInput.build());
|
return new CertifyResult(log, allRequiredInput.build());
|
||||||
}
|
}
|
||||||
@ -202,7 +198,8 @@ public class CertifyOperation extends BaseOperation {
|
|||||||
// Check if we were cancelled
|
// Check if we were cancelled
|
||||||
if (checkCancelled()) {
|
if (checkCancelled()) {
|
||||||
log.add(LogType.MSG_OPERATION_CANCELLED, 0);
|
log.add(LogType.MSG_OPERATION_CANCELLED, 0);
|
||||||
return new CertifyResult(CertifyResult.RESULT_CANCELLED, log, certifyOk, certifyError, uploadOk, uploadError);
|
return new CertifyResult(CertifyResult.RESULT_CANCELLED, log, certifyOk, certifyError, uploadOk,
|
||||||
|
uploadError);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.add(LogType.MSG_CRT_SAVE, 2,
|
log.add(LogType.MSG_CRT_SAVE, 2,
|
||||||
@ -243,7 +240,8 @@ public class CertifyOperation extends BaseOperation {
|
|||||||
|
|
||||||
log.add(LogType.MSG_CRT_SUCCESS, 0);
|
log.add(LogType.MSG_CRT_SUCCESS, 0);
|
||||||
if (uploadError != 0) {
|
if (uploadError != 0) {
|
||||||
return new CertifyResult(CertifyResult.RESULT_WARNINGS, log, certifyOk, certifyError, uploadOk, uploadError);
|
return new CertifyResult(CertifyResult.RESULT_WARNINGS, log, certifyOk, certifyError, uploadOk,
|
||||||
|
uploadError);
|
||||||
} else {
|
} else {
|
||||||
return new CertifyResult(CertifyResult.RESULT_OK, log, certifyOk, certifyError, uploadOk, uploadError);
|
return new CertifyResult(CertifyResult.RESULT_OK, log, certifyOk, certifyError, uploadOk, uploadError);
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,12 @@ import org.sufficientlysecure.keychain.keyimport.KeybaseKeyserver;
|
|||||||
import org.sufficientlysecure.keychain.keyimport.Keyserver;
|
import org.sufficientlysecure.keychain.keyimport.Keyserver;
|
||||||
import org.sufficientlysecure.keychain.keyimport.Keyserver.AddKeyException;
|
import org.sufficientlysecure.keychain.keyimport.Keyserver.AddKeyException;
|
||||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||||
import org.sufficientlysecure.keychain.operations.results.*;
|
import org.sufficientlysecure.keychain.operations.results.ConsolidateResult;
|
||||||
|
import org.sufficientlysecure.keychain.operations.results.ExportResult;
|
||||||
|
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
|
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
|
||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||||
@ -61,12 +64,13 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
/** An operation class which implements high level import and export
|
/**
|
||||||
|
* An operation class which implements high level import and export
|
||||||
* operations.
|
* operations.
|
||||||
*
|
* <p/>
|
||||||
* This class receives a source and/or destination of keys as input and performs
|
* This class receives a source and/or destination of keys as input and performs
|
||||||
* all steps for this import or export.
|
* all steps for this import or export.
|
||||||
*
|
* <p/>
|
||||||
* For the import operation, the only valid source is an Iterator of
|
* For the import operation, the only valid source is an Iterator of
|
||||||
* ParcelableKeyRing, each of which must contain either a single
|
* ParcelableKeyRing, each of which must contain either a single
|
||||||
* keyring encoded as bytes, or a unique reference to a keyring
|
* keyring encoded as bytes, or a unique reference to a keyring
|
||||||
@ -76,13 +80,13 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
* not include self certificates for user ids in the secret keyring. The import
|
* not include self certificates for user ids in the secret keyring. The import
|
||||||
* method here will generally import keyrings in the order given by the
|
* method here will generally import keyrings in the order given by the
|
||||||
* iterator. so this should be ensured beforehand.
|
* iterator. so this should be ensured beforehand.
|
||||||
* @see org.sufficientlysecure.keychain.ui.adapter.ImportKeysAdapter#getSelectedEntries()
|
|
||||||
*
|
*
|
||||||
|
* @see org.sufficientlysecure.keychain.ui.adapter.ImportKeysAdapter#getSelectedEntries()
|
||||||
|
* <p/>
|
||||||
* For the export operation, the input consists of a set of key ids and
|
* For the export operation, the input consists of a set of key ids and
|
||||||
* either the name of a file or an output uri to write to.
|
* either the name of a file or an output uri to write to.
|
||||||
*
|
* <p/>
|
||||||
* TODO rework uploadKeyRingToServer
|
* TODO rework uploadKeyRingToServer
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ImportExportOperation extends BaseOperation {
|
public class ImportExportOperation extends BaseOperation {
|
||||||
|
|
||||||
@ -173,8 +177,8 @@ public class ImportExportOperation extends BaseOperation {
|
|||||||
* Since the introduction of multithreaded import, we expect calling functions to handle the key sync i,e
|
* Since the introduction of multithreaded import, we expect calling functions to handle the key sync i,e
|
||||||
* ContactSyncAdapterService.requestSync()
|
* ContactSyncAdapterService.requestSync()
|
||||||
*
|
*
|
||||||
* @param entries keys to import
|
* @param entries keys to import
|
||||||
* @param num number of keys to import
|
* @param num number of keys to import
|
||||||
* @param keyServerUri contains uri of keyserver to import from, if it is an import from cloud
|
* @param keyServerUri contains uri of keyserver to import from, if it is an import from cloud
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -238,7 +242,8 @@ public class ImportExportOperation extends BaseOperation {
|
|||||||
byte[] data;
|
byte[] data;
|
||||||
// Download by fingerprint, or keyId - whichever is available
|
// Download by fingerprint, or keyId - whichever is available
|
||||||
if (entry.mExpectedFingerprint != null) {
|
if (entry.mExpectedFingerprint != null) {
|
||||||
log.add(LogType.MSG_IMPORT_FETCH_KEYSERVER, 2, "0x" + entry.mExpectedFingerprint.substring(24));
|
log.add(LogType.MSG_IMPORT_FETCH_KEYSERVER, 2, "0x" + entry.mExpectedFingerprint
|
||||||
|
.substring(24));
|
||||||
data = keyServer.get("0x" + entry.mExpectedFingerprint, proxy).getBytes();
|
data = keyServer.get("0x" + entry.mExpectedFingerprint, proxy).getBytes();
|
||||||
} else {
|
} else {
|
||||||
log.add(LogType.MSG_IMPORT_FETCH_KEYSERVER, 2, entry.mKeyIdHex);
|
log.add(LogType.MSG_IMPORT_FETCH_KEYSERVER, 2, entry.mKeyIdHex);
|
||||||
@ -316,10 +321,12 @@ public class ImportExportOperation extends BaseOperation {
|
|||||||
mProviderHelper.clearLog();
|
mProviderHelper.clearLog();
|
||||||
if (key.isSecret()) {
|
if (key.isSecret()) {
|
||||||
result = mProviderHelper.saveSecretKeyRing(key,
|
result = mProviderHelper.saveSecretKeyRing(key,
|
||||||
new ProgressScaler(mProgressable, (int)(position*progSteps), (int)((position+1)*progSteps), 100));
|
new ProgressScaler(mProgressable, (int) (position * progSteps), (int) ((position + 1) *
|
||||||
|
progSteps), 100));
|
||||||
} else {
|
} else {
|
||||||
result = mProviderHelper.savePublicKeyRing(key,
|
result = mProviderHelper.savePublicKeyRing(key,
|
||||||
new ProgressScaler(mProgressable, (int)(position*progSteps), (int)((position+1)*progSteps), 100));
|
new ProgressScaler(mProgressable, (int) (position * progSteps), (int) ((position + 1) *
|
||||||
|
progSteps), 100));
|
||||||
}
|
}
|
||||||
if (!result.success()) {
|
if (!result.success()) {
|
||||||
badKeys += 1;
|
badKeys += 1;
|
||||||
@ -390,7 +397,7 @@ public class ImportExportOperation extends BaseOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Final log entry, it's easier to do this individually
|
// Final log entry, it's easier to do this individually
|
||||||
if ( (newKeys > 0 || updatedKeys > 0) && badKeys > 0) {
|
if ((newKeys > 0 || updatedKeys > 0) && badKeys > 0) {
|
||||||
log.add(LogType.MSG_IMPORT_PARTIAL, 1);
|
log.add(LogType.MSG_IMPORT_PARTIAL, 1);
|
||||||
} else if (newKeys > 0 || updatedKeys > 0) {
|
} else if (newKeys > 0 || updatedKeys > 0) {
|
||||||
log.add(LogType.MSG_IMPORT_SUCCESS, 1);
|
log.add(LogType.MSG_IMPORT_SUCCESS, 1);
|
||||||
@ -464,7 +471,7 @@ public class ImportExportOperation extends BaseOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExportResult exportKeyRings(OperationLog log, long[] masterKeyIds, boolean exportSecret,
|
ExportResult exportKeyRings(OperationLog log, long[] masterKeyIds, boolean exportSecret,
|
||||||
OutputStream outStream) {
|
OutputStream outStream) {
|
||||||
|
|
||||||
/* TODO isn't this checked above, with the isStorageMounted call?
|
/* TODO isn't this checked above, with the isStorageMounted call?
|
||||||
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
||||||
@ -473,7 +480,7 @@ public class ImportExportOperation extends BaseOperation {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! BufferedOutputStream.class.isInstance(outStream)) {
|
if (!BufferedOutputStream.class.isInstance(outStream)) {
|
||||||
outStream = new BufferedOutputStream(outStream);
|
outStream = new BufferedOutputStream(outStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -906,7 +906,8 @@ public class ProviderHelper {
|
|||||||
// If there is a secret key, merge new data (if any) and save the key for later
|
// If there is a secret key, merge new data (if any) and save the key for later
|
||||||
CanonicalizedSecretKeyRing canSecretRing;
|
CanonicalizedSecretKeyRing canSecretRing;
|
||||||
try {
|
try {
|
||||||
UncachedKeyRing secretRing = getCanonicalizedSecretKeyRing(publicRing.getMasterKeyId()).getUncachedKeyRing();
|
UncachedKeyRing secretRing = getCanonicalizedSecretKeyRing(publicRing.getMasterKeyId())
|
||||||
|
.getUncachedKeyRing();
|
||||||
|
|
||||||
// Merge data from new public ring into secret one
|
// Merge data from new public ring into secret one
|
||||||
log(LogType.MSG_IP_MERGE_SECRET);
|
log(LogType.MSG_IP_MERGE_SECRET);
|
||||||
@ -1031,7 +1032,8 @@ public class ProviderHelper {
|
|||||||
publicRing = secretRing.extractPublicKeyRing();
|
publicRing = secretRing.extractPublicKeyRing();
|
||||||
}
|
}
|
||||||
|
|
||||||
CanonicalizedPublicKeyRing canPublicRing = (CanonicalizedPublicKeyRing) publicRing.canonicalize(mLog, mIndent);
|
CanonicalizedPublicKeyRing canPublicRing = (CanonicalizedPublicKeyRing) publicRing.canonicalize(mLog,
|
||||||
|
mIndent);
|
||||||
if (canPublicRing == null) {
|
if (canPublicRing == null) {
|
||||||
return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog, null);
|
return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog, null);
|
||||||
}
|
}
|
||||||
@ -1082,7 +1084,7 @@ public class ProviderHelper {
|
|||||||
indent += 1;
|
indent += 1;
|
||||||
|
|
||||||
final Cursor cursor = mContentResolver.query(KeyRingData.buildSecretKeyRingUri(),
|
final Cursor cursor = mContentResolver.query(KeyRingData.buildSecretKeyRingUri(),
|
||||||
new String[]{ KeyRingData.KEY_RING_DATA }, null, null, null);
|
new String[]{KeyRingData.KEY_RING_DATA}, null, null, null);
|
||||||
|
|
||||||
if (cursor == null) {
|
if (cursor == null) {
|
||||||
log.add(LogType.MSG_CON_ERROR_DB, indent);
|
log.add(LogType.MSG_CON_ERROR_DB, indent);
|
||||||
@ -1143,7 +1145,7 @@ public class ProviderHelper {
|
|||||||
|
|
||||||
final Cursor cursor = mContentResolver.query(
|
final Cursor cursor = mContentResolver.query(
|
||||||
KeyRingData.buildPublicKeyRingUri(),
|
KeyRingData.buildPublicKeyRingUri(),
|
||||||
new String[]{ KeyRingData.KEY_RING_DATA }, null, null, null);
|
new String[]{KeyRingData.KEY_RING_DATA}, null, null, null);
|
||||||
|
|
||||||
if (cursor == null) {
|
if (cursor == null) {
|
||||||
log.add(LogType.MSG_CON_ERROR_DB, indent);
|
log.add(LogType.MSG_CON_ERROR_DB, indent);
|
||||||
|
@ -22,13 +22,9 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute;
|
import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute;
|
||||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
|
||||||
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
||||||
|
|
||||||
|
|
||||||
@ -100,7 +96,7 @@ public class CertifyActionsParcel implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CertifyAction(long masterKeyId, ArrayList<String> userIds,
|
public CertifyAction(long masterKeyId, ArrayList<String> userIds,
|
||||||
ArrayList<WrappedUserAttribute> attributes) {
|
ArrayList<WrappedUserAttribute> attributes) {
|
||||||
mMasterKeyId = masterKeyId;
|
mMasterKeyId = masterKeyId;
|
||||||
mUserIds = userIds;
|
mUserIds = userIds;
|
||||||
mUserAttributes = attributes;
|
mUserAttributes = attributes;
|
||||||
|
@ -35,15 +35,11 @@ import org.spongycastle.openpgp.PGPUtil;
|
|||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
|
import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
|
||||||
import org.sufficientlysecure.keychain.keyimport.Keyserver;
|
|
||||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||||
import org.sufficientlysecure.keychain.operations.CertifyOperation;
|
|
||||||
import org.sufficientlysecure.keychain.operations.DeleteOperation;
|
import org.sufficientlysecure.keychain.operations.DeleteOperation;
|
||||||
import org.sufficientlysecure.keychain.operations.EditKeyOperation;
|
import org.sufficientlysecure.keychain.operations.EditKeyOperation;
|
||||||
import org.sufficientlysecure.keychain.operations.ImportExportOperation;
|
import org.sufficientlysecure.keychain.operations.ImportExportOperation;
|
||||||
import org.sufficientlysecure.keychain.operations.PromoteKeyOperation;
|
import org.sufficientlysecure.keychain.operations.PromoteKeyOperation;
|
||||||
import org.sufficientlysecure.keychain.operations.SignEncryptOperation;
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.CertifyResult;
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.ConsolidateResult;
|
import org.sufficientlysecure.keychain.operations.results.ConsolidateResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.DeleteResult;
|
import org.sufficientlysecure.keychain.operations.results.DeleteResult;
|
||||||
@ -52,12 +48,10 @@ import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
|||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.operations.results.PromoteKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.PromoteKeyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.SignEncryptResult;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify;
|
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel;
|
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel;
|
||||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||||
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralMsgIdException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralMsgIdException;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
|
@ -187,10 +187,12 @@ public class CertifyKeyFragment
|
|||||||
};
|
};
|
||||||
if (!OrbotHelper.isOrbotInstalled(getActivity())) {
|
if (!OrbotHelper.isOrbotInstalled(getActivity())) {
|
||||||
OrbotHelper.getInstallDialogFragmentWithThirdButton(new Messenger(ignoreTorHandler),
|
OrbotHelper.getInstallDialogFragmentWithThirdButton(new Messenger(ignoreTorHandler),
|
||||||
R.string.orbot_install_dialog_ignore_tor).show(getActivity().getSupportFragmentManager(), "installOrbot");
|
R.string.orbot_install_dialog_ignore_tor).show(getActivity()
|
||||||
|
.getSupportFragmentManager(), "installOrbot");
|
||||||
} else if (!OrbotHelper.isOrbotRunning()) {
|
} else if (!OrbotHelper.isOrbotRunning()) {
|
||||||
OrbotHelper.getOrbotStartDialogFragment(new Messenger(ignoreTorHandler),
|
OrbotHelper.getOrbotStartDialogFragment(new Messenger(ignoreTorHandler),
|
||||||
R.string.orbot_install_dialog_ignore_tor).show(getActivity().getSupportFragmentManager(), "startOrbot");
|
R.string.orbot_install_dialog_ignore_tor).show(getActivity()
|
||||||
|
.getSupportFragmentManager(), "startOrbot");
|
||||||
} else {
|
} else {
|
||||||
cryptoOperation();
|
cryptoOperation();
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ public class CreateKeyYubiKeyImportFragment extends Fragment implements NfcListe
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if(OrbotHelper.isOrbotInRequiredState(R.string.orbot_ignore_tor, ignoreTor, proxyPrefs,
|
if (OrbotHelper.isOrbotInRequiredState(R.string.orbot_ignore_tor, ignoreTor, proxyPrefs,
|
||||||
getActivity())) {
|
getActivity())) {
|
||||||
importKey(proxyPrefs.parcelableProxy);
|
importKey(proxyPrefs.parcelableProxy);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,6 @@ import org.sufficientlysecure.keychain.util.Preferences;
|
|||||||
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Proxy;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ImportKeysActivity extends BaseNfcActivity {
|
public class ImportKeysActivity extends BaseNfcActivity {
|
||||||
@ -317,7 +316,8 @@ public class ImportKeysActivity extends BaseNfcActivity {
|
|||||||
* specified in user preferences
|
* specified in user preferences
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void startCloudFragment(Bundle savedInstanceState, String query, boolean disableQueryEdit, String keyserver) {
|
private void startCloudFragment(Bundle savedInstanceState, String query, boolean disableQueryEdit, String
|
||||||
|
keyserver) {
|
||||||
// However, if we're being restored from a previous state,
|
// However, if we're being restored from a previous state,
|
||||||
// then we don't need to do anything and should return or else
|
// then we don't need to do anything and should return or else
|
||||||
// we could end up with overlapping fragments.
|
// we could end up with overlapping fragments.
|
||||||
|
@ -71,12 +71,16 @@ import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment;
|
|||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.KeyAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.KeyAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
import org.sufficientlysecure.keychain.util.*;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.util.ExportHelper;
|
||||||
|
import org.sufficientlysecure.keychain.util.FabContainer;
|
||||||
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
||||||
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
||||||
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
|
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
|
||||||
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
||||||
@ -464,7 +468,7 @@ public class KeyListFragment extends LoaderFragment
|
|||||||
|
|
||||||
case R.id.menu_key_list_update_all_keys:
|
case R.id.menu_key_list_update_all_keys:
|
||||||
final Preferences.ProxyPrefs proxyPrefs = Preferences.getPreferences(getActivity())
|
final Preferences.ProxyPrefs proxyPrefs = Preferences.getPreferences(getActivity())
|
||||||
.getProxyPrefs();
|
.getProxyPrefs();
|
||||||
Runnable ignoreTor = new Runnable() {
|
Runnable ignoreTor = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -68,7 +68,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
String action = getIntent().getAction();
|
String action = getIntent().getAction();
|
||||||
if (action == null) return;
|
if (action == null) return;
|
||||||
|
|
||||||
switch(action) {
|
switch (action) {
|
||||||
case ACTION_PREFS_CLOUD: {
|
case ACTION_PREFS_CLOUD: {
|
||||||
addPreferencesFromResource(R.xml.cloud_search_prefs);
|
addPreferencesFromResource(R.xml.cloud_search_prefs);
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Preference automaticallyFindPreference(String key) {
|
public Preference automaticallyFindPreference(String key) {
|
||||||
if(mFragment != null) {
|
if (mFragment != null) {
|
||||||
return mFragment.findPreference(key);
|
return mFragment.findPreference(key);
|
||||||
} else {
|
} else {
|
||||||
return mActivity.findPreference(key);
|
return mActivity.findPreference(key);
|
||||||
@ -333,8 +333,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
Preferences.setPreferenceManagerFileAndMode(mFragment.getPreferenceManager());
|
Preferences.setPreferenceManagerFileAndMode(mFragment.getPreferenceManager());
|
||||||
// Load the preferences from an XML resource
|
// Load the preferences from an XML resource
|
||||||
mFragment.addPreferencesFromResource(R.xml.proxy_prefs);
|
mFragment.addPreferencesFromResource(R.xml.proxy_prefs);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Preferences.setPreferenceManagerFileAndMode(mActivity.getPreferenceManager());
|
Preferences.setPreferenceManagerFileAndMode(mActivity.getPreferenceManager());
|
||||||
// Load the preferences from an XML resource
|
// Load the preferences from an XML resource
|
||||||
mActivity.addPreferencesFromResource(R.xml.proxy_prefs);
|
mActivity.addPreferencesFromResource(R.xml.proxy_prefs);
|
||||||
@ -359,7 +358,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
Activity activity = mFragment != null ? mFragment.getActivity() : mActivity;
|
Activity activity = mFragment != null ? mFragment.getActivity() : mActivity;
|
||||||
if ((Boolean)newValue) {
|
if ((Boolean) newValue) {
|
||||||
boolean installed = OrbotHelper.isOrbotInstalled(activity);
|
boolean installed = OrbotHelper.isOrbotInstalled(activity);
|
||||||
if (!installed) {
|
if (!installed) {
|
||||||
Log.d(Constants.TAG, "Prompting to install Tor");
|
Log.d(Constants.TAG, "Prompting to install Tor");
|
||||||
@ -372,8 +371,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
// let the enable tor box be checked
|
// let the enable tor box be checked
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// we're unchecking Tor, so enable other proxy
|
// we're unchecking Tor, so enable other proxy
|
||||||
enableNormalProxyPrefs();
|
enableNormalProxyPrefs();
|
||||||
return true;
|
return true;
|
||||||
@ -424,7 +422,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
Activity activity = mFragment != null ? mFragment.getActivity() : mActivity;
|
Activity activity = mFragment != null ? mFragment.getActivity() : mActivity;
|
||||||
try {
|
try {
|
||||||
int port = Integer.parseInt((String) newValue);
|
int port = Integer.parseInt((String) newValue);
|
||||||
if(port < 0 || port > 65535) {
|
if (port < 0 || port > 65535) {
|
||||||
Notify.create(
|
Notify.create(
|
||||||
activity,
|
activity,
|
||||||
R.string.pref_proxy_port_err_invalid,
|
R.string.pref_proxy_port_err_invalid,
|
||||||
|
@ -53,7 +53,6 @@ import android.widget.RelativeLayout;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import com.getbase.floatingactionbutton.FloatingActionButton;
|
import com.getbase.floatingactionbutton.FloatingActionButton;
|
||||||
import edu.cmu.cylab.starslinger.exchange.ExchangeActivity;
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||||
@ -79,7 +78,12 @@ import org.sufficientlysecure.keychain.ui.util.Notify;
|
|||||||
import org.sufficientlysecure.keychain.ui.util.Notify.ActionListener;
|
import org.sufficientlysecure.keychain.ui.util.Notify.ActionListener;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
||||||
import org.sufficientlysecure.keychain.ui.util.QrCodeUtils;
|
import org.sufficientlysecure.keychain.ui.util.QrCodeUtils;
|
||||||
import org.sufficientlysecure.keychain.util.*;
|
import org.sufficientlysecure.keychain.util.ContactHelper;
|
||||||
|
import org.sufficientlysecure.keychain.util.ExportHelper;
|
||||||
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
import org.sufficientlysecure.keychain.util.NfcHelper;
|
||||||
|
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
||||||
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -409,7 +413,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
|||||||
|
|
||||||
private void certifyImmediate() {
|
private void certifyImmediate() {
|
||||||
Intent intent = new Intent(this, CertifyKeyActivity.class);
|
Intent intent = new Intent(this, CertifyKeyActivity.class);
|
||||||
intent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, new long[] {mMasterKeyId});
|
intent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, new long[]{mMasterKeyId});
|
||||||
|
|
||||||
startCertifyIntent(intent);
|
startCertifyIntent(intent);
|
||||||
}
|
}
|
||||||
@ -465,11 +469,11 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
|||||||
|
|
||||||
HashMap<String, Object> data = providerHelper.getGenericData(
|
HashMap<String, Object> data = providerHelper.getGenericData(
|
||||||
baseUri,
|
baseUri,
|
||||||
new String[] {KeychainContract.Keys.MASTER_KEY_ID, KeychainContract.KeyRings.HAS_SECRET},
|
new String[]{KeychainContract.Keys.MASTER_KEY_ID, KeychainContract.KeyRings.HAS_SECRET},
|
||||||
new int[] {ProviderHelper.FIELD_TYPE_INTEGER, ProviderHelper.FIELD_TYPE_INTEGER});
|
new int[]{ProviderHelper.FIELD_TYPE_INTEGER, ProviderHelper.FIELD_TYPE_INTEGER});
|
||||||
|
|
||||||
exportHelper.showExportKeysDialog(
|
exportHelper.showExportKeysDialog(
|
||||||
new long[] {(Long) data.get(KeychainContract.KeyRings.MASTER_KEY_ID)},
|
new long[]{(Long) data.get(KeychainContract.KeyRings.MASTER_KEY_ID)},
|
||||||
Constants.Path.APP_DIR_FILE, ((Long) data.get(KeychainContract.KeyRings.HAS_SECRET) != 0)
|
Constants.Path.APP_DIR_FILE, ((Long) data.get(KeychainContract.KeyRings.HAS_SECRET) != 0)
|
||||||
);
|
);
|
||||||
} catch (ProviderHelper.NotFoundException e) {
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
@ -493,7 +497,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
|||||||
// Create a new Messenger for the communication back
|
// Create a new Messenger for the communication back
|
||||||
Messenger messenger = new Messenger(returnHandler);
|
Messenger messenger = new Messenger(returnHandler);
|
||||||
DeleteKeyDialogFragment deleteKeyDialog = DeleteKeyDialogFragment.newInstance(messenger,
|
DeleteKeyDialogFragment deleteKeyDialog = DeleteKeyDialogFragment.newInstance(messenger,
|
||||||
new long[] {mMasterKeyId});
|
new long[]{mMasterKeyId});
|
||||||
deleteKeyDialog.show(getSupportFragmentManager(), "deleteKeyDialog");
|
deleteKeyDialog.show(getSupportFragmentManager(), "deleteKeyDialog");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -630,7 +634,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
|||||||
long keyId = new ProviderHelper(this)
|
long keyId = new ProviderHelper(this)
|
||||||
.getCachedPublicKeyRing(dataUri)
|
.getCachedPublicKeyRing(dataUri)
|
||||||
.extractOrGetMasterKeyId();
|
.extractOrGetMasterKeyId();
|
||||||
long[] encryptionKeyIds = new long[] {keyId};
|
long[] encryptionKeyIds = new long[]{keyId};
|
||||||
Intent intent;
|
Intent intent;
|
||||||
if (text) {
|
if (text) {
|
||||||
intent = new Intent(this, EncryptTextActivity.class);
|
intent = new Intent(this, EncryptTextActivity.class);
|
||||||
@ -774,7 +778,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
|||||||
|
|
||||||
|
|
||||||
// These are the rows that we will retrieve.
|
// These are the rows that we will retrieve.
|
||||||
static final String[] PROJECTION = new String[] {
|
static final String[] PROJECTION = new String[]{
|
||||||
KeychainContract.KeyRings._ID,
|
KeychainContract.KeyRings._ID,
|
||||||
KeychainContract.KeyRings.MASTER_KEY_ID,
|
KeychainContract.KeyRings.MASTER_KEY_ID,
|
||||||
KeychainContract.KeyRings.USER_ID,
|
KeychainContract.KeyRings.USER_ID,
|
||||||
@ -862,7 +866,8 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
|||||||
AsyncTask<Long, Void, Bitmap> photoTask =
|
AsyncTask<Long, Void, Bitmap> photoTask =
|
||||||
new AsyncTask<Long, Void, Bitmap>() {
|
new AsyncTask<Long, Void, Bitmap>() {
|
||||||
protected Bitmap doInBackground(Long... mMasterKeyId) {
|
protected Bitmap doInBackground(Long... mMasterKeyId) {
|
||||||
return ContactHelper.loadPhotoByMasterKeyId(getContentResolver(), mMasterKeyId[0], true);
|
return ContactHelper.loadPhotoByMasterKeyId(getContentResolver(),
|
||||||
|
mMasterKeyId[0], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onPostExecute(Bitmap photo) {
|
protected void onPostExecute(Bitmap photo) {
|
||||||
|
@ -57,7 +57,6 @@ import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
|||||||
import org.sufficientlysecure.keychain.util.Preferences;
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
||||||
|
|
||||||
import java.net.Proxy;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -194,7 +193,8 @@ public class ViewKeyTrustFragment extends LoaderFragment implements
|
|||||||
mStartSearch.setOnClickListener(new View.OnClickListener() {
|
mStartSearch.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
final Preferences.ProxyPrefs proxyPrefs = Preferences.getPreferences(getActivity()).getProxyPrefs();
|
final Preferences.ProxyPrefs proxyPrefs = Preferences.getPreferences(getActivity())
|
||||||
|
.getProxyPrefs();
|
||||||
|
|
||||||
Runnable ignoreTor = new Runnable() {
|
Runnable ignoreTor = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -283,11 +283,13 @@ public class ViewKeyTrustFragment extends LoaderFragment implements
|
|||||||
return new ResultPage(getString(R.string.key_trust_results_prefix), proofList);
|
return new ResultPage(getString(R.string.key_trust_results_prefix), proofList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SpannableStringBuilder appendProofLinks(SpannableStringBuilder ssb, final String fingerprint, final Proof proof) throws KeybaseException {
|
private SpannableStringBuilder appendProofLinks(SpannableStringBuilder ssb, final String fingerprint, final
|
||||||
|
Proof proof) throws KeybaseException {
|
||||||
int startAt = ssb.length();
|
int startAt = ssb.length();
|
||||||
String handle = proof.getHandle();
|
String handle = proof.getHandle();
|
||||||
ssb.append(handle);
|
ssb.append(handle);
|
||||||
ssb.setSpan(new URLSpan(proof.getServiceUrl()), startAt, startAt + handle.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
ssb.setSpan(new URLSpan(proof.getServiceUrl()), startAt, startAt + handle.length(), Spanned
|
||||||
|
.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
if (haveProofFor(proof.getType())) {
|
if (haveProofFor(proof.getType())) {
|
||||||
ssb.append("\u00a0[");
|
ssb.append("\u00a0[");
|
||||||
startAt = ssb.length();
|
startAt = ssb.length();
|
||||||
@ -296,7 +298,8 @@ public class ViewKeyTrustFragment extends LoaderFragment implements
|
|||||||
ClickableSpan clicker = new ClickableSpan() {
|
ClickableSpan clicker = new ClickableSpan() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
final Preferences.ProxyPrefs proxyPrefs = Preferences.getPreferences(getActivity()).getProxyPrefs();
|
final Preferences.ProxyPrefs proxyPrefs = Preferences.getPreferences(getActivity())
|
||||||
|
.getProxyPrefs();
|
||||||
|
|
||||||
Runnable ignoreTor = new Runnable() {
|
Runnable ignoreTor = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -349,19 +352,35 @@ public class ViewKeyTrustFragment extends LoaderFragment implements
|
|||||||
private String getProofNarrative(int proofType) {
|
private String getProofNarrative(int proofType) {
|
||||||
int stringIndex;
|
int stringIndex;
|
||||||
switch (proofType) {
|
switch (proofType) {
|
||||||
case Proof.PROOF_TYPE_TWITTER: stringIndex = R.string.keybase_narrative_twitter; break;
|
case Proof.PROOF_TYPE_TWITTER:
|
||||||
case Proof.PROOF_TYPE_GITHUB: stringIndex = R.string.keybase_narrative_github; break;
|
stringIndex = R.string.keybase_narrative_twitter;
|
||||||
case Proof.PROOF_TYPE_DNS: stringIndex = R.string.keybase_narrative_dns; break;
|
break;
|
||||||
case Proof.PROOF_TYPE_WEB_SITE: stringIndex = R.string.keybase_narrative_web_site; break;
|
case Proof.PROOF_TYPE_GITHUB:
|
||||||
case Proof.PROOF_TYPE_HACKERNEWS: stringIndex = R.string.keybase_narrative_hackernews; break;
|
stringIndex = R.string.keybase_narrative_github;
|
||||||
case Proof.PROOF_TYPE_COINBASE: stringIndex = R.string.keybase_narrative_coinbase; break;
|
break;
|
||||||
case Proof.PROOF_TYPE_REDDIT: stringIndex = R.string.keybase_narrative_reddit; break;
|
case Proof.PROOF_TYPE_DNS:
|
||||||
default: stringIndex = R.string.keybase_narrative_unknown;
|
stringIndex = R.string.keybase_narrative_dns;
|
||||||
|
break;
|
||||||
|
case Proof.PROOF_TYPE_WEB_SITE:
|
||||||
|
stringIndex = R.string.keybase_narrative_web_site;
|
||||||
|
break;
|
||||||
|
case Proof.PROOF_TYPE_HACKERNEWS:
|
||||||
|
stringIndex = R.string.keybase_narrative_hackernews;
|
||||||
|
break;
|
||||||
|
case Proof.PROOF_TYPE_COINBASE:
|
||||||
|
stringIndex = R.string.keybase_narrative_coinbase;
|
||||||
|
break;
|
||||||
|
case Proof.PROOF_TYPE_REDDIT:
|
||||||
|
stringIndex = R.string.keybase_narrative_reddit;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
stringIndex = R.string.keybase_narrative_unknown;
|
||||||
}
|
}
|
||||||
return getActivity().getString(stringIndex);
|
return getActivity().getString(stringIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendIfOK(Hashtable<Integer, ArrayList<Proof>> table, Integer proofType, Proof proof) throws KeybaseException {
|
private void appendIfOK(Hashtable<Integer, ArrayList<Proof>> table, Integer proofType, Proof proof) throws
|
||||||
|
KeybaseException {
|
||||||
ArrayList<Proof> list = table.get(proofType);
|
ArrayList<Proof> list = table.get(proofType);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = new ArrayList<Proof>();
|
list = new ArrayList<Proof>();
|
||||||
@ -373,14 +392,22 @@ public class ViewKeyTrustFragment extends LoaderFragment implements
|
|||||||
// which proofs do we have working verifiers for?
|
// which proofs do we have working verifiers for?
|
||||||
private boolean haveProofFor(int proofType) {
|
private boolean haveProofFor(int proofType) {
|
||||||
switch (proofType) {
|
switch (proofType) {
|
||||||
case Proof.PROOF_TYPE_TWITTER: return true;
|
case Proof.PROOF_TYPE_TWITTER:
|
||||||
case Proof.PROOF_TYPE_GITHUB: return true;
|
return true;
|
||||||
case Proof.PROOF_TYPE_DNS: return true;
|
case Proof.PROOF_TYPE_GITHUB:
|
||||||
case Proof.PROOF_TYPE_WEB_SITE: return true;
|
return true;
|
||||||
case Proof.PROOF_TYPE_HACKERNEWS: return true;
|
case Proof.PROOF_TYPE_DNS:
|
||||||
case Proof.PROOF_TYPE_COINBASE: return true;
|
return true;
|
||||||
case Proof.PROOF_TYPE_REDDIT: return true;
|
case Proof.PROOF_TYPE_WEB_SITE:
|
||||||
default: return false;
|
return true;
|
||||||
|
case Proof.PROOF_TYPE_HACKERNEWS:
|
||||||
|
return true;
|
||||||
|
case Proof.PROOF_TYPE_COINBASE:
|
||||||
|
return true;
|
||||||
|
case Proof.PROOF_TYPE_REDDIT:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +474,8 @@ public class ViewKeyTrustFragment extends LoaderFragment implements
|
|||||||
ssb.append(proofLabel);
|
ssb.append(proofLabel);
|
||||||
if (proofUrl != null) {
|
if (proofUrl != null) {
|
||||||
URLSpan postLink = new URLSpan(proofUrl);
|
URLSpan postLink = new URLSpan(proofUrl);
|
||||||
ssb.setSpan(postLink, length, length + proofLabel.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
ssb.setSpan(postLink, length, length + proofLabel.length(), Spanned
|
||||||
|
.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
}
|
}
|
||||||
if (Proof.PROOF_TYPE_DNS == proof.getType()) {
|
if (Proof.PROOF_TYPE_DNS == proof.getType()) {
|
||||||
ssb.append(" ").append(getString(R.string.keybase_for_the_domain)).append(" ");
|
ssb.append(" ").append(getString(R.string.keybase_for_the_domain)).append(" ");
|
||||||
@ -457,7 +485,8 @@ public class ViewKeyTrustFragment extends LoaderFragment implements
|
|||||||
length = ssb.length();
|
length = ssb.length();
|
||||||
URLSpan presenceLink = new URLSpan(presenceUrl);
|
URLSpan presenceLink = new URLSpan(presenceUrl);
|
||||||
ssb.append(presenceLabel);
|
ssb.append(presenceLabel);
|
||||||
ssb.setSpan(presenceLink, length, length + presenceLabel.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
ssb.setSpan(presenceLink, length, length + presenceLabel.length(), Spanned
|
||||||
|
.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
if (Proof.PROOF_TYPE_REDDIT == proof.getType()) {
|
if (Proof.PROOF_TYPE_REDDIT == proof.getType()) {
|
||||||
ssb.append(", ").
|
ssb.append(", ").
|
||||||
append(getString(R.string.keybase_reddit_attribution)).
|
append(getString(R.string.keybase_reddit_attribution)).
|
||||||
|
@ -30,7 +30,6 @@ import org.sufficientlysecure.keychain.util.Log;
|
|||||||
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
||||||
import org.sufficientlysecure.keychain.util.Preferences;
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
|
|
||||||
import java.net.Proxy;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ImportKeysListCloudLoader
|
public class ImportKeysListCloudLoader
|
||||||
|
@ -30,7 +30,6 @@ import android.os.Message;
|
|||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.test.suitebuilder.TestSuiteBuilder;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -48,15 +47,15 @@ import org.sufficientlysecure.keychain.Constants;
|
|||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
|
import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
|
||||||
import org.sufficientlysecure.keychain.util.Preferences;
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
import org.sufficientlysecure.keychain.util.TlsHelper;
|
import org.sufficientlysecure.keychain.util.TlsHelper;
|
||||||
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.*;
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.Proxy;
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
public class AddKeyserverDialogFragment extends DialogFragment implements OnEditorActionListener {
|
public class AddKeyserverDialogFragment extends DialogFragment implements OnEditorActionListener {
|
||||||
private static final String ARG_MESSENGER = "messenger";
|
private static final String ARG_MESSENGER = "messenger";
|
||||||
|
@ -48,15 +48,16 @@ public class InstallDialogFragment extends DialogFragment {
|
|||||||
* Creates a dialog which prompts the user to install an application. Consists of two default buttons ("Install"
|
* Creates a dialog which prompts the user to install an application. Consists of two default buttons ("Install"
|
||||||
* and "Cancel") and an optional third button. Callbacks are provided only for the middle button, if set.
|
* and "Cancel") and an optional third button. Callbacks are provided only for the middle button, if set.
|
||||||
*
|
*
|
||||||
* @param messenger required only for callback from middle button if it has been set
|
* @param messenger required only for callback from middle button if it has been set
|
||||||
* @param title
|
* @param title
|
||||||
* @param message content of dialog
|
* @param message content of dialog
|
||||||
* @param packageToInstall package name of application to install
|
* @param packageToInstall package name of application to install
|
||||||
* @param middleButton if not null, adds a third button to the app with a call back
|
* @param middleButton if not null, adds a third button to the app with a call back
|
||||||
* @return The dialog to display
|
* @return The dialog to display
|
||||||
*/
|
*/
|
||||||
public static InstallDialogFragment newInstance(Messenger messenger, int title, int message,
|
public static InstallDialogFragment newInstance(Messenger messenger, int title, int message,
|
||||||
String packageToInstall, int middleButton, boolean useMiddleButton) {
|
String packageToInstall, int middleButton, boolean
|
||||||
|
useMiddleButton) {
|
||||||
InstallDialogFragment frag = new InstallDialogFragment();
|
InstallDialogFragment frag = new InstallDialogFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putParcelable(ARG_MESSENGER, messenger);
|
args.putParcelable(ARG_MESSENGER, messenger);
|
||||||
@ -125,7 +126,7 @@ public class InstallDialogFragment extends DialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
Message msg = new Message();
|
Message msg = new Message();
|
||||||
msg.what=MESSAGE_MIDDLE_CLICKED;
|
msg.what = MESSAGE_MIDDLE_CLICKED;
|
||||||
try {
|
try {
|
||||||
messenger.send(msg);
|
messenger.send(msg);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
@ -25,6 +25,7 @@ import android.os.Message;
|
|||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
@ -27,6 +27,7 @@ import android.os.Message;
|
|||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.app.DialogFragment;
|
import android.app.DialogFragment;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
@ -47,15 +48,16 @@ public class PreferenceInstallDialogFragment extends DialogFragment {
|
|||||||
* Creates a dialog which prompts the user to install an application. Consists of two default buttons ("Install"
|
* Creates a dialog which prompts the user to install an application. Consists of two default buttons ("Install"
|
||||||
* and "Cancel") and an optional third button. Callbacks are provided only for the middle button, if set.
|
* and "Cancel") and an optional third button. Callbacks are provided only for the middle button, if set.
|
||||||
*
|
*
|
||||||
* @param messenger required only for callback from middle button if it has been set
|
* @param messenger required only for callback from middle button if it has been set
|
||||||
* @param title
|
* @param title
|
||||||
* @param message content of dialog
|
* @param message content of dialog
|
||||||
* @param packageToInstall package name of application to install
|
* @param packageToInstall package name of application to install
|
||||||
* @param middleButton if not null, adds a third button to the app with a call back
|
* @param middleButton if not null, adds a third button to the app with a call back
|
||||||
* @return The dialog to display
|
* @return The dialog to display
|
||||||
*/
|
*/
|
||||||
public static PreferenceInstallDialogFragment newInstance(Messenger messenger, int title, int message,
|
public static PreferenceInstallDialogFragment newInstance(Messenger messenger, int title, int message,
|
||||||
String packageToInstall, int middleButton, boolean useMiddleButton) {
|
String packageToInstall, int middleButton, boolean
|
||||||
|
useMiddleButton) {
|
||||||
PreferenceInstallDialogFragment frag = new PreferenceInstallDialogFragment();
|
PreferenceInstallDialogFragment frag = new PreferenceInstallDialogFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putParcelable(ARG_MESSENGER, messenger);
|
args.putParcelable(ARG_MESSENGER, messenger);
|
||||||
@ -80,7 +82,7 @@ public class PreferenceInstallDialogFragment extends DialogFragment {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static PreferenceInstallDialogFragment newInstance(int title, int message,
|
public static PreferenceInstallDialogFragment newInstance(int title, int message,
|
||||||
String packageToInstall) {
|
String packageToInstall) {
|
||||||
return newInstance(null, title, message, packageToInstall, -1, false);
|
return newInstance(null, title, message, packageToInstall, -1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +127,7 @@ public class PreferenceInstallDialogFragment extends DialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
Message msg = new Message();
|
Message msg = new Message();
|
||||||
msg.what=MESSAGE_MIDDLE_CLICKED;
|
msg.what = MESSAGE_MIDDLE_CLICKED;
|
||||||
try {
|
try {
|
||||||
messenger.send(msg);
|
messenger.send(msg);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
@ -54,7 +54,7 @@ public class ParcelableProxy implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Proxy getProxy() {
|
public Proxy getProxy() {
|
||||||
if(mProxyHost == null) return null;
|
if (mProxyHost == null) return null;
|
||||||
|
|
||||||
Proxy.Type type = null;
|
Proxy.Type type = null;
|
||||||
switch (mProxyType) {
|
switch (mProxyType) {
|
||||||
|
@ -292,8 +292,7 @@ public class Preferences {
|
|||||||
if (useTor) {
|
if (useTor) {
|
||||||
return new ProxyPrefs(true, false, Constants.Orbot.PROXY_HOST, Constants.Orbot.PROXY_PORT,
|
return new ProxyPrefs(true, false, Constants.Orbot.PROXY_HOST, Constants.Orbot.PROXY_PORT,
|
||||||
Constants.Orbot.PROXY_TYPE);
|
Constants.Orbot.PROXY_TYPE);
|
||||||
}
|
} else if (useNormalProxy) {
|
||||||
else if (useNormalProxy) {
|
|
||||||
return new ProxyPrefs(useTor, useNormalProxy, getProxyHost(), getProxyPort(), getProxyType());
|
return new ProxyPrefs(useTor, useNormalProxy, getProxyHost(), getProxyPort(), getProxyType());
|
||||||
} else {
|
} else {
|
||||||
return new ProxyPrefs(false, false, null, -1, null);
|
return new ProxyPrefs(false, false, null, -1, null);
|
||||||
@ -314,7 +313,7 @@ public class Preferences {
|
|||||||
public ProxyPrefs(boolean torEnabled, boolean normalPorxyEnabled, String hostName, int port, Proxy.Type type) {
|
public ProxyPrefs(boolean torEnabled, boolean normalPorxyEnabled, String hostName, int port, Proxy.Type type) {
|
||||||
this.torEnabled = torEnabled;
|
this.torEnabled = torEnabled;
|
||||||
this.normalPorxyEnabled = normalPorxyEnabled;
|
this.normalPorxyEnabled = normalPorxyEnabled;
|
||||||
if(!torEnabled && !normalPorxyEnabled) this.parcelableProxy = new ParcelableProxy(null, -1, null);
|
if (!torEnabled && !normalPorxyEnabled) this.parcelableProxy = new ParcelableProxy(null, -1, null);
|
||||||
else this.parcelableProxy = new ParcelableProxy(hostName, port, type);
|
else this.parcelableProxy = new ParcelableProxy(hostName, port, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class TlsHelper {
|
|||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
int reads = is.read();
|
int reads = is.read();
|
||||||
|
|
||||||
while(reads != -1){
|
while (reads != -1) {
|
||||||
baos.write(reads);
|
baos.write(reads);
|
||||||
reads = is.read();
|
reads = is.read();
|
||||||
}
|
}
|
||||||
@ -75,17 +75,6 @@ public class TlsHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static URLConnection opeanConnection(URL url) throws IOException, TlsHelperException {
|
|
||||||
if (url.getProtocol().equals("https")) {
|
|
||||||
for (String domain : sStaticCA.keySet()) {
|
|
||||||
if (url.getHost().endsWith(domain)) {
|
|
||||||
return openCAConnection(sStaticCA.get(domain), url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return url.openConnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void pinCertificateIfNecessary(OkHttpClient client, URL url) throws TlsHelperException, IOException {
|
public static void pinCertificateIfNecessary(OkHttpClient client, URL url) throws TlsHelperException, IOException {
|
||||||
if (url.getProtocol().equals("https")) {
|
if (url.getProtocol().equals("https")) {
|
||||||
for (String domain : sStaticCA.keySet()) {
|
for (String domain : sStaticCA.keySet()) {
|
||||||
@ -103,7 +92,7 @@ public class TlsHelper {
|
|||||||
* TODO: Refactor - More like SSH StrictHostKeyChecking than pinning?
|
* TODO: Refactor - More like SSH StrictHostKeyChecking than pinning?
|
||||||
*
|
*
|
||||||
* @param certificate certificate to pin
|
* @param certificate certificate to pin
|
||||||
* @param client OkHttpClient to enforce pinning on
|
* @param client OkHttpClient to enforce pinning on
|
||||||
* @throws TlsHelperException
|
* @throws TlsHelperException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@ -77,15 +77,13 @@ public class OrbotHelper {
|
|||||||
|
|
||||||
public final static String ACTION_START_TOR = "org.torproject.android.START_TOR";
|
public final static String ACTION_START_TOR = "org.torproject.android.START_TOR";
|
||||||
|
|
||||||
public static boolean isOrbotRunning()
|
public static boolean isOrbotRunning() {
|
||||||
{
|
|
||||||
int procId = TorServiceUtils.findProcessId(TOR_BIN_PATH);
|
int procId = TorServiceUtils.findProcessId(TOR_BIN_PATH);
|
||||||
|
|
||||||
return (procId != -1);
|
return (procId != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOrbotInstalled(Context context)
|
public static boolean isOrbotInstalled(Context context) {
|
||||||
{
|
|
||||||
return isAppInstalled(ORBOT_PACKAGE_NAME, context);
|
return isAppInstalled(ORBOT_PACKAGE_NAME, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,30 +100,28 @@ public class OrbotHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hack to get around teh fact that PreferenceActivity still supports only android.app.DialogFragment
|
* hack to get around the fact that PreferenceActivity still supports only android.app.DialogFragment
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static android.app.DialogFragment getPreferenceInstallDialogFragment()
|
public static android.app.DialogFragment getPreferenceInstallDialogFragment() {
|
||||||
{
|
|
||||||
return PreferenceInstallDialogFragment.newInstance(R.string.orbot_install_dialog_title,
|
return PreferenceInstallDialogFragment.newInstance(R.string.orbot_install_dialog_title,
|
||||||
R.string.orbot_install_dialog_content, ORBOT_PACKAGE_NAME);
|
R.string.orbot_install_dialog_content, ORBOT_PACKAGE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DialogFragment getInstallDialogFragment()
|
public static DialogFragment getInstallDialogFragment() {
|
||||||
{
|
|
||||||
return InstallDialogFragment.newInstance(R.string.orbot_install_dialog_title,
|
return InstallDialogFragment.newInstance(R.string.orbot_install_dialog_title,
|
||||||
R.string.orbot_install_dialog_content, ORBOT_PACKAGE_NAME);
|
R.string.orbot_install_dialog_content, ORBOT_PACKAGE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DialogFragment getInstallDialogFragmentWithThirdButton(Messenger messenger, int middleButton)
|
public static DialogFragment getInstallDialogFragmentWithThirdButton(Messenger messenger, int middleButton) {
|
||||||
{
|
|
||||||
return InstallDialogFragment.newInstance(messenger, R.string.orbot_install_dialog_title,
|
return InstallDialogFragment.newInstance(messenger, R.string.orbot_install_dialog_title,
|
||||||
R.string.orbot_install_dialog_content, ORBOT_PACKAGE_NAME, middleButton, true);
|
R.string.orbot_install_dialog_content, ORBOT_PACKAGE_NAME, middleButton, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DialogFragment getOrbotStartDialogFragment(Messenger messenger, int middleButton) {
|
public static DialogFragment getOrbotStartDialogFragment(Messenger messenger, int middleButton) {
|
||||||
return OrbotStartDialogFragment.newInstance(messenger, R.string.orbot_start_dialog_title, R.string.orbot_start_dialog_content,
|
return OrbotStartDialogFragment.newInstance(messenger, R.string.orbot_start_dialog_title, R.string
|
||||||
|
.orbot_start_dialog_content,
|
||||||
middleButton);
|
middleButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +135,7 @@ public class OrbotHelper {
|
|||||||
/**
|
/**
|
||||||
* checks if Tor is enabled and if it is, that Orbot is installed and runnign. Generates appropriate dialogs.
|
* checks if Tor is enabled and if it is, that Orbot is installed and runnign. Generates appropriate dialogs.
|
||||||
*
|
*
|
||||||
* @param middleButton resourceId of string to display as the middle button of install and enable dialogs
|
* @param middleButton resourceId of string to display as the middle button of install and enable dialogs
|
||||||
* @param middleButtonRunnable runnable to be executed if the user clicks on the middle button
|
* @param middleButtonRunnable runnable to be executed if the user clicks on the middle button
|
||||||
* @param proxyPrefs
|
* @param proxyPrefs
|
||||||
* @param fragmentActivity
|
* @param fragmentActivity
|
||||||
@ -159,7 +155,7 @@ public class OrbotHelper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!OrbotHelper.isOrbotInstalled(fragmentActivity)) {
|
if (!OrbotHelper.isOrbotInstalled(fragmentActivity)) {
|
||||||
|
|
||||||
OrbotHelper.getInstallDialogFragmentWithThirdButton(
|
OrbotHelper.getInstallDialogFragmentWithThirdButton(
|
||||||
new Messenger(ignoreTorHandler),
|
new Messenger(ignoreTorHandler),
|
||||||
@ -167,7 +163,7 @@ public class OrbotHelper {
|
|||||||
).show(fragmentActivity.getSupportFragmentManager(), "OrbotHelperOrbotInstallDialog");
|
).show(fragmentActivity.getSupportFragmentManager(), "OrbotHelperOrbotInstallDialog");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else if(!OrbotHelper.isOrbotRunning()) {
|
} else if (!OrbotHelper.isOrbotRunning()) {
|
||||||
|
|
||||||
OrbotHelper.getOrbotStartDialogFragment(new Messenger(ignoreTorHandler),
|
OrbotHelper.getOrbotStartDialogFragment(new Messenger(ignoreTorHandler),
|
||||||
R.string.orbot_install_dialog_ignore_tor)
|
R.string.orbot_install_dialog_ignore_tor)
|
||||||
|
@ -49,14 +49,14 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.util.orbot;
|
package org.sufficientlysecure.keychain.util.orbot;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is taken from the NetCipher library: https://github.com/guardianproject/NetCipher/
|
* This class is taken from the NetCipher library: https://github.com/guardianproject/NetCipher/
|
||||||
*/
|
*/
|
||||||
@ -68,23 +68,18 @@ public class TorServiceUtils {
|
|||||||
public final static String SHELL_CMD_PS = "ps";
|
public final static String SHELL_CMD_PS = "ps";
|
||||||
public final static String SHELL_CMD_PIDOF = "pidof";
|
public final static String SHELL_CMD_PIDOF = "pidof";
|
||||||
|
|
||||||
public static int findProcessId(String command)
|
public static int findProcessId(String command) {
|
||||||
{
|
|
||||||
int procId = -1;
|
int procId = -1;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
procId = findProcessIdWithPidOf(command);
|
procId = findProcessIdWithPidOf(command);
|
||||||
|
|
||||||
if (procId == -1)
|
if (procId == -1)
|
||||||
procId = findProcessIdWithPS(command);
|
procId = findProcessIdWithPS(command);
|
||||||
} catch (Exception e)
|
} catch (Exception e) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
procId = findProcessIdWithPS(command);
|
procId = findProcessIdWithPS(command);
|
||||||
} catch (Exception e2)
|
} catch (Exception e2) {
|
||||||
{
|
|
||||||
Log.e(TAG, "Unable to get proc id for command: " + URLEncoder.encode(command), e2);
|
Log.e(TAG, "Unable to get proc id for command: " + URLEncoder.encode(command), e2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,8 +88,7 @@ public class TorServiceUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// use 'pidof' command
|
// use 'pidof' command
|
||||||
public static int findProcessIdWithPidOf(String command) throws Exception
|
public static int findProcessIdWithPidOf(String command) throws Exception {
|
||||||
{
|
|
||||||
|
|
||||||
int procId = -1;
|
int procId = -1;
|
||||||
|
|
||||||
@ -104,7 +98,7 @@ public class TorServiceUtils {
|
|||||||
|
|
||||||
String baseName = new File(command).getName();
|
String baseName = new File(command).getName();
|
||||||
// fix contributed my mikos on 2010.12.10
|
// fix contributed my mikos on 2010.12.10
|
||||||
procPs = r.exec(new String[] {
|
procPs = r.exec(new String[]{
|
||||||
SHELL_CMD_PIDOF, baseName
|
SHELL_CMD_PIDOF, baseName
|
||||||
});
|
});
|
||||||
// procPs = r.exec(SHELL_CMD_PIDOF);
|
// procPs = r.exec(SHELL_CMD_PIDOF);
|
||||||
@ -112,16 +106,13 @@ public class TorServiceUtils {
|
|||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
|
||||||
String line = null;
|
String line = null;
|
||||||
|
|
||||||
while ((line = reader.readLine()) != null)
|
while ((line = reader.readLine()) != null) {
|
||||||
{
|
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
// this line should just be the process id
|
// this line should just be the process id
|
||||||
procId = Integer.parseInt(line.trim());
|
procId = Integer.parseInt(line.trim());
|
||||||
break;
|
break;
|
||||||
} catch (NumberFormatException e)
|
} catch (NumberFormatException e) {
|
||||||
{
|
|
||||||
Log.e("TorServiceUtils", "unable to parse process pid: " + line, e);
|
Log.e("TorServiceUtils", "unable to parse process pid: " + line, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,8 +122,7 @@ public class TorServiceUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// use 'ps' command
|
// use 'ps' command
|
||||||
public static int findProcessIdWithPS(String command) throws Exception
|
public static int findProcessIdWithPS(String command) throws Exception {
|
||||||
{
|
|
||||||
|
|
||||||
int procId = -1;
|
int procId = -1;
|
||||||
|
|
||||||
@ -145,10 +135,8 @@ public class TorServiceUtils {
|
|||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
|
||||||
String line = null;
|
String line = null;
|
||||||
|
|
||||||
while ((line = reader.readLine()) != null)
|
while ((line = reader.readLine()) != null) {
|
||||||
{
|
if (line.indexOf(' ' + command) != -1) {
|
||||||
if (line.indexOf(' ' + command) != -1)
|
|
||||||
{
|
|
||||||
|
|
||||||
StringTokenizer st = new StringTokenizer(line, " ");
|
StringTokenizer st = new StringTokenizer(line, " ");
|
||||||
st.nextToken(); // proc owner
|
st.nextToken(); // proc owner
|
||||||
|
Loading…
Reference in New Issue
Block a user