Update KMS method signatures to standardize on KeyringException

It came up during the review of [] that it doesn't make a lot of sense
for encrypt() and decrypt() to not throw the same kinds of Exceptions,
especially not for the same kind of problem, just because one happens to use a
Retrier in its internal implementation and the other doesn't.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201054057
This commit is contained in:
mcilwain 2018-06-18 14:01:37 -07:00 committed by Ben McIlwain
parent f971583dc0
commit a7256f5edd
4 changed files with 24 additions and 10 deletions

View file

@ -15,7 +15,6 @@
package google.registry.keyring.kms;
import com.google.common.io.BaseEncoding;
import java.io.IOException;
import org.bouncycastle.util.Arrays;
class FakeKmsConnection implements KmsConnection {
@ -29,7 +28,7 @@ class FakeKmsConnection implements KmsConnection {
* and the name of the cryptoKeyVersion is {@code cryptoKeyName + "/foo"}.
*/
@Override
public EncryptResponse encrypt(String cryptoKeyName, byte[] plaintext) throws IOException {
public EncryptResponse encrypt(String cryptoKeyName, byte[] plaintext) {
return EncryptResponse.create(
BaseEncoding.base64().encode(Arrays.reverse(plaintext)), cryptoKeyName + "/foo");
}
@ -40,7 +39,7 @@ class FakeKmsConnection implements KmsConnection {
* <p>The plaintext is the encodedCiphertext base64-decoded and then reversed.
*/
@Override
public byte[] decrypt(String cryptoKeyName, String encodedCiphertext) throws IOException {
public byte[] decrypt(String cryptoKeyName, String encodedCiphertext) {
return Arrays.reverse(BaseEncoding.base64().decode(encodedCiphertext));
}
}