aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-09-07 20:09:36 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-09-07 20:09:36 +0200
commitbb0d04de82895adca2f701446a813fc4f0efdd42 (patch)
tree0743c010e4706bcf5345888b478a453ccc39c643 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain
parentcfe20d89eaa008d62d4d1636c126f74a7b247040 (diff)
downloadopen-keychain-bb0d04de82895adca2f701446a813fc4f0efdd42.tar.gz
open-keychain-bb0d04de82895adca2f701446a813fc4f0efdd42.tar.bz2
open-keychain-bb0d04de82895adca2f701446a813fc4f0efdd42.zip
Fix for user ids in API
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java5
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpSignatureResultBuilder.java22
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java26
3 files changed, 29 insertions, 24 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java
index 8076a14f3..0d3e5676a 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedKeyRing.java
@@ -24,6 +24,7 @@ import org.sufficientlysecure.keychain.util.IterableIterator;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.ArrayList;
/** A generic wrapped PGPKeyRing object.
*
@@ -58,6 +59,10 @@ public abstract class CanonicalizedKeyRing extends KeyRing {
return getPublicKey().getPrimaryUserIdWithFallback();
}
+ public ArrayList<String> getUnorderedUserIds() {
+ return getPublicKey().getUnorderedUserIds();
+ }
+
public boolean isRevoked() throws PgpGeneralException {
// Is the master key revoked?
return getRing().getPublicKey().isRevoked();
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpSignatureResultBuilder.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpSignatureResultBuilder.java
index ab88d1b4b..3d41c928b 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpSignatureResultBuilder.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpSignatureResultBuilder.java
@@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain.pgp;
import org.openintents.openpgp.OpenPgpSignatureResult;
import org.sufficientlysecure.keychain.Constants;
+import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.util.Log;
import java.util.ArrayList;
@@ -86,6 +87,27 @@ public class OpenPgpSignatureResultBuilder {
return mValidSignature;
}
+ public void initValid(CanonicalizedPublicKeyRing signingRing,
+ CanonicalizedPublicKey signingKey) {
+ setSignatureAvailable(true);
+ setKnownKey(true);
+
+ // from RING
+ setKeyId(signingRing.getMasterKeyId());
+ try {
+ setPrimaryUserId(signingRing.getPrimaryUserIdWithFallback());
+ } catch (PgpGeneralException e) {
+ Log.d(Constants.TAG, "No primary user id in keyring with master key id " + signingRing.getMasterKeyId());
+ }
+ setSignatureKeyCertified(signingRing.getVerified() > 0);
+ Log.d(Constants.TAG, "signingRing.getUnorderedUserIds(): " + signingRing.getUnorderedUserIds());
+ setUserIds(signingRing.getUnorderedUserIds());
+
+ // from KEY
+ setKeyExpired(signingKey.isExpired());
+ setKeyRevoked(signingKey.isRevoked());
+ }
+
public OpenPgpSignatureResult build() {
if (mSignatureAvailable) {
OpenPgpSignatureResult result = new OpenPgpSignatureResult();
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
index e7bb6d7b1..cb077c55c 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
@@ -421,18 +421,7 @@ public class PgpDecryptVerify {
// key found in our database!
signature = sigList.get(signatureIndex);
- signatureResultBuilder.setSignatureAvailable(true);
- signatureResultBuilder.setKnownKey(true);
- signatureResultBuilder.setKeyId(signingRing.getMasterKeyId());
- try {
- signatureResultBuilder.setPrimaryUserId(signingRing.getPrimaryUserIdWithFallback());
- } catch (PgpGeneralException e) {
- Log.d(Constants.TAG, "No primary user id in keyring with master key id " + signingRing.getMasterKeyId());
- }
- signatureResultBuilder.setSignatureKeyCertified(signingRing.getVerified() > 0);
- signatureResultBuilder.setKeyExpired(signingKey.isExpired());
- signatureResultBuilder.setKeyRevoked(signingKey.isRevoked());
- signatureResultBuilder.setUserIds(signingKey.getUnorderedUserIds());
+ signatureResultBuilder.initValid(signingRing, signingKey);
JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider =
new JcaPGPContentVerifierBuilderProvider()
@@ -658,18 +647,7 @@ public class PgpDecryptVerify {
// key found in our database!
signature = sigList.get(signatureIndex);
- signatureResultBuilder.setSignatureAvailable(true);
- signatureResultBuilder.setKnownKey(true);
- signatureResultBuilder.setKeyId(signingRing.getMasterKeyId());
- try {
- signatureResultBuilder.setPrimaryUserId(signingRing.getPrimaryUserIdWithFallback());
- } catch (PgpGeneralException e) {
- Log.d(Constants.TAG, "No primary user id in key with master key id " + signingRing.getMasterKeyId());
- }
- signatureResultBuilder.setSignatureKeyCertified(signingRing.getVerified() > 0);
- signatureResultBuilder.setKeyExpired(signingKey.isExpired());
- signatureResultBuilder.setKeyRevoked(signingKey.isRevoked());
- signatureResultBuilder.setUserIds(signingKey.getUnorderedUserIds());
+ signatureResultBuilder.initValid(signingRing, signingKey);
JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider =
new JcaPGPContentVerifierBuilderProvider()