mirror of
https://github.com/corda/corda.git
synced 2024-12-20 13:33:12 +00:00
Plumb in plugin whitelist additions to AMQP implementation. (#1415)
This commit is contained in:
parent
30687592c2
commit
ead4d09011
@ -1,20 +1,35 @@
|
|||||||
package net.corda.nodeapi.internal.serialization
|
package net.corda.nodeapi.internal.serialization
|
||||||
|
|
||||||
import net.corda.core.serialization.ClassWhitelist
|
import net.corda.core.node.CordaPluginRegistry
|
||||||
import net.corda.core.serialization.SerializationContext
|
import net.corda.core.serialization.*
|
||||||
import net.corda.core.serialization.SerializationDefaults
|
|
||||||
import net.corda.core.serialization.SerializedBytes
|
|
||||||
import net.corda.core.utilities.ByteSequence
|
import net.corda.core.utilities.ByteSequence
|
||||||
import net.corda.nodeapi.internal.serialization.amqp.AmqpHeaderV1_0
|
import net.corda.nodeapi.internal.serialization.amqp.AmqpHeaderV1_0
|
||||||
import net.corda.nodeapi.internal.serialization.amqp.DeserializationInput
|
import net.corda.nodeapi.internal.serialization.amqp.DeserializationInput
|
||||||
import net.corda.nodeapi.internal.serialization.amqp.SerializationOutput
|
import net.corda.nodeapi.internal.serialization.amqp.SerializationOutput
|
||||||
import net.corda.nodeapi.internal.serialization.amqp.SerializerFactory
|
import net.corda.nodeapi.internal.serialization.amqp.SerializerFactory
|
||||||
|
import java.util.*
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
val AMQP_ENABLED get() = SerializationDefaults.P2P_CONTEXT.preferredSerializationVersion == AmqpHeaderV1_0
|
val AMQP_ENABLED get() = SerializationDefaults.P2P_CONTEXT.preferredSerializationVersion == AmqpHeaderV1_0
|
||||||
|
|
||||||
|
class AMQPSerializationCustomization(val factory: SerializerFactory) : SerializationCustomization {
|
||||||
|
override fun addToWhitelist(vararg types: Class<*>) {
|
||||||
|
factory.addToWhitelist(*types)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun SerializerFactory.addToWhitelist(vararg types: Class<*>) {
|
||||||
|
for (type in types) {
|
||||||
|
(this.whitelist as? MutableClassWhitelist)?.add(type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
abstract class AbstractAMQPSerializationScheme : SerializationScheme {
|
abstract class AbstractAMQPSerializationScheme : SerializationScheme {
|
||||||
internal companion object {
|
internal companion object {
|
||||||
|
private val pluginRegistries: List<CordaPluginRegistry> by lazy {
|
||||||
|
ServiceLoader.load(CordaPluginRegistry::class.java, this.javaClass.classLoader).toList()
|
||||||
|
}
|
||||||
|
|
||||||
fun registerCustomSerializers(factory: SerializerFactory) {
|
fun registerCustomSerializers(factory: SerializerFactory) {
|
||||||
factory.apply {
|
factory.apply {
|
||||||
register(net.corda.nodeapi.internal.serialization.amqp.custom.PublicKeySerializer)
|
register(net.corda.nodeapi.internal.serialization.amqp.custom.PublicKeySerializer)
|
||||||
@ -40,6 +55,8 @@ abstract class AbstractAMQPSerializationScheme : SerializationScheme {
|
|||||||
register(net.corda.nodeapi.internal.serialization.amqp.custom.X509CertificateHolderSerializer)
|
register(net.corda.nodeapi.internal.serialization.amqp.custom.X509CertificateHolderSerializer)
|
||||||
register(net.corda.nodeapi.internal.serialization.amqp.custom.PartyAndCertificateSerializer(factory))
|
register(net.corda.nodeapi.internal.serialization.amqp.custom.PartyAndCertificateSerializer(factory))
|
||||||
}
|
}
|
||||||
|
val customizer = AMQPSerializationCustomization(factory)
|
||||||
|
pluginRegistries.forEach { it.customizeSerialization(customizer) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,8 @@ class DefaultWhitelist : CordaPluginRegistry() {
|
|||||||
LocalDate::class.java,
|
LocalDate::class.java,
|
||||||
Period::class.java,
|
Period::class.java,
|
||||||
BitSet::class.java,
|
BitSet::class.java,
|
||||||
OnErrorNotImplementedException::class.java)
|
OnErrorNotImplementedException::class.java,
|
||||||
|
StackTraceElement::class.java)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user