fix missing userIds in ImportKeysListEntry

This commit is contained in:
Vincent Breitmoser 2014-05-27 13:49:39 +02:00
parent 97af8b2a01
commit 4a6aaf1e83
2 changed files with 9 additions and 4 deletions

View File

@ -229,8 +229,6 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
*/
@SuppressWarnings("unchecked")
public ImportKeysListEntry(Context context, UncachedKeyRing ring) {
// TODO less bouncy castle objects!
// save actual key object into entry, used to import it later
try {
this.mBytes = ring.getEncoded();
@ -245,6 +243,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
UncachedPublicKey key = ring.getPublicKey();
mPrimaryUserId = key.getPrimaryUserId();
userIds = key.getUnorderedUserIds();
// if there was no user id flagged as primary, use the first one
if (mPrimaryUserId == null) {

View File

@ -71,9 +71,7 @@ public class UncachedPublicKey {
}
public String getPrimaryUserId() {
List<String> userIds = new ArrayList<String>();
for (String userId : new IterableIterator<String>(mPublicKey.getUserIDs())) {
userIds.add(userId);
for (PGPSignature sig : new IterableIterator<PGPSignature>(mPublicKey.getSignaturesForID(userId))) {
if (sig.getHashedSubPackets() != null
&& sig.getHashedSubPackets().hasSubpacket(SignatureSubpacketTags.PRIMARY_USER_ID)) {
@ -94,6 +92,14 @@ public class UncachedPublicKey {
return null;
}
public ArrayList<String> getUnorderedUserIds() {
ArrayList<String> userIds = new ArrayList<String>();
for (String userId : new IterableIterator<String>(mPublicKey.getUserIDs())) {
userIds.add(userId);
}
return userIds;
}
public boolean isElGamalEncrypt() {
return getAlgorithm() == PGPPublicKey.ELGAMAL_ENCRYPT;
}