mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-25 04:17:59 +01:00
Kotlin conversion: KeySpec
This commit is contained in:
parent
3e8c78225e
commit
ec23d71ec4
2 changed files with 28 additions and 62 deletions
|
@ -1,62 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2018 Paul Schaub <vanitasvitae@fsfe.org>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
package org.pgpainless.key.generation;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.bouncycastle.openpgp.PGPSignatureSubpacketVector;
|
|
||||||
import org.pgpainless.algorithm.KeyFlag;
|
|
||||||
import org.pgpainless.key.generation.type.KeyType;
|
|
||||||
import org.pgpainless.signature.subpackets.SignatureSubpackets;
|
|
||||||
import org.pgpainless.signature.subpackets.SignatureSubpacketsHelper;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class KeySpec {
|
|
||||||
|
|
||||||
private final KeyType keyType;
|
|
||||||
private final SignatureSubpackets subpacketGenerator;
|
|
||||||
private final boolean inheritedSubPackets;
|
|
||||||
private final Date keyCreationDate;
|
|
||||||
|
|
||||||
KeySpec(@Nonnull KeyType type,
|
|
||||||
@Nonnull SignatureSubpackets subpacketGenerator,
|
|
||||||
boolean inheritedSubPackets,
|
|
||||||
@Nullable Date keyCreationDate) {
|
|
||||||
this.keyType = type;
|
|
||||||
this.subpacketGenerator = subpacketGenerator;
|
|
||||||
this.inheritedSubPackets = inheritedSubPackets;
|
|
||||||
this.keyCreationDate = keyCreationDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public KeyType getKeyType() {
|
|
||||||
return keyType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public PGPSignatureSubpacketVector getSubpackets() {
|
|
||||||
return SignatureSubpacketsHelper.toVector(subpacketGenerator);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public SignatureSubpackets getSubpacketGenerator() {
|
|
||||||
return subpacketGenerator;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isInheritedSubPackets() {
|
|
||||||
return inheritedSubPackets;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public Date getKeyCreationDate() {
|
|
||||||
return keyCreationDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static KeySpecBuilder getBuilder(KeyType type, KeyFlag flag, KeyFlag... flags) {
|
|
||||||
return new KeySpecBuilder(type, flag, flags);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package org.pgpainless.key.generation
|
||||||
|
|
||||||
|
import org.bouncycastle.openpgp.PGPSignatureSubpacketVector
|
||||||
|
import org.pgpainless.algorithm.KeyFlag
|
||||||
|
import org.pgpainless.key.generation.type.KeyType
|
||||||
|
import org.pgpainless.signature.subpackets.SignatureSubpackets
|
||||||
|
import org.pgpainless.signature.subpackets.SignatureSubpacketsHelper
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
data class KeySpec(
|
||||||
|
val keyType: KeyType,
|
||||||
|
val subpacketGenerator: SignatureSubpackets,
|
||||||
|
val isInheritedSubPackets: Boolean,
|
||||||
|
val keyCreationDate: Date
|
||||||
|
) {
|
||||||
|
|
||||||
|
val subpackets: PGPSignatureSubpacketVector
|
||||||
|
get() = SignatureSubpacketsHelper.toVector(subpacketGenerator)
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
fun getBuilder(type: KeyType, flag: KeyFlag, vararg flags: KeyFlag) = KeySpecBuilder(type, flag, *flags)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue