mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-11-25 16:42:07 +01:00
Kotlin conversion: SigningResult
This commit is contained in:
parent
0cb5c74a11
commit
bbe159e88c
2 changed files with 28 additions and 50 deletions
|
@ -1,50 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop;
|
||||
|
||||
/**
|
||||
* This class contains various information about a signed message.
|
||||
*/
|
||||
public final class SigningResult {
|
||||
|
||||
private final MicAlg micAlg;
|
||||
|
||||
private SigningResult(MicAlg micAlg) {
|
||||
this.micAlg = micAlg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string identifying the digest mechanism used to create the signed message.
|
||||
* This is useful for setting the micalg= parameter for the multipart/signed
|
||||
* content type of a PGP/MIME object as described in section 5 of [RFC3156].
|
||||
* <p>
|
||||
* If more than one signature was generated and different digest mechanisms were used,
|
||||
* the value of the micalg object is an empty string.
|
||||
*
|
||||
* @return micalg
|
||||
*/
|
||||
public MicAlg getMicAlg() {
|
||||
return micAlg;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private MicAlg micAlg;
|
||||
|
||||
public Builder setMicAlg(MicAlg micAlg) {
|
||||
this.micAlg = micAlg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SigningResult build() {
|
||||
SigningResult signingResult = new SigningResult(micAlg);
|
||||
return signingResult;
|
||||
}
|
||||
}
|
||||
}
|
28
sop-java/src/main/kotlin/sop/SigningResult.kt
Normal file
28
sop-java/src/main/kotlin/sop/SigningResult.kt
Normal file
|
@ -0,0 +1,28 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop
|
||||
|
||||
/**
|
||||
* This class contains various information about a signed message.
|
||||
*
|
||||
* @param micAlg string identifying the digest mechanism used to create the signed message. This is
|
||||
* useful for setting the `micalg=` parameter for the multipart/signed content-type of a PGP/MIME
|
||||
* object as described in section 5 of [RFC3156]. If more than one signature was generated and
|
||||
* different digest mechanisms were used, the value of the micalg object is an empty string.
|
||||
*/
|
||||
data class SigningResult(val micAlg: MicAlg) {
|
||||
|
||||
class Builder internal constructor() {
|
||||
private var micAlg = MicAlg.empty()
|
||||
|
||||
fun setMicAlg(micAlg: MicAlg) = apply { this.micAlg = micAlg }
|
||||
|
||||
fun build() = SigningResult(micAlg)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic fun builder() = Builder()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue