Move the RDE PGP file encoding to a dedicated file

The "file encoding" saves the file + metadata (filename and modification) in a "blob" format that PGP knows how to read.

Merges the file-encoder creation between RyDE and Ghostryde.

The new file - RydeFileEncoding.java - is a merge of the removed functions in
Ghostryde.java and the RydePgpFileOutputStream.java.

This is one of a series of CLs - each merging a single "part" of the encoding.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=205295756
This commit is contained in:
guyben 2018-07-19 13:49:56 -07:00 committed by jianglai
parent a2fe058865
commit 9f83544113
5 changed files with 169 additions and 125 deletions

View file

@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static google.registry.rde.RydeCompression.openCompressor;
import static google.registry.rde.RydeEncryption.RYDE_USE_INTEGRITY_PACKET;
import static google.registry.rde.RydeEncryption.openEncryptor;
import static google.registry.rde.RydeFileEncoding.openPgpFileWriter;
import com.google.common.collect.ImmutableList;
import com.google.common.io.Closer;
@ -73,8 +74,7 @@ public final class RydeEncoder extends FilterOutputStream {
signer = closer.register(new RydePgpSigningOutputStream(checkNotNull(rydeOutput), signingKey));
encryptLayer = closer.register(openEncryptor(signer, RYDE_USE_INTEGRITY_PACKET, receiverKeys));
kompressor = closer.register(openCompressor(encryptLayer));
fileLayer =
closer.register(new RydePgpFileOutputStream(kompressor, modified, filenamePrefix + ".tar"));
fileLayer = closer.register(openPgpFileWriter(kompressor, filenamePrefix + ".tar", modified));
tarLayer =
closer.register(
new RydeTarOutputStream(fileLayer, dataLength, modified, filenamePrefix + ".xml"));