Simplify the Ghostryde API

First step of RDE encoding refactoring.

Creates a single InputStream (OutputStream) to decode (encode) Ghostryde files.
This replaces the 3 InputStreams (OutputStreams) that were needed before.

Also removes a lot of classes, and removes the "injection" of the Ghostryde
class. It's an encoding, there's no point in injecting it.

Finally, removed the buffer-size configuration and replaced with a static final
const value. It's just a buffer size - it doesn't actually affect much. There
are much more "important" fields that weren't configured (such as the
compression algorithm and whether or not to do integrity checks)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202319102
This commit is contained in:
guyben 2018-06-27 09:10:19 -07:00 committed by Ben McIlwain
parent bee3d6a5a4
commit 6ff48b7dae
15 changed files with 347 additions and 589 deletions

View file

@ -19,7 +19,6 @@ import static com.google.common.truth.Truth.assertWithMessage;
import static google.registry.testing.GcsTestingUtils.readGcsFile;
import static google.registry.testing.SystemInfo.hasCommand;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.joda.time.DateTimeZone.UTC;
import static org.junit.Assume.assumeTrue;
import com.google.appengine.tools.cloudstorage.GcsFilename;
@ -101,7 +100,6 @@ public class BrdaCopyActionTest extends ShardableTestCase {
@Before
public void before() throws Exception {
action.gcsUtils = gcsUtils;
action.ghostryde = new Ghostryde(23);
action.pgpCompressionFactory = new RydePgpCompressionOutputStreamFactory(() -> 1024);
action.pgpEncryptionFactory = new RydePgpEncryptionOutputStreamFactory(() -> 1024);
action.pgpFileFactory = new RydePgpFileOutputStreamFactory(() -> 1024);
@ -116,8 +114,7 @@ public class BrdaCopyActionTest extends ShardableTestCase {
action.stagingDecryptionKey = decryptKey;
byte[] xml = DEPOSIT_XML.read();
GcsTestingUtils.writeGcsFile(gcsService, STAGE_FILE,
Ghostryde.encode(xml, encryptKey, "lobster.xml", new DateTime(UTC)));
GcsTestingUtils.writeGcsFile(gcsService, STAGE_FILE, Ghostryde.encode(xml, encryptKey));
GcsTestingUtils.writeGcsFile(gcsService, STAGE_LENGTH_FILE,
Long.toString(xml.length).getBytes(UTF_8));
}