mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-08 17:59:43 +02:00
validate-userid: Add --validate-at option
This commit is contained in:
parent
5105b6f4ad
commit
b300be42a4
3 changed files with 15 additions and 0 deletions
|
@ -8,6 +8,7 @@ import java.io.InputStream
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import sop.external.ExternalSOP
|
import sop.external.ExternalSOP
|
||||||
import sop.operation.ValidateUserId
|
import sop.operation.ValidateUserId
|
||||||
|
import sop.util.UTCUtil
|
||||||
|
|
||||||
class ValidateUserIdExternal(binary: String, environment: Properties) : ValidateUserId {
|
class ValidateUserIdExternal(binary: String, environment: Properties) : ValidateUserId {
|
||||||
|
|
||||||
|
@ -35,4 +36,8 @@ class ValidateUserIdExternal(binary: String, environment: Properties) : Validate
|
||||||
.bytes
|
.bytes
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun validateAt(date: Date): ValidateUserId = apply {
|
||||||
|
commandList.add("--validate-at=${UTCUtil.formatUTCDate(date)}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import picocli.CommandLine.Parameters
|
||||||
import sop.cli.picocli.SopCLI
|
import sop.cli.picocli.SopCLI
|
||||||
import sop.exception.SOPGPException
|
import sop.exception.SOPGPException
|
||||||
import sop.util.HexUtil.Companion.bytesToHex
|
import sop.util.HexUtil.Companion.bytesToHex
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "validate-userid",
|
name = "validate-userid",
|
||||||
|
@ -21,6 +22,8 @@ class ValidateUserIdCmd : AbstractSopCmd() {
|
||||||
|
|
||||||
@Option(names = ["--addr-spec-only"]) var addrSpecOnly: Boolean = false
|
@Option(names = ["--addr-spec-only"]) var addrSpecOnly: Boolean = false
|
||||||
|
|
||||||
|
@Option(names = ["--validate-at"]) var validateAt: Date? = null
|
||||||
|
|
||||||
@Parameters(index = "0", arity = "1", paramLabel = "USERID") lateinit var userId: String
|
@Parameters(index = "0", arity = "1", paramLabel = "USERID") lateinit var userId: String
|
||||||
|
|
||||||
@Parameters(index = "1..*", arity = "1..*", paramLabel = "CERTS")
|
@Parameters(index = "1..*", arity = "1..*", paramLabel = "CERTS")
|
||||||
|
@ -34,6 +37,10 @@ class ValidateUserIdCmd : AbstractSopCmd() {
|
||||||
validateUserId.addrSpecOnly()
|
validateUserId.addrSpecOnly()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (validateAt != null) {
|
||||||
|
validateUserId.validateAt(validateAt!!)
|
||||||
|
}
|
||||||
|
|
||||||
validateUserId.userId(userId)
|
validateUserId.userId(userId)
|
||||||
|
|
||||||
for (authority in authorities) {
|
for (authority in authorities) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ package sop.operation
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import sop.exception.SOPGPException
|
import sop.exception.SOPGPException
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
/** Subcommand to validate UserIDs on certificates. */
|
/** Subcommand to validate UserIDs on certificates. */
|
||||||
interface ValidateUserId {
|
interface ValidateUserId {
|
||||||
|
@ -75,4 +76,6 @@ interface ValidateUserId {
|
||||||
@Throws(
|
@Throws(
|
||||||
SOPGPException.BadData::class, IOException::class, SOPGPException.CertUserIdNoMatch::class)
|
SOPGPException.BadData::class, IOException::class, SOPGPException.CertUserIdNoMatch::class)
|
||||||
fun subjects(certs: ByteArray): Boolean = subjects(certs.inputStream())
|
fun subjects(certs: ByteArray): Boolean = subjects(certs.inputStream())
|
||||||
|
|
||||||
|
fun validateAt(date: Date): ValidateUserId
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue