mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-19 10:52:05 +01:00
Kotlin conversion: KeySpec
This commit is contained in:
parent
bb17c627ce
commit
41f56bdf99
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... flags) {
|
|
||||||
return new KeySpecBuilder(type, 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, vararg flags: KeyFlag) = KeySpecBuilder(type, *flags)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue