mirror of
https://github.com/corda/corda.git
synced 2025-01-05 20:54:13 +00:00
fix failing build due to changes in x500name to CordaX500Name and moving around of some classes in corda master. (#40)
This commit is contained in:
parent
56c7c91fee
commit
4d46239c68
@ -3,7 +3,7 @@ package com.r3.corda.doorman
|
|||||||
import com.r3.corda.doorman.persistence.CertificateResponse
|
import com.r3.corda.doorman.persistence.CertificateResponse
|
||||||
import com.r3.corda.doorman.persistence.CertificationRequestData
|
import com.r3.corda.doorman.persistence.CertificationRequestData
|
||||||
import com.r3.corda.doorman.persistence.CertificationRequestStorage
|
import com.r3.corda.doorman.persistence.CertificationRequestStorage
|
||||||
import net.corda.core.utilities.CertificateAndKeyPair
|
import net.corda.node.utilities.CertificateAndKeyPair
|
||||||
import net.corda.node.utilities.X509Utilities.CORDA_CLIENT_CA
|
import net.corda.node.utilities.X509Utilities.CORDA_CLIENT_CA
|
||||||
import net.corda.node.utilities.X509Utilities.CORDA_INTERMEDIATE_CA
|
import net.corda.node.utilities.X509Utilities.CORDA_INTERMEDIATE_CA
|
||||||
import net.corda.node.utilities.X509Utilities.CORDA_ROOT_CA
|
import net.corda.node.utilities.X509Utilities.CORDA_ROOT_CA
|
||||||
|
@ -8,11 +8,10 @@ import com.r3.corda.doorman.persistence.DBCertificateRequestStorage
|
|||||||
import com.r3.corda.doorman.persistence.DoormanSchemaService
|
import com.r3.corda.doorman.persistence.DoormanSchemaService
|
||||||
import com.r3.corda.doorman.persistence.JiraCertificateRequestStorage
|
import com.r3.corda.doorman.persistence.JiraCertificateRequestStorage
|
||||||
import net.corda.core.crypto.Crypto
|
import net.corda.core.crypto.Crypto
|
||||||
|
import net.corda.core.identity.CordaX500Name
|
||||||
import net.corda.core.internal.createDirectories
|
import net.corda.core.internal.createDirectories
|
||||||
import net.corda.core.utilities.CertificateAndKeyPair
|
|
||||||
import net.corda.core.utilities.loggerFor
|
import net.corda.core.utilities.loggerFor
|
||||||
import net.corda.core.utilities.seconds
|
import net.corda.core.utilities.seconds
|
||||||
import net.corda.core.utilities.withCommonName
|
|
||||||
import net.corda.node.utilities.*
|
import net.corda.node.utilities.*
|
||||||
import net.corda.node.utilities.X509Utilities.CORDA_INTERMEDIATE_CA
|
import net.corda.node.utilities.X509Utilities.CORDA_INTERMEDIATE_CA
|
||||||
import net.corda.node.utilities.X509Utilities.CORDA_ROOT_CA
|
import net.corda.node.utilities.X509Utilities.CORDA_ROOT_CA
|
||||||
@ -89,11 +88,11 @@ class DoormanServer(webServerAddr: HostAndPort, val caCertAndKey: CertificateAnd
|
|||||||
// please see [sun.security.x509.X500Name.isWithinSubtree()] for more information.
|
// please see [sun.security.x509.X500Name.isWithinSubtree()] for more information.
|
||||||
// We assume all attributes in the subject name has been checked prior approval.
|
// We assume all attributes in the subject name has been checked prior approval.
|
||||||
// TODO: add validation to subject name.
|
// TODO: add validation to subject name.
|
||||||
val nameConstraints = NameConstraints(arrayOf(GeneralSubtree(GeneralName(GeneralName.directoryName, request.subject.withCommonName(null)))), arrayOf())
|
val nameConstraints = NameConstraints(arrayOf(GeneralSubtree(GeneralName(GeneralName.directoryName, CordaX500Name.build(request.subject).copy(commonName = null).x500Name))), arrayOf())
|
||||||
createCertificate(CertificateType.CLIENT_CA,
|
createCertificate(CertificateType.CLIENT_CA,
|
||||||
caCertAndKey.certificate,
|
caCertAndKey.certificate,
|
||||||
caCertAndKey.keyPair,
|
caCertAndKey.keyPair,
|
||||||
request.subject.withCommonName(X509Utilities.CORDA_CLIENT_CA_CN),
|
CordaX500Name.build(request.subject).copy(commonName = X509Utilities.CORDA_CLIENT_CA_CN),
|
||||||
request.publicKey,
|
request.publicKey,
|
||||||
nameConstraints = nameConstraints).toX509Certificate()
|
nameConstraints = nameConstraints).toX509Certificate()
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,7 @@ package com.r3.corda.doorman.persistence
|
|||||||
|
|
||||||
import com.r3.corda.doorman.CertificateUtilities
|
import com.r3.corda.doorman.CertificateUtilities
|
||||||
import net.corda.core.crypto.SecureHash
|
import net.corda.core.crypto.SecureHash
|
||||||
import net.corda.core.utilities.validateX500Name
|
import net.corda.core.identity.CordaX500Name
|
||||||
import net.corda.core.utilities.withCommonName
|
|
||||||
import net.corda.node.utilities.CordaPersistence
|
import net.corda.node.utilities.CordaPersistence
|
||||||
import org.bouncycastle.pkcs.PKCS10CertificationRequest
|
import org.bouncycastle.pkcs.PKCS10CertificationRequest
|
||||||
import java.security.cert.Certificate
|
import java.security.cert.Certificate
|
||||||
@ -50,9 +49,13 @@ class DBCertificateRequestStorage(private val database: CordaPersistence) : Cert
|
|||||||
)
|
)
|
||||||
|
|
||||||
override fun saveRequest(certificationData: CertificationRequestData): String {
|
override fun saveRequest(certificationData: CertificationRequestData): String {
|
||||||
val legalName = certificationData.request.subject.withCommonName(null)
|
|
||||||
val requestId = SecureHash.randomSHA256().toString()
|
val requestId = SecureHash.randomSHA256().toString()
|
||||||
|
|
||||||
database.transaction {
|
database.transaction {
|
||||||
|
val (legalName, rejectReason) = try {
|
||||||
|
// This will fail with IllegalArgumentException if subject name is malformed.
|
||||||
|
val legalName = CordaX500Name.build(certificationData.request.subject).copy(commonName = null)
|
||||||
|
// Checks database for duplicate name.
|
||||||
val query = session.criteriaBuilder.run {
|
val query = session.criteriaBuilder.run {
|
||||||
val criteriaQuery = createQuery(CertificateSigningRequest::class.java)
|
val criteriaQuery = createQuery(CertificateSigningRequest::class.java)
|
||||||
criteriaQuery.from(CertificateSigningRequest::class.java).run {
|
criteriaQuery.from(CertificateSigningRequest::class.java).run {
|
||||||
@ -63,17 +66,14 @@ class DBCertificateRequestStorage(private val database: CordaPersistence) : Cert
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val duplicate = session.createQuery(query).resultList.isNotEmpty()
|
val duplicate = session.createQuery(query).resultList.isNotEmpty()
|
||||||
val rejectReason = if (duplicate) {
|
if (duplicate) {
|
||||||
"Duplicate legal name"
|
Pair(legalName.x500Name, "Duplicate legal name")
|
||||||
} else {
|
} else {
|
||||||
try {
|
Pair(legalName.x500Name, null)
|
||||||
validateX500Name(legalName)
|
}
|
||||||
null
|
|
||||||
} catch (e: IllegalArgumentException) {
|
} catch (e: IllegalArgumentException) {
|
||||||
"Name validation failed with exception : ${e.message}"
|
Pair(certificationData.request.subject, "Name validation failed with exception : ${e.message}")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val now = Instant.now()
|
val now = Instant.now()
|
||||||
val request = CertificateSigningRequest(
|
val request = CertificateSigningRequest(
|
||||||
requestId,
|
requestId,
|
||||||
|
@ -7,7 +7,7 @@ import com.r3.corda.doorman.persistence.CertificationRequestData
|
|||||||
import com.r3.corda.doorman.persistence.CertificationRequestStorage
|
import com.r3.corda.doorman.persistence.CertificationRequestStorage
|
||||||
import net.corda.core.crypto.Crypto
|
import net.corda.core.crypto.Crypto
|
||||||
import net.corda.core.crypto.SecureHash
|
import net.corda.core.crypto.SecureHash
|
||||||
import net.corda.core.utilities.CertificateAndKeyPair
|
import net.corda.node.utilities.CertificateAndKeyPair
|
||||||
import net.corda.node.utilities.CertificateStream
|
import net.corda.node.utilities.CertificateStream
|
||||||
import net.corda.node.utilities.CertificateType
|
import net.corda.node.utilities.CertificateType
|
||||||
import net.corda.node.utilities.X509Utilities
|
import net.corda.node.utilities.X509Utilities
|
||||||
|
Loading…
Reference in New Issue
Block a user