mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-09 18:29:39 +02:00
Remove unused SignatureComparator classes
This commit is contained in:
parent
02a997fb26
commit
3340614595
2 changed files with 0 additions and 62 deletions
|
@ -1,30 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
package org.pgpainless.signature.consumer
|
|
||||||
|
|
||||||
import org.bouncycastle.openpgp.PGPSignature
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new comparator which sorts signatures according to the passed ordering.
|
|
||||||
*
|
|
||||||
* @param order ordering
|
|
||||||
*/
|
|
||||||
class SignatureCreationDateComparator(private val order: Order = Order.OLD_TO_NEW) :
|
|
||||||
Comparator<PGPSignature> {
|
|
||||||
|
|
||||||
enum class Order {
|
|
||||||
/** Oldest signatures first. */
|
|
||||||
OLD_TO_NEW,
|
|
||||||
/** Newest signatures first. */
|
|
||||||
NEW_TO_OLD
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun compare(one: PGPSignature, two: PGPSignature): Int {
|
|
||||||
return when (order) {
|
|
||||||
Order.OLD_TO_NEW -> one.creationTime.compareTo(two.creationTime)
|
|
||||||
Order.NEW_TO_OLD -> two.creationTime.compareTo(one.creationTime)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
package org.pgpainless.signature.consumer
|
|
||||||
|
|
||||||
import org.bouncycastle.openpgp.PGPSignature
|
|
||||||
import org.pgpainless.bouncycastle.extensions.isHardRevocation
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Comparator which sorts signatures based on an ordering and on revocation hardness.
|
|
||||||
*
|
|
||||||
* If a list of signatures gets ordered using this comparator, hard revocations will always come
|
|
||||||
* first. Further, signatures are ordered by date according to the
|
|
||||||
* [SignatureCreationDateComparator.Order].
|
|
||||||
*/
|
|
||||||
class SignatureValidityComparator(
|
|
||||||
order: SignatureCreationDateComparator.Order = SignatureCreationDateComparator.Order.OLD_TO_NEW
|
|
||||||
) : Comparator<PGPSignature> {
|
|
||||||
|
|
||||||
private val creationDateComparator: SignatureCreationDateComparator =
|
|
||||||
SignatureCreationDateComparator(order)
|
|
||||||
|
|
||||||
override fun compare(one: PGPSignature, two: PGPSignature): Int {
|
|
||||||
return if (one.isHardRevocation == two.isHardRevocation) {
|
|
||||||
// Both have the same hardness, so compare creation time
|
|
||||||
creationDateComparator.compare(one, two)
|
|
||||||
}
|
|
||||||
// else favor the "harder" signature
|
|
||||||
else if (one.isHardRevocation) -1 else 1
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue