mirror of
https://github.com/corda/corda.git
synced 2025-02-07 11:30:22 +00:00
Improving revocation reason selection (#845)
* Improving revocation reason selection * Addressing review comments - round 2
This commit is contained in:
parent
da6957e6d1
commit
71aeb6c339
@ -53,7 +53,7 @@ Allowed parameters are:
|
||||
|
||||
:revocation: Revocation service specific configuration
|
||||
|
||||
:localSigning: Configuration for local CRL signing using the file key store. If not defined t
|
||||
:localSigning: Configuration for local CRL signing using the file key store. If not defined then an external signing process is assumed.
|
||||
|
||||
:crlUpdateInterval: Validity time of the issued certificate revocation lists (in milliseconds).
|
||||
|
||||
|
@ -29,7 +29,7 @@ fun submit(url: URL, inputReader: InputReader = ConsoleInputReader()) {
|
||||
val csrRequestId = inputReader.getOptionalInput("certificate signing request ID")
|
||||
val legalName = inputReader.getOptionalInput("node X.500 legal name")?.let { CordaX500Name.parse(it) }
|
||||
CertificateRevocationRequest.validateOptional(certificateSerialNumber, csrRequestId, legalName)
|
||||
val reason = inputReader.getRequiredInput("revocation reason").let { CRLReason.valueOf(it) }
|
||||
val reason = getReason(inputReader)
|
||||
val reporter = inputReader.getRequiredInput("reporter of the revocation request")
|
||||
val request = CertificateRevocationRequest(certificateSerialNumber, csrRequestId, legalName, reason, reporter)
|
||||
logger.debug("POST to $url request: $request")
|
||||
@ -53,4 +53,29 @@ private fun InputReader.getRequiredInput(attributeName: String): String {
|
||||
} else {
|
||||
line
|
||||
}
|
||||
}
|
||||
|
||||
private enum class SupportedCrlReasons {
|
||||
UNSPECIFIED,
|
||||
KEY_COMPROMISE,
|
||||
CA_COMPROMISE,
|
||||
AFFILIATION_CHANGED,
|
||||
SUPERSEDED,
|
||||
CESSATION_OF_OPERATION,
|
||||
PRIVILEGE_WITHDRAWN
|
||||
}
|
||||
|
||||
private fun getReason(inputReader: InputReader): CRLReason {
|
||||
while (true) {
|
||||
SupportedCrlReasons.values().forEachIndexed { index, value ->
|
||||
println("${index + 1}. $value")
|
||||
}
|
||||
print("Selected the reason for the revocation:")
|
||||
val input = inputReader.readLine()!!.toInt()
|
||||
if (input < 1 || input > SupportedCrlReasons.values().size) {
|
||||
println("Incorrect selection. Try again.")
|
||||
} else {
|
||||
return CRLReason.valueOf(SupportedCrlReasons.values()[input -1 ].name)
|
||||
}
|
||||
}
|
||||
}
|
@ -65,7 +65,7 @@ class CertificateRevocationRequestSubmissionToolTest {
|
||||
givenUserConsoleSequentialInputOnReadLine(request.certificateSerialNumber.toString(),
|
||||
request.csrRequestId!!,
|
||||
request.legalName.toString(),
|
||||
request.reason.name,
|
||||
"${request.reason.ordinal + 1}",
|
||||
request.reporter)
|
||||
|
||||
val requestId = SecureHash.randomSHA256().toString()
|
||||
|
Loading…
x
Reference in New Issue
Block a user