Kotlin conversion: SigningResult

This commit is contained in:
Paul Schaub 2023-10-31 12:56:12 +01:00
parent 0cb5c74a11
commit bbe159e88c
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 28 additions and 50 deletions

View file

@ -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;
}
}
}

View 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()
}
}