2021-10-07 15:48:52 +02:00
|
|
|
// SPDX-FileCopyrightText: 2020 Paul Schaub <vanitasvitae@fsfe.org>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2021-07-15 16:55:13 +02:00
|
|
|
package org.pgpainless.sop;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
|
|
|
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
2021-07-31 20:40:31 +02:00
|
|
|
import org.bouncycastle.util.io.Streams;
|
2021-07-15 16:55:13 +02:00
|
|
|
import org.pgpainless.util.ArmoredOutputStreamFactory;
|
|
|
|
import sop.Ready;
|
|
|
|
import sop.enums.ArmorLabel;
|
|
|
|
import sop.exception.SOPGPException;
|
|
|
|
import sop.operation.Armor;
|
|
|
|
|
|
|
|
public class ArmorImpl implements Armor {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Armor label(ArmorLabel label) throws SOPGPException.UnsupportedOption {
|
2021-07-19 18:20:52 +02:00
|
|
|
throw new SOPGPException.UnsupportedOption("Setting custom Armor labels not supported.");
|
2021-07-15 16:55:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Ready data(InputStream data) throws SOPGPException.BadData {
|
|
|
|
return new Ready() {
|
|
|
|
@Override
|
|
|
|
public void writeTo(OutputStream outputStream) throws IOException {
|
2021-10-04 16:02:28 +02:00
|
|
|
ArmoredOutputStream armor = ArmoredOutputStreamFactory.get(outputStream);
|
2021-08-19 16:44:29 +02:00
|
|
|
Streams.pipeAll(data, armor);
|
|
|
|
armor.close();
|
2021-07-15 16:55:13 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|