mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-17 07:30:14 -05:00
lift language level to java 7, and some code cleanup
This commit is contained in:
parent
41aba69fad
commit
8d9c3c0534
@ -32,10 +32,10 @@ public class CloudSearch {
|
|||||||
|
|
||||||
public static ArrayList<ImportKeysListEntry> search(final String query, Preferences.CloudSearchPrefs cloudPrefs)
|
public static ArrayList<ImportKeysListEntry> search(final String query, Preferences.CloudSearchPrefs cloudPrefs)
|
||||||
throws Keyserver.CloudSearchFailureException {
|
throws Keyserver.CloudSearchFailureException {
|
||||||
final ArrayList<Keyserver> servers = new ArrayList<Keyserver>();
|
final ArrayList<Keyserver> servers = new ArrayList<>();
|
||||||
|
|
||||||
// it's a Vector for sync, multiple threads might report problems
|
// it's a Vector for sync, multiple threads might report problems
|
||||||
final Vector<Keyserver.CloudSearchFailureException> problems = new Vector<Keyserver.CloudSearchFailureException>();
|
final Vector<Keyserver.CloudSearchFailureException> problems = new Vector<>();
|
||||||
|
|
||||||
if (cloudPrefs.searchKeyserver) {
|
if (cloudPrefs.searchKeyserver) {
|
||||||
servers.add(new HkpKeyserver(cloudPrefs.keyserver));
|
servers.add(new HkpKeyserver(cloudPrefs.keyserver));
|
||||||
|
@ -234,7 +234,7 @@ public class HkpKeyserver extends Keyserver {
|
|||||||
@Override
|
@Override
|
||||||
public ArrayList<ImportKeysListEntry> search(String query) throws QueryFailedException,
|
public ArrayList<ImportKeysListEntry> search(String query) throws QueryFailedException,
|
||||||
QueryNeedsRepairException {
|
QueryNeedsRepairException {
|
||||||
ArrayList<ImportKeysListEntry> results = new ArrayList<ImportKeysListEntry>();
|
ArrayList<ImportKeysListEntry> results = new ArrayList<>();
|
||||||
|
|
||||||
if (query.length() < 3) {
|
if (query.length() < 3) {
|
||||||
throw new QueryTooShortException();
|
throw new QueryTooShortException();
|
||||||
@ -305,7 +305,7 @@ public class HkpKeyserver extends Keyserver {
|
|||||||
entry.setRevoked(matcher.group(6).contains("r"));
|
entry.setRevoked(matcher.group(6).contains("r"));
|
||||||
entry.setExpired(matcher.group(6).contains("e"));
|
entry.setExpired(matcher.group(6).contains("e"));
|
||||||
|
|
||||||
ArrayList<String> userIds = new ArrayList<String>();
|
ArrayList<String> userIds = new ArrayList<>();
|
||||||
final String uidLines = matcher.group(7);
|
final String uidLines = matcher.group(7);
|
||||||
final Matcher uidMatcher = UID_LINE.matcher(uidLines);
|
final Matcher uidMatcher = UID_LINE.matcher(uidLines);
|
||||||
while (uidMatcher.find()) {
|
while (uidMatcher.find()) {
|
||||||
|
@ -89,7 +89,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
public ImportKeysListEntry createFromParcel(final Parcel source) {
|
public ImportKeysListEntry createFromParcel(final Parcel source) {
|
||||||
ImportKeysListEntry vr = new ImportKeysListEntry();
|
ImportKeysListEntry vr = new ImportKeysListEntry();
|
||||||
vr.mPrimaryUserId = source.readString();
|
vr.mPrimaryUserId = source.readString();
|
||||||
vr.mUserIds = new ArrayList<String>();
|
vr.mUserIds = new ArrayList<>();
|
||||||
source.readStringList(vr.mUserIds);
|
source.readStringList(vr.mUserIds);
|
||||||
vr.mMergedUserIds = (HashMap<String, HashSet<String>>) source.readSerializable();
|
vr.mMergedUserIds = (HashMap<String, HashSet<String>>) source.readSerializable();
|
||||||
vr.mKeyId = source.readLong();
|
vr.mKeyId = source.readLong();
|
||||||
@ -103,7 +103,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
vr.mSecretKey = source.readByte() == 1;
|
vr.mSecretKey = source.readByte() == 1;
|
||||||
vr.mSelected = source.readByte() == 1;
|
vr.mSelected = source.readByte() == 1;
|
||||||
vr.mExtraData = source.readString();
|
vr.mExtraData = source.readString();
|
||||||
vr.mOrigins = new ArrayList<String>();
|
vr.mOrigins = new ArrayList<>();
|
||||||
source.readStringList(vr.mOrigins);
|
source.readStringList(vr.mOrigins);
|
||||||
|
|
||||||
return vr;
|
return vr;
|
||||||
@ -265,8 +265,8 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
mSecretKey = false;
|
mSecretKey = false;
|
||||||
// do not select by default
|
// do not select by default
|
||||||
mSelected = false;
|
mSelected = false;
|
||||||
mUserIds = new ArrayList<String>();
|
mUserIds = new ArrayList<>();
|
||||||
mOrigins = new ArrayList<String>();
|
mOrigins = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -304,7 +304,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateMergedUserIds() {
|
public void updateMergedUserIds() {
|
||||||
mMergedUserIds = new HashMap<String, HashSet<String>>();
|
mMergedUserIds = new HashMap<>();
|
||||||
for (String userId : mUserIds) {
|
for (String userId : mUserIds) {
|
||||||
String[] userIdSplit = KeyRing.splitUserId(userId);
|
String[] userIdSplit = KeyRing.splitUserId(userId);
|
||||||
|
|
||||||
@ -315,7 +315,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
// email
|
// email
|
||||||
if (userIdSplit[1] != null) {
|
if (userIdSplit[1] != null) {
|
||||||
if (!mMergedUserIds.containsKey(userIdSplit[0])) {
|
if (!mMergedUserIds.containsKey(userIdSplit[0])) {
|
||||||
HashSet<String> emails = new HashSet<String>();
|
HashSet<String> emails = new HashSet<>();
|
||||||
emails.add(userIdSplit[1]);
|
emails.add(userIdSplit[1]);
|
||||||
mMergedUserIds.put(userIdSplit[0], emails);
|
mMergedUserIds.put(userIdSplit[0], emails);
|
||||||
} else {
|
} else {
|
||||||
|
@ -36,7 +36,7 @@ public class KeybaseKeyserver extends Keyserver {
|
|||||||
@Override
|
@Override
|
||||||
public ArrayList<ImportKeysListEntry> search(String query) throws QueryFailedException,
|
public ArrayList<ImportKeysListEntry> search(String query) throws QueryFailedException,
|
||||||
QueryNeedsRepairException {
|
QueryNeedsRepairException {
|
||||||
ArrayList<ImportKeysListEntry> results = new ArrayList<ImportKeysListEntry>();
|
ArrayList<ImportKeysListEntry> results = new ArrayList<>();
|
||||||
|
|
||||||
if (query.startsWith("0x")) {
|
if (query.startsWith("0x")) {
|
||||||
// cut off "0x" if a user is searching for a key id
|
// cut off "0x" if a user is searching for a key id
|
||||||
@ -81,7 +81,7 @@ public class KeybaseKeyserver extends Keyserver {
|
|||||||
final int algorithmId = match.getAlgorithmId();
|
final int algorithmId = match.getAlgorithmId();
|
||||||
entry.setAlgorithm(KeyFormattingUtils.getAlgorithmInfo(algorithmId, bitStrength, null));
|
entry.setAlgorithm(KeyFormattingUtils.getAlgorithmInfo(algorithmId, bitStrength, null));
|
||||||
|
|
||||||
ArrayList<String> userIds = new ArrayList<String>();
|
ArrayList<String> userIds = new ArrayList<>();
|
||||||
String name = "<keybase.io/" + username + ">";
|
String name = "<keybase.io/" + username + ">";
|
||||||
if (fullName != null) {
|
if (fullName != null) {
|
||||||
name = fullName + " " + name;
|
name = fullName + " " + name;
|
||||||
|
@ -78,7 +78,7 @@ public class CertifyOperation extends BaseOperation {
|
|||||||
return new CertifyResult(CertifyResult.RESULT_ERROR, log);
|
return new CertifyResult(CertifyResult.RESULT_ERROR, log);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<UncachedKeyRing> certifiedKeys = new ArrayList<UncachedKeyRing>();
|
ArrayList<UncachedKeyRing> certifiedKeys = new ArrayList<>();
|
||||||
|
|
||||||
log.add(LogType.MSG_CRT_CERTIFYING, 1);
|
log.add(LogType.MSG_CRT_CERTIFYING, 1);
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import org.sufficientlysecure.keychain.pgp.Progressable;
|
|||||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
|
||||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
|
|
||||||
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;
|
||||||
|
@ -137,7 +137,7 @@ public class ImportExportOperation extends BaseOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int newKeys = 0, oldKeys = 0, badKeys = 0, secret = 0;
|
int newKeys = 0, oldKeys = 0, badKeys = 0, secret = 0;
|
||||||
ArrayList<Long> importedMasterKeyIds = new ArrayList<Long>();
|
ArrayList<Long> importedMasterKeyIds = new ArrayList<>();
|
||||||
|
|
||||||
boolean cancelled = false;
|
boolean cancelled = false;
|
||||||
int position = 0;
|
int position = 0;
|
||||||
|
@ -735,7 +735,7 @@ public abstract class OperationResult implements Parcelable {
|
|||||||
|
|
||||||
public static class OperationLog implements Iterable<LogEntryParcel> {
|
public static class OperationLog implements Iterable<LogEntryParcel> {
|
||||||
|
|
||||||
private final List<LogEntryParcel> mParcels = new ArrayList<LogEntryParcel>();
|
private final List<LogEntryParcel> mParcels = new ArrayList<>();
|
||||||
|
|
||||||
/// Simple convenience method
|
/// Simple convenience method
|
||||||
public void add(LogType type, int indent, Object... parameters) {
|
public void add(LogType type, int indent, Object... parameters) {
|
||||||
@ -760,7 +760,7 @@ public abstract class OperationResult implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsType(LogType type) {
|
public boolean containsType(LogType type) {
|
||||||
for(LogEntryParcel entry : new IterableIterator<LogEntryParcel>(mParcels.iterator())) {
|
for(LogEntryParcel entry : new IterableIterator<>(mParcels.iterator())) {
|
||||||
if (entry.mType == type) {
|
if (entry.mType == type) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -769,7 +769,7 @@ public abstract class OperationResult implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsWarnings() {
|
public boolean containsWarnings() {
|
||||||
for(LogEntryParcel entry : new IterableIterator<LogEntryParcel>(mParcels.iterator())) {
|
for(LogEntryParcel entry : new IterableIterator<>(mParcels.iterator())) {
|
||||||
if (entry.mType.mLevel == LogLevel.WARN || entry.mType.mLevel == LogLevel.ERROR) {
|
if (entry.mType.mLevel == LogLevel.WARN || entry.mType.mLevel == LogLevel.ERROR) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package org.sufficientlysecure.keychain.pgp;
|
package org.sufficientlysecure.keychain.pgp;
|
||||||
|
|
||||||
import org.spongycastle.openpgp.PGPKeyRing;
|
import org.spongycastle.openpgp.PGPKeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class CanonicalizedPublicKeyRing extends CanonicalizedKeyRing {
|
|||||||
public IterableIterator<CanonicalizedPublicKey> publicKeyIterator() {
|
public IterableIterator<CanonicalizedPublicKey> publicKeyIterator() {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final Iterator<PGPPublicKey> it = getRing().getPublicKeys();
|
final Iterator<PGPPublicKey> it = getRing().getPublicKeys();
|
||||||
return new IterableIterator<CanonicalizedPublicKey>(new Iterator<CanonicalizedPublicKey>() {
|
return new IterableIterator<>(new Iterator<CanonicalizedPublicKey>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return it.hasNext();
|
return it.hasNext();
|
||||||
|
@ -182,7 +182,7 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public LinkedList<Integer> getSupportedHashAlgorithms() {
|
public LinkedList<Integer> getSupportedHashAlgorithms() {
|
||||||
LinkedList<Integer> supported = new LinkedList<Integer>();
|
LinkedList<Integer> supported = new LinkedList<>();
|
||||||
|
|
||||||
if (mPrivateKeyState == PRIVATE_KEY_STATE_DIVERT_TO_CARD) {
|
if (mPrivateKeyState == PRIVATE_KEY_STATE_DIVERT_TO_CARD) {
|
||||||
// No support for MD5
|
// No support for MD5
|
||||||
@ -262,11 +262,9 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
|
|||||||
spGen.setSignatureCreationTime(false, nfcCreationTimestamp);
|
spGen.setSignatureCreationTime(false, nfcCreationTimestamp);
|
||||||
signatureGenerator.setHashedSubpackets(spGen.generate());
|
signatureGenerator.setHashedSubpackets(spGen.generate());
|
||||||
return signatureGenerator;
|
return signatureGenerator;
|
||||||
} catch (PgpKeyNotFoundException e) {
|
} catch (PgpKeyNotFoundException | PGPException e) {
|
||||||
// TODO: simply throw PGPException!
|
// TODO: simply throw PGPException!
|
||||||
throw new PgpGeneralException("Error initializing signature!", e);
|
throw new PgpGeneralException("Error initializing signature!", e);
|
||||||
} catch (PGPException e) {
|
|
||||||
throw new PgpGeneralException("Error initializing signature!", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,27 +18,19 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.pgp;
|
package org.sufficientlysecure.keychain.pgp;
|
||||||
|
|
||||||
import org.spongycastle.bcpg.S2K;
|
|
||||||
import org.spongycastle.openpgp.PGPException;
|
|
||||||
import org.spongycastle.openpgp.PGPKeyRing;
|
import org.spongycastle.openpgp.PGPKeyRing;
|
||||||
import org.spongycastle.openpgp.PGPObjectFactory;
|
import org.spongycastle.openpgp.PGPObjectFactory;
|
||||||
import org.spongycastle.openpgp.PGPPrivateKey;
|
|
||||||
import org.spongycastle.openpgp.PGPPublicKey;
|
import org.spongycastle.openpgp.PGPPublicKey;
|
||||||
import org.spongycastle.openpgp.PGPSecretKey;
|
import org.spongycastle.openpgp.PGPSecretKey;
|
||||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.spongycastle.openpgp.PGPSignature;
|
import org.spongycastle.openpgp.PGPSignature;
|
||||||
import org.spongycastle.openpgp.operator.PBESecretKeyDecryptor;
|
|
||||||
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
|
||||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
public class CanonicalizedSecretKeyRing extends CanonicalizedKeyRing {
|
public class CanonicalizedSecretKeyRing extends CanonicalizedKeyRing {
|
||||||
@ -94,7 +86,7 @@ public class CanonicalizedSecretKeyRing extends CanonicalizedKeyRing {
|
|||||||
|
|
||||||
public IterableIterator<CanonicalizedSecretKey> secretKeyIterator() {
|
public IterableIterator<CanonicalizedSecretKey> secretKeyIterator() {
|
||||||
final Iterator<PGPSecretKey> it = mRing.getSecretKeys();
|
final Iterator<PGPSecretKey> it = mRing.getSecretKeys();
|
||||||
return new IterableIterator<CanonicalizedSecretKey>(new Iterator<CanonicalizedSecretKey>() {
|
return new IterableIterator<>(new Iterator<CanonicalizedSecretKey>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return it.hasNext();
|
return it.hasNext();
|
||||||
@ -114,7 +106,7 @@ public class CanonicalizedSecretKeyRing extends CanonicalizedKeyRing {
|
|||||||
|
|
||||||
public IterableIterator<CanonicalizedPublicKey> publicKeyIterator() {
|
public IterableIterator<CanonicalizedPublicKey> publicKeyIterator() {
|
||||||
final Iterator<PGPPublicKey> it = getRing().getPublicKeys();
|
final Iterator<PGPPublicKey> it = getRing().getPublicKeys();
|
||||||
return new IterableIterator<CanonicalizedPublicKey>(new Iterator<CanonicalizedPublicKey>() {
|
return new IterableIterator<>(new Iterator<CanonicalizedPublicKey>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return it.hasNext();
|
return it.hasNext();
|
||||||
@ -133,7 +125,7 @@ public class CanonicalizedSecretKeyRing extends CanonicalizedKeyRing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String,String> getLocalNotationData() {
|
public HashMap<String,String> getLocalNotationData() {
|
||||||
HashMap<String,String> result = new HashMap<String,String>();
|
HashMap<String,String> result = new HashMap<>();
|
||||||
Iterator<PGPSignature> it = getRing().getPublicKey().getKeySignatures();
|
Iterator<PGPSignature> it = getRing().getPublicKey().getKeySignatures();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
WrappedSignature sig = new WrappedSignature(it.next());
|
WrappedSignature sig = new WrappedSignature(it.next());
|
||||||
|
@ -19,7 +19,6 @@ package org.sufficientlysecure.keychain.pgp;
|
|||||||
|
|
||||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
@ -33,7 +32,7 @@ public class OpenPgpSignatureResultBuilder {
|
|||||||
// OpenPgpSignatureResult
|
// OpenPgpSignatureResult
|
||||||
private boolean mSignatureOnly = false;
|
private boolean mSignatureOnly = false;
|
||||||
private String mPrimaryUserId;
|
private String mPrimaryUserId;
|
||||||
private ArrayList<String> mUserIds = new ArrayList<String>();
|
private ArrayList<String> mUserIds = new ArrayList<>();
|
||||||
private long mKeyId;
|
private long mKeyId;
|
||||||
|
|
||||||
// builder
|
// builder
|
||||||
|
@ -135,7 +135,7 @@ public class PgpKeyOperation {
|
|||||||
public PgpKeyOperation(Progressable progress) {
|
public PgpKeyOperation(Progressable progress) {
|
||||||
super();
|
super();
|
||||||
if (progress != null) {
|
if (progress != null) {
|
||||||
mProgress = new Stack<Progressable>();
|
mProgress = new Stack<>();
|
||||||
mProgress.push(progress);
|
mProgress.push(progress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -288,13 +288,11 @@ public class PgpKeyOperation {
|
|||||||
// build new key pair
|
// build new key pair
|
||||||
return new JcaPGPKeyPair(algorithm, keyGen.generateKeyPair(), new Date());
|
return new JcaPGPKeyPair(algorithm, keyGen.generateKeyPair(), new Date());
|
||||||
|
|
||||||
} catch(NoSuchProviderException e) {
|
} catch(NoSuchProviderException | InvalidAlgorithmParameterException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch(NoSuchAlgorithmException e) {
|
} catch(NoSuchAlgorithmException e) {
|
||||||
log.add(LogType.MSG_CR_ERROR_UNKNOWN_ALGO, indent);
|
log.add(LogType.MSG_CR_ERROR_UNKNOWN_ALGO, indent);
|
||||||
return null;
|
return null;
|
||||||
} catch(InvalidAlgorithmParameterException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch(PGPException e) {
|
} catch(PGPException e) {
|
||||||
Log.e(Constants.TAG, "internal pgp error", e);
|
Log.e(Constants.TAG, "internal pgp error", e);
|
||||||
log.add(LogType.MSG_CR_ERROR_INTERNAL_PGP, indent);
|
log.add(LogType.MSG_CR_ERROR_INTERNAL_PGP, indent);
|
||||||
@ -504,7 +502,7 @@ public class PgpKeyOperation {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Iterator<PGPSignature> it = modifiedPublicKey.getSignaturesForID(userId);
|
Iterator<PGPSignature> it = modifiedPublicKey.getSignaturesForID(userId);
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
for (PGPSignature cert : new IterableIterator<PGPSignature>(it)) {
|
for (PGPSignature cert : new IterableIterator<>(it)) {
|
||||||
if (cert.getKeyID() != masterPublicKey.getKeyID()) {
|
if (cert.getKeyID() != masterPublicKey.getKeyID()) {
|
||||||
// foreign certificate?! error error error
|
// foreign certificate?! error error error
|
||||||
log.add(LogType.MSG_MF_ERROR_INTEGRITY, indent);
|
log.add(LogType.MSG_MF_ERROR_INTEGRITY, indent);
|
||||||
|
@ -445,7 +445,7 @@ public class UncachedKeyRing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> processedUserIds = new ArrayList<String>();
|
ArrayList<String> processedUserIds = new ArrayList<>();
|
||||||
for (byte[] rawUserId : new IterableIterator<byte[]>(masterKey.getRawUserIDs())) {
|
for (byte[] rawUserId : new IterableIterator<byte[]>(masterKey.getRawUserIDs())) {
|
||||||
String userId = Utf8Util.fromUTF8ByteArrayReplaceBadEncoding(rawUserId);
|
String userId = Utf8Util.fromUTF8ByteArrayReplaceBadEncoding(rawUserId);
|
||||||
|
|
||||||
@ -470,7 +470,7 @@ public class UncachedKeyRing {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Iterator<PGPSignature> signaturesIt = masterKey.getSignaturesForID(rawUserId);
|
Iterator<PGPSignature> signaturesIt = masterKey.getSignaturesForID(rawUserId);
|
||||||
if (signaturesIt != null) {
|
if (signaturesIt != null) {
|
||||||
for (PGPSignature zert : new IterableIterator<PGPSignature>(signaturesIt)) {
|
for (PGPSignature zert : new IterableIterator<>(signaturesIt)) {
|
||||||
WrappedSignature cert = new WrappedSignature(zert);
|
WrappedSignature cert = new WrappedSignature(zert);
|
||||||
long certId = cert.getKeyId();
|
long certId = cert.getKeyId();
|
||||||
|
|
||||||
@ -635,7 +635,7 @@ public class UncachedKeyRing {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Iterator<PGPSignature> signaturesIt = masterKey.getSignaturesForUserAttribute(userAttribute);
|
Iterator<PGPSignature> signaturesIt = masterKey.getSignaturesForUserAttribute(userAttribute);
|
||||||
if (signaturesIt != null) {
|
if (signaturesIt != null) {
|
||||||
for (PGPSignature zert : new IterableIterator<PGPSignature>(signaturesIt)) {
|
for (PGPSignature zert : new IterableIterator<>(signaturesIt)) {
|
||||||
WrappedSignature cert = new WrappedSignature(zert);
|
WrappedSignature cert = new WrappedSignature(zert);
|
||||||
long certId = cert.getKeyId();
|
long certId = cert.getKeyId();
|
||||||
|
|
||||||
@ -778,7 +778,7 @@ public class UncachedKeyRing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Keep track of ids we encountered so far
|
// Keep track of ids we encountered so far
|
||||||
Set<Long> knownIds = new HashSet<Long>();
|
Set<Long> knownIds = new HashSet<>();
|
||||||
|
|
||||||
// Process all keys
|
// Process all keys
|
||||||
for (PGPPublicKey key : new IterableIterator<PGPPublicKey>(ring.getPublicKeys())) {
|
for (PGPPublicKey key : new IterableIterator<PGPPublicKey>(ring.getPublicKeys())) {
|
||||||
@ -1042,7 +1042,7 @@ public class UncachedKeyRing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remember which certs we already added. this is cheaper than semantic deduplication
|
// remember which certs we already added. this is cheaper than semantic deduplication
|
||||||
Set<byte[]> certs = new TreeSet<byte[]>(new Comparator<byte[]>() {
|
Set<byte[]> certs = new TreeSet<>(new Comparator<byte[]>() {
|
||||||
public int compare(byte[] left, byte[] right) {
|
public int compare(byte[] left, byte[] right) {
|
||||||
// check for length equality
|
// check for length equality
|
||||||
if (left.length != right.length) {
|
if (left.length != right.length) {
|
||||||
@ -1124,7 +1124,7 @@ public class UncachedKeyRing {
|
|||||||
if (signaturesIt == null) {
|
if (signaturesIt == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (PGPSignature cert : new IterableIterator<PGPSignature>(signaturesIt)) {
|
for (PGPSignature cert : new IterableIterator<>(signaturesIt)) {
|
||||||
// Don't merge foreign stuff into secret keys
|
// Don't merge foreign stuff into secret keys
|
||||||
if (cert.getKeyID() != masterKeyId && isSecret()) {
|
if (cert.getKeyID() != masterKeyId && isSecret()) {
|
||||||
continue;
|
continue;
|
||||||
@ -1149,7 +1149,7 @@ public class UncachedKeyRing {
|
|||||||
if (signaturesIt == null) {
|
if (signaturesIt == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (PGPSignature cert : new IterableIterator<PGPSignature>(signaturesIt)) {
|
for (PGPSignature cert : new IterableIterator<>(signaturesIt)) {
|
||||||
// Don't merge foreign stuff into secret keys
|
// Don't merge foreign stuff into secret keys
|
||||||
if (cert.getKeyID() != masterKeyId && isSecret()) {
|
if (cert.getKeyID() != masterKeyId && isSecret()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.pgp;
|
|||||||
|
|
||||||
import org.spongycastle.bcpg.ECPublicBCPGKey;
|
import org.spongycastle.bcpg.ECPublicBCPGKey;
|
||||||
import org.spongycastle.bcpg.SignatureSubpacketTags;
|
import org.spongycastle.bcpg.SignatureSubpacketTags;
|
||||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
|
||||||
import org.spongycastle.openpgp.PGPPublicKey;
|
import org.spongycastle.openpgp.PGPPublicKey;
|
||||||
import org.spongycastle.openpgp.PGPSignature;
|
import org.spongycastle.openpgp.PGPSignature;
|
||||||
import org.spongycastle.openpgp.PGPSignatureSubpacketVector;
|
import org.spongycastle.openpgp.PGPSignatureSubpacketVector;
|
||||||
@ -136,7 +135,7 @@ public class UncachedPublicKey {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PGPSignature sig : new IterableIterator<PGPSignature>(signaturesIt)) {
|
for (PGPSignature sig : new IterableIterator<>(signaturesIt)) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// if this is a revocation, this is not the user id
|
// if this is a revocation, this is not the user id
|
||||||
@ -200,7 +199,7 @@ public class UncachedPublicKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getUnorderedUserIds() {
|
public ArrayList<String> getUnorderedUserIds() {
|
||||||
ArrayList<String> userIds = new ArrayList<String>();
|
ArrayList<String> userIds = new ArrayList<>();
|
||||||
for (byte[] rawUserId : new IterableIterator<byte[]>(mPublicKey.getRawUserIDs())) {
|
for (byte[] rawUserId : new IterableIterator<byte[]>(mPublicKey.getRawUserIDs())) {
|
||||||
// use our decoding method
|
// use our decoding method
|
||||||
userIds.add(Utf8Util.fromUTF8ByteArrayReplaceBadEncoding(rawUserId));
|
userIds.add(Utf8Util.fromUTF8ByteArrayReplaceBadEncoding(rawUserId));
|
||||||
@ -209,7 +208,7 @@ public class UncachedPublicKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<byte[]> getUnorderedRawUserIds() {
|
public ArrayList<byte[]> getUnorderedRawUserIds() {
|
||||||
ArrayList<byte[]> userIds = new ArrayList<byte[]>();
|
ArrayList<byte[]> userIds = new ArrayList<>();
|
||||||
for (byte[] userId : new IterableIterator<byte[]>(mPublicKey.getRawUserIDs())) {
|
for (byte[] userId : new IterableIterator<byte[]>(mPublicKey.getRawUserIDs())) {
|
||||||
userIds.add(userId);
|
userIds.add(userId);
|
||||||
}
|
}
|
||||||
@ -217,7 +216,7 @@ public class UncachedPublicKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<WrappedUserAttribute> getUnorderedUserAttributes() {
|
public ArrayList<WrappedUserAttribute> getUnorderedUserAttributes() {
|
||||||
ArrayList<WrappedUserAttribute> userAttributes = new ArrayList<WrappedUserAttribute>();
|
ArrayList<WrappedUserAttribute> userAttributes = new ArrayList<>();
|
||||||
for (PGPUserAttributeSubpacketVector userAttribute :
|
for (PGPUserAttributeSubpacketVector userAttribute :
|
||||||
new IterableIterator<PGPUserAttributeSubpacketVector>(mPublicKey.getUserAttributes())) {
|
new IterableIterator<PGPUserAttributeSubpacketVector>(mPublicKey.getUserAttributes())) {
|
||||||
userAttributes.add(new WrappedUserAttribute(userAttribute));
|
userAttributes.add(new WrappedUserAttribute(userAttribute));
|
||||||
|
@ -36,7 +36,6 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
|||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.SignatureException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -80,7 +79,7 @@ public class WrappedSignature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<WrappedSignature> getEmbeddedSignatures() {
|
public ArrayList<WrappedSignature> getEmbeddedSignatures() {
|
||||||
ArrayList<WrappedSignature> sigs = new ArrayList<WrappedSignature>();
|
ArrayList<WrappedSignature> sigs = new ArrayList<>();
|
||||||
if (!mSig.hasSubpackets()) {
|
if (!mSig.hasSubpackets()) {
|
||||||
return sigs;
|
return sigs;
|
||||||
}
|
}
|
||||||
@ -255,7 +254,7 @@ public class WrappedSignature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String,String> getNotation() {
|
public HashMap<String,String> getNotation() {
|
||||||
HashMap<String,String> result = new HashMap<String,String>();
|
HashMap<String,String> result = new HashMap<>();
|
||||||
|
|
||||||
// If there is any notation data
|
// If there is any notation data
|
||||||
if (mSig.getHashedSubPackets() != null
|
if (mSig.getHashedSubPackets() != null
|
||||||
|
@ -248,7 +248,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
case KEY_RINGS_UNIFIED:
|
case KEY_RINGS_UNIFIED:
|
||||||
case KEY_RINGS_FIND_BY_EMAIL:
|
case KEY_RINGS_FIND_BY_EMAIL:
|
||||||
case KEY_RINGS_FIND_BY_SUBKEY: {
|
case KEY_RINGS_FIND_BY_SUBKEY: {
|
||||||
HashMap<String, String> projectionMap = new HashMap<String, String>();
|
HashMap<String, String> projectionMap = new HashMap<>();
|
||||||
projectionMap.put(KeyRings._ID, Tables.KEYS + ".oid AS _id");
|
projectionMap.put(KeyRings._ID, Tables.KEYS + ".oid AS _id");
|
||||||
projectionMap.put(KeyRings.MASTER_KEY_ID, Tables.KEYS + "." + Keys.MASTER_KEY_ID);
|
projectionMap.put(KeyRings.MASTER_KEY_ID, Tables.KEYS + "." + Keys.MASTER_KEY_ID);
|
||||||
projectionMap.put(KeyRings.KEY_ID, Tables.KEYS + "." + Keys.KEY_ID);
|
projectionMap.put(KeyRings.KEY_ID, Tables.KEYS + "." + Keys.KEY_ID);
|
||||||
@ -432,7 +432,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case KEY_RING_KEYS: {
|
case KEY_RING_KEYS: {
|
||||||
HashMap<String, String> projectionMap = new HashMap<String, String>();
|
HashMap<String, String> projectionMap = new HashMap<>();
|
||||||
projectionMap.put(Keys._ID, Tables.KEYS + ".oid AS _id");
|
projectionMap.put(Keys._ID, Tables.KEYS + ".oid AS _id");
|
||||||
projectionMap.put(Keys.MASTER_KEY_ID, Tables.KEYS + "." + Keys.MASTER_KEY_ID);
|
projectionMap.put(Keys.MASTER_KEY_ID, Tables.KEYS + "." + Keys.MASTER_KEY_ID);
|
||||||
projectionMap.put(Keys.RANK, Tables.KEYS + "." + Keys.RANK);
|
projectionMap.put(Keys.RANK, Tables.KEYS + "." + Keys.RANK);
|
||||||
@ -460,7 +460,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
|
|
||||||
case KEY_RINGS_USER_IDS:
|
case KEY_RINGS_USER_IDS:
|
||||||
case KEY_RING_USER_IDS: {
|
case KEY_RING_USER_IDS: {
|
||||||
HashMap<String, String> projectionMap = new HashMap<String, String>();
|
HashMap<String, String> projectionMap = new HashMap<>();
|
||||||
projectionMap.put(UserPackets._ID, Tables.USER_PACKETS + ".oid AS _id");
|
projectionMap.put(UserPackets._ID, Tables.USER_PACKETS + ".oid AS _id");
|
||||||
projectionMap.put(UserPackets.MASTER_KEY_ID, Tables.USER_PACKETS + "." + UserPackets.MASTER_KEY_ID);
|
projectionMap.put(UserPackets.MASTER_KEY_ID, Tables.USER_PACKETS + "." + UserPackets.MASTER_KEY_ID);
|
||||||
projectionMap.put(UserPackets.TYPE, Tables.USER_PACKETS + "." + UserPackets.TYPE);
|
projectionMap.put(UserPackets.TYPE, Tables.USER_PACKETS + "." + UserPackets.TYPE);
|
||||||
@ -507,7 +507,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
|
|
||||||
case KEY_RINGS_PUBLIC:
|
case KEY_RINGS_PUBLIC:
|
||||||
case KEY_RING_PUBLIC: {
|
case KEY_RING_PUBLIC: {
|
||||||
HashMap<String, String> projectionMap = new HashMap<String, String>();
|
HashMap<String, String> projectionMap = new HashMap<>();
|
||||||
projectionMap.put(KeyRingData._ID, Tables.KEY_RINGS_PUBLIC + ".oid AS _id");
|
projectionMap.put(KeyRingData._ID, Tables.KEY_RINGS_PUBLIC + ".oid AS _id");
|
||||||
projectionMap.put(KeyRingData.MASTER_KEY_ID, KeyRingData.MASTER_KEY_ID);
|
projectionMap.put(KeyRingData.MASTER_KEY_ID, KeyRingData.MASTER_KEY_ID);
|
||||||
projectionMap.put(KeyRingData.KEY_RING_DATA, KeyRingData.KEY_RING_DATA);
|
projectionMap.put(KeyRingData.KEY_RING_DATA, KeyRingData.KEY_RING_DATA);
|
||||||
@ -525,7 +525,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
|
|
||||||
case KEY_RINGS_SECRET:
|
case KEY_RINGS_SECRET:
|
||||||
case KEY_RING_SECRET: {
|
case KEY_RING_SECRET: {
|
||||||
HashMap<String, String> projectionMap = new HashMap<String, String>();
|
HashMap<String, String> projectionMap = new HashMap<>();
|
||||||
projectionMap.put(KeyRingData._ID, Tables.KEY_RINGS_SECRET + ".oid AS _id");
|
projectionMap.put(KeyRingData._ID, Tables.KEY_RINGS_SECRET + ".oid AS _id");
|
||||||
projectionMap.put(KeyRingData.MASTER_KEY_ID, KeyRingData.MASTER_KEY_ID);
|
projectionMap.put(KeyRingData.MASTER_KEY_ID, KeyRingData.MASTER_KEY_ID);
|
||||||
projectionMap.put(KeyRingData.KEY_RING_DATA, KeyRingData.KEY_RING_DATA);
|
projectionMap.put(KeyRingData.KEY_RING_DATA, KeyRingData.KEY_RING_DATA);
|
||||||
@ -543,7 +543,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
|
|
||||||
case KEY_RING_CERTS:
|
case KEY_RING_CERTS:
|
||||||
case KEY_RING_CERTS_SPECIFIC: {
|
case KEY_RING_CERTS_SPECIFIC: {
|
||||||
HashMap<String, String> projectionMap = new HashMap<String, String>();
|
HashMap<String, String> projectionMap = new HashMap<>();
|
||||||
projectionMap.put(Certs._ID, Tables.CERTS + ".oid AS " + Certs._ID);
|
projectionMap.put(Certs._ID, Tables.CERTS + ".oid AS " + Certs._ID);
|
||||||
projectionMap.put(Certs.MASTER_KEY_ID, Tables.CERTS + "." + Certs.MASTER_KEY_ID);
|
projectionMap.put(Certs.MASTER_KEY_ID, Tables.CERTS + "." + Certs.MASTER_KEY_ID);
|
||||||
projectionMap.put(Certs.RANK, Tables.CERTS + "." + Certs.RANK);
|
projectionMap.put(Certs.RANK, Tables.CERTS + "." + Certs.RANK);
|
||||||
|
@ -170,7 +170,7 @@ public class ProviderHelper {
|
|||||||
Cursor cursor = mContentResolver.query(uri, proj, selection, null, null);
|
Cursor cursor = mContentResolver.query(uri, proj, selection, null, null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
HashMap<String, Object> result = new HashMap<String, Object>(proj.length);
|
HashMap<String, Object> result = new HashMap<>(proj.length);
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
for (String p : proj) {
|
for (String p : proj) {
|
||||||
@ -221,7 +221,7 @@ public class ProviderHelper {
|
|||||||
}, KeyRings.HAS_ANY_SECRET + " = 1", null, null);
|
}, KeyRings.HAS_ANY_SECRET + " = 1", null, null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LongSparseArray<CanonicalizedPublicKey> result = new LongSparseArray<CanonicalizedPublicKey>();
|
LongSparseArray<CanonicalizedPublicKey> result = new LongSparseArray<>();
|
||||||
|
|
||||||
if (cursor != null && cursor.moveToFirst()) do {
|
if (cursor != null && cursor.moveToFirst()) do {
|
||||||
long masterKeyId = cursor.getLong(0);
|
long masterKeyId = cursor.getLong(0);
|
||||||
@ -350,7 +350,7 @@ public class ProviderHelper {
|
|||||||
mIndent += 1;
|
mIndent += 1;
|
||||||
|
|
||||||
// save all keys and userIds included in keyRing object in database
|
// save all keys and userIds included in keyRing object in database
|
||||||
operations = new ArrayList<ContentProviderOperation>();
|
operations = new ArrayList<>();
|
||||||
|
|
||||||
log(LogType.MSG_IP_INSERT_KEYRING);
|
log(LogType.MSG_IP_INSERT_KEYRING);
|
||||||
{ // insert keyring
|
{ // insert keyring
|
||||||
@ -440,7 +440,7 @@ public class ProviderHelper {
|
|||||||
|
|
||||||
// classify and order user ids. primary are moved to the front, revoked to the back,
|
// classify and order user ids. primary are moved to the front, revoked to the back,
|
||||||
// otherwise the order in the keyfile is preserved.
|
// otherwise the order in the keyfile is preserved.
|
||||||
List<UserPacketItem> uids = new ArrayList<UserPacketItem>();
|
List<UserPacketItem> uids = new ArrayList<>();
|
||||||
|
|
||||||
if (trustedKeys.size() == 0) {
|
if (trustedKeys.size() == 0) {
|
||||||
log(LogType.MSG_IP_UID_CLASSIFYING_ZERO);
|
log(LogType.MSG_IP_UID_CLASSIFYING_ZERO);
|
||||||
@ -460,7 +460,7 @@ public class ProviderHelper {
|
|||||||
log(LogType.MSG_IP_UID_PROCESSING, userId);
|
log(LogType.MSG_IP_UID_PROCESSING, userId);
|
||||||
mIndent += 1;
|
mIndent += 1;
|
||||||
// look through signatures for this specific key
|
// look through signatures for this specific key
|
||||||
for (WrappedSignature cert : new IterableIterator<WrappedSignature>(
|
for (WrappedSignature cert : new IterableIterator<>(
|
||||||
masterKey.getSignaturesForRawId(rawUserId))) {
|
masterKey.getSignaturesForRawId(rawUserId))) {
|
||||||
long certId = cert.getKeyId();
|
long certId = cert.getKeyId();
|
||||||
// self signature
|
// self signature
|
||||||
@ -560,7 +560,7 @@ public class ProviderHelper {
|
|||||||
}
|
}
|
||||||
mIndent += 1;
|
mIndent += 1;
|
||||||
// look through signatures for this specific key
|
// look through signatures for this specific key
|
||||||
for (WrappedSignature cert : new IterableIterator<WrappedSignature>(
|
for (WrappedSignature cert : new IterableIterator<>(
|
||||||
masterKey.getSignaturesForUserAttribute(userAttribute))) {
|
masterKey.getSignaturesForUserAttribute(userAttribute))) {
|
||||||
long certId = cert.getKeyId();
|
long certId = cert.getKeyId();
|
||||||
// self signature
|
// self signature
|
||||||
@ -712,7 +712,7 @@ public class ProviderHelper {
|
|||||||
boolean isPrimary = false;
|
boolean isPrimary = false;
|
||||||
boolean isRevoked = false;
|
boolean isRevoked = false;
|
||||||
WrappedSignature selfCert;
|
WrappedSignature selfCert;
|
||||||
LongSparseArray<WrappedSignature> trustedCerts = new LongSparseArray<WrappedSignature>();
|
LongSparseArray<WrappedSignature> trustedCerts = new LongSparseArray<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(UserPacketItem o) {
|
public int compareTo(UserPacketItem o) {
|
||||||
@ -1075,7 +1075,7 @@ public class ProviderHelper {
|
|||||||
// No keys existing might be a legitimate option, we write an empty file in that case
|
// No keys existing might be a legitimate option, we write an empty file in that case
|
||||||
cursor.moveToFirst();
|
cursor.moveToFirst();
|
||||||
ParcelableFileCache<ParcelableKeyRing> cache =
|
ParcelableFileCache<ParcelableKeyRing> cache =
|
||||||
new ParcelableFileCache<ParcelableKeyRing>(mContext, "consolidate_secret.pcl");
|
new ParcelableFileCache<>(mContext, "consolidate_secret.pcl");
|
||||||
cache.writeCache(cursor.getCount(), new Iterator<ParcelableKeyRing>() {
|
cache.writeCache(cursor.getCount(), new Iterator<ParcelableKeyRing>() {
|
||||||
ParcelableKeyRing ring;
|
ParcelableKeyRing ring;
|
||||||
|
|
||||||
@ -1137,7 +1137,7 @@ public class ProviderHelper {
|
|||||||
// No keys existing might be a legitimate option, we write an empty file in that case
|
// No keys existing might be a legitimate option, we write an empty file in that case
|
||||||
cursor.moveToFirst();
|
cursor.moveToFirst();
|
||||||
ParcelableFileCache<ParcelableKeyRing> cache =
|
ParcelableFileCache<ParcelableKeyRing> cache =
|
||||||
new ParcelableFileCache<ParcelableKeyRing>(mContext, "consolidate_public.pcl");
|
new ParcelableFileCache<>(mContext, "consolidate_public.pcl");
|
||||||
cache.writeCache(cursor.getCount(), new Iterator<ParcelableKeyRing>() {
|
cache.writeCache(cursor.getCount(), new Iterator<ParcelableKeyRing>() {
|
||||||
ParcelableKeyRing ring;
|
ParcelableKeyRing ring;
|
||||||
|
|
||||||
@ -1220,9 +1220,9 @@ public class ProviderHelper {
|
|||||||
mContentResolver.delete(KeyRings.buildUnifiedKeyRingsUri(), null, null);
|
mContentResolver.delete(KeyRings.buildUnifiedKeyRingsUri(), null, null);
|
||||||
|
|
||||||
ParcelableFileCache<ParcelableKeyRing> cacheSecret =
|
ParcelableFileCache<ParcelableKeyRing> cacheSecret =
|
||||||
new ParcelableFileCache<ParcelableKeyRing>(mContext, "consolidate_secret.pcl");
|
new ParcelableFileCache<>(mContext, "consolidate_secret.pcl");
|
||||||
ParcelableFileCache<ParcelableKeyRing> cachePublic =
|
ParcelableFileCache<ParcelableKeyRing> cachePublic =
|
||||||
new ParcelableFileCache<ParcelableKeyRing>(mContext, "consolidate_public.pcl");
|
new ParcelableFileCache<>(mContext, "consolidate_public.pcl");
|
||||||
|
|
||||||
// Set flag that we have a cached consolidation here
|
// Set flag that we have a cached consolidation here
|
||||||
try {
|
try {
|
||||||
@ -1380,7 +1380,7 @@ public class ProviderHelper {
|
|||||||
public ArrayList<String> getRegisteredApiApps() {
|
public ArrayList<String> getRegisteredApiApps() {
|
||||||
Cursor cursor = mContentResolver.query(ApiApps.CONTENT_URI, null, null, null, null);
|
Cursor cursor = mContentResolver.query(ApiApps.CONTENT_URI, null, null, null, null);
|
||||||
|
|
||||||
ArrayList<String> packageNames = new ArrayList<String>();
|
ArrayList<String> packageNames = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
int packageNameCol = cursor.getColumnIndex(ApiApps.PACKAGE_NAME);
|
int packageNameCol = cursor.getColumnIndex(ApiApps.PACKAGE_NAME);
|
||||||
@ -1485,7 +1485,7 @@ public class ProviderHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<Long> getAllKeyIdsForApp(Uri uri) {
|
public Set<Long> getAllKeyIdsForApp(Uri uri) {
|
||||||
Set<Long> keyIds = new HashSet<Long>();
|
Set<Long> keyIds = new HashSet<>();
|
||||||
|
|
||||||
Cursor cursor = mContentResolver.query(uri, null, null, null, null);
|
Cursor cursor = mContentResolver.query(uri, null, null, null, null);
|
||||||
try {
|
try {
|
||||||
@ -1505,7 +1505,7 @@ public class ProviderHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getAllFingerprints(Uri uri) {
|
public Set<String> getAllFingerprints(Uri uri) {
|
||||||
Set<String> fingerprints = new HashSet<String>();
|
Set<String> fingerprints = new HashSet<>();
|
||||||
String[] projection = new String[]{KeyRings.FINGERPRINT};
|
String[] projection = new String[]{KeyRings.FINGERPRINT};
|
||||||
Cursor cursor = mContentResolver.query(uri, projection, null, null, null);
|
Cursor cursor = mContentResolver.query(uri, projection, null, null, null);
|
||||||
try {
|
try {
|
||||||
|
@ -85,9 +85,9 @@ public class OpenPgpService extends RemoteService {
|
|||||||
boolean missingUserIdsCheck = false;
|
boolean missingUserIdsCheck = false;
|
||||||
boolean duplicateUserIdsCheck = false;
|
boolean duplicateUserIdsCheck = false;
|
||||||
|
|
||||||
ArrayList<Long> keyIds = new ArrayList<Long>();
|
ArrayList<Long> keyIds = new ArrayList<>();
|
||||||
ArrayList<String> missingUserIds = new ArrayList<String>();
|
ArrayList<String> missingUserIds = new ArrayList<>();
|
||||||
ArrayList<String> duplicateUserIds = new ArrayList<String>();
|
ArrayList<String> duplicateUserIds = new ArrayList<>();
|
||||||
if (!noUserIdsCheck) {
|
if (!noUserIdsCheck) {
|
||||||
for (String email : encryptionUserIds) {
|
for (String email : encryptionUserIds) {
|
||||||
// try to find the key for this specific email
|
// try to find the key for this specific email
|
||||||
@ -718,29 +718,32 @@ public class OpenPgpService extends RemoteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String action = data.getAction();
|
String action = data.getAction();
|
||||||
if (OpenPgpApi.ACTION_SIGN.equals(action)) {
|
switch (action) {
|
||||||
|
case OpenPgpApi.ACTION_SIGN:
|
||||||
return signImpl(data, input, output, accSettings);
|
return signImpl(data, input, output, accSettings);
|
||||||
} else if (OpenPgpApi.ACTION_ENCRYPT.equals(action)) {
|
case OpenPgpApi.ACTION_ENCRYPT:
|
||||||
return encryptAndSignImpl(data, input, output, accSettings, false);
|
return encryptAndSignImpl(data, input, output, accSettings, false);
|
||||||
} else if (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(action)) {
|
case OpenPgpApi.ACTION_SIGN_AND_ENCRYPT:
|
||||||
return encryptAndSignImpl(data, input, output, accSettings, true);
|
return encryptAndSignImpl(data, input, output, accSettings, true);
|
||||||
} else if (OpenPgpApi.ACTION_DECRYPT_VERIFY.equals(action)) {
|
case OpenPgpApi.ACTION_DECRYPT_VERIFY: {
|
||||||
String currentPkg = getCurrentCallingPackage();
|
String currentPkg = getCurrentCallingPackage();
|
||||||
Set<Long> allowedKeyIds =
|
Set<Long> allowedKeyIds =
|
||||||
mProviderHelper.getAllKeyIdsForApp(
|
mProviderHelper.getAllKeyIdsForApp(
|
||||||
ApiAccounts.buildBaseUri(currentPkg));
|
ApiAccounts.buildBaseUri(currentPkg));
|
||||||
return decryptAndVerifyImpl(data, input, output, allowedKeyIds, false);
|
return decryptAndVerifyImpl(data, input, output, allowedKeyIds, false);
|
||||||
} else if (OpenPgpApi.ACTION_DECRYPT_METADATA.equals(action)) {
|
}
|
||||||
|
case OpenPgpApi.ACTION_DECRYPT_METADATA: {
|
||||||
String currentPkg = getCurrentCallingPackage();
|
String currentPkg = getCurrentCallingPackage();
|
||||||
Set<Long> allowedKeyIds =
|
Set<Long> allowedKeyIds =
|
||||||
mProviderHelper.getAllKeyIdsForApp(
|
mProviderHelper.getAllKeyIdsForApp(
|
||||||
ApiAccounts.buildBaseUri(currentPkg));
|
ApiAccounts.buildBaseUri(currentPkg));
|
||||||
return decryptAndVerifyImpl(data, input, output, allowedKeyIds, true);
|
return decryptAndVerifyImpl(data, input, output, allowedKeyIds, true);
|
||||||
} else if (OpenPgpApi.ACTION_GET_KEY.equals(action)) {
|
}
|
||||||
|
case OpenPgpApi.ACTION_GET_KEY:
|
||||||
return getKeyImpl(data);
|
return getKeyImpl(data);
|
||||||
} else if (OpenPgpApi.ACTION_GET_KEY_IDS.equals(action)) {
|
case OpenPgpApi.ACTION_GET_KEY_IDS:
|
||||||
return getKeyIdsImpl(data);
|
return getKeyIdsImpl(data);
|
||||||
} else {
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||||||
import android.content.pm.Signature;
|
import android.content.pm.Signature;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import org.openintents.openpgp.OpenPgpError;
|
import org.openintents.openpgp.OpenPgpError;
|
||||||
import org.openintents.openpgp.util.OpenPgpApi;
|
import org.openintents.openpgp.util.OpenPgpApi;
|
||||||
@ -216,9 +215,7 @@ public abstract class RemoteService extends Service {
|
|||||||
String[] callingPackages = getPackageManager().getPackagesForUid(uid);
|
String[] callingPackages = getPackageManager().getPackagesForUid(uid);
|
||||||
|
|
||||||
// is calling package allowed to use this service?
|
// is calling package allowed to use this service?
|
||||||
for (int i = 0; i < callingPackages.length; i++) {
|
for (String currentPkg : callingPackages) {
|
||||||
String currentPkg = callingPackages[i];
|
|
||||||
|
|
||||||
if (isPackageAllowed(currentPkg)) {
|
if (isPackageAllowed(currentPkg)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.remote.ui;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -22,8 +22,6 @@ import android.content.pm.ApplicationInfo;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import android.graphics.Color;
|
|||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
@ -108,7 +107,8 @@ public class RemoteServiceActivity extends BaseActivity {
|
|||||||
final Bundle extras = intent.getExtras();
|
final Bundle extras = intent.getExtras();
|
||||||
|
|
||||||
|
|
||||||
if (ACTION_REGISTER.equals(action)) {
|
switch (action) {
|
||||||
|
case ACTION_REGISTER: {
|
||||||
final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
|
final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
|
||||||
final byte[] packageSignature = extras.getByteArray(EXTRA_PACKAGE_SIGNATURE);
|
final byte[] packageSignature = extras.getByteArray(EXTRA_PACKAGE_SIGNATURE);
|
||||||
Log.d(Constants.TAG, "ACTION_REGISTER packageName: " + packageName);
|
Log.d(Constants.TAG, "ACTION_REGISTER packageName: " + packageName);
|
||||||
@ -147,7 +147,9 @@ public class RemoteServiceActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else if (ACTION_CREATE_ACCOUNT.equals(action)) {
|
break;
|
||||||
|
}
|
||||||
|
case ACTION_CREATE_ACCOUNT: {
|
||||||
final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
|
final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
|
||||||
final String accName = extras.getString(EXTRA_ACC_NAME);
|
final String accName = extras.getString(EXTRA_ACC_NAME);
|
||||||
|
|
||||||
@ -217,7 +219,9 @@ public class RemoteServiceActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
} else if (ACTION_SELECT_PUB_KEYS.equals(action)) {
|
break;
|
||||||
|
}
|
||||||
|
case ACTION_SELECT_PUB_KEYS: {
|
||||||
long[] selectedMasterKeyIds = intent.getLongArrayExtra(EXTRA_SELECTED_MASTER_KEY_IDS);
|
long[] selectedMasterKeyIds = intent.getLongArrayExtra(EXTRA_SELECTED_MASTER_KEY_IDS);
|
||||||
boolean noUserIdsCheck = intent.getBooleanExtra(EXTRA_NO_USER_IDS_CHECK, true);
|
boolean noUserIdsCheck = intent.getBooleanExtra(EXTRA_NO_USER_IDS_CHECK, true);
|
||||||
ArrayList<String> missingUserIds = intent
|
ArrayList<String> missingUserIds = intent
|
||||||
@ -307,7 +311,9 @@ public class RemoteServiceActivity extends BaseActivity {
|
|||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
.add(R.id.api_select_pub_keys_fragment_container, mSelectFragment).commit();
|
.add(R.id.api_select_pub_keys_fragment_container, mSelectFragment).commit();
|
||||||
}
|
}
|
||||||
} else if (ACTION_ERROR_MESSAGE.equals(action)) {
|
break;
|
||||||
|
}
|
||||||
|
case ACTION_ERROR_MESSAGE: {
|
||||||
String errorMessage = intent.getStringExtra(EXTRA_ERROR_MESSAGE);
|
String errorMessage = intent.getStringExtra(EXTRA_ERROR_MESSAGE);
|
||||||
|
|
||||||
Spannable redErrorMessage = new SpannableString(errorMessage);
|
Spannable redErrorMessage = new SpannableString(errorMessage);
|
||||||
@ -332,10 +338,13 @@ public class RemoteServiceActivity extends BaseActivity {
|
|||||||
// set text on view
|
// set text on view
|
||||||
TextView textView = (TextView) findViewById(R.id.api_app_error_message_text);
|
TextView textView = (TextView) findViewById(R.id.api_app_error_message_text);
|
||||||
textView.setText(redErrorMessage);
|
textView.setText(redErrorMessage);
|
||||||
} else {
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
Log.e(Constants.TAG, "Action does not exist!");
|
Log.e(Constants.TAG, "Action does not exist!");
|
||||||
setResult(RESULT_CANCELED);
|
setResult(RESULT_CANCELED);
|
||||||
finish();
|
finish();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class CertifyActionsParcel implements Parcelable {
|
|||||||
final public long mMasterKeyId;
|
final public long mMasterKeyId;
|
||||||
public CertifyLevel mLevel;
|
public CertifyLevel mLevel;
|
||||||
|
|
||||||
public ArrayList<CertifyAction> mCertifyActions = new ArrayList<CertifyAction>();
|
public ArrayList<CertifyAction> mCertifyActions = new ArrayList<>();
|
||||||
|
|
||||||
public CertifyActionsParcel(long masterKeyId) {
|
public CertifyActionsParcel(long masterKeyId) {
|
||||||
mMasterKeyId = masterKeyId;
|
mMasterKeyId = masterKeyId;
|
||||||
|
@ -34,7 +34,6 @@ import org.sufficientlysecure.keychain.operations.PromoteKeyOperation;
|
|||||||
import org.sufficientlysecure.keychain.operations.results.DeleteResult;
|
import org.sufficientlysecure.keychain.operations.results.DeleteResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.EditKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.EditKeyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.ExportResult;
|
import org.sufficientlysecure.keychain.operations.results.ExportResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.PromoteKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.PromoteKeyResult;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
import org.sufficientlysecure.keychain.operations.results.CertifyResult;
|
import org.sufficientlysecure.keychain.operations.results.CertifyResult;
|
||||||
@ -232,7 +231,8 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
|
|
||||||
// executeServiceMethod action from extra bundle
|
// executeServiceMethod action from extra bundle
|
||||||
if (ACTION_CERTIFY_KEYRING.equals(action)) {
|
switch (action) {
|
||||||
|
case ACTION_CERTIFY_KEYRING: {
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
CertifyActionsParcel parcel = data.getParcelable(CERTIFY_PARCEL);
|
CertifyActionsParcel parcel = data.getParcelable(CERTIFY_PARCEL);
|
||||||
@ -245,7 +245,9 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
// Result
|
// Result
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
||||||
|
|
||||||
} else if (ACTION_CONSOLIDATE.equals(action)) {
|
break;
|
||||||
|
}
|
||||||
|
case ACTION_CONSOLIDATE: {
|
||||||
|
|
||||||
// Operation
|
// Operation
|
||||||
ConsolidateResult result;
|
ConsolidateResult result;
|
||||||
@ -258,7 +260,9 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
// Result
|
// Result
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
||||||
|
|
||||||
} else if (ACTION_DECRYPT_METADATA.equals(action)) {
|
break;
|
||||||
|
}
|
||||||
|
case ACTION_DECRYPT_METADATA:
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/* Input */
|
/* Input */
|
||||||
@ -288,7 +292,8 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
sendErrorToHandler(e);
|
sendErrorToHandler(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (ACTION_DECRYPT_VERIFY.equals(action)) {
|
break;
|
||||||
|
case ACTION_DECRYPT_VERIFY:
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/* Input */
|
/* Input */
|
||||||
@ -329,7 +334,8 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
sendErrorToHandler(e);
|
sendErrorToHandler(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (ACTION_DELETE.equals(action)) {
|
break;
|
||||||
|
case ACTION_DELETE: {
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
long[] masterKeyIds = data.getLongArray(DELETE_KEY_LIST);
|
long[] masterKeyIds = data.getLongArray(DELETE_KEY_LIST);
|
||||||
@ -342,7 +348,9 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
// Result
|
// Result
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
||||||
|
|
||||||
} else if (ACTION_EDIT_KEYRING.equals(action)) {
|
break;
|
||||||
|
}
|
||||||
|
case ACTION_EDIT_KEYRING: {
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
SaveKeyringParcel saveParcel = data.getParcelable(EDIT_KEYRING_PARCEL);
|
SaveKeyringParcel saveParcel = data.getParcelable(EDIT_KEYRING_PARCEL);
|
||||||
@ -355,7 +363,9 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
// Result
|
// Result
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
||||||
|
|
||||||
} else if (ACTION_PROMOTE_KEYRING.equals(action)) {
|
break;
|
||||||
|
}
|
||||||
|
case ACTION_PROMOTE_KEYRING: {
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
long keyRingId = data.getInt(EXPORT_KEY_RING_MASTER_KEY_ID);
|
long keyRingId = data.getInt(EXPORT_KEY_RING_MASTER_KEY_ID);
|
||||||
@ -367,7 +377,9 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
// Result
|
// Result
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
||||||
|
|
||||||
} else if (ACTION_EXPORT_KEYRING.equals(action)) {
|
break;
|
||||||
|
}
|
||||||
|
case ACTION_EXPORT_KEYRING: {
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
boolean exportSecret = data.getBoolean(EXPORT_SECRET, false);
|
boolean exportSecret = data.getBoolean(EXPORT_SECRET, false);
|
||||||
@ -389,7 +401,9 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
// Result
|
// Result
|
||||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, result);
|
||||||
|
|
||||||
} else if (ACTION_IMPORT_KEYRING.equals(action)) {
|
break;
|
||||||
|
}
|
||||||
|
case ACTION_IMPORT_KEYRING:
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -405,7 +419,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
} else {
|
} else {
|
||||||
// get entries from cached file
|
// get entries from cached file
|
||||||
ParcelableFileCache<ParcelableKeyRing> cache =
|
ParcelableFileCache<ParcelableKeyRing> cache =
|
||||||
new ParcelableFileCache<ParcelableKeyRing>(this, "key_import.pcl");
|
new ParcelableFileCache<>(this, "key_import.pcl");
|
||||||
IteratorWithSize<ParcelableKeyRing> it = cache.readCache();
|
IteratorWithSize<ParcelableKeyRing> it = cache.readCache();
|
||||||
entries = it;
|
entries = it;
|
||||||
numEntries = it.getSize();
|
numEntries = it.getSize();
|
||||||
@ -431,7 +445,8 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
sendErrorToHandler(e);
|
sendErrorToHandler(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (ACTION_SIGN_ENCRYPT.equals(action)) {
|
break;
|
||||||
|
case ACTION_SIGN_ENCRYPT:
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/* Input */
|
/* Input */
|
||||||
@ -515,7 +530,8 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
sendErrorToHandler(e);
|
sendErrorToHandler(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (ACTION_UPLOAD_KEYRING.equals(action)) {
|
break;
|
||||||
|
case ACTION_UPLOAD_KEYRING:
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -539,6 +555,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sendErrorToHandler(e);
|
sendErrorToHandler(e);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@ import android.support.v4.util.LongSparseArray;
|
|||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
|
||||||
import org.sufficientlysecure.keychain.util.Preferences;
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||||
@ -103,7 +102,7 @@ public class PassphraseCacheService extends Service {
|
|||||||
|
|
||||||
private BroadcastReceiver mIntentReceiver;
|
private BroadcastReceiver mIntentReceiver;
|
||||||
|
|
||||||
private LongSparseArray<CachedPassphrase> mPassphraseCache = new LongSparseArray<CachedPassphrase>();
|
private LongSparseArray<CachedPassphrase> mPassphraseCache = new LongSparseArray<>();
|
||||||
|
|
||||||
Context mContext;
|
Context mContext;
|
||||||
|
|
||||||
|
@ -71,13 +71,13 @@ public class SaveKeyringParcel implements Parcelable {
|
|||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
mNewUnlock = null;
|
mNewUnlock = null;
|
||||||
mAddUserIds = new ArrayList<String>();
|
mAddUserIds = new ArrayList<>();
|
||||||
mAddUserAttribute = new ArrayList<WrappedUserAttribute>();
|
mAddUserAttribute = new ArrayList<>();
|
||||||
mAddSubKeys = new ArrayList<SubkeyAdd>();
|
mAddSubKeys = new ArrayList<>();
|
||||||
mChangePrimaryUserId = null;
|
mChangePrimaryUserId = null;
|
||||||
mChangeSubKeys = new ArrayList<SubkeyChange>();
|
mChangeSubKeys = new ArrayList<>();
|
||||||
mRevokeUserIds = new ArrayList<String>();
|
mRevokeUserIds = new ArrayList<>();
|
||||||
mRevokeSubKeys = new ArrayList<Long>();
|
mRevokeSubKeys = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true iff this parcel does not contain any operations which require a passphrase. */
|
/** Returns true iff this parcel does not contain any operations which require a passphrase. */
|
||||||
@ -173,7 +173,7 @@ public class SaveKeyringParcel implements Parcelable {
|
|||||||
out += "mFlags: " + mFlags + ", ";
|
out += "mFlags: " + mFlags + ", ";
|
||||||
out += "mExpiry: " + mExpiry + ", ";
|
out += "mExpiry: " + mExpiry + ", ";
|
||||||
out += "mDummyStrip: " + mDummyStrip + ", ";
|
out += "mDummyStrip: " + mDummyStrip + ", ";
|
||||||
out += "mDummyDivert: " + mDummyDivert;
|
out += "mDummyDivert: [" + (mDummyDivert == null ? 0 : mDummyDivert.length) + " bytes]";
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,6 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -234,7 +234,7 @@ public class CertifyKeyFragment extends LoaderFragment
|
|||||||
|
|
||||||
long lastMasterKeyId = 0;
|
long lastMasterKeyId = 0;
|
||||||
String lastName = "";
|
String lastName = "";
|
||||||
ArrayList<String> uids = new ArrayList<String>();
|
ArrayList<String> uids = new ArrayList<>();
|
||||||
|
|
||||||
boolean header = true;
|
boolean header = true;
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@ import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
|||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
||||||
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
|
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
public class CreateKeyFinalFragment extends Fragment {
|
public class CreateKeyFinalFragment extends Fragment {
|
||||||
|
@ -89,7 +89,7 @@ public class CreateKeyInputFragment extends Fragment {
|
|||||||
|
|
||||||
mEmailEdit.setThreshold(1); // Start working from first character
|
mEmailEdit.setThreshold(1); // Start working from first character
|
||||||
mEmailEdit.setAdapter(
|
mEmailEdit.setAdapter(
|
||||||
new ArrayAdapter<String>
|
new ArrayAdapter<>
|
||||||
(getActivity(), android.R.layout.simple_spinner_dropdown_item,
|
(getActivity(), android.R.layout.simple_spinner_dropdown_item,
|
||||||
ContactHelper.getPossibleUserEmails(getActivity())
|
ContactHelper.getPossibleUserEmails(getActivity())
|
||||||
)
|
)
|
||||||
@ -124,7 +124,7 @@ public class CreateKeyInputFragment extends Fragment {
|
|||||||
|
|
||||||
mNameEdit.setThreshold(1); // Start working from first character
|
mNameEdit.setThreshold(1); // Start working from first character
|
||||||
mNameEdit.setAdapter(
|
mNameEdit.setAdapter(
|
||||||
new ArrayAdapter<String>
|
new ArrayAdapter<>
|
||||||
(getActivity(), android.R.layout.simple_spinner_dropdown_item,
|
(getActivity(), android.R.layout.simple_spinner_dropdown_item,
|
||||||
ContactHelper.getPossibleUserNames(getActivity())
|
ContactHelper.getPossibleUserNames(getActivity())
|
||||||
)
|
)
|
||||||
|
@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
@ -19,7 +19,6 @@ package org.sufficientlysecure.keychain.ui;
|
|||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
@ -231,10 +231,7 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
mSaveKeyringParcel = new SaveKeyringParcel(masterKeyId, keyRing.getFingerprint());
|
mSaveKeyringParcel = new SaveKeyringParcel(masterKeyId, keyRing.getFingerprint());
|
||||||
mPrimaryUserId = keyRing.getPrimaryUserIdWithFallback();
|
mPrimaryUserId = keyRing.getPrimaryUserIdWithFallback();
|
||||||
|
|
||||||
} catch (PgpKeyNotFoundException e) {
|
} catch (PgpKeyNotFoundException | NotFoundException e) {
|
||||||
finishWithError(LogType.MSG_EK_ERROR_NOT_FOUND);
|
|
||||||
return;
|
|
||||||
} catch (NotFoundException e) {
|
|
||||||
finishWithError(LogType.MSG_EK_ERROR_NOT_FOUND);
|
finishWithError(LogType.MSG_EK_ERROR_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ import com.tokenautocomplete.TokenCompleteTextView;
|
|||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
@ -164,8 +163,8 @@ public class EncryptAsymmetricFragment extends Fragment implements EncryptActivi
|
|||||||
|
|
||||||
private void updateEncryptionKeys() {
|
private void updateEncryptionKeys() {
|
||||||
List<Object> objects = mEncryptKeyView.getObjects();
|
List<Object> objects = mEncryptKeyView.getObjects();
|
||||||
List<Long> keyIds = new ArrayList<Long>();
|
List<Long> keyIds = new ArrayList<>();
|
||||||
List<String> userIds = new ArrayList<String>();
|
List<String> userIds = new ArrayList<>();
|
||||||
for (Object object : objects) {
|
for (Object object : objects) {
|
||||||
if (object instanceof EncryptKeyCompletionView.EncryptionKey) {
|
if (object instanceof EncryptKeyCompletionView.EncryptionKey) {
|
||||||
keyIds.add(((EncryptKeyCompletionView.EncryptionKey) object).getKeyId());
|
keyIds.add(((EncryptKeyCompletionView.EncryptionKey) object).getKeyId());
|
||||||
|
@ -122,13 +122,13 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<Uri> getInputUris() {
|
public ArrayList<Uri> getInputUris() {
|
||||||
if (mInputUris == null) mInputUris = new ArrayList<Uri>();
|
if (mInputUris == null) mInputUris = new ArrayList<>();
|
||||||
return mInputUris;
|
return mInputUris;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<Uri> getOutputUris() {
|
public ArrayList<Uri> getOutputUris() {
|
||||||
if (mOutputUris == null) mOutputUris = new ArrayList<Uri>();
|
if (mOutputUris == null) mOutputUris = new ArrayList<>();
|
||||||
return mOutputUris;
|
return mOutputUris;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi
|
|||||||
sendIntent.setType("application/octet-stream");
|
sendIntent.setType("application/octet-stream");
|
||||||
|
|
||||||
if (!isModeSymmetric() && mEncryptionUserIds != null) {
|
if (!isModeSymmetric() && mEncryptionUserIds != null) {
|
||||||
Set<String> users = new HashSet<String>();
|
Set<String> users = new HashSet<>();
|
||||||
for (String user : mEncryptionUserIds) {
|
for (String user : mEncryptionUserIds) {
|
||||||
String[] userId = KeyRing.splitUserId(user);
|
String[] userId = KeyRing.splitUserId(user);
|
||||||
if (userId[1] != null) {
|
if (userId[1] != null) {
|
||||||
@ -382,7 +382,7 @@ public class EncryptFilesActivity extends EncryptActivity implements EncryptActi
|
|||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
Bundle extras = intent.getExtras();
|
Bundle extras = intent.getExtras();
|
||||||
String type = intent.getType();
|
String type = intent.getType();
|
||||||
ArrayList<Uri> uris = new ArrayList<Uri>();
|
ArrayList<Uri> uris = new ArrayList<>();
|
||||||
|
|
||||||
if (extras == null) {
|
if (extras == null) {
|
||||||
extras = new Bundle();
|
extras = new Bundle();
|
||||||
|
@ -59,7 +59,7 @@ public class EncryptFilesFragment extends Fragment implements EncryptActivityInt
|
|||||||
private View mShareFile;
|
private View mShareFile;
|
||||||
private ListView mSelectedFiles;
|
private ListView mSelectedFiles;
|
||||||
private SelectedFilesAdapter mAdapter = new SelectedFilesAdapter();
|
private SelectedFilesAdapter mAdapter = new SelectedFilesAdapter();
|
||||||
private final Map<Uri, Bitmap> thumbnailCache = new HashMap<Uri, Bitmap>();
|
private final Map<Uri, Bitmap> thumbnailCache = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
@ -224,7 +224,7 @@ public class EncryptFilesFragment extends Fragment implements EncryptActivityInt
|
|||||||
@Override
|
@Override
|
||||||
public void onNotifyUpdate() {
|
public void onNotifyUpdate() {
|
||||||
// Clear cache if needed
|
// Clear cache if needed
|
||||||
for (Uri uri : new HashSet<Uri>(thumbnailCache.keySet())) {
|
for (Uri uri : new HashSet<>(thumbnailCache.keySet())) {
|
||||||
if (!mEncryptInterface.getInputUris().contains(uri)) {
|
if (!mEncryptInterface.getInputUris().contains(uri)) {
|
||||||
thumbnailCache.remove(uri);
|
thumbnailCache.remove(uri);
|
||||||
}
|
}
|
||||||
|
@ -121,13 +121,13 @@ public class EncryptTextActivity extends EncryptActivity implements EncryptActiv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<Uri> getInputUris() {
|
public ArrayList<Uri> getInputUris() {
|
||||||
if (mInputUris == null) mInputUris = new ArrayList<Uri>();
|
if (mInputUris == null) mInputUris = new ArrayList<>();
|
||||||
return mInputUris;
|
return mInputUris;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<Uri> getOutputUris() {
|
public ArrayList<Uri> getOutputUris() {
|
||||||
if (mOutputUris == null) mOutputUris = new ArrayList<Uri>();
|
if (mOutputUris == null) mOutputUris = new ArrayList<>();
|
||||||
return mOutputUris;
|
return mOutputUris;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ public class EncryptTextActivity extends EncryptActivity implements EncryptActiv
|
|||||||
sendIntent.putExtra(Intent.EXTRA_TEXT, new String(message.getData().getByteArray(KeychainIntentService.RESULT_BYTES)));
|
sendIntent.putExtra(Intent.EXTRA_TEXT, new String(message.getData().getByteArray(KeychainIntentService.RESULT_BYTES)));
|
||||||
|
|
||||||
if (!isModeSymmetric() && mEncryptionUserIds != null) {
|
if (!isModeSymmetric() && mEncryptionUserIds != null) {
|
||||||
Set<String> users = new HashSet<String>();
|
Set<String> users = new HashSet<>();
|
||||||
for (String user : mEncryptionUserIds) {
|
for (String user : mEncryptionUserIds) {
|
||||||
String[] userId = KeyRing.splitUserId(user);
|
String[] userId = KeyRing.splitUserId(user);
|
||||||
if (userId[1] != null) {
|
if (userId[1] != null) {
|
||||||
|
@ -19,7 +19,6 @@ package org.sufficientlysecure.keychain.ui;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
@ -29,7 +29,6 @@ import android.os.Message;
|
|||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
|
||||||
@ -122,7 +121,8 @@ public class ImportKeysActivity extends BaseActivity {
|
|||||||
action = ACTION_IMPORT_KEY;
|
action = ACTION_IMPORT_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ACTION_IMPORT_KEY.equals(action)) {
|
switch (action) {
|
||||||
|
case ACTION_IMPORT_KEY:
|
||||||
/* Keychain's own Actions */
|
/* Keychain's own Actions */
|
||||||
startFileFragment(savedInstanceState);
|
startFileFragment(savedInstanceState);
|
||||||
|
|
||||||
@ -135,9 +135,10 @@ public class ImportKeysActivity extends BaseActivity {
|
|||||||
// action: directly load data
|
// action: directly load data
|
||||||
startListFragment(savedInstanceState, importData, null, null);
|
startListFragment(savedInstanceState, importData, null, null);
|
||||||
}
|
}
|
||||||
} else if (ACTION_IMPORT_KEY_FROM_KEYSERVER.equals(action)
|
break;
|
||||||
|| ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE.equals(action)
|
case ACTION_IMPORT_KEY_FROM_KEYSERVER:
|
||||||
|| ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT.equals(action)) {
|
case ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE:
|
||||||
|
case ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT:
|
||||||
|
|
||||||
// only used for OpenPgpService
|
// only used for OpenPgpService
|
||||||
if (extras.containsKey(EXTRA_PENDING_INTENT_DATA)) {
|
if (extras.containsKey(EXTRA_PENDING_INTENT_DATA)) {
|
||||||
@ -189,28 +190,33 @@ public class ImportKeysActivity extends BaseActivity {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (ACTION_IMPORT_KEY_FROM_FILE.equals(action)) {
|
break;
|
||||||
|
case ACTION_IMPORT_KEY_FROM_FILE:
|
||||||
// NOTE: this only displays the appropriate fragment, no actions are taken
|
// NOTE: this only displays the appropriate fragment, no actions are taken
|
||||||
startFileFragment(savedInstanceState);
|
startFileFragment(savedInstanceState);
|
||||||
|
|
||||||
// no immediate actions!
|
// no immediate actions!
|
||||||
startListFragment(savedInstanceState, null, null, null);
|
startListFragment(savedInstanceState, null, null, null);
|
||||||
} else if (ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN.equals(action)) {
|
break;
|
||||||
|
case ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN:
|
||||||
// NOTE: this only displays the appropriate fragment, no actions are taken
|
// NOTE: this only displays the appropriate fragment, no actions are taken
|
||||||
startFileFragment(savedInstanceState);
|
startFileFragment(savedInstanceState);
|
||||||
|
|
||||||
// no immediate actions!
|
// no immediate actions!
|
||||||
startListFragment(savedInstanceState, null, null, null);
|
startListFragment(savedInstanceState, null, null, null);
|
||||||
} else if (ACTION_IMPORT_KEY_FROM_NFC.equals(action)) {
|
break;
|
||||||
|
case ACTION_IMPORT_KEY_FROM_NFC:
|
||||||
// NOTE: this only displays the appropriate fragment, no actions are taken
|
// NOTE: this only displays the appropriate fragment, no actions are taken
|
||||||
startFileFragment(savedInstanceState);
|
startFileFragment(savedInstanceState);
|
||||||
// TODO!!!!!
|
// TODO!!!!!
|
||||||
|
|
||||||
// no immediate actions!
|
// no immediate actions!
|
||||||
startListFragment(savedInstanceState, null, null, null);
|
startListFragment(savedInstanceState, null, null, null);
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
startCloudFragment(savedInstanceState, null, false);
|
startCloudFragment(savedInstanceState, null, false);
|
||||||
startListFragment(savedInstanceState, null, null, null);
|
startListFragment(savedInstanceState, null, null, null);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +362,7 @@ public class ImportKeysActivity extends BaseActivity {
|
|||||||
// We parcel this iteratively into a file - anything we can
|
// We parcel this iteratively into a file - anything we can
|
||||||
// display here, we should be able to import.
|
// display here, we should be able to import.
|
||||||
ParcelableFileCache<ParcelableKeyRing> cache =
|
ParcelableFileCache<ParcelableKeyRing> cache =
|
||||||
new ParcelableFileCache<ParcelableKeyRing>(this, "key_import.pcl");
|
new ParcelableFileCache<>(this, "key_import.pcl");
|
||||||
cache.writeCache(selectedEntries);
|
cache.writeCache(selectedEntries);
|
||||||
|
|
||||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||||
@ -388,7 +394,7 @@ public class ImportKeysActivity extends BaseActivity {
|
|||||||
data.putString(KeychainIntentService.IMPORT_KEY_SERVER, sls.mCloudPrefs.keyserver);
|
data.putString(KeychainIntentService.IMPORT_KEY_SERVER, sls.mCloudPrefs.keyserver);
|
||||||
|
|
||||||
// get selected key entries
|
// get selected key entries
|
||||||
ArrayList<ParcelableKeyRing> keys = new ArrayList<ParcelableKeyRing>();
|
ArrayList<ParcelableKeyRing> keys = new ArrayList<>();
|
||||||
{
|
{
|
||||||
// change the format into ParcelableKeyRing
|
// change the format into ParcelableKeyRing
|
||||||
ArrayList<ImportKeysListEntry> entries = mListFragment.getSelectedEntries();
|
ArrayList<ImportKeysListEntry> entries = mListFragment.getSelectedEntries();
|
||||||
|
@ -81,7 +81,7 @@ public class ImportKeysCloudFragment extends Fragment {
|
|||||||
namesAndEmails.addAll(ContactHelper.getContactMails(getActivity()));
|
namesAndEmails.addAll(ContactHelper.getContactMails(getActivity()));
|
||||||
mQueryEditText.setThreshold(3);
|
mQueryEditText.setThreshold(3);
|
||||||
mQueryEditText.setAdapter(
|
mQueryEditText.setAdapter(
|
||||||
new ArrayAdapter<String>
|
new ArrayAdapter<>
|
||||||
(getActivity(), android.R.layout.simple_spinner_dropdown_item,
|
(getActivity(), android.R.layout.simple_spinner_dropdown_item,
|
||||||
namesAndEmails
|
namesAndEmails
|
||||||
)
|
)
|
||||||
|
@ -113,7 +113,7 @@ public class ImportKeysListFragment extends ListFragment implements
|
|||||||
return mAdapter.getSelectedEntries();
|
return mAdapter.getSelectedEntries();
|
||||||
} else {
|
} else {
|
||||||
Log.e(Constants.TAG, "Adapter not initialized, returning empty list");
|
Log.e(Constants.TAG, "Adapter not initialized, returning empty list");
|
||||||
return new ArrayList<ImportKeysListEntry>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.ProgressDialog;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
@ -31,7 +30,6 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
@ -52,7 +50,6 @@ import android.view.View.OnClickListener;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView.MultiChoiceModeListener;
|
import android.widget.AbsListView.MultiChoiceModeListener;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
@ -60,16 +57,9 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
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.operations.results.DeleteResult;
|
import org.sufficientlysecure.keychain.operations.results.DeleteResult;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.util.ExportHelper;
|
import org.sufficientlysecure.keychain.util.ExportHelper;
|
||||||
import org.sufficientlysecure.keychain.util.KeyUpdateHelper;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
@ -78,15 +68,10 @@ import org.sufficientlysecure.keychain.ui.widget.ListAwareSwipeRefreshLayout;
|
|||||||
import org.sufficientlysecure.keychain.ui.util.Highlighter;
|
import org.sufficientlysecure.keychain.ui.util.Highlighter;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
import org.sufficientlysecure.keychain.util.ParcelableFileCache;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import edu.cmu.cylab.starslinger.exchange.ExchangeActivity;
|
|
||||||
import edu.cmu.cylab.starslinger.exchange.ExchangeConfig;
|
|
||||||
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
|
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
|
||||||
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
||||||
|
|
||||||
@ -517,7 +502,7 @@ public class KeyListFragment extends LoaderFragment
|
|||||||
private String mQuery;
|
private String mQuery;
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
|
|
||||||
private HashMap<Integer, Boolean> mSelection = new HashMap<Integer, Boolean>();
|
private HashMap<Integer, Boolean> mSelection = new HashMap<>();
|
||||||
|
|
||||||
public KeyListAdapter(Context context, Cursor c, int flags) {
|
public KeyListAdapter(Context context, Cursor c, int flags) {
|
||||||
super(context, c, flags);
|
super(context, c, flags);
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
@ -15,7 +15,6 @@ import android.nfc.Tag;
|
|||||||
import android.nfc.tech.IsoDep;
|
import android.nfc.tech.IsoDep;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -23,13 +22,11 @@ import org.spongycastle.bcpg.HashAlgorithmTags;
|
|||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
|
||||||
import org.sufficientlysecure.keychain.util.Iso7816TLV;
|
import org.sufficientlysecure.keychain.util.Iso7816TLV;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides a communication interface to OpenPGP applications on ISO SmartCard compliant
|
* This class provides a communication interface to OpenPGP applications on ISO SmartCard compliant
|
||||||
@ -91,7 +88,8 @@ public class NfcActivity extends BaseActivity {
|
|||||||
mKeyId = data.getLong(EXTRA_KEY_ID);
|
mKeyId = data.getLong(EXTRA_KEY_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ACTION_SIGN_HASH.equals(action)) {
|
switch (action) {
|
||||||
|
case ACTION_SIGN_HASH:
|
||||||
mAction = action;
|
mAction = action;
|
||||||
mPin = data.getString(EXTRA_PIN);
|
mPin = data.getString(EXTRA_PIN);
|
||||||
mHashToSign = data.getByteArray(EXTRA_NFC_HASH_TO_SIGN);
|
mHashToSign = data.getByteArray(EXTRA_NFC_HASH_TO_SIGN);
|
||||||
@ -102,7 +100,8 @@ public class NfcActivity extends BaseActivity {
|
|||||||
Log.d(Constants.TAG, "NfcActivity mPin: " + mPin);
|
Log.d(Constants.TAG, "NfcActivity mPin: " + mPin);
|
||||||
Log.d(Constants.TAG, "NfcActivity mHashToSign as hex: " + getHex(mHashToSign));
|
Log.d(Constants.TAG, "NfcActivity mHashToSign as hex: " + getHex(mHashToSign));
|
||||||
Log.d(Constants.TAG, "NfcActivity mServiceIntent: " + mServiceIntent.toString());
|
Log.d(Constants.TAG, "NfcActivity mServiceIntent: " + mServiceIntent.toString());
|
||||||
} else if (ACTION_DECRYPT_SESSION_KEY.equals(action)) {
|
break;
|
||||||
|
case ACTION_DECRYPT_SESSION_KEY:
|
||||||
mAction = action;
|
mAction = action;
|
||||||
mPin = data.getString(EXTRA_PIN);
|
mPin = data.getString(EXTRA_PIN);
|
||||||
mEncryptedSessionKey = data.getByteArray(EXTRA_NFC_ENC_SESSION_KEY);
|
mEncryptedSessionKey = data.getByteArray(EXTRA_NFC_ENC_SESSION_KEY);
|
||||||
@ -112,12 +111,15 @@ public class NfcActivity extends BaseActivity {
|
|||||||
Log.d(Constants.TAG, "NfcActivity mPin: " + mPin);
|
Log.d(Constants.TAG, "NfcActivity mPin: " + mPin);
|
||||||
Log.d(Constants.TAG, "NfcActivity mEncryptedSessionKey as hex: " + getHex(mEncryptedSessionKey));
|
Log.d(Constants.TAG, "NfcActivity mEncryptedSessionKey as hex: " + getHex(mEncryptedSessionKey));
|
||||||
Log.d(Constants.TAG, "NfcActivity mServiceIntent: " + mServiceIntent.toString());
|
Log.d(Constants.TAG, "NfcActivity mServiceIntent: " + mServiceIntent.toString());
|
||||||
} else if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)) {
|
break;
|
||||||
|
case NfcAdapter.ACTION_TAG_DISCOVERED:
|
||||||
Log.e(Constants.TAG, "This should not happen! NfcActivity.onCreate() is being called instead of onNewIntent()!");
|
Log.e(Constants.TAG, "This should not happen! NfcActivity.onCreate() is being called instead of onNewIntent()!");
|
||||||
toast("This should not happen! Please create a new bug report that the NFC screen is restarted!");
|
toast("This should not happen! Please create a new bug report that the NFC screen is restarted!");
|
||||||
finish();
|
finish();
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
Log.d(Constants.TAG, "Action not supported: " + action);
|
Log.d(Constants.TAG, "Action not supported: " + action);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ import android.nfc.Tag;
|
|||||||
import android.nfc.tech.IsoDep;
|
import android.nfc.tech.IsoDep;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -209,9 +209,7 @@ public class PassphraseWizardActivity extends FragmentActivity implements LockPa
|
|||||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
transaction.replace(R.id.fragmentContainer, lpf).addToBackStack(null).commit();
|
transaction.replace(R.id.fragmentContainer, lpf).addToBackStack(null).commit();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException | FormatException e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (FormatException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,9 +234,7 @@ public class PassphraseWizardActivity extends FragmentActivity implements LockPa
|
|||||||
nfc.setText(R.string.nfc_wrong_tag);
|
nfc.setText(R.string.nfc_wrong_tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException | FormatException e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (FormatException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ public class QrCodeScanActivity extends FragmentActivity {
|
|||||||
data.putString(KeychainIntentService.IMPORT_KEY_SERVER, cloudPrefs.keyserver);
|
data.putString(KeychainIntentService.IMPORT_KEY_SERVER, cloudPrefs.keyserver);
|
||||||
|
|
||||||
ParcelableKeyRing keyEntry = new ParcelableKeyRing(fingerprint, null, null);
|
ParcelableKeyRing keyEntry = new ParcelableKeyRing(fingerprint, null, null);
|
||||||
ArrayList<ParcelableKeyRing> selectedEntries = new ArrayList<ParcelableKeyRing>();
|
ArrayList<ParcelableKeyRing> selectedEntries = new ArrayList<>();
|
||||||
selectedEntries.add(keyEntry);
|
selectedEntries.add(keyEntry);
|
||||||
|
|
||||||
data.putParcelableArrayList(KeychainIntentService.IMPORT_KEY_LIST, selectedEntries);
|
data.putParcelableArrayList(KeychainIntentService.IMPORT_KEY_LIST, selectedEntries);
|
||||||
|
@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
@ -27,13 +27,9 @@ import android.os.Bundle;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.NumberPicker;
|
import android.widget.NumberPicker;
|
||||||
import android.widget.Spinner;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
@ -50,7 +46,6 @@ import org.sufficientlysecure.keychain.util.ParcelableFileCache;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import edu.cmu.cylab.starslinger.exchange.ExchangeActivity;
|
import edu.cmu.cylab.starslinger.exchange.ExchangeActivity;
|
||||||
import edu.cmu.cylab.starslinger.exchange.ExchangeConfig;
|
import edu.cmu.cylab.starslinger.exchange.ExchangeConfig;
|
||||||
@ -192,7 +187,7 @@ public class SafeSlingerActivity extends BaseActivity {
|
|||||||
// We parcel this iteratively into a file - anything we can
|
// We parcel this iteratively into a file - anything we can
|
||||||
// display here, we should be able to import.
|
// display here, we should be able to import.
|
||||||
ParcelableFileCache<ParcelableKeyRing> cache =
|
ParcelableFileCache<ParcelableKeyRing> cache =
|
||||||
new ParcelableFileCache<ParcelableKeyRing>(activity, "key_import.pcl");
|
new ParcelableFileCache<>(activity, "key_import.pcl");
|
||||||
cache.writeCache(it.size(), it.iterator());
|
cache.writeCache(it.size(), it.iterator());
|
||||||
|
|
||||||
// fill values for this action
|
// fill values for this action
|
||||||
@ -220,7 +215,7 @@ public class SafeSlingerActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<ParcelableKeyRing> getSlingedKeys(Bundle extras) {
|
private static ArrayList<ParcelableKeyRing> getSlingedKeys(Bundle extras) {
|
||||||
ArrayList<ParcelableKeyRing> list = new ArrayList<ParcelableKeyRing>();
|
ArrayList<ParcelableKeyRing> list = new ArrayList<>();
|
||||||
|
|
||||||
if (extras != null) {
|
if (extras != null) {
|
||||||
byte[] d;
|
byte[] d;
|
||||||
|
@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
@ -42,7 +42,6 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.compatibility.ListFragmentWorkaround;
|
import org.sufficientlysecure.keychain.compatibility.ListFragmentWorkaround;
|
||||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.SelectKeyCursorAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.SelectKeyCursorAdapter;
|
||||||
@ -216,7 +215,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
|||||||
public long[] getSelectedMasterKeyIds() {
|
public long[] getSelectedMasterKeyIds() {
|
||||||
// mListView.getCheckedItemIds() would give the row ids of the KeyRings not the master key
|
// mListView.getCheckedItemIds() would give the row ids of the KeyRings not the master key
|
||||||
// ids!
|
// ids!
|
||||||
Vector<Long> vector = new Vector<Long>();
|
Vector<Long> vector = new Vector<>();
|
||||||
for (int i = 0; i < getListView().getCount(); ++i) {
|
for (int i = 0; i < getListView().getCount(); ++i) {
|
||||||
if (getListView().isItemChecked(i)) {
|
if (getListView().isItemChecked(i)) {
|
||||||
vector.add(mAdapter.getMasterKeyId(i));
|
vector.add(mAdapter.getMasterKeyId(i));
|
||||||
@ -238,7 +237,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String[] getSelectedUserIds() {
|
public String[] getSelectedUserIds() {
|
||||||
Vector<String> userIds = new Vector<String>();
|
Vector<String> userIds = new Vector<>();
|
||||||
for (int i = 0; i < getListView().getCount(); ++i) {
|
for (int i = 0; i < getListView().getCount(); ++i) {
|
||||||
if (getListView().isItemChecked(i)) {
|
if (getListView().isItemChecked(i)) {
|
||||||
userIds.add(mAdapter.getUserId(i));
|
userIds.add(mAdapter.getUserId(i));
|
||||||
|
@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@ -140,7 +139,7 @@ public class SettingsKeyServerActivity extends BaseActivity implements OnClickLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Vector<String> serverList() {
|
private Vector<String> serverList() {
|
||||||
Vector<String> servers = new Vector<String>();
|
Vector<String> servers = new Vector<>();
|
||||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||||
KeyServerEditor editor = (KeyServerEditor) mEditors.getChildAt(i);
|
KeyServerEditor editor = (KeyServerEditor) mEditors.getChildAt(i);
|
||||||
String tmp = editor.getValue();
|
String tmp = editor.getValue();
|
||||||
@ -153,7 +152,7 @@ public class SettingsKeyServerActivity extends BaseActivity implements OnClickLi
|
|||||||
|
|
||||||
private void okClicked() {
|
private void okClicked() {
|
||||||
Intent data = new Intent();
|
Intent data = new Intent();
|
||||||
Vector<String> servers = new Vector<String>();
|
Vector<String> servers = new Vector<>();
|
||||||
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||||
KeyServerEditor editor = (KeyServerEditor) mEditors.getChildAt(i);
|
KeyServerEditor editor = (KeyServerEditor) mEditors.getChildAt(i);
|
||||||
String tmp = editor.getValue();
|
String tmp = editor.getValue();
|
||||||
|
@ -24,7 +24,6 @@ import android.os.Bundle;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.support.v4.app.NavUtils;
|
import android.support.v4.app.NavUtils;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@ -57,7 +56,7 @@ public class UploadKeyActivity extends BaseActivity {
|
|||||||
mUploadButton = findViewById(R.id.upload_key_action_upload);
|
mUploadButton = findViewById(R.id.upload_key_action_upload);
|
||||||
mKeyServerSpinner = (Spinner) findViewById(R.id.upload_key_keyserver);
|
mKeyServerSpinner = (Spinner) findViewById(R.id.upload_key_keyserver);
|
||||||
|
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
|
||||||
android.R.layout.simple_spinner_item, Preferences.getPreferences(this)
|
android.R.layout.simple_spinner_item, Preferences.getPreferences(this)
|
||||||
.getKeyServers()
|
.getKeyServers()
|
||||||
);
|
);
|
||||||
|
@ -27,9 +27,6 @@ import android.support.v4.app.NavUtils;
|
|||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.text.SpannableString;
|
|
||||||
import android.text.SpannableStringBuilder;
|
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -37,7 +34,6 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.pgp.WrappedSignature;
|
import org.sufficientlysecure.keychain.pgp.WrappedSignature;
|
||||||
|
@ -20,8 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
|||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
@ -228,10 +228,7 @@ public class ViewKeyShareFragment extends LoaderFragment implements
|
|||||||
}
|
}
|
||||||
startActivity(Intent.createChooser(sendIntent, title));
|
startActivity(Intent.createChooser(sendIntent, title));
|
||||||
}
|
}
|
||||||
} catch (PgpGeneralException e) {
|
} catch (PgpGeneralException | IOException e) {
|
||||||
Log.e(Constants.TAG, "error processing key!", e);
|
|
||||||
Notify.showNotify(getActivity(), R.string.error_key_processing, Notify.Style.ERROR);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(Constants.TAG, "error processing key!", e);
|
Log.e(Constants.TAG, "error processing key!", e);
|
||||||
Notify.showNotify(getActivity(), R.string.error_key_processing, Notify.Style.ERROR);
|
Notify.showNotify(getActivity(), R.string.error_key_processing, Notify.Style.ERROR);
|
||||||
} catch (ProviderHelper.NotFoundException e) {
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
|
@ -95,8 +95,8 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
* @see org.sufficientlysecure.keychain.operations.ImportExportOperation
|
* @see org.sufficientlysecure.keychain.operations.ImportExportOperation
|
||||||
*/
|
*/
|
||||||
public ArrayList<ImportKeysListEntry> getSelectedEntries() {
|
public ArrayList<ImportKeysListEntry> getSelectedEntries() {
|
||||||
ArrayList<ImportKeysListEntry> result = new ArrayList<ImportKeysListEntry>();
|
ArrayList<ImportKeysListEntry> result = new ArrayList<>();
|
||||||
ArrayList<ImportKeysListEntry> secrets = new ArrayList<ImportKeysListEntry>();
|
ArrayList<ImportKeysListEntry> secrets = new ArrayList<>();
|
||||||
if (mData == null) {
|
if (mData == null) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class ImportKeysListCloudLoader
|
|||||||
Preferences.CloudSearchPrefs mCloudPrefs;
|
Preferences.CloudSearchPrefs mCloudPrefs;
|
||||||
String mServerQuery;
|
String mServerQuery;
|
||||||
|
|
||||||
private ArrayList<ImportKeysListEntry> mEntryList = new ArrayList<ImportKeysListEntry>();
|
private ArrayList<ImportKeysListEntry> mEntryList = new ArrayList<>();
|
||||||
private AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper;
|
private AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper;
|
||||||
|
|
||||||
public ImportKeysListCloudLoader(Context context, String serverQuery, Preferences.CloudSearchPrefs cloudPrefs) {
|
public ImportKeysListCloudLoader(Context context, String serverQuery, Preferences.CloudSearchPrefs cloudPrefs) {
|
||||||
@ -51,7 +51,7 @@ public class ImportKeysListCloudLoader
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> loadInBackground() {
|
public AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> loadInBackground() {
|
||||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
|
mEntryListWrapper = new AsyncTaskResultWrapper<>(mEntryList, null);
|
||||||
|
|
||||||
if (mServerQuery == null) {
|
if (mServerQuery == null) {
|
||||||
Log.e(Constants.TAG, "mServerQuery is null!");
|
Log.e(Constants.TAG, "mServerQuery is null!");
|
||||||
@ -119,7 +119,7 @@ public class ImportKeysListCloudLoader
|
|||||||
mEntryList.addAll(searchResult);
|
mEntryList.addAll(searchResult);
|
||||||
}
|
}
|
||||||
GetKeyResult getKeyResult = new GetKeyResult(GetKeyResult.RESULT_OK, null);
|
GetKeyResult getKeyResult = new GetKeyResult(GetKeyResult.RESULT_OK, null);
|
||||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, getKeyResult);
|
mEntryListWrapper = new AsyncTaskResultWrapper<>(mEntryList, getKeyResult);
|
||||||
} catch (Keyserver.CloudSearchFailureException e) {
|
} catch (Keyserver.CloudSearchFailureException e) {
|
||||||
// convert exception to result parcel
|
// convert exception to result parcel
|
||||||
int error = GetKeyResult.RESULT_ERROR;
|
int error = GetKeyResult.RESULT_ERROR;
|
||||||
@ -140,7 +140,7 @@ public class ImportKeysListCloudLoader
|
|||||||
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
||||||
log.add(logType, 0);
|
log.add(logType, 0);
|
||||||
GetKeyResult getKeyResult = new GetKeyResult(error, log);
|
GetKeyResult getKeyResult = new GetKeyResult(error, log);
|
||||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, getKeyResult);
|
mEntryListWrapper = new AsyncTaskResultWrapper<>(mEntryList, getKeyResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@ import org.sufficientlysecure.keychain.util.PositionAwareInputStream;
|
|||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class ImportKeysListLoader
|
public class ImportKeysListLoader
|
||||||
extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
||||||
@ -55,8 +54,8 @@ public class ImportKeysListLoader
|
|||||||
final Context mContext;
|
final Context mContext;
|
||||||
final InputData mInputData;
|
final InputData mInputData;
|
||||||
|
|
||||||
ArrayList<ImportKeysListEntry> mData = new ArrayList<ImportKeysListEntry>();
|
ArrayList<ImportKeysListEntry> mData = new ArrayList<>();
|
||||||
LongSparseArray<ParcelableKeyRing> mParcelableRings = new LongSparseArray<ParcelableKeyRing>();
|
LongSparseArray<ParcelableKeyRing> mParcelableRings = new LongSparseArray<>();
|
||||||
AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper;
|
AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper;
|
||||||
|
|
||||||
public ImportKeysListLoader(Context context, InputData inputData) {
|
public ImportKeysListLoader(Context context, InputData inputData) {
|
||||||
@ -73,7 +72,7 @@ public class ImportKeysListLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
GetKeyResult getKeyResult = new GetKeyResult(GetKeyResult.RESULT_OK, null);
|
GetKeyResult getKeyResult = new GetKeyResult(GetKeyResult.RESULT_OK, null);
|
||||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mData, getKeyResult);
|
mEntryListWrapper = new AsyncTaskResultWrapper<>(mData, getKeyResult);
|
||||||
|
|
||||||
if (mInputData == null) {
|
if (mInputData == null) {
|
||||||
Log.e(Constants.TAG, "Input data is null!");
|
Log.e(Constants.TAG, "Input data is null!");
|
||||||
@ -140,7 +139,7 @@ public class ImportKeysListLoader
|
|||||||
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
||||||
log.add(OperationResult.LogType.MSG_GET_NO_VALID_KEYS, 0);
|
log.add(OperationResult.LogType.MSG_GET_NO_VALID_KEYS, 0);
|
||||||
GetKeyResult getKeyResult = new GetKeyResult(GetKeyResult.RESULT_ERROR_NO_VALID_KEYS, log);
|
GetKeyResult getKeyResult = new GetKeyResult(GetKeyResult.RESULT_ERROR_NO_VALID_KEYS, log);
|
||||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>
|
mEntryListWrapper = new AsyncTaskResultWrapper<>
|
||||||
(mData, getKeyResult);
|
(mData, getKeyResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public class KeyValueSpinnerAdapter extends ArrayAdapter<String> {
|
|||||||
|
|
||||||
static <K, V extends Comparable<? super V>> SortedSet<Map.Entry<K, V>> entriesSortedByValues(
|
static <K, V extends Comparable<? super V>> SortedSet<Map.Entry<K, V>> entriesSortedByValues(
|
||||||
Map<K, V> map) {
|
Map<K, V> map) {
|
||||||
SortedSet<Map.Entry<K, V>> sortedEntries = new TreeSet<Map.Entry<K, V>>(
|
SortedSet<Map.Entry<K, V>> sortedEntries = new TreeSet<>(
|
||||||
new Comparator<Map.Entry<K, V>>() {
|
new Comparator<Map.Entry<K, V>>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) {
|
public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) {
|
||||||
|
@ -44,7 +44,7 @@ public class MultiUserIdsAdapter extends CursorAdapter {
|
|||||||
public MultiUserIdsAdapter(Context context, Cursor c, int flags) {
|
public MultiUserIdsAdapter(Context context, Cursor c, int flags) {
|
||||||
super(context, c, flags);
|
super(context, c, flags);
|
||||||
mInflater = LayoutInflater.from(context);
|
mInflater = LayoutInflater.from(context);
|
||||||
mCheckStates = new ArrayList<Boolean>();
|
mCheckStates = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -148,7 +148,7 @@ public class MultiUserIdsAdapter extends CursorAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<CertifyAction> getSelectedCertifyActions() {
|
public ArrayList<CertifyAction> getSelectedCertifyActions() {
|
||||||
LongSparseArray<CertifyAction> actions = new LongSparseArray<CertifyAction>();
|
LongSparseArray<CertifyAction> actions = new LongSparseArray<>();
|
||||||
for (int i = 0; i < mCheckStates.size(); i++) {
|
for (int i = 0; i < mCheckStates.size(); i++) {
|
||||||
if (mCheckStates.get(i)) {
|
if (mCheckStates.get(i)) {
|
||||||
mCursor.moveToPosition(i);
|
mCursor.moveToPosition(i);
|
||||||
@ -171,7 +171,7 @@ public class MultiUserIdsAdapter extends CursorAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<CertifyAction> result = new ArrayList<CertifyAction>(actions.size());
|
ArrayList<CertifyAction> result = new ArrayList<>(actions.size());
|
||||||
for (int i = 0; i < actions.size(); i++) {
|
for (int i = 0; i < actions.size(); i++) {
|
||||||
result.add(actions.valueAt(i));
|
result.add(actions.valueAt(i));
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class PagerTabStripAdapter extends FragmentPagerAdapter {
|
public class PagerTabStripAdapter extends FragmentPagerAdapter {
|
||||||
protected final Activity mActivity;
|
protected final Activity mActivity;
|
||||||
protected final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
|
protected final ArrayList<TabInfo> mTabs = new ArrayList<>();
|
||||||
|
|
||||||
static final class TabInfo {
|
static final class TabInfo {
|
||||||
public final Class<?> clss;
|
public final Class<?> clss;
|
||||||
|
@ -36,7 +36,6 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.SubkeyChange;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.SubkeyChange;
|
||||||
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
|
||||||
|
@ -33,7 +33,7 @@ public class TabsAdapter extends FragmentStatePagerAdapter implements ActionBar.
|
|||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final ActionBar mActionBar;
|
private final ActionBar mActionBar;
|
||||||
private final ViewPager mViewPager;
|
private final ViewPager mViewPager;
|
||||||
private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
|
private final ArrayList<TabInfo> mTabs = new ArrayList<>();
|
||||||
|
|
||||||
static final class TabInfo {
|
static final class TabInfo {
|
||||||
public final Class<?> clss;
|
public final Class<?> clss;
|
||||||
|
@ -221,7 +221,7 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getSelectedUserIds() {
|
public ArrayList<String> getSelectedUserIds() {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
for (int i = 0; i < mCheckStates.size(); i++) {
|
for (int i = 0; i < mCheckStates.size(); i++) {
|
||||||
if (mCheckStates.get(i)) {
|
if (mCheckStates.get(i)) {
|
||||||
mCursor.moveToPosition(i);
|
mCursor.moveToPosition(i);
|
||||||
|
@ -145,20 +145,20 @@ public class AddSubkeyDialogFragment extends DialogFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ArrayList<Choice<Algorithm>> choices = new ArrayList<Choice<Algorithm>>();
|
ArrayList<Choice<Algorithm>> choices = new ArrayList<>();
|
||||||
choices.add(new Choice<Algorithm>(Algorithm.DSA, getResources().getString(
|
choices.add(new Choice<>(Algorithm.DSA, getResources().getString(
|
||||||
R.string.dsa)));
|
R.string.dsa)));
|
||||||
if (!mWillBeMasterKey) {
|
if (!mWillBeMasterKey) {
|
||||||
choices.add(new Choice<Algorithm>(Algorithm.ELGAMAL, getResources().getString(
|
choices.add(new Choice<>(Algorithm.ELGAMAL, getResources().getString(
|
||||||
R.string.elgamal)));
|
R.string.elgamal)));
|
||||||
}
|
}
|
||||||
choices.add(new Choice<Algorithm>(Algorithm.RSA, getResources().getString(
|
choices.add(new Choice<>(Algorithm.RSA, getResources().getString(
|
||||||
R.string.rsa)));
|
R.string.rsa)));
|
||||||
choices.add(new Choice<Algorithm>(Algorithm.ECDSA, getResources().getString(
|
choices.add(new Choice<>(Algorithm.ECDSA, getResources().getString(
|
||||||
R.string.ecdsa)));
|
R.string.ecdsa)));
|
||||||
choices.add(new Choice<Algorithm>(Algorithm.ECDH, getResources().getString(
|
choices.add(new Choice<>(Algorithm.ECDH, getResources().getString(
|
||||||
R.string.ecdh)));
|
R.string.ecdh)));
|
||||||
ArrayAdapter<Choice<Algorithm>> adapter = new ArrayAdapter<Choice<Algorithm>>(context,
|
ArrayAdapter<Choice<Algorithm>> adapter = new ArrayAdapter<>(context,
|
||||||
android.R.layout.simple_spinner_item, choices);
|
android.R.layout.simple_spinner_item, choices);
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
mAlgorithmSpinner.setAdapter(adapter);
|
mAlgorithmSpinner.setAdapter(adapter);
|
||||||
@ -172,20 +172,20 @@ public class AddSubkeyDialogFragment extends DialogFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// dynamic ArrayAdapter must be created (instead of ArrayAdapter.getFromResource), because it's content may change
|
// dynamic ArrayAdapter must be created (instead of ArrayAdapter.getFromResource), because it's content may change
|
||||||
ArrayAdapter<CharSequence> keySizeAdapter = new ArrayAdapter<CharSequence>(context, android.R.layout.simple_spinner_item,
|
ArrayAdapter<CharSequence> keySizeAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item,
|
||||||
new ArrayList<CharSequence>(Arrays.asList(getResources().getStringArray(R.array.rsa_key_size_spinner_values))));
|
new ArrayList<CharSequence>(Arrays.asList(getResources().getStringArray(R.array.rsa_key_size_spinner_values))));
|
||||||
keySizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
keySizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
mKeySizeSpinner.setAdapter(keySizeAdapter);
|
mKeySizeSpinner.setAdapter(keySizeAdapter);
|
||||||
mKeySizeSpinner.setSelection(1); // Default to 4096 for the key length
|
mKeySizeSpinner.setSelection(1); // Default to 4096 for the key length
|
||||||
|
|
||||||
{
|
{
|
||||||
ArrayList<Choice<Curve>> choices = new ArrayList<Choice<Curve>>();
|
ArrayList<Choice<Curve>> choices = new ArrayList<>();
|
||||||
|
|
||||||
choices.add(new Choice<Curve>(Curve.NIST_P256, getResources().getString(
|
choices.add(new Choice<>(Curve.NIST_P256, getResources().getString(
|
||||||
R.string.key_curve_nist_p256)));
|
R.string.key_curve_nist_p256)));
|
||||||
choices.add(new Choice<Curve>(Curve.NIST_P384, getResources().getString(
|
choices.add(new Choice<>(Curve.NIST_P384, getResources().getString(
|
||||||
R.string.key_curve_nist_p384)));
|
R.string.key_curve_nist_p384)));
|
||||||
choices.add(new Choice<Curve>(Curve.NIST_P521, getResources().getString(
|
choices.add(new Choice<>(Curve.NIST_P521, getResources().getString(
|
||||||
R.string.key_curve_nist_p521)));
|
R.string.key_curve_nist_p521)));
|
||||||
|
|
||||||
/* @see SaveKeyringParcel
|
/* @see SaveKeyringParcel
|
||||||
@ -197,7 +197,7 @@ public class AddSubkeyDialogFragment extends DialogFragment {
|
|||||||
R.string.key_curve_bp_p512)));
|
R.string.key_curve_bp_p512)));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ArrayAdapter<Choice<Curve>> adapter = new ArrayAdapter<Choice<Curve>>(context,
|
ArrayAdapter<Choice<Curve>> adapter = new ArrayAdapter<>(context,
|
||||||
android.R.layout.simple_spinner_item, choices);
|
android.R.layout.simple_spinner_item, choices);
|
||||||
mCurveSpinner.setAdapter(adapter);
|
mCurveSpinner.setAdapter(adapter);
|
||||||
// make NIST P-256 the default
|
// make NIST P-256 the default
|
||||||
|
@ -85,7 +85,7 @@ public class AddUserIdDialogFragment extends DialogFragment implements OnEditorA
|
|||||||
mMessenger = getArguments().getParcelable(ARG_MESSENGER);
|
mMessenger = getArguments().getParcelable(ARG_MESSENGER);
|
||||||
String predefinedName = getArguments().getString(ARG_NAME);
|
String predefinedName = getArguments().getString(ARG_NAME);
|
||||||
|
|
||||||
ArrayAdapter<String> autoCompleteEmailAdapter = new ArrayAdapter<String>
|
ArrayAdapter<String> autoCompleteEmailAdapter = new ArrayAdapter<>
|
||||||
(getActivity(), android.R.layout.simple_spinner_dropdown_item,
|
(getActivity(), android.R.layout.simple_spinner_dropdown_item,
|
||||||
ContactHelper.getPossibleUserEmails(getActivity())
|
ContactHelper.getPossibleUserEmails(getActivity())
|
||||||
);
|
);
|
||||||
@ -150,7 +150,7 @@ public class AddUserIdDialogFragment extends DialogFragment implements OnEditorA
|
|||||||
|
|
||||||
mName.setThreshold(1); // Start working from first character
|
mName.setThreshold(1); // Start working from first character
|
||||||
mName.setAdapter(
|
mName.setAdapter(
|
||||||
new ArrayAdapter<String>
|
new ArrayAdapter<>
|
||||||
(getActivity(), android.R.layout.simple_spinner_dropdown_item,
|
(getActivity(), android.R.layout.simple_spinner_dropdown_item,
|
||||||
ContactHelper.getPossibleUserNames(getActivity())
|
ContactHelper.getPossibleUserNames(getActivity())
|
||||||
)
|
)
|
||||||
|
@ -28,7 +28,6 @@ import android.support.v4.app.DialogFragment;
|
|||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.apache.http.conn.scheme.Scheme;
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.util.FileHelper;
|
import org.sufficientlysecure.keychain.util.FileHelper;
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class QrCodeUtils {
|
|||||||
*/
|
*/
|
||||||
public static Bitmap getQRCodeBitmap(final String input, final int size) {
|
public static Bitmap getQRCodeBitmap(final String input, final int size) {
|
||||||
try {
|
try {
|
||||||
final Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
|
final Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
|
||||||
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
|
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
|
||||||
final BitMatrix result = new QRCodeWriter().encode(input, BarcodeFormat.QR_CODE, size,
|
final BitMatrix result = new QRCodeWriter().encode(input, BarcodeFormat.QR_CODE, size,
|
||||||
size, hints);
|
size, hints);
|
||||||
|
@ -29,7 +29,6 @@ import android.widget.ImageView;
|
|||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
|
|
||||||
public class CertifyKeySpinner extends KeySpinner {
|
public class CertifyKeySpinner extends KeySpinner {
|
||||||
|
@ -28,7 +28,6 @@ import android.support.v4.app.FragmentActivity;
|
|||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
import android.text.SpannableStringBuilder;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -46,7 +45,6 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
|||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.util.ContactHelper;
|
import org.sufficientlysecure.keychain.util.ContactHelper;
|
||||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
|
||||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
||||||
@ -165,7 +163,7 @@ public class EncryptKeyCompletionView extends TokenCompleteTextView {
|
|||||||
setAdapter(new EncryptKeyAdapter(Collections.<EncryptionKey>emptyList()));
|
setAdapter(new EncryptKeyAdapter(Collections.<EncryptionKey>emptyList()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ArrayList<EncryptionKey> keys = new ArrayList<EncryptionKey>();
|
ArrayList<EncryptionKey> keys = new ArrayList<>();
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
try {
|
try {
|
||||||
EncryptionKey key = new EncryptionKey(cursor);
|
EncryptionKey key = new EncryptionKey(cursor);
|
||||||
|
@ -20,13 +20,8 @@ package org.sufficientlysecure.keychain.ui.widget;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.v4.widget.NoScrollableSwipeRefreshLayout;
|
import android.support.v4.widget.NoScrollableSwipeRefreshLayout;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.InputDevice;
|
|
||||||
import android.view.InputDevice.MotionRange;
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
|
||||||
|
|
||||||
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
||||||
|
|
||||||
public class ListAwareSwipeRefreshLayout extends NoScrollableSwipeRefreshLayout {
|
public class ListAwareSwipeRefreshLayout extends NoScrollableSwipeRefreshLayout {
|
||||||
|
@ -26,7 +26,6 @@ import android.support.v4.content.Loader;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import android.app.Activity;
|
|||||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -32,9 +31,9 @@ import java.util.HashMap;
|
|||||||
public class AlgorithmNames {
|
public class AlgorithmNames {
|
||||||
Activity mActivity;
|
Activity mActivity;
|
||||||
|
|
||||||
HashMap<Integer, String> mEncryptionNames = new HashMap<Integer, String>();
|
HashMap<Integer, String> mEncryptionNames = new HashMap<>();
|
||||||
HashMap<Integer, String> mHashNames = new HashMap<Integer, String>();
|
HashMap<Integer, String> mHashNames = new HashMap<>();
|
||||||
HashMap<Integer, String> mCompressionNames = new HashMap<Integer, String>();
|
HashMap<Integer, String> mCompressionNames = new HashMap<>();
|
||||||
|
|
||||||
public AlgorithmNames(Activity context) {
|
public AlgorithmNames(Activity context) {
|
||||||
super();
|
super();
|
||||||
|
@ -73,20 +73,20 @@ public class ContactHelper {
|
|||||||
ContactsContract.Data.RAW_CONTACT_ID + "=? AND " + ContactsContract.Data.MIMETYPE + "=?";
|
ContactsContract.Data.RAW_CONTACT_ID + "=? AND " + ContactsContract.Data.MIMETYPE + "=?";
|
||||||
public static final String ID_SELECTION = ContactsContract.RawContacts._ID + "=?";
|
public static final String ID_SELECTION = ContactsContract.RawContacts._ID + "=?";
|
||||||
|
|
||||||
private static final Map<String, Bitmap> photoCache = new HashMap<String, Bitmap>();
|
private static final Map<String, Bitmap> photoCache = new HashMap<>();
|
||||||
|
|
||||||
public static List<String> getPossibleUserEmails(Context context) {
|
public static List<String> getPossibleUserEmails(Context context) {
|
||||||
Set<String> accountMails = getAccountEmails(context);
|
Set<String> accountMails = getAccountEmails(context);
|
||||||
accountMails.addAll(getMainProfileContactEmails(context));
|
accountMails.addAll(getMainProfileContactEmails(context));
|
||||||
// now return the Set (without duplicates) as a List
|
// now return the Set (without duplicates) as a List
|
||||||
return new ArrayList<String>(accountMails);
|
return new ArrayList<>(accountMails);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getPossibleUserNames(Context context) {
|
public static List<String> getPossibleUserNames(Context context) {
|
||||||
Set<String> accountMails = getAccountEmails(context);
|
Set<String> accountMails = getAccountEmails(context);
|
||||||
Set<String> names = getContactNamesFromEmails(context, accountMails);
|
Set<String> names = getContactNamesFromEmails(context, accountMails);
|
||||||
names.addAll(getMainProfileContactName(context));
|
names.addAll(getMainProfileContactName(context));
|
||||||
return new ArrayList<String>(names);
|
return new ArrayList<>(names);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,7 +97,7 @@ public class ContactHelper {
|
|||||||
*/
|
*/
|
||||||
private static Set<String> getAccountEmails(Context context) {
|
private static Set<String> getAccountEmails(Context context) {
|
||||||
final Account[] accounts = AccountManager.get(context).getAccounts();
|
final Account[] accounts = AccountManager.get(context).getAccounts();
|
||||||
final Set<String> emailSet = new HashSet<String>();
|
final Set<String> emailSet = new HashSet<>();
|
||||||
for (Account account : accounts) {
|
for (Account account : accounts) {
|
||||||
if (Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) {
|
if (Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) {
|
||||||
emailSet.add(account.name);
|
emailSet.add(account.name);
|
||||||
@ -116,7 +116,7 @@ public class ContactHelper {
|
|||||||
*/
|
*/
|
||||||
private static Set<String> getContactNamesFromEmails(Context context, Set<String> emails) {
|
private static Set<String> getContactNamesFromEmails(Context context, Set<String> emails) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||||
Set<String> names = new HashSet<String>();
|
Set<String> names = new HashSet<>();
|
||||||
for (String email : emails) {
|
for (String email : emails) {
|
||||||
ContentResolver resolver = context.getContentResolver();
|
ContentResolver resolver = context.getContentResolver();
|
||||||
Cursor profileCursor = resolver.query(
|
Cursor profileCursor = resolver.query(
|
||||||
@ -128,7 +128,7 @@ public class ContactHelper {
|
|||||||
);
|
);
|
||||||
if (profileCursor == null) return null;
|
if (profileCursor == null) return null;
|
||||||
|
|
||||||
Set<String> currNames = new HashSet<String>();
|
Set<String> currNames = new HashSet<>();
|
||||||
while (profileCursor.moveToNext()) {
|
while (profileCursor.moveToNext()) {
|
||||||
String name = profileCursor.getString(1);
|
String name = profileCursor.getString(1);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
@ -140,7 +140,7 @@ public class ContactHelper {
|
|||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
} else {
|
} else {
|
||||||
return new HashSet<String>();
|
return new HashSet<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ public class ContactHelper {
|
|||||||
);
|
);
|
||||||
if (profileCursor == null) return null;
|
if (profileCursor == null) return null;
|
||||||
|
|
||||||
Set<String> emails = new HashSet<String>();
|
Set<String> emails = new HashSet<>();
|
||||||
while (profileCursor.moveToNext()) {
|
while (profileCursor.moveToNext()) {
|
||||||
String email = profileCursor.getString(0);
|
String email = profileCursor.getString(0);
|
||||||
if (email != null) {
|
if (email != null) {
|
||||||
@ -182,7 +182,7 @@ public class ContactHelper {
|
|||||||
profileCursor.close();
|
profileCursor.close();
|
||||||
return emails;
|
return emails;
|
||||||
} else {
|
} else {
|
||||||
return new HashSet<String>();
|
return new HashSet<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ public class ContactHelper {
|
|||||||
null, null, null);
|
null, null, null);
|
||||||
if (profileCursor == null) return null;
|
if (profileCursor == null) return null;
|
||||||
|
|
||||||
Set<String> names = new HashSet<String>();
|
Set<String> names = new HashSet<>();
|
||||||
// should only contain one entry!
|
// should only contain one entry!
|
||||||
while (profileCursor.moveToNext()) {
|
while (profileCursor.moveToNext()) {
|
||||||
String name = profileCursor.getString(0);
|
String name = profileCursor.getString(0);
|
||||||
@ -210,9 +210,9 @@ public class ContactHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
profileCursor.close();
|
profileCursor.close();
|
||||||
return new ArrayList<String>(names);
|
return new ArrayList<>(names);
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<String>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,9 +221,9 @@ public class ContactHelper {
|
|||||||
Cursor mailCursor = resolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
|
Cursor mailCursor = resolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
|
||||||
new String[]{ContactsContract.CommonDataKinds.Email.DATA},
|
new String[]{ContactsContract.CommonDataKinds.Email.DATA},
|
||||||
null, null, null);
|
null, null, null);
|
||||||
if (mailCursor == null) return new ArrayList<String>();
|
if (mailCursor == null) return new ArrayList<>();
|
||||||
|
|
||||||
Set<String> mails = new HashSet<String>();
|
Set<String> mails = new HashSet<>();
|
||||||
while (mailCursor.moveToNext()) {
|
while (mailCursor.moveToNext()) {
|
||||||
String email = mailCursor.getString(0);
|
String email = mailCursor.getString(0);
|
||||||
if (email != null) {
|
if (email != null) {
|
||||||
@ -231,7 +231,7 @@ public class ContactHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mailCursor.close();
|
mailCursor.close();
|
||||||
return new ArrayList<String>(mails);
|
return new ArrayList<>(mails);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getContactNames(Context context) {
|
public static List<String> getContactNames(Context context) {
|
||||||
@ -239,9 +239,9 @@ public class ContactHelper {
|
|||||||
Cursor cursor = resolver.query(ContactsContract.Contacts.CONTENT_URI,
|
Cursor cursor = resolver.query(ContactsContract.Contacts.CONTENT_URI,
|
||||||
new String[]{ContactsContract.Contacts.DISPLAY_NAME},
|
new String[]{ContactsContract.Contacts.DISPLAY_NAME},
|
||||||
null, null, null);
|
null, null, null);
|
||||||
if (cursor == null) return new ArrayList<String>();
|
if (cursor == null) return new ArrayList<>();
|
||||||
|
|
||||||
Set<String> names = new HashSet<String>();
|
Set<String> names = new HashSet<>();
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
String name = cursor.getString(0);
|
String name = cursor.getString(0);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
@ -249,7 +249,7 @@ public class ContactHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
return new ArrayList<String>(names);
|
return new ArrayList<>(names);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||||
@ -309,7 +309,7 @@ public class ContactHelper {
|
|||||||
boolean isExpired = !cursor.isNull(4) && new Date(cursor.getLong(4) * 1000).before(new Date());
|
boolean isExpired = !cursor.isNull(4) && new Date(cursor.getLong(4) * 1000).before(new Date());
|
||||||
boolean isRevoked = cursor.getInt(5) > 0;
|
boolean isRevoked = cursor.getInt(5) > 0;
|
||||||
int rawContactId = findRawContactId(resolver, fingerprint);
|
int rawContactId = findRawContactId(resolver, fingerprint);
|
||||||
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
|
ArrayList<ContentProviderOperation> ops = new ArrayList<>();
|
||||||
|
|
||||||
// Do not store expired or revoked keys in contact db - and remove them if they already exist
|
// Do not store expired or revoked keys in contact db - and remove them if they already exist
|
||||||
if (isExpired || isRevoked) {
|
if (isExpired || isRevoked) {
|
||||||
@ -351,7 +351,7 @@ public class ContactHelper {
|
|||||||
* @return a set of all key fingerprints currently present in the contact db
|
* @return a set of all key fingerprints currently present in the contact db
|
||||||
*/
|
*/
|
||||||
private static Set<String> getRawContactFingerprints(ContentResolver resolver) {
|
private static Set<String> getRawContactFingerprints(ContentResolver resolver) {
|
||||||
HashSet<String> result = new HashSet<String>();
|
HashSet<String> result = new HashSet<>();
|
||||||
Cursor fingerprints = resolver.query(ContactsContract.RawContacts.CONTENT_URI, SOURCE_ID_PROJECTION,
|
Cursor fingerprints = resolver.query(ContactsContract.RawContacts.CONTENT_URI, SOURCE_ID_PROJECTION,
|
||||||
ACCOUNT_TYPE_SELECTION, new String[]{Constants.ACCOUNT_TYPE}, null);
|
ACCOUNT_TYPE_SELECTION, new String[]{Constants.ACCOUNT_TYPE}, null);
|
||||||
if (fingerprints != null) {
|
if (fingerprints != null) {
|
||||||
|
@ -42,13 +42,13 @@ public class EmailKeyHelper {
|
|||||||
|
|
||||||
public static void importAll(Context context, Messenger messenger, List<String> mails) {
|
public static void importAll(Context context, Messenger messenger, List<String> mails) {
|
||||||
// Collect all candidates as ImportKeysListEntry (set for deduplication)
|
// Collect all candidates as ImportKeysListEntry (set for deduplication)
|
||||||
Set<ImportKeysListEntry> entries = new HashSet<ImportKeysListEntry>();
|
Set<ImportKeysListEntry> entries = new HashSet<>();
|
||||||
for (String mail : mails) {
|
for (String mail : mails) {
|
||||||
entries.addAll(getEmailKeys(context, mail));
|
entries.addAll(getEmailKeys(context, mail));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put them in a list and import
|
// Put them in a list and import
|
||||||
ArrayList<ParcelableKeyRing> keys = new ArrayList<ParcelableKeyRing>(entries.size());
|
ArrayList<ParcelableKeyRing> keys = new ArrayList<>(entries.size());
|
||||||
for (ImportKeysListEntry entry : entries) {
|
for (ImportKeysListEntry entry : entries) {
|
||||||
keys.add(new ParcelableKeyRing(entry.getFingerprintHex(), entry.getKeyIdHex(), null));
|
keys.add(new ParcelableKeyRing(entry.getFingerprintHex(), entry.getKeyIdHex(), null));
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ public class EmailKeyHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Set<ImportKeysListEntry> getEmailKeys(Context context, String mail) {
|
public static Set<ImportKeysListEntry> getEmailKeys(Context context, String mail) {
|
||||||
Set<ImportKeysListEntry> keys = new HashSet<ImportKeysListEntry>();
|
Set<ImportKeysListEntry> keys = new HashSet<>();
|
||||||
|
|
||||||
// Try _hkp._tcp SRV record first
|
// Try _hkp._tcp SRV record first
|
||||||
String[] mailparts = mail.split("@");
|
String[] mailparts = mail.split("@");
|
||||||
@ -90,7 +90,7 @@ public class EmailKeyHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<ImportKeysListEntry> getEmailKeys(String mail, Keyserver keyServer) {
|
public static List<ImportKeysListEntry> getEmailKeys(String mail, Keyserver keyServer) {
|
||||||
Set<ImportKeysListEntry> keys = new HashSet<ImportKeysListEntry>();
|
Set<ImportKeysListEntry> keys = new HashSet<>();
|
||||||
try {
|
try {
|
||||||
for (ImportKeysListEntry key : keyServer.search(mail)) {
|
for (ImportKeysListEntry key : keyServer.search(mail)) {
|
||||||
if (key.isRevoked() || key.isExpired()) continue;
|
if (key.isRevoked() || key.isExpired()) continue;
|
||||||
@ -103,6 +103,6 @@ public class EmailKeyHelper {
|
|||||||
} catch (Keyserver.QueryFailedException ignored) {
|
} catch (Keyserver.QueryFailedException ignored) {
|
||||||
} catch (Keyserver.QueryNeedsRepairException ignored) {
|
} catch (Keyserver.QueryNeedsRepairException ignored) {
|
||||||
}
|
}
|
||||||
return new ArrayList<ImportKeysListEntry>(keys);
|
return new ArrayList<>(keys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,10 @@ import android.os.Handler;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.operations.results.ExportResult;
|
import org.sufficientlysecure.keychain.operations.results.ExportResult;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
|
@ -125,7 +125,7 @@ public class Iso7816TLV {
|
|||||||
public static Iso7816TLV[] readList(byte[] data, boolean recursive) throws IOException {
|
public static Iso7816TLV[] readList(byte[] data, boolean recursive) throws IOException {
|
||||||
ByteBuffer buf = ByteBuffer.wrap(data);
|
ByteBuffer buf = ByteBuffer.wrap(data);
|
||||||
|
|
||||||
ArrayList<Iso7816TLV> result = new ArrayList<Iso7816TLV>();
|
ArrayList<Iso7816TLV> result = new ArrayList<>();
|
||||||
|
|
||||||
// read while data is available. this will fail if there is trailing data!
|
// read while data is available. this will fail if there is trailing data!
|
||||||
while (buf.hasRemaining()) {
|
while (buf.hasRemaining()) {
|
||||||
|
@ -17,21 +17,6 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.util;
|
package org.sufficientlysecure.keychain.util;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Messenger;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class KeyUpdateHelper {
|
public class KeyUpdateHelper {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -21,9 +21,6 @@ import android.os.Bundle;
|
|||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StreamTokenizer;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -32,9 +32,7 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When sending large data (over 1MB) through Androids Binder IPC you get
|
* When sending large data (over 1MB) through Androids Binder IPC you get
|
||||||
|
@ -200,7 +200,7 @@ public class Preferences {
|
|||||||
public String[] getKeyServers() {
|
public String[] getKeyServers() {
|
||||||
String rawData = mSharedPreferences.getString(Constants.Pref.KEY_SERVERS,
|
String rawData = mSharedPreferences.getString(Constants.Pref.KEY_SERVERS,
|
||||||
Constants.Defaults.KEY_SERVERS);
|
Constants.Defaults.KEY_SERVERS);
|
||||||
Vector<String> servers = new Vector<String>();
|
Vector<String> servers = new Vector<>();
|
||||||
String chunks[] = rawData.split(",");
|
String chunks[] = rawData.split(",");
|
||||||
for (String c : chunks) {
|
for (String c : chunks) {
|
||||||
String tmp = c.trim();
|
String tmp = c.trim();
|
||||||
@ -281,7 +281,7 @@ public class Preferences {
|
|||||||
case 3: {
|
case 3: {
|
||||||
// migrate keyserver to hkps
|
// migrate keyserver to hkps
|
||||||
String[] serversArray = getKeyServers();
|
String[] serversArray = getKeyServers();
|
||||||
ArrayList<String> servers = new ArrayList<String>(Arrays.asList(serversArray));
|
ArrayList<String> servers = new ArrayList<>(Arrays.asList(serversArray));
|
||||||
ListIterator<String> it = servers.listIterator();
|
ListIterator<String> it = servers.listIterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
String server = it.next();
|
String server = it.next();
|
||||||
|
@ -51,10 +51,10 @@ public class ShareHelper {
|
|||||||
return Intent.createChooser(prototype, title);
|
return Intent.createChooser(prototype, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<LabeledIntent> targetedShareIntents = new ArrayList<LabeledIntent>();
|
List<LabeledIntent> targetedShareIntents = new ArrayList<>();
|
||||||
|
|
||||||
List<ResolveInfo> resInfoList = mContext.getPackageManager().queryIntentActivities(prototype, 0);
|
List<ResolveInfo> resInfoList = mContext.getPackageManager().queryIntentActivities(prototype, 0);
|
||||||
List<ResolveInfo> resInfoListFiltered = new ArrayList<ResolveInfo>();
|
List<ResolveInfo> resInfoListFiltered = new ArrayList<>();
|
||||||
if (!resInfoList.isEmpty()) {
|
if (!resInfoList.isEmpty()) {
|
||||||
for (ResolveInfo resolveInfo : resInfoList) {
|
for (ResolveInfo resolveInfo : resInfoList) {
|
||||||
// do not add blacklisted ones
|
// do not add blacklisted ones
|
||||||
|
@ -50,7 +50,7 @@ public class TlsHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<String, byte[]> sStaticCA = new HashMap<String, byte[]>();
|
private static Map<String, byte[]> sStaticCA = new HashMap<>();
|
||||||
|
|
||||||
public static void addStaticCA(String domain, byte[] certificate) {
|
public static void addStaticCA(String domain, byte[] certificate) {
|
||||||
sStaticCA.put(domain, certificate);
|
sStaticCA.put(domain, certificate);
|
||||||
@ -120,13 +120,7 @@ public class TlsHelper {
|
|||||||
urlConnection.setSSLSocketFactory(context.getSocketFactory());
|
urlConnection.setSSLSocketFactory(context.getSocketFactory());
|
||||||
|
|
||||||
return urlConnection;
|
return urlConnection;
|
||||||
} catch (CertificateException e) {
|
} catch (CertificateException | KeyManagementException | KeyStoreException | NoSuchAlgorithmException e) {
|
||||||
throw new TlsHelperException(e);
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
throw new TlsHelperException(e);
|
|
||||||
} catch (KeyStoreException e) {
|
|
||||||
throw new TlsHelperException(e);
|
|
||||||
} catch (KeyManagementException e) {
|
|
||||||
throw new TlsHelperException(e);
|
throw new TlsHelperException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user