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

pgpainless / sop-java / #65

12 Jan 2026 11:37AM UTC coverage: 57.95% (-0.3%) from 58.291%
#65

push

other

vanitasvitae
Add comments

2103 of 3629 relevant lines covered (57.95%)

0.58 hits per line

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

20.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
     * Specify, whether deprecated component keys shall be revoked with reason superseded.
43
     *
44
     * @return builder instance
45
     * @throws UnsupportedOption if this option is not supported
46
     */
47
    @Throws(UnsupportedOption::class) fun revokeDeprecatedKeys(): UpdateKey
48

49
    /**
50
     * Provide a passphrase for unlocking the secret key.
51
     *
52
     * @param password password
53
     * @return builder instance
54
     * @throws UnsupportedOption if this option is not supported
55
     */
56
    @Throws(UnsupportedOption::class)
57
    fun withKeyPassword(password: CharArray): UpdateKey = withKeyPassword(password.concatToString())
×
58

59
    /**
60
     * Provide a passphrase for unlocking the secret key.
61
     *
62
     * @param password password
63
     * @return builder instance
64
     * @throws UnsupportedOption if this option is not supported
65
     */
66
    @Throws(UnsupportedOption::class)
67
    fun withKeyPassword(password: String): UpdateKey =
×
68
        withKeyPassword(password.toByteArray(UTF8Util.UTF8))
×
69

70
    /**
71
     * Provide a passphrase for unlocking the secret key.
72
     *
73
     * @param password password
74
     * @return builder instance
75
     * @throws PasswordNotHumanReadable if the password is not human-readable
76
     * @throws UnsupportedOption if this option is not supported
77
     */
78
    @Throws(PasswordNotHumanReadable::class, UnsupportedOption::class)
79
    fun withKeyPassword(password: ByteArray): UpdateKey
80

81
    /**
82
     * Provide certificates that might contain updated signatures or third-party certifications.
83
     * These certificates will be merged into the key.
84
     *
85
     * @param certs input stream of certificates
86
     * @return builder instance
87
     * @throws UnsupportedOption if this option is not supported
88
     * @throws BadData if the certificate cannot be read
89
     * @throws IOException if an IO error occurs
90
     */
91
    @Throws(UnsupportedOption::class, BadData::class, IOException::class)
92
    fun mergeCerts(certs: InputStream): UpdateKey
93

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

107
    /**
108
     * Provide the OpenPGP key to update.
109
     *
110
     * @param key input stream containing the key
111
     * @return handle to acquire the updated OpenPGP key from
112
     * @throws BadData if the key cannot be read
113
     * @throws IOException if an IO error occurs
114
     * @throws KeyIsProtected if the key is passphrase protected and cannot be unlocked
115
     * @throws PrimaryKeyBad if the primary key is bad (e.g. expired, too weak)
116
     */
117
    @Throws(BadData::class, IOException::class, KeyIsProtected::class, PrimaryKeyBad::class)
118
    fun key(key: InputStream): Ready
119

120
    /**
121
     * Provide the OpenPGP key to update.
122
     *
123
     * @param key binary OpenPGP key
124
     * @return handle to acquire the updated OpenPGP key from
125
     * @throws BadData if the key cannot be read
126
     * @throws IOException if an IO error occurs
127
     * @throws KeyIsProtected if the key is passphrase protected and cannot be unlocked
128
     * @throws PrimaryKeyBad if the primary key is bad (e.g. expired, too weak)
129
     */
130
    @Throws(BadData::class, IOException::class, KeyIsProtected::class, PrimaryKeyBad::class)
131
    fun key(key: ByteArray): Ready = key(key.inputStream())
1✔
132
}
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