mirror of
https://github.com/corda/corda.git
synced 2025-06-21 00:23:09 +00:00
Merge OS -> ENT up to e00c7706c3
This commit is contained in:
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* R3 Proprietary and Confidential
|
||||
*
|
||||
* Copyright (c) 2018 R3 Limited. All rights reserved.
|
||||
*
|
||||
* The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law.
|
||||
*
|
||||
* Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited.
|
||||
*/
|
||||
|
||||
package net.corda.nodeapi
|
||||
|
||||
import net.corda.core.serialization.*
|
||||
import net.corda.core.transactions.LedgerTransaction
|
||||
import net.corda.core.utilities.sequence
|
||||
import org.apache.activemq.artemis.api.core.SimpleString
|
||||
import org.apache.activemq.artemis.api.core.client.ClientMessage
|
||||
import org.apache.activemq.artemis.reader.MessageUtil
|
||||
|
||||
object VerifierApi {
|
||||
const val VERIFIER_USERNAME = "SystemUsers/Verifier"
|
||||
const val VERIFICATION_REQUESTS_QUEUE_NAME = "verifier.requests"
|
||||
const val VERIFICATION_RESPONSES_QUEUE_NAME_PREFIX = "verifier.responses"
|
||||
private const val VERIFICATION_ID_FIELD_NAME = "id"
|
||||
private const val RESULT_EXCEPTION_FIELD_NAME = "result-exception"
|
||||
|
||||
data class VerificationRequest(
|
||||
val verificationId: Long,
|
||||
val transaction: LedgerTransaction,
|
||||
val responseAddress: SimpleString
|
||||
) {
|
||||
companion object {
|
||||
fun fromClientMessage(message: ClientMessage): ObjectWithCompatibleContext<VerificationRequest> {
|
||||
val bytes = ByteArray(message.bodySize).apply { message.bodyBuffer.readBytes(this) }
|
||||
val bytesSequence = bytes.sequence()
|
||||
val (transaction, context) = bytesSequence.deserializeWithCompatibleContext<LedgerTransaction>()
|
||||
val request = VerificationRequest(
|
||||
message.getLongProperty(VERIFICATION_ID_FIELD_NAME),
|
||||
transaction,
|
||||
MessageUtil.getJMSReplyTo(message))
|
||||
return ObjectWithCompatibleContext(request, context)
|
||||
}
|
||||
}
|
||||
|
||||
fun writeToClientMessage(message: ClientMessage) {
|
||||
message.putLongProperty(VERIFICATION_ID_FIELD_NAME, verificationId)
|
||||
message.writeBodyBufferBytes(transaction.serialize().bytes)
|
||||
MessageUtil.setJMSReplyTo(message, responseAddress)
|
||||
}
|
||||
}
|
||||
|
||||
data class VerificationResponse(
|
||||
val verificationId: Long,
|
||||
val exception: Throwable?
|
||||
) {
|
||||
companion object {
|
||||
fun fromClientMessage(message: ClientMessage): VerificationResponse {
|
||||
return VerificationResponse(
|
||||
message.getLongProperty(VERIFICATION_ID_FIELD_NAME),
|
||||
message.getBytesProperty(RESULT_EXCEPTION_FIELD_NAME)?.deserialize()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun writeToClientMessage(message: ClientMessage, context: SerializationContext) {
|
||||
message.putLongProperty(VERIFICATION_ID_FIELD_NAME, verificationId)
|
||||
if (exception != null) {
|
||||
message.putBytesProperty(RESULT_EXCEPTION_FIELD_NAME, exception.serialize(context = context).bytes)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,41 @@
|
||||
package net.corda.nodeapi.internal.crypto
|
||||
|
||||
import net.corda.core.internal.validate
|
||||
import net.corda.nodeapi.internal.DEV_CA_TRUST_STORE_FILE
|
||||
import net.corda.nodeapi.internal.DEV_CA_TRUST_STORE_PASS
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import java.security.cert.TrustAnchor
|
||||
import java.security.cert.X509Certificate
|
||||
|
||||
class DevCertificatesTest {
|
||||
private companion object {
|
||||
const val OLD_DEV_KEYSTORE_PASS = "password"
|
||||
const val OLD_NODE_DEV_KEYSTORE_FILE_NAME = "nodekeystore.jks"
|
||||
}
|
||||
|
||||
@Rule
|
||||
@JvmField
|
||||
val tempFolder = TemporaryFolder()
|
||||
|
||||
@Test
|
||||
fun `create server certificate in keystore for SSL`() {
|
||||
// given
|
||||
val newTrustStore = loadKeyStore(javaClass.classLoader.getResourceAsStream("certificates/$DEV_CA_TRUST_STORE_FILE"), DEV_CA_TRUST_STORE_PASS)
|
||||
val newTrustRoot = newTrustStore.getX509Certificate(X509Utilities.CORDA_ROOT_CA)
|
||||
val newTrustAnchor = TrustAnchor(newTrustRoot, null)
|
||||
|
||||
val oldNodeCaKeyStore = loadKeyStore(javaClass.classLoader.getResourceAsStream("regression-test/$OLD_NODE_DEV_KEYSTORE_FILE_NAME"), OLD_DEV_KEYSTORE_PASS)
|
||||
val oldX509Certificates = oldNodeCaKeyStore.getCertificateChain(X509Utilities.CORDA_CLIENT_CA).map {
|
||||
it as X509Certificate
|
||||
}.toTypedArray()
|
||||
|
||||
val certPath = X509Utilities.buildCertPath(*oldX509Certificates)
|
||||
|
||||
// when
|
||||
certPath.validate(newTrustAnchor)
|
||||
|
||||
// then no exception is thrown
|
||||
}
|
||||
}
|
BIN
node-api/src/test/resources/regression-test/nodekeystore.jks
Normal file
BIN
node-api/src/test/resources/regression-test/nodekeystore.jks
Normal file
Binary file not shown.
BIN
node-api/src/test/resources/regression-test/sslkeystore.jks
Normal file
BIN
node-api/src/test/resources/regression-test/sslkeystore.jks
Normal file
Binary file not shown.
Reference in New Issue
Block a user