mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-06-16 16:44:50 +02:00
Move StreamDumper to own module
This commit is contained in:
parent
e97ca3e3f2
commit
f1dbfa22b6
27
pgpainless-dump/build.gradle
Normal file
27
pgpainless-dump/build.gradle
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id 'java-library'
|
||||||
|
}
|
||||||
|
|
||||||
|
group 'org.pgpainless'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
|
||||||
|
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
|
||||||
|
|
||||||
|
// Logging
|
||||||
|
testImplementation "ch.qos.logback:logback-classic:$logbackVersion"
|
||||||
|
|
||||||
|
implementation(project(":pgpainless-core"))
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package org.pgpainless.util;
|
package org.pgpainless.dump;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -68,6 +68,8 @@ import org.pgpainless.algorithm.StreamEncoding;
|
||||||
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
||||||
import org.pgpainless.key.util.RevocationAttributes;
|
import org.pgpainless.key.util.RevocationAttributes;
|
||||||
import org.pgpainless.signature.subpackets.KeyServerPreferences;
|
import org.pgpainless.signature.subpackets.KeyServerPreferences;
|
||||||
|
import org.pgpainless.util.CollectionUtils;
|
||||||
|
import org.pgpainless.util.DateUtil;
|
||||||
|
|
||||||
public class StreamDumper {
|
public class StreamDumper {
|
||||||
|
|
||||||
|
@ -85,7 +87,8 @@ public class StreamDumper {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dump(InputStream inputStream, PGPSessionKey sessionKey, OutputStream outputStream) throws IOException, PGPException {
|
public static void dump(InputStream inputStream, PGPSessionKey sessionKey, OutputStream outputStream)
|
||||||
|
throws IOException, PGPException {
|
||||||
PrintWriter printWriter = new PrintWriter(outputStream);
|
PrintWriter printWriter = new PrintWriter(outputStream);
|
||||||
PrintWriterWrapper pww = new PrintWriterWrapper(printWriter);
|
PrintWriterWrapper pww = new PrintWriterWrapper(printWriter);
|
||||||
|
|
||||||
|
@ -94,16 +97,15 @@ public class StreamDumper {
|
||||||
printWriter.flush();
|
printWriter.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void walkObjects(PrintWriterWrapper pww, PGPObjectFactory objectFactory, PGPSessionKey sessionKey) throws IOException, PGPException {
|
private static void walkObjects(PrintWriterWrapper pww, PGPObjectFactory objectFactory, PGPSessionKey sessionKey)
|
||||||
|
throws IOException, PGPException {
|
||||||
Object next;
|
Object next;
|
||||||
|
|
||||||
while ((next = objectFactory.nextObject()) != null) {
|
while ((next = objectFactory.nextObject()) != null) {
|
||||||
|
|
||||||
if (next instanceof PGPOnePassSignatureList) {
|
if (next instanceof PGPOnePassSignatureList) {
|
||||||
PGPOnePassSignatureList onePassSignatures = (PGPOnePassSignatureList) next;
|
PGPOnePassSignatureList onePassSignatures = (PGPOnePassSignatureList) next;
|
||||||
Iterator<PGPOnePassSignature> iterator = onePassSignatures.iterator();
|
for (PGPOnePassSignature pgpOnePassSignature : onePassSignatures) {
|
||||||
while (iterator.hasNext()) {
|
|
||||||
PGPOnePassSignature pgpOnePassSignature = iterator.next();
|
|
||||||
pww.appendLine("One-Pass Signature Packet").iind()
|
pww.appendLine("One-Pass Signature Packet").iind()
|
||||||
.appendLine("Type: " + SignatureType.valueOf(pgpOnePassSignature.getSignatureType()))
|
.appendLine("Type: " + SignatureType.valueOf(pgpOnePassSignature.getSignatureType()))
|
||||||
.appendLine("Public Key Algorithm: " + PublicKeyAlgorithm.fromId(pgpOnePassSignature.getKeyAlgorithm()))
|
.appendLine("Public Key Algorithm: " + PublicKeyAlgorithm.fromId(pgpOnePassSignature.getKeyAlgorithm()))
|
||||||
|
@ -276,7 +278,7 @@ public class StreamDumper {
|
||||||
|
|
||||||
else if (next instanceof Packet) {
|
else if (next instanceof Packet) {
|
||||||
Packet packet = (Packet) next;
|
Packet packet = (Packet) next;
|
||||||
pww.appendLine("Experimental Packet: " + packet.toString());
|
pww.appendLine("Experimental Packet: " + packet);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OpenPGP Packet Dumper.
|
||||||
|
*/
|
||||||
|
package org.pgpainless.dump;
|
|
@ -1,8 +1,8 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package org.pgpainless.util;
|
package org.pgpainless.dump;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
|
@ -6,5 +6,6 @@ rootProject.name = 'PGPainless'
|
||||||
|
|
||||||
include 'pgpainless-core',
|
include 'pgpainless-core',
|
||||||
'pgpainless-sop',
|
'pgpainless-sop',
|
||||||
'pgpainless-cli'
|
'pgpainless-cli',
|
||||||
|
'pgpainless-dump'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue