mirror of
https://github.com/google/nomulus.git
synced 2025-06-10 22:44:44 +02:00
Simplify the RyDE API
Second step of RDE encoding refactoring. Creates a single OutputStream encode RyDE files. This replaces the 5 OutputStreams that were needed before. Also removes all the factories that were injected. 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 in each individual OutputStream. This doesn't yet include a decoder (InputStream). And there's still a lot of overlap between the Ryde and the Ghostryde code. Both of those are left for the next CLs. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=204898369
This commit is contained in:
parent
c4a2b5fa8d
commit
8ec2eaf39c
15 changed files with 215 additions and 345 deletions
|
@ -68,12 +68,6 @@ public class RydeGpgIntegrationTest extends ShardableTestCase {
|
|||
new GpgCommand("gpg2"),
|
||||
};
|
||||
|
||||
@DataPoints
|
||||
public static BufferSize[] bufferSizes = new BufferSize[] {
|
||||
new BufferSize(1),
|
||||
new BufferSize(7),
|
||||
};
|
||||
|
||||
@DataPoints
|
||||
public static Filename[] filenames = new Filename[] {
|
||||
new Filename("sloth"),
|
||||
|
@ -88,22 +82,11 @@ public class RydeGpgIntegrationTest extends ShardableTestCase {
|
|||
};
|
||||
|
||||
@Theory
|
||||
public void test(GpgCommand cmd, BufferSize bufSize, Filename name, Content content)
|
||||
public void test(GpgCommand cmd, Filename name, Content content)
|
||||
throws Exception {
|
||||
assumeTrue(hasCommand("tar"));
|
||||
assumeTrue(hasCommand(cmd.get() + " --version"));
|
||||
|
||||
RydeTarOutputStreamFactory tarFactory =
|
||||
new RydeTarOutputStreamFactory();
|
||||
RydePgpFileOutputStreamFactory pgpFileFactory =
|
||||
new RydePgpFileOutputStreamFactory(bufSize::get);
|
||||
RydePgpEncryptionOutputStreamFactory pgpEncryptionFactory =
|
||||
new RydePgpEncryptionOutputStreamFactory(bufSize::get);
|
||||
RydePgpCompressionOutputStreamFactory pgpCompressionFactory =
|
||||
new RydePgpCompressionOutputStreamFactory(bufSize::get);
|
||||
RydePgpSigningOutputStreamFactory pgpSigningFactory =
|
||||
new RydePgpSigningOutputStreamFactory();
|
||||
|
||||
Keyring keyring = keyringFactory.get();
|
||||
PGPKeyPair signingKey = keyring.getRdeSigningKey();
|
||||
PGPPublicKey receiverKey = keyring.getRdeReceiverKey();
|
||||
|
@ -116,20 +99,13 @@ public class RydeGpgIntegrationTest extends ShardableTestCase {
|
|||
byte[] data = content.get().getBytes(UTF_8);
|
||||
|
||||
try (OutputStream rydeOut = new FileOutputStream(rydeFile);
|
||||
RydePgpSigningOutputStream signLayer = pgpSigningFactory.create(rydeOut, signingKey)) {
|
||||
try (RydePgpEncryptionOutputStream encryptLayer =
|
||||
pgpEncryptionFactory.create(signLayer, receiverKey);
|
||||
RydePgpCompressionOutputStream compressLayer =
|
||||
pgpCompressionFactory.create(encryptLayer);
|
||||
RydePgpFileOutputStream fileLayer =
|
||||
pgpFileFactory.create(compressLayer, modified, name.get() + ".tar");
|
||||
RydeTarOutputStream tarLayer =
|
||||
tarFactory.create(fileLayer, data.length, modified, name.get() + ".xml")) {
|
||||
tarLayer.write(data);
|
||||
}
|
||||
try (OutputStream sigOut = new FileOutputStream(sigFile)) {
|
||||
sigOut.write(signLayer.getSignature());
|
||||
}
|
||||
OutputStream sigOut = new FileOutputStream(sigFile);
|
||||
RydeEncoder rydeEncoder = new RydeEncoder.Builder()
|
||||
.setRydeOutput(rydeOut, receiverKey)
|
||||
.setSignatureOutput(sigOut, signingKey)
|
||||
.setFileMetadata(name.get(), data.length, modified)
|
||||
.build()) {
|
||||
rydeEncoder.write(data);
|
||||
}
|
||||
|
||||
// Iron Mountain examines the ryde file to see what sort of OpenPGP layers it contains.
|
||||
|
@ -252,18 +228,6 @@ public class RydeGpgIntegrationTest extends ShardableTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
private static class BufferSize {
|
||||
private final int value;
|
||||
|
||||
BufferSize(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
int get() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Filename {
|
||||
private final String value;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue