From 4c8dabc2889200cfb19c03d1b33e80a617b19944 Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Thu, 22 Nov 2018 18:35:30 +0000 Subject: [PATCH] ENT-2506 restore the attachment party signers (#4255) * ENT-2506 restore the attachment party signers * ENT-2506 restore the attachment party signers * ENT-2506 restore the attachment party signers * ENT-2675 Address code review changes. * ENT-2675 Address code review changes. --- .ci/api-current.txt | 6 ++++-- .../net/corda/client/jackson/JacksonSupportTest.kt | 2 +- .../deterministic/contracts/AttachmentTest.kt | 6 ++++-- .../verifier/MockContractAttachment.kt | 8 +++++++- .../kotlin/net/corda/core/contracts/Attachment.kt | 14 +++++++++++++- .../corda/core/contracts/AttachmentConstraint.kt | 4 ++-- .../net/corda/core/contracts/ContractAttachment.kt | 2 +- .../net/corda/core/internal/AbstractAttachment.kt | 8 +++++++- .../transactions/ContractUpgradeTransactions.kt | 2 +- .../corda/core/transactions/LedgerTransaction.kt | 2 +- .../corda/core/transactions/TransactionBuilder.kt | 9 ++++----- .../core/contracts/ConstraintsPropagationTests.kt | 3 +-- .../net/corda/core/contracts/StructuresTests.kt | 4 +++- .../serialization/AttachmentSerializationTest.kt | 3 ++- .../core/transactions/TransactionBuilderTest.kt | 8 ++++---- docs/source/changelog.rst | 7 +++++-- .../AttachmentsClassLoaderStaticContractTests.kt | 2 +- .../serialization/kryo/DefaultKryoCustomizer.kt | 2 +- .../persistence/NodeAttachmentServiceTest.kt | 4 ++-- .../amqp/custom/ContractAttachmentSerializer.kt | 2 +- .../testing/services/MockAttachmentStorage.kt | 2 +- 21 files changed, 66 insertions(+), 34 deletions(-) diff --git a/.ci/api-current.txt b/.ci/api-current.txt index 58d8d92ba5..221cde3cae 100644 --- a/.ci/api-current.txt +++ b/.ci/api-current.txt @@ -431,7 +431,9 @@ public static final class net.corda.core.contracts.AmountTransfer$Companion exte public interface net.corda.core.contracts.Attachment extends net.corda.core.contracts.NamedByHash public void extractFile(String, java.io.OutputStream) @NotNull - public abstract java.util.List getSigners() + public abstract java.util.List getSignerKeys() + @NotNull + public abstract java.util.List getSigners() public abstract int getSize() @NotNull public abstract java.io.InputStream open() @@ -542,7 +544,7 @@ public final class net.corda.core.contracts.ContractAttachment extends java.lang @NotNull public net.corda.core.crypto.SecureHash getId() @NotNull - public java.util.List getSigners() + public java.util.List getSigners() public int getSize() @Nullable public final String getUploader() diff --git a/client/jackson/src/test/kotlin/net/corda/client/jackson/JacksonSupportTest.kt b/client/jackson/src/test/kotlin/net/corda/client/jackson/JacksonSupportTest.kt index e08b166dcc..7f30b63dcc 100644 --- a/client/jackson/src/test/kotlin/net/corda/client/jackson/JacksonSupportTest.kt +++ b/client/jackson/src/test/kotlin/net/corda/client/jackson/JacksonSupportTest.kt @@ -234,7 +234,7 @@ class JacksonSupportTest(@Suppress("unused") private val name: String, factory: val attachment = rigorousMock() doReturn(attachment).whenever(attachmentStorage).openAttachment(attachmentId) doReturn(attachmentId).whenever(attachment).id - doReturn(emptyList()).whenever(attachment).signers + doReturn(emptyList()).whenever(attachment).signerKeys doReturn(setOf(DummyContract.PROGRAM_ID)).whenever(attachment).allContracts doReturn("app").whenever(attachment).uploader diff --git a/core-deterministic/testing/src/test/kotlin/net/corda/deterministic/contracts/AttachmentTest.kt b/core-deterministic/testing/src/test/kotlin/net/corda/deterministic/contracts/AttachmentTest.kt index 01f7751905..f8db67bf49 100644 --- a/core-deterministic/testing/src/test/kotlin/net/corda/deterministic/contracts/AttachmentTest.kt +++ b/core-deterministic/testing/src/test/kotlin/net/corda/deterministic/contracts/AttachmentTest.kt @@ -40,10 +40,12 @@ class AttachmentTest { @Before fun setup() { attachment = object : Attachment { + override val signerKeys: List + get() = listOf(ALICE_KEY) override val id: SecureHash get() = SecureHash.allOnesHash - override val signers: List - get() = listOf(ALICE_KEY) + override val signers: List + get() = listOf(ALICE) override val size: Int get() = jarData.size diff --git a/core-deterministic/testing/verifier/src/main/kotlin/net/corda/deterministic/verifier/MockContractAttachment.kt b/core-deterministic/testing/verifier/src/main/kotlin/net/corda/deterministic/verifier/MockContractAttachment.kt index f7e90ce2cc..b9f8c1166e 100644 --- a/core-deterministic/testing/verifier/src/main/kotlin/net/corda/deterministic/verifier/MockContractAttachment.kt +++ b/core-deterministic/testing/verifier/src/main/kotlin/net/corda/deterministic/verifier/MockContractAttachment.kt @@ -3,13 +3,19 @@ package net.corda.deterministic.verifier import net.corda.core.contracts.Attachment import net.corda.core.contracts.ContractClassName import net.corda.core.crypto.SecureHash +import net.corda.core.identity.Party import net.corda.core.serialization.CordaSerializable import java.io.ByteArrayInputStream import java.io.InputStream import java.security.PublicKey @CordaSerializable -class MockContractAttachment(override val id: SecureHash = SecureHash.zeroHash, val contract: ContractClassName, override val signers: List = emptyList()) : Attachment { +class MockContractAttachment( + override val id: SecureHash = SecureHash.zeroHash, + val contract: ContractClassName, + override val signerKeys: List = emptyList(), + override val signers: List = emptyList() +) : Attachment { override fun open(): InputStream = ByteArrayInputStream(id.bytes) override val size = id.size } diff --git a/core/src/main/kotlin/net/corda/core/contracts/Attachment.kt b/core/src/main/kotlin/net/corda/core/contracts/Attachment.kt index 42faff24f2..51fad89acf 100644 --- a/core/src/main/kotlin/net/corda/core/contracts/Attachment.kt +++ b/core/src/main/kotlin/net/corda/core/contracts/Attachment.kt @@ -1,6 +1,8 @@ package net.corda.core.contracts +import net.corda.core.DoNotImplement import net.corda.core.KeepForDJVM +import net.corda.core.identity.Party import net.corda.core.internal.extractFile import net.corda.core.serialization.CordaSerializable import java.io.FileNotFoundException @@ -31,6 +33,7 @@ import java.util.jar.JarInputStream */ @KeepForDJVM @CordaSerializable +@DoNotImplement interface Attachment : NamedByHash { fun open(): InputStream @@ -51,11 +54,20 @@ interface Attachment : NamedByHash { @JvmDefault fun extractFile(path: String, outputTo: OutputStream) = openAsJAR().use { it.extractFile(path, outputTo) } + /** + * The parties that have correctly signed the whole attachment. + * Even though this returns a list of party objects, it is not required that these parties exist on the network, but rather they are a mapping from the signing key to the X.500 name. + * + * Note: Anyone can sign attachments, not only Corda parties. It's recommended to use [signerKeys]. + */ + @Deprecated("Use signerKeys. There is no requirement that attachment signers are Corda parties.") + val signers: List + /** * The keys that have correctly signed the whole attachment. * Can be empty, for example non-contract attachments won't be necessarily be signed. */ - val signers: List + val signerKeys: List /** * Attachment size in bytes. diff --git a/core/src/main/kotlin/net/corda/core/contracts/AttachmentConstraint.kt b/core/src/main/kotlin/net/corda/core/contracts/AttachmentConstraint.kt index f3022c319f..951eaa436b 100644 --- a/core/src/main/kotlin/net/corda/core/contracts/AttachmentConstraint.kt +++ b/core/src/main/kotlin/net/corda/core/contracts/AttachmentConstraint.kt @@ -72,7 +72,7 @@ interface AttachmentConstraint { // You can transition from the WhitelistConstraint to the SignatureConstraint only if all signers of the JAR are required to sign in the future. input is WhitelistedByZoneAttachmentConstraint && output is SignatureAttachmentConstraint -> - attachment.signers.isNotEmpty() && output.key.keys.containsAll(attachment.signers) + attachment.signerKeys.isNotEmpty() && output.key.keys.containsAll(attachment.signerKeys) else -> false } @@ -180,5 +180,5 @@ data class SignatureAttachmentConstraint( val key: PublicKey ) : AttachmentConstraint { override fun isSatisfiedBy(attachment: Attachment): Boolean = - key.isFulfilledBy(attachment.signers.map { it }) + key.isFulfilledBy(attachment.signerKeys.map { it }) } \ No newline at end of file diff --git a/core/src/main/kotlin/net/corda/core/contracts/ContractAttachment.kt b/core/src/main/kotlin/net/corda/core/contracts/ContractAttachment.kt index 4b1c25fed8..01bcff4fc6 100644 --- a/core/src/main/kotlin/net/corda/core/contracts/ContractAttachment.kt +++ b/core/src/main/kotlin/net/corda/core/contracts/ContractAttachment.kt @@ -18,7 +18,7 @@ class ContractAttachment @JvmOverloads constructor( val contract: ContractClassName, val additionalContracts: Set = emptySet(), val uploader: String? = null, - override val signers: List = emptyList()) : Attachment by attachment { + override val signerKeys: List = emptyList()) : Attachment by attachment { val allContracts: Set get() = additionalContracts + contract diff --git a/core/src/main/kotlin/net/corda/core/internal/AbstractAttachment.kt b/core/src/main/kotlin/net/corda/core/internal/AbstractAttachment.kt index 5b27d28ef5..d4f04cc432 100644 --- a/core/src/main/kotlin/net/corda/core/internal/AbstractAttachment.kt +++ b/core/src/main/kotlin/net/corda/core/internal/AbstractAttachment.kt @@ -6,6 +6,7 @@ import net.corda.core.DeleteForDJVM import net.corda.core.KeepForDJVM import net.corda.core.contracts.Attachment import net.corda.core.crypto.SecureHash +import net.corda.core.identity.Party import net.corda.core.serialization.MissingAttachmentsException import net.corda.core.serialization.SerializeAsTokenContext import java.io.FileNotFoundException @@ -47,10 +48,15 @@ abstract class AbstractAttachment(dataLoader: () -> ByteArray) : Attachment { override val size: Int get() = attachmentData.size override fun open(): InputStream = attachmentData.inputStream() - override val signers: List by lazy { + + override val signerKeys: List by lazy { openAsJAR().use(JarSignatureCollector::collectSigners) } + override val signers: List by lazy { + openAsJAR().use(JarSignatureCollector::collectSigningParties) + } + override fun equals(other: Any?) = other === this || other is Attachment && other.id == this.id override fun hashCode() = id.hashCode() override fun toString() = "${javaClass.simpleName}(id=$id)" diff --git a/core/src/main/kotlin/net/corda/core/transactions/ContractUpgradeTransactions.kt b/core/src/main/kotlin/net/corda/core/transactions/ContractUpgradeTransactions.kt index 0ea2c661aa..31eb89ad5f 100644 --- a/core/src/main/kotlin/net/corda/core/transactions/ContractUpgradeTransactions.kt +++ b/core/src/main/kotlin/net/corda/core/transactions/ContractUpgradeTransactions.kt @@ -252,7 +252,7 @@ data class ContractUpgradeLedgerTransaction( private fun verifyConstraints() { val attachmentForConstraintVerification = AttachmentWithContext( legacyContractAttachment as? ContractAttachment - ?: ContractAttachment(legacyContractAttachment, legacyContractClassName, signers = legacyContractAttachment.signers), + ?: ContractAttachment(legacyContractAttachment, legacyContractClassName, signerKeys = legacyContractAttachment.signerKeys), upgradedContract.legacyContract, networkParameters.whitelistedContractImplementations ) diff --git a/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt b/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt index 222a04897c..23718cb28f 100644 --- a/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt +++ b/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt @@ -166,7 +166,7 @@ data class LedgerTransaction private constructor( contractsAndOwners.forEach { contract, owner -> val attachment = contractAttachmentsByContract[contract]!! - if (!owner.isFulfilledBy(attachment.signers)) { + if (!owner.isFulfilledBy(attachment.signerKeys)) { throw TransactionVerificationException.ContractAttachmentNotSignedByPackageOwnerException(this.id, id, contract) } } diff --git a/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt b/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt index 03c4a267af..8b01a95040 100644 --- a/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt +++ b/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt @@ -19,7 +19,6 @@ import net.corda.core.node.services.AttachmentId import net.corda.core.node.services.KeyManagementService import net.corda.core.serialization.SerializationContext import net.corda.core.serialization.SerializationFactory -import net.corda.core.utilities.loggerFor import net.corda.core.utilities.contextLogger import net.corda.core.utilities.warnOnce import java.security.PublicKey @@ -310,7 +309,7 @@ open class TransactionBuilder @JvmOverloads constructor( attachmentToUse: ContractAttachment, services: ServicesForResolution): AttachmentConstraint = when { inputStates != null -> attachmentConstraintsTransition(inputStates.groupBy { it.constraint }.keys, attachmentToUse) - attachmentToUse.signers.isNotEmpty() && services.networkParameters.minimumPlatformVersion < 4 -> { + attachmentToUse.signerKeys.isNotEmpty() && services.networkParameters.minimumPlatformVersion < 4 -> { log.warnOnce("Signature constraints not available on network requiring a minimum platform version of 4. Current is: ${services.networkParameters.minimumPlatformVersion}.") if (useWhitelistedByZoneAttachmentConstraint(contractClassName, services.networkParameters)) { log.warnOnce("Reverting back to using whitelisted zone constraints for contract $contractClassName") @@ -320,7 +319,7 @@ open class TransactionBuilder @JvmOverloads constructor( HashAttachmentConstraint(attachmentToUse.id) } } - attachmentToUse.signers.isNotEmpty() -> makeSignatureAttachmentConstraint(attachmentToUse.signers) + attachmentToUse.signerKeys.isNotEmpty() -> makeSignatureAttachmentConstraint(attachmentToUse.signerKeys) useWhitelistedByZoneAttachmentConstraint(contractClassName, services.networkParameters) -> WhitelistedByZoneAttachmentConstraint else -> HashAttachmentConstraint(attachmentToUse.id) } @@ -361,8 +360,8 @@ open class TransactionBuilder @JvmOverloads constructor( constraints.any { it is SignatureAttachmentConstraint } && constraints.any { it is WhitelistedByZoneAttachmentConstraint } -> { val signatureConstraint = constraints.mapNotNull { it as? SignatureAttachmentConstraint }.single() when { - attachmentToUse.signers.isEmpty() -> throw IllegalArgumentException("Cannot mix a state with the WhitelistedByZoneAttachmentConstraint and a state with the SignatureAttachmentConstraint, when the latest attachment is not signed. Please contact your Zone operator.") - signatureConstraint.key.keys.containsAll(attachmentToUse.signers) -> signatureConstraint + attachmentToUse.signerKeys.isEmpty() -> throw IllegalArgumentException("Cannot mix a state with the WhitelistedByZoneAttachmentConstraint and a state with the SignatureAttachmentConstraint, when the latest attachment is not signed. Please contact your Zone operator.") + signatureConstraint.key.keys.containsAll(attachmentToUse.signerKeys) -> signatureConstraint else -> throw IllegalArgumentException("Attempting to transition a WhitelistedByZoneAttachmentConstraint state backed by an attachment signed by multiple parties to a weaker SignatureConstraint that does not require all those signatures. Please contact your Zone operator.") } } diff --git a/core/src/test/kotlin/net/corda/core/contracts/ConstraintsPropagationTests.kt b/core/src/test/kotlin/net/corda/core/contracts/ConstraintsPropagationTests.kt index 9417f14caa..55f6ac29d1 100644 --- a/core/src/test/kotlin/net/corda/core/contracts/ConstraintsPropagationTests.kt +++ b/core/src/test/kotlin/net/corda/core/contracts/ConstraintsPropagationTests.kt @@ -7,7 +7,6 @@ import net.corda.core.crypto.SecureHash import net.corda.core.identity.AbstractParty import net.corda.core.identity.CordaX500Name import net.corda.core.transactions.LedgerTransaction -import net.corda.core.transactions.MissingContractAttachments import net.corda.finance.POUNDS import net.corda.finance.`issued by` import net.corda.finance.contracts.asset.Cash @@ -223,7 +222,7 @@ class ConstraintsPropagationTests { fun `Attachment canBeTransitionedFrom behaves as expected`() { val attachment = mock() - whenever(attachment.signers).thenReturn(listOf(ALICE_PARTY.owningKey)) + whenever(attachment.signerKeys).thenReturn(listOf(ALICE_PARTY.owningKey)) // Exhaustive positive check assertTrue(HashAttachmentConstraint(SecureHash.randomSHA256()).canBeTransitionedFrom(SignatureAttachmentConstraint(ALICE_PUBKEY), attachment)) diff --git a/core/src/test/kotlin/net/corda/core/contracts/StructuresTests.kt b/core/src/test/kotlin/net/corda/core/contracts/StructuresTests.kt index 189a1e0dd2..73cb9a3637 100644 --- a/core/src/test/kotlin/net/corda/core/contracts/StructuresTests.kt +++ b/core/src/test/kotlin/net/corda/core/contracts/StructuresTests.kt @@ -3,6 +3,7 @@ package net.corda.core.contracts import com.nhaarman.mockito_kotlin.doAnswer import com.nhaarman.mockito_kotlin.spy import com.nhaarman.mockito_kotlin.whenever +import net.corda.core.identity.Party import org.junit.Test import java.io.ByteArrayOutputStream import java.io.IOException @@ -30,7 +31,8 @@ class AttachmentTest { val attachment = object : Attachment { override val id get() = throw UnsupportedOperationException() override fun open() = inputStream - override val signers get() = throw UnsupportedOperationException() + override val signerKeys get() = throw UnsupportedOperationException() + override val signers: List get() = throw UnsupportedOperationException() override val size: Int = 512 } try { diff --git a/core/src/test/kotlin/net/corda/core/serialization/AttachmentSerializationTest.kt b/core/src/test/kotlin/net/corda/core/serialization/AttachmentSerializationTest.kt index c89e1d0c17..72619fb2de 100644 --- a/core/src/test/kotlin/net/corda/core/serialization/AttachmentSerializationTest.kt +++ b/core/src/test/kotlin/net/corda/core/serialization/AttachmentSerializationTest.kt @@ -111,7 +111,8 @@ class AttachmentSerializationTest { private class CustomAttachment(override val id: SecureHash, internal val customContent: String) : Attachment { override fun open() = throw UnsupportedOperationException("Not implemented.") - override val signers get() = throw UnsupportedOperationException() + override val signerKeys get() = throw UnsupportedOperationException() + override val signers: List get() = throw UnsupportedOperationException() override val size get() = throw UnsupportedOperationException() } diff --git a/core/src/test/kotlin/net/corda/core/transactions/TransactionBuilderTest.kt b/core/src/test/kotlin/net/corda/core/transactions/TransactionBuilderTest.kt index ecfdabdf20..d560c1fe56 100644 --- a/core/src/test/kotlin/net/corda/core/transactions/TransactionBuilderTest.kt +++ b/core/src/test/kotlin/net/corda/core/transactions/TransactionBuilderTest.kt @@ -50,7 +50,7 @@ class TransactionBuilderTest { doReturn(contractAttachmentId).whenever(attachment).id doReturn(setOf(DummyContract.PROGRAM_ID)).whenever(attachment).allContracts doReturn("app").whenever(attachment).uploader - doReturn(emptyList()).whenever(attachment).signers + doReturn(emptyList()).whenever(attachment).signerKeys } @Test @@ -128,12 +128,12 @@ class TransactionBuilderTest { private val unsignedAttachment = ContractAttachment(object : AbstractAttachment({ byteArrayOf() }) { override val id: SecureHash get() = throw UnsupportedOperationException() - override val signers: List get() = emptyList() + override val signerKeys: List get() = emptyList() }, DummyContract.PROGRAM_ID) private fun signedAttachment(vararg parties: Party) = ContractAttachment(object : AbstractAttachment({ byteArrayOf() }) { override val id: SecureHash get() = throw UnsupportedOperationException() - override val signers: List get() = parties.map { it.owningKey } - }, DummyContract.PROGRAM_ID, signers = parties.map { it.owningKey }) + override val signerKeys: List get() = parties.map { it.owningKey } + }, DummyContract.PROGRAM_ID, signerKeys = parties.map { it.owningKey }) } diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index ed3a45b4da..2a812079e5 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -7,9 +7,12 @@ release, see :doc:`upgrade-notes`. Unreleased ---------- +* Marked the `Attachment` interface as `@DoNotImplement` because it is not meant to be extended by CorDapp developers. If you have already done so, +please get in contact on the usual communication channels. + * Added auto-acceptance of network parameters for network updates. This behaviour is available for a subset of the network parameters - and is configurable via the node config. See :doc:`network-map` for more information. - +and is configurable via the node config. See :doc:`network-map` for more information. + * Deprecated `SerializationContext.withAttachmentsClassLoader`. This functionality has always been disabled by flags and there is no reason for a CorDapp developer to use it. It is just an internal implementation detail of Corda. diff --git a/node-api/src/test/kotlin/net/corda/nodeapi/internal/AttachmentsClassLoaderStaticContractTests.kt b/node-api/src/test/kotlin/net/corda/nodeapi/internal/AttachmentsClassLoaderStaticContractTests.kt index c0ffa1403d..594c67bff6 100644 --- a/node-api/src/test/kotlin/net/corda/nodeapi/internal/AttachmentsClassLoaderStaticContractTests.kt +++ b/node-api/src/test/kotlin/net/corda/nodeapi/internal/AttachmentsClassLoaderStaticContractTests.kt @@ -87,7 +87,7 @@ class AttachmentsClassLoaderStaticContractTests { doReturn(it.cordappProvider.getContractAttachmentID(AttachmentDummyContract.ATTACHMENT_PROGRAM_ID)).whenever(attachment).id doReturn(setOf(AttachmentDummyContract.ATTACHMENT_PROGRAM_ID)).whenever(attachment).allContracts doReturn("app").whenever(attachment).uploader - doReturn(emptyList()).whenever(attachment).signers + doReturn(emptyList()).whenever(attachment).signerKeys } @Test diff --git a/node/src/main/kotlin/net/corda/node/serialization/kryo/DefaultKryoCustomizer.kt b/node/src/main/kotlin/net/corda/node/serialization/kryo/DefaultKryoCustomizer.kt index 3ca151ea8c..c5a380c63e 100644 --- a/node/src/main/kotlin/net/corda/node/serialization/kryo/DefaultKryoCustomizer.kt +++ b/node/src/main/kotlin/net/corda/node/serialization/kryo/DefaultKryoCustomizer.kt @@ -211,7 +211,7 @@ object DefaultKryoCustomizer { output.writeString(obj.contract) kryo.writeClassAndObject(output, obj.additionalContracts) output.writeString(obj.uploader) - kryo.writeClassAndObject(output, obj.signers) + kryo.writeClassAndObject(output, obj.signerKeys) } @Suppress("UNCHECKED_CAST") diff --git a/node/src/test/kotlin/net/corda/node/services/persistence/NodeAttachmentServiceTest.kt b/node/src/test/kotlin/net/corda/node/services/persistence/NodeAttachmentServiceTest.kt index 335a7d7ea6..887faca322 100644 --- a/node/src/test/kotlin/net/corda/node/services/persistence/NodeAttachmentServiceTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/persistence/NodeAttachmentServiceTest.kt @@ -91,7 +91,7 @@ class NodeAttachmentServiceTest { val signedJar = jarAndSigner.first signedJar.inputStream().use { jarStream -> val attachmentId = storage.importAttachment(jarStream, "test", null) - assertEquals(listOf(jarAndSigner.second.hash), storage.openAttachment(attachmentId)!!.signers.map { it.hash }) + assertEquals(listOf(jarAndSigner.second.hash), storage.openAttachment(attachmentId)!!.signerKeys.map { it.hash }) } } } @@ -102,7 +102,7 @@ class NodeAttachmentServiceTest { val jarName = makeTestContractJar(it.path, "com.example.MyContract") it.path.resolve(jarName).inputStream().use { jarStream -> val attachmentId = storage.importAttachment(jarStream, "test", null) - assertEquals(0, storage.openAttachment(attachmentId)!!.signers.size) + assertEquals(0, storage.openAttachment(attachmentId)!!.signerKeys.size) } } } diff --git a/serialization/src/main/kotlin/net/corda/serialization/internal/amqp/custom/ContractAttachmentSerializer.kt b/serialization/src/main/kotlin/net/corda/serialization/internal/amqp/custom/ContractAttachmentSerializer.kt index f487840f25..9764c25758 100644 --- a/serialization/src/main/kotlin/net/corda/serialization/internal/amqp/custom/ContractAttachmentSerializer.kt +++ b/serialization/src/main/kotlin/net/corda/serialization/internal/amqp/custom/ContractAttachmentSerializer.kt @@ -24,7 +24,7 @@ class ContractAttachmentSerializer(factory: SerializerFactory) : CustomSerialize } catch (e: Exception) { throw MissingAttachmentsException(listOf(obj.id)) } - return ContractAttachmentProxy(GeneratedAttachment(bytes), obj.contract, obj.additionalContracts, obj.uploader, obj.signers) + return ContractAttachmentProxy(GeneratedAttachment(bytes), obj.contract, obj.additionalContracts, obj.uploader, obj.signerKeys) } override fun fromProxy(proxy: ContractAttachmentProxy): ContractAttachment { diff --git a/testing/test-utils/src/main/kotlin/net/corda/testing/services/MockAttachmentStorage.kt b/testing/test-utils/src/main/kotlin/net/corda/testing/services/MockAttachmentStorage.kt index 727ca1fd48..a0599c1a8d 100644 --- a/testing/test-utils/src/main/kotlin/net/corda/testing/services/MockAttachmentStorage.kt +++ b/testing/test-utils/src/main/kotlin/net/corda/testing/services/MockAttachmentStorage.kt @@ -61,7 +61,7 @@ class MockAttachmentStorage : AttachmentStorage, SingletonSerializeAsToken() { fun getAttachmentIdAndBytes(jar: InputStream): Pair = jar.readFully().let { bytes -> Pair(bytes.sha256(), bytes) } - private class MockAttachment(dataLoader: () -> ByteArray, override val id: SecureHash, override val signers: List) : AbstractAttachment(dataLoader) + private class MockAttachment(dataLoader: () -> ByteArray, override val id: SecureHash, override val signerKeys: List) : AbstractAttachment(dataLoader) private fun importAttachmentInternal(jar: InputStream, uploader: String, contractClassNames: List? = null, attachmentId: AttachmentId? = null, signers: List = emptyList()): AttachmentId { // JIS makes read()/readBytes() return bytes of the current file, but we want to hash the entire container here.