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.Ready;
012import sop.exception.SOPGPException;
013
014public interface ExtractCert {
015
016    /**
017     * Disable ASCII armor encoding.
018     *
019     * @return builder instance
020     */
021    ExtractCert noArmor();
022
023    /**
024     * Extract the cert from the provided key.
025     *
026     * @param keyInputStream input stream containing the encoding of an OpenPGP key
027     * @return result containing the encoding of the keys cert
028     */
029    Ready key(InputStream keyInputStream) throws IOException, SOPGPException.BadData;
030
031    /**
032     * Extract the cert from the provided key.
033     *
034     * @param key byte array containing the encoding of an OpenPGP key
035     * @return result containing the encoding of the keys cert
036     */
037    default Ready key(byte[] key) throws IOException, SOPGPException.BadData {
038        return key(new ByteArrayInputStream(key));
039    }
040}