Addressed PR issues

This commit is contained in:
Patrick Kuo 2017-02-16 14:45:36 +00:00
parent d76db6d047
commit e2f93f64a9
2 changed files with 6 additions and 5 deletions

View File

@ -168,6 +168,7 @@ private fun DoormanParameters.startDoorman() {
logger.warn("Doorman server is in 'Approve All' mode, this will approve all incoming certificate signing request.")
// Approve all pending request.
object : CertificationRequestStorage by DBCertificateRequestStorage(database) {
// The doorman is in approve all mode, returns all pending request id as approved request id.
override fun getApprovedRequestIds() = getPendingRequestIds()
}
} else {

View File

@ -22,7 +22,9 @@ class JiraCertificateRequestStorage(val delegate: CertificationRequestStorage,
Approved, Rejected
}
private val logger = loggerFor<JiraCertificateRequestStorage>()
companion object{
private val logger = loggerFor<JiraCertificateRequestStorage>()
}
// The JIRA project must have a Request ID field and the Task issue type.
private val requestIdField: Field = jiraClient.metadataClient.fields.claim().find { it.name == "Request ID" }!!
@ -34,9 +36,7 @@ class JiraCertificateRequestStorage(val delegate: CertificationRequestStorage,
val response = getResponse(requestId)
if (response !is CertificateResponse.Unauthorised) {
val request = StringWriter()
JcaPEMWriter(request).use {
it.writeObject(PemObject("CERTIFICATE REQUEST", certificationData.request.encoded))
}
JcaPEMWriter(request).writeObject(PemObject("CERTIFICATE REQUEST", certificationData.request.encoded))
val commonName = certificationData.request.subject.commonName
val email = certificationData.request.subject.getRDNs(BCStyle.EmailAddress).firstOrNull()?.first?.value
val nearestCity = certificationData.request.subject.getRDNs(BCStyle.L).firstOrNull()?.first?.value
@ -46,7 +46,7 @@ class JiraCertificateRequestStorage(val delegate: CertificationRequestStorage,
.setDescription("Legal Name: $commonName\nNearest City: $nearestCity\nEmail: $email\n\n{code}$request{code}")
.setSummary(commonName)
.setFieldValue(requestIdField.id, requestId)
// This will block until the jira is created.
// This will block until the issue is created.
jiraClient.issueClient.createIssue(issue.build()).fail { logger.error("Exception when creating JIRA issue.", it) }.claim()
}
return requestId