001// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
002//
003// SPDX-License-Identifier: Apache-2.0
004
005package sop.operation;
006
007import java.io.ByteArrayInputStream;
008import java.io.IOException;
009import java.io.InputStream;
010
011import sop.ReadyWithResult;
012import sop.Signatures;
013
014public interface DetachInbandSignatureAndMessage {
015
016    /**
017     * Do not wrap the signatures in ASCII armor.
018     * @return builder
019     */
020    DetachInbandSignatureAndMessage noArmor();
021
022    /**
023     * Detach the provided cleartext signed message from its signatures.
024     *
025     * @param messageInputStream input stream containing the signed message
026     * @return result containing the detached message
027     * @throws IOException in case of an IO error
028     */
029    ReadyWithResult<Signatures> message(InputStream messageInputStream) throws IOException;
030
031    /**
032     * Detach the provided cleartext signed message from its signatures.
033     *
034     * @param message byte array containing the signed message
035     * @return result containing the detached message
036     * @throws IOException in case of an IO error
037     */
038    default ReadyWithResult<Signatures> message(byte[] message) throws IOException {
039        return message(new ByteArrayInputStream(message));
040    }
041}