All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sop.operation.AbstractVerify.kt Maven / Gradle / Ivy

There is a newer version: 10.0.3
Show newest version
// SPDX-FileCopyrightText: 2023 Paul Schaub 
//
// SPDX-License-Identifier: Apache-2.0

package sop.operation

import java.io.IOException
import java.io.InputStream
import java.util.*
import sop.exception.SOPGPException.BadData
import sop.exception.SOPGPException.UnsupportedOption

/**
 * Common API methods shared between verification of inline signatures ([InlineVerify]) and
 * verification of detached signatures ([DetachedVerify]).
 *
 * @param  Builder type ([DetachedVerify], [InlineVerify])
 */
interface AbstractVerify {

    /**
     * Makes the SOP implementation consider signatures before this date invalid.
     *
     * @param timestamp timestamp
     * @return builder instance
     */
    @Throws(UnsupportedOption::class) fun notBefore(timestamp: Date): T

    /**
     * Makes the SOP implementation consider signatures after this date invalid.
     *
     * @param timestamp timestamp
     * @return builder instance
     */
    @Throws(UnsupportedOption::class) fun notAfter(timestamp: Date): T

    /**
     * Add one or more verification cert.
     *
     * @param cert input stream containing the encoded certs
     * @return builder instance
     * @throws BadData if the input stream does not contain an OpenPGP certificate
     * @throws IOException in case of an IO error
     */
    @Throws(BadData::class, IOException::class) fun cert(cert: InputStream): T

    /**
     * Add one or more verification cert.
     *
     * @param cert byte array containing the encoded certs
     * @return builder instance
     * @throws BadData if the byte array does not contain an OpenPGP certificate
     * @throws IOException in case of an IO error
     */
    @Throws(BadData::class, IOException::class)
    fun cert(cert: ByteArray): T = cert(cert.inputStream())
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy