• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pgpainless / sop-java / #54

25 Sep 2025 09:07PM UTC coverage: 58.308% (-0.1%) from 58.411%
#54

push

other

vanitasvitae
Remove unused import

2088 of 3581 relevant lines covered (58.31%)

0.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/sop-java/src/main/kotlin/sop/operation/AbstractSign.kt
1
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
2
//
3
// SPDX-License-Identifier: Apache-2.0
4

5
package sop.operation
6

7
import java.io.IOException
8
import java.io.InputStream
9
import sop.exception.SOPGPException.BadData
10
import sop.exception.SOPGPException.KeyCannotSign
11
import sop.exception.SOPGPException.PasswordNotHumanReadable
12
import sop.exception.SOPGPException.UnsupportedAsymmetricAlgo
13
import sop.exception.SOPGPException.UnsupportedOption
14
import sop.util.UTF8Util
15

16
/**
17
 * Interface for signing operations.
18
 *
19
 * @param <T> builder subclass
20
 */
21
interface AbstractSign<T> {
22

23
    /**
24
     * Disable ASCII armor encoding.
25
     *
26
     * @return builder instance
27
     */
28
    fun noArmor(): T
29

30
    /**
31
     * Add one or more signing keys.
32
     *
33
     * @param key input stream containing encoded keys
34
     * @return builder instance
35
     * @throws KeyCannotSign if the key cannot be used for signing
36
     * @throws BadData if the [InputStream] does not contain an OpenPGP key
37
     * @throws UnsupportedAsymmetricAlgo if the key uses an unsupported asymmetric algorithm
38
     * @throws IOException in case of an IO error
39
     */
40
    @Throws(
41
        KeyCannotSign::class, BadData::class, UnsupportedAsymmetricAlgo::class, IOException::class)
42
    fun key(key: InputStream): T
43

44
    /**
45
     * Add one or more signing keys.
46
     *
47
     * @param key byte array containing encoded keys
48
     * @return builder instance
49
     * @throws KeyCannotSign if the key cannot be used for signing
50
     * @throws BadData if the byte array does not contain an OpenPGP key
51
     * @throws UnsupportedAsymmetricAlgo if the key uses an unsupported asymmetric algorithm
52
     * @throws IOException in case of an IO error
53
     */
54
    @Throws(
55
        KeyCannotSign::class, BadData::class, UnsupportedAsymmetricAlgo::class, IOException::class)
56
    fun key(key: ByteArray): T = key(key.inputStream())
1✔
57

58
    /**
59
     * Provide the password for the secret key used for signing.
60
     *
61
     * @param password password
62
     * @return builder instance
63
     * @throws UnsupportedOption if key passwords are not supported
64
     */
65
    @Throws(UnsupportedOption::class)
66
    fun withKeyPassword(password: CharArray): T = withKeyPassword(password.concatToString())
×
67

68
    /**
69
     * Provide the password for the secret key used for signing.
70
     *
71
     * @param password password
72
     * @return builder instance
73
     * @throws UnsupportedOption if key passwords are not supported
74
     */
75
    @Throws(UnsupportedOption::class)
76
    fun withKeyPassword(password: String): T = withKeyPassword(password.toByteArray(UTF8Util.UTF8))
1✔
77

78
    /**
79
     * Provide the password for the secret key used for signing.
80
     *
81
     * @param password password
82
     * @return builder instance
83
     * @throws UnsupportedOption if key passwords are not supported
84
     * @throws PasswordNotHumanReadable if the provided passphrase is not human-readable
85
     */
86
    @Throws(UnsupportedOption::class, PasswordNotHumanReadable::class)
87
    fun withKeyPassword(password: ByteArray): T
88
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc