summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2013-12-06 14:05:45 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2014-04-25 11:19:32 +0900
commit0503d412f4504e82e76459a354ffd7b4c8199e53 (patch)
treefdae209be4feef4bcb77b12e212cf5c249f43424
parent0e26575790a7502a83fec0efde7e084fba6063ac (diff)
Split PGPEncryptedDataGenerator creation out into a utility method
Split the creation of PGPEncryptedDataGenerator out into a utility method. Inline the call to the open() method on the returned generator rather than storing the generator in a temporary variable. Suppress deprecation warnings caused by using methods that have been deprecated in the new version of Bouncycastle that was introduced recently. We cannot yet replace the calls with the newer versions because some Gerrit sites still use the older version of Bouncycastle. Change-Id: I98f4b7c7bf8ab1ee74eb8bbc86b673d057d98e46
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/contact/EncryptedContactStore.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/contact/EncryptedContactStore.java b/gerrit-server/src/main/java/com/google/gerrit/server/contact/EncryptedContactStore.java
index 17c90605b8..40699c83de 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/contact/EncryptedContactStore.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/contact/EncryptedContactStore.java
@@ -173,17 +173,23 @@ class EncryptedContactStore implements ContactStore {
}
}
+ @SuppressWarnings("deprecation")
+ private final PGPEncryptedDataGenerator cpk()
+ throws NoSuchProviderException, PGPException {
+ PGPEncryptedDataGenerator cpk =
+ new PGPEncryptedDataGenerator(PGPEncryptedData.CAST5, true, prng, "BC");
+ cpk.addMethod(dest);
+ return cpk;
+ }
+
private byte[] encrypt(final String name, final Date date,
final byte[] rawText) throws NoSuchProviderException, PGPException,
IOException {
final byte[] zText = compress(name, date, rawText);
- final PGPEncryptedDataGenerator cpk =
- new PGPEncryptedDataGenerator(PGPEncryptedData.CAST5, true, prng, "BC");
- cpk.addMethod(dest);
final ByteArrayOutputStream buf = new ByteArrayOutputStream();
final ArmoredOutputStream aout = new ArmoredOutputStream(buf);
- final OutputStream cout = cpk.open(aout, zText.length);
+ final OutputStream cout = cpk().open(aout, zText.length);
cout.write(zText);
cout.close();
aout.close();