move getPublicKey into abstract WrappedKeyRing (also, fix getPrimaryUserId)
This commit is contained in:
@@ -258,7 +258,7 @@ public class PgpDecryptVerify {
|
||||
continue;
|
||||
}
|
||||
// get subkey which has been used for this encryption packet
|
||||
secretEncryptionKey = secretKeyRing.getSubKey(encData.getKeyID());
|
||||
secretEncryptionKey = secretKeyRing.getSecretKey(encData.getKeyID());
|
||||
if (secretEncryptionKey == null) {
|
||||
// continue with the next packet in the while loop
|
||||
continue;
|
||||
@@ -393,7 +393,7 @@ public class PgpDecryptVerify {
|
||||
signingRing = mProviderHelper.getWrappedPublicKeyRing(
|
||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(sigKeyId)
|
||||
);
|
||||
signingKey = signingRing.getSubkey(sigKeyId);
|
||||
signingKey = signingRing.getPublicKey(sigKeyId);
|
||||
signatureIndex = i;
|
||||
} catch (ProviderHelper.NotFoundException e) {
|
||||
Log.d(Constants.TAG, "key not found!");
|
||||
@@ -578,7 +578,7 @@ public class PgpDecryptVerify {
|
||||
signingRing = mProviderHelper.getWrappedPublicKeyRing(
|
||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(sigKeyId)
|
||||
);
|
||||
signingKey = signingRing.getSubkey(sigKeyId);
|
||||
signingKey = signingRing.getPublicKey(sigKeyId);
|
||||
signatureIndex = i;
|
||||
} catch (ProviderHelper.NotFoundException e) {
|
||||
Log.d(Constants.TAG, "key not found!");
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class WrappedKeyRing extends KeyRing {
|
||||
}
|
||||
|
||||
public String getPrimaryUserId() throws PgpGeneralException {
|
||||
return (String) getRing().getPublicKey().getUserIDs().next();
|
||||
return getPublicKey().getPrimaryUserId();
|
||||
};
|
||||
|
||||
public boolean isRevoked() throws PgpGeneralException {
|
||||
@@ -101,6 +101,14 @@ public abstract class WrappedKeyRing extends KeyRing {
|
||||
|
||||
abstract public IterableIterator<WrappedPublicKey> publicKeyIterator();
|
||||
|
||||
public WrappedPublicKey getPublicKey() {
|
||||
return new WrappedPublicKey(this, getRing().getPublicKey());
|
||||
}
|
||||
|
||||
public WrappedPublicKey getPublicKey(long id) {
|
||||
return new WrappedPublicKey(this, getRing().getPublicKey(id));
|
||||
}
|
||||
|
||||
public byte[] getEncoded() throws IOException {
|
||||
return getRing().getEncoded();
|
||||
}
|
||||
|
||||
@@ -44,14 +44,6 @@ public class WrappedPublicKeyRing extends WrappedKeyRing {
|
||||
getRing().encode(stream);
|
||||
}
|
||||
|
||||
public WrappedPublicKey getSubkey() {
|
||||
return new WrappedPublicKey(this, getRing().getPublicKey());
|
||||
}
|
||||
|
||||
public WrappedPublicKey getSubkey(long id) {
|
||||
return new WrappedPublicKey(this, getRing().getPublicKey(id));
|
||||
}
|
||||
|
||||
/** Getter that returns the subkey that should be used for signing. */
|
||||
WrappedPublicKey getEncryptionSubKey() throws PgpGeneralException {
|
||||
PGPPublicKey key = getRing().getPublicKey(getEncryptId());
|
||||
|
||||
@@ -175,7 +175,7 @@ public class WrappedSecretKey extends WrappedPublicKey {
|
||||
}
|
||||
|
||||
// get the master subkey (which we certify for)
|
||||
PGPPublicKey publicKey = publicKeyRing.getSubkey().getPublicKey();
|
||||
PGPPublicKey publicKey = publicKeyRing.getPublicKey().getPublicKey();
|
||||
|
||||
// fetch public key ring, add the certification and return it
|
||||
for (String userId : new IterableIterator<String>(userIds.iterator())) {
|
||||
|
||||
@@ -41,11 +41,11 @@ public class WrappedSecretKeyRing extends WrappedKeyRing {
|
||||
return mRing;
|
||||
}
|
||||
|
||||
public WrappedSecretKey getSubKey() {
|
||||
public WrappedSecretKey getSecretKey() {
|
||||
return new WrappedSecretKey(this, mRing.getSecretKey());
|
||||
}
|
||||
|
||||
public WrappedSecretKey getSubKey(long id) {
|
||||
public WrappedSecretKey getSecretKey(long id) {
|
||||
return new WrappedSecretKey(this, mRing.getSecretKey(id));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user