• 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

0.0
/sop-java/src/main/kotlin/sop/operation/UpdateKey.kt
1
// SPDX-FileCopyrightText: 2024 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.Ready
10
import sop.exception.SOPGPException.*
11
import sop.util.UTF8Util
12

13
/** Interface for bringing an OpenPGP key up to date. */
14
interface UpdateKey {
15

16
    /**
17
     * Disable ASCII armor encoding of the output.
18
     *
19
     * @return builder instance
20
     */
21
    fun noArmor(): UpdateKey
22

23
    /**
24
     * Allow key to be used for signing only. If this option is not present, the operation may add a
25
     * new, encryption-capable component key.
26
     *
27
     * @return builder instance
28
     * @throws UnsupportedOption if this option is not supported
29
     */
30
    @Throws(UnsupportedOption::class) fun signingOnly(): UpdateKey
31

32
    /**
33
     * Do not allow adding new capabilities to the key. If this option is not present, the operation
34
     * may add support for new capabilities to the key.
35
     *
36
     * @return builder instance
37
     * @throws UnsupportedOption if this option is not supported
38
     */
39
    @Throws(UnsupportedOption::class) fun noAddedCapabilities(): UpdateKey
40

41
    /**
42
     * Provide a passphrase for unlocking the secret key.
43
     *
44
     * @param password password
45
     * @return builder instance
46
     * @throws UnsupportedOption if this option is not supported
47
     */
48
    @Throws(UnsupportedOption::class)
49
    fun withKeyPassword(password: CharArray): UpdateKey = withKeyPassword(password.concatToString())
×
50

51
    /**
52
     * Provide a passphrase for unlocking the secret key.
53
     *
54
     * @param password password
55
     * @return builder instance
56
     * @throws UnsupportedOption if this option is not supported
57
     */
58
    @Throws(UnsupportedOption::class)
59
    fun withKeyPassword(password: String): UpdateKey =
×
60
        withKeyPassword(password.toByteArray(UTF8Util.UTF8))
×
61

62
    /**
63
     * Provide a passphrase for unlocking the secret key.
64
     *
65
     * @param password password
66
     * @return builder instance
67
     * @throws PasswordNotHumanReadable if the password is not human-readable
68
     * @throws UnsupportedOption if this option is not supported
69
     */
70
    @Throws(PasswordNotHumanReadable::class, UnsupportedOption::class)
71
    fun withKeyPassword(password: ByteArray): UpdateKey
72

73
    /**
74
     * Provide certificates that might contain updated signatures or third-party certifications.
75
     * These certificates will be merged into the key.
76
     *
77
     * @param certs input stream of certificates
78
     * @return builder instance
79
     * @throws UnsupportedOption if this option is not supported
80
     * @throws BadData if the certificate cannot be read
81
     * @throws IOException if an IO error occurs
82
     */
83
    @Throws(UnsupportedOption::class, BadData::class, IOException::class)
84
    fun mergeCerts(certs: InputStream): UpdateKey
85

86
    /**
87
     * Provide certificates that might contain updated signatures or third-party certifications.
88
     * These certificates will be merged into the key.
89
     *
90
     * @param certs binary certificates
91
     * @return builder instance
92
     * @throws UnsupportedOption if this option is not supported
93
     * @throws BadData if the certificate cannot be read
94
     * @throws IOException if an IO error occurs
95
     */
96
    @Throws(UnsupportedOption::class, BadData::class, IOException::class)
97
    fun mergeCerts(certs: ByteArray): UpdateKey = mergeCerts(certs.inputStream())
×
98

99
    /**
100
     * Provide the OpenPGP key to update.
101
     *
102
     * @param key input stream containing the key
103
     * @return handle to acquire the updated OpenPGP key from
104
     * @throws BadData if the key cannot be read
105
     * @throws IOException if an IO error occurs
106
     * @throws KeyIsProtected if the key is passphrase protected and cannot be unlocked
107
     * @throws PrimaryKeyBad if the primary key is bad (e.g. expired, too weak)
108
     */
109
    @Throws(BadData::class, IOException::class, KeyIsProtected::class, PrimaryKeyBad::class)
110
    fun key(key: InputStream): Ready
111

112
    /**
113
     * Provide the OpenPGP key to update.
114
     *
115
     * @param key binary OpenPGP key
116
     * @return handle to acquire the updated OpenPGP key from
117
     * @throws BadData if the key cannot be read
118
     * @throws IOException if an IO error occurs
119
     * @throws KeyIsProtected if the key is passphrase protected and cannot be unlocked
120
     * @throws PrimaryKeyBad if the primary key is bad (e.g. expired, too weak)
121
     */
122
    @Throws(BadData::class, IOException::class, KeyIsProtected::class, PrimaryKeyBad::class)
123
    fun key(key: ByteArray): Ready = key(key.inputStream())
×
124
}
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