1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-10 18:59:39 +02:00

Revert PassphraseProvider API change

This commit is contained in:
Paul Schaub 2023-11-15 19:23:52 +01:00
parent cf638da130
commit 481dfac455
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
10 changed files with 31 additions and 31 deletions

View file

@ -63,13 +63,13 @@ public class MissingPassphraseForDecryptionTest {
// interactive callback
SecretKeyPassphraseProvider callback = new SecretKeyPassphraseProvider() {
@Override
public Passphrase getPassphraseFor(long keyId) {
public Passphrase getPassphraseFor(Long keyId) {
// is called in interactive mode
return Passphrase.fromPassword(passphrase);
}
@Override
public boolean hasPassphrase(long keyId) {
public boolean hasPassphrase(Long keyId) {
return true;
}
};
@ -95,13 +95,13 @@ public class MissingPassphraseForDecryptionTest {
SecretKeyPassphraseProvider callback = new SecretKeyPassphraseProvider() {
@Override
public Passphrase getPassphraseFor(long keyId) {
public Passphrase getPassphraseFor(Long keyId) {
fail("MUST NOT get called in non-interactive mode.");
return null;
}
@Override
public boolean hasPassphrase(long keyId) {
public boolean hasPassphrase(Long keyId) {
return true;
}
};

View file

@ -120,13 +120,13 @@ public class PostponeDecryptionUsingKeyWithMissingPassphraseTest {
public void missingPassphraseFirst() throws PGPException, IOException {
SecretKeyRingProtector protector1 = new CachingSecretKeyRingProtector(new SecretKeyPassphraseProvider() {
@Override
public Passphrase getPassphraseFor(long keyId) {
public Passphrase getPassphraseFor(Long keyId) {
fail("Although the first PKESK is for k1, we should have skipped it and tried k2 first, which has passphrase available.");
return null;
}
@Override
public boolean hasPassphrase(long keyId) {
public boolean hasPassphrase(Long keyId) {
return false;
}
});
@ -150,13 +150,13 @@ public class PostponeDecryptionUsingKeyWithMissingPassphraseTest {
SecretKeyRingProtector protector1 = SecretKeyRingProtector.unlockEachKeyWith(p1, k1);
SecretKeyRingProtector protector2 = new CachingSecretKeyRingProtector(new SecretKeyPassphraseProvider() {
@Override
public Passphrase getPassphraseFor(long keyId) {
public Passphrase getPassphraseFor(Long keyId) {
fail("This callback should not get called, since the first PKESK is for k1, which has a passphrase available.");
return null;
}
@Override
public boolean hasPassphrase(long keyId) {
public boolean hasPassphrase(Long keyId) {
return false;
}
});
@ -178,13 +178,13 @@ public class PostponeDecryptionUsingKeyWithMissingPassphraseTest {
public void messagePassphraseFirst() throws PGPException, IOException {
SecretKeyPassphraseProvider provider = new SecretKeyPassphraseProvider() {
@Override
public Passphrase getPassphraseFor(long keyId) {
public Passphrase getPassphraseFor(Long keyId) {
fail("Since we provide a decryption passphrase, we should not try to decrypt any key.");
return null;
}
@Override
public boolean hasPassphrase(long keyId) {
public boolean hasPassphrase(Long keyId) {
return false;
}
};

View file

@ -32,13 +32,13 @@ public class CachingSecretKeyRingProtectorTest {
// Dummy passphrase callback that returns the doubled key-id as passphrase
private final SecretKeyPassphraseProvider dummyCallback = new SecretKeyPassphraseProvider() {
@Override
public Passphrase getPassphraseFor(long keyId) {
public Passphrase getPassphraseFor(Long keyId) {
long doubled = keyId * 2;
return Passphrase.fromPassword(Long.toString(doubled));
}
@Override
public boolean hasPassphrase(long keyId) {
public boolean hasPassphrase(Long keyId) {
return true;
}
};

View file

@ -31,7 +31,7 @@ public class PassphraseProtectedKeyTest {
new SecretKeyPassphraseProvider() {
@Nullable
@Override
public Passphrase getPassphraseFor(long keyId) {
public Passphrase getPassphraseFor(Long keyId) {
if (keyId == TestKeys.CRYPTIE_KEY_ID) {
return new Passphrase(TestKeys.CRYPTIE_PASSWORD.toCharArray());
} else {
@ -40,7 +40,7 @@ public class PassphraseProtectedKeyTest {
}
@Override
public boolean hasPassphrase(long keyId) {
public boolean hasPassphrase(Long keyId) {
return keyId == TestKeys.CRYPTIE_KEY_ID;
}
});

View file

@ -108,12 +108,12 @@ public class SecretKeyRingProtectorTest {
CachingSecretKeyRingProtector protector = new CachingSecretKeyRingProtector(passphraseMap,
KeyRingProtectionSettings.secureDefaultSettings(), new SecretKeyPassphraseProvider() {
@Override
public Passphrase getPassphraseFor(long keyId) {
public Passphrase getPassphraseFor(Long keyId) {
return Passphrase.fromPassword("missingP455w0rd");
}
@Override
public boolean hasPassphrase(long keyId) {
public boolean hasPassphrase(Long keyId) {
return true;
}
});