diff --git a/core/src/main/kotlin/net/corda/core/crypto/CryptoUtils.kt b/core/src/main/kotlin/net/corda/core/crypto/CryptoUtils.kt index 1cb0f50934..02d0c11627 100644 --- a/core/src/main/kotlin/net/corda/core/crypto/CryptoUtils.kt +++ b/core/src/main/kotlin/net/corda/core/crypto/CryptoUtils.kt @@ -149,7 +149,7 @@ fun entropyToKeyPair(entropy: BigInteger): KeyPair = Crypto.deriveKeyPairFromEnt /** * Helper function for signing. * @param metaData tha attached MetaData object. - * @return a [TransactionSignature] object. + * @return a [TransactionSignature ] object. * @throws IllegalArgumentException if the signature scheme is not supported for this private key. * @throws InvalidKeyException if the private key is invalid. * @throws SignatureException if signing is not possible due to malformed data or private key. diff --git a/core/src/main/kotlin/net/corda/core/serialization/amqp/PropertySerializer.kt b/core/src/main/kotlin/net/corda/core/serialization/amqp/PropertySerializer.kt index 6e26441633..2295a07b45 100644 --- a/core/src/main/kotlin/net/corda/core/serialization/amqp/PropertySerializer.kt +++ b/core/src/main/kotlin/net/corda/core/serialization/amqp/PropertySerializer.kt @@ -68,9 +68,9 @@ sealed class PropertySerializer(val name: String, val readMethod: Method) { /** * A property serializer for a complex type (another object). */ - class DescribedTypePropertySerializer(name: String, readMethod: Method, private val lazyTypeSerializer: () -> AMQPSerializer) : PropertySerializer(name, readMethod) { + class DescribedTypePropertySerializer(name: String, readMethod: Method, private val lazyTypeSerializer: () -> AMQPSerializer) : PropertySerializer(name, readMethod) { // This is lazy so we don't get an infinite loop when a method returns an instance of the class. - private val typeSerializer: AMQPSerializer by lazy { lazyTypeSerializer() } + private val typeSerializer: AMQPSerializer by lazy { lazyTypeSerializer() } override fun writeClassInfo(output: SerializationOutput) { typeSerializer.writeClassInfo(output) diff --git a/core/src/main/kotlin/net/corda/core/serialization/amqp/SerializerFactory.kt b/core/src/main/kotlin/net/corda/core/serialization/amqp/SerializerFactory.kt index 207f0979df..3883aad9dd 100644 --- a/core/src/main/kotlin/net/corda/core/serialization/amqp/SerializerFactory.kt +++ b/core/src/main/kotlin/net/corda/core/serialization/amqp/SerializerFactory.kt @@ -35,8 +35,8 @@ import javax.annotation.concurrent.ThreadSafe // TODO: automatically support byte[] without having to wrap in [Binary]. @ThreadSafe class SerializerFactory(val whitelist: ClassWhitelist = AllWhitelist) { - private val serializersByType = ConcurrentHashMap>() - private val serializersByDescriptor = ConcurrentHashMap>() + private val serializersByType = ConcurrentHashMap>() + private val serializersByDescriptor = ConcurrentHashMap>() private val customSerializers = CopyOnWriteArrayList>() /** @@ -46,7 +46,7 @@ class SerializerFactory(val whitelist: ClassWhitelist = AllWhitelist) { * restricted type processing). */ @Throws(NotSerializableException::class) - fun get(actualType: Class<*>?, declaredType: Type): AMQPSerializer { + fun get(actualType: Class<*>?, declaredType: Type): AMQPSerializer { if (declaredType is ParameterizedType) { return serializersByType.computeIfAbsent(declaredType) { // We allow only Collection and Map. @@ -85,7 +85,7 @@ class SerializerFactory(val whitelist: ClassWhitelist = AllWhitelist) { * contained in the [Schema]. */ @Throws(NotSerializableException::class) - fun get(typeDescriptor: Any, schema: Schema): AMQPSerializer { + fun get(typeDescriptor: Any, schema: Schema): AMQPSerializer { return serializersByDescriptor[typeDescriptor] ?: { processSchema(schema) serializersByDescriptor[typeDescriptor] ?: throw NotSerializableException("Could not find type matching descriptor $typeDescriptor.") @@ -162,7 +162,7 @@ class SerializerFactory(val whitelist: ClassWhitelist = AllWhitelist) { } } - private fun makeClassSerializer(clazz: Class<*>): AMQPSerializer { + private fun makeClassSerializer(clazz: Class<*>): AMQPSerializer { return serializersByType.computeIfAbsent(clazz) { if (isPrimitive(clazz)) { AMQPPrimitiveSerializer(clazz) @@ -180,7 +180,7 @@ class SerializerFactory(val whitelist: ClassWhitelist = AllWhitelist) { } } - internal fun findCustomSerializer(clazz: Class<*>): AMQPSerializer? { + internal fun findCustomSerializer(clazz: Class<*>): AMQPSerializer? { for (customSerializer in customSerializers) { if (customSerializer.isSerializerFor(clazz)) { return customSerializer @@ -204,7 +204,7 @@ class SerializerFactory(val whitelist: ClassWhitelist = AllWhitelist) { || (type.superclass != null && hasAnnotationInHierarchy(type.superclass)) } - private fun makeMapSerializer(declaredType: ParameterizedType): AMQPSerializer { + private fun makeMapSerializer(declaredType: ParameterizedType): AMQPSerializer { val rawType = declaredType.rawType as Class<*> rawType.checkNotUnorderedHashMap() return MapSerializer(declaredType, this) diff --git a/core/src/test/kotlin/net/corda/core/crypto/X509NameConstraintsTest.kt b/core/src/test/kotlin/net/corda/core/crypto/X509NameConstraintsTest.kt index 8915ccd955..e78073c6e4 100644 --- a/core/src/test/kotlin/net/corda/core/crypto/X509NameConstraintsTest.kt +++ b/core/src/test/kotlin/net/corda/core/crypto/X509NameConstraintsTest.kt @@ -17,13 +17,13 @@ class X509NameConstraintsTest { private fun makeKeyStores(subjectName: X500Name, nameConstraints: NameConstraints): Pair { val rootKeys = Crypto.generateKeyPair(X509Utilities.DEFAULT_TLS_SIGNATURE_SCHEME) - val rootCACert = X509Utilities.createSelfSignedCACertificate(X509Utilities.getDevX509Name("Corda Root CA"), rootKeys) + val rootCACert = X509Utilities.createSelfSignedCACertificate(X509Utilities.getX509Name("Corda Root CA","London","demo@r3.com",null), rootKeys) val intermediateCAKeyPair = Crypto.generateKeyPair(X509Utilities.DEFAULT_TLS_SIGNATURE_SCHEME) - val intermediateCACert = X509Utilities.createCertificate(CertificateType.INTERMEDIATE_CA, rootCACert, rootKeys, X509Utilities.getDevX509Name("Corda Intermediate CA"), intermediateCAKeyPair.public) + val intermediateCACert = X509Utilities.createCertificate(CertificateType.INTERMEDIATE_CA, rootCACert, rootKeys, X509Utilities.getX509Name("Corda Intermediate CA","London","demo@r3.com",null), intermediateCAKeyPair.public) val clientCAKeyPair = Crypto.generateKeyPair(X509Utilities.DEFAULT_TLS_SIGNATURE_SCHEME) - val clientCACert = X509Utilities.createCertificate(CertificateType.INTERMEDIATE_CA, intermediateCACert, intermediateCAKeyPair, X509Utilities.getDevX509Name("Corda Client CA"), clientCAKeyPair.public, nameConstraints = nameConstraints) + val clientCACert = X509Utilities.createCertificate(CertificateType.INTERMEDIATE_CA, intermediateCACert, intermediateCAKeyPair, X509Utilities.getX509Name("Corda Client CA","London","demo@r3.com",null), clientCAKeyPair.public, nameConstraints = nameConstraints) val keyPass = "password" val trustStore = KeyStore.getInstance(KeyStoreUtilities.KEYSTORE_TYPE) diff --git a/core/src/test/kotlin/net/corda/core/crypto/X509UtilitiesTest.kt b/core/src/test/kotlin/net/corda/core/crypto/X509UtilitiesTest.kt index 6ebaa7e919..780c300044 100644 --- a/core/src/test/kotlin/net/corda/core/crypto/X509UtilitiesTest.kt +++ b/core/src/test/kotlin/net/corda/core/crypto/X509UtilitiesTest.kt @@ -342,10 +342,10 @@ class X509UtilitiesTest { trustStorePassword: String ): KeyStore { val rootCAKey = generateKeyPair(DEFAULT_TLS_SIGNATURE_SCHEME) - val rootCACert = createSelfSignedCACertificate(X509Utilities.getDevX509Name("Corda Node Root CA"), rootCAKey) + val rootCACert = createSelfSignedCACertificate(X509Utilities.getX509Name("Corda Node Root CA","London","demo@r3.com",null), rootCAKey) val intermediateCAKeyPair = Crypto.generateKeyPair(X509Utilities.DEFAULT_TLS_SIGNATURE_SCHEME) - val intermediateCACert = X509Utilities.createCertificate(CertificateType.INTERMEDIATE_CA, rootCACert, rootCAKey, X509Utilities.getDevX509Name("Corda Node Intermediate CA"), intermediateCAKeyPair.public) + val intermediateCACert = X509Utilities.createCertificate(CertificateType.INTERMEDIATE_CA, rootCACert, rootCAKey, X509Utilities.getX509Name("Corda Node Intermediate CA","London","demo@r3.com",null), intermediateCAKeyPair.public) val keyPass = keyPassword.toCharArray() val keyStore = KeyStoreUtilities.loadOrCreateKeyStore(keyStoreFilePath, storePassword) diff --git a/core/src/test/kotlin/net/corda/core/testing/Generators.kt b/core/src/test/kotlin/net/corda/core/testing/Generators.kt index 910bac6edd..bf08440e51 100644 --- a/core/src/test/kotlin/net/corda/core/testing/Generators.kt +++ b/core/src/test/kotlin/net/corda/core/testing/Generators.kt @@ -135,7 +135,7 @@ class X500NameGenerator : Generator(X500Name::class.java) { /** * Append something that looks a bit like a proper noun to the string builder. */ - private fun appendProperNoun(builder: StringBuilder, random: SourceOfRandomness, status: GenerationStatus) : StringBuilder { + private fun appendProperNoun(builder: StringBuilder, random: SourceOfRandomness) : StringBuilder { val length = random.nextByte(1, 8) val encoded = ByteBuffer.allocate(length.toInt()) encoded.put((random.nextByte(0, 25) + asciiA).toByte()) @@ -149,7 +149,7 @@ class X500NameGenerator : Generator(X500Name::class.java) { val wordCount = random.nextByte(1, 3) val cn = StringBuilder() for (word in 0..wordCount) { - appendProperNoun(cn, random, status).append(" ") + appendProperNoun(cn, random).append(" ") } return getTestX509Name(cn.trim().toString()) } diff --git a/finance/src/main/kotlin/net/corda/contracts/testing/VaultFiller.kt b/finance/src/main/kotlin/net/corda/contracts/testing/VaultFiller.kt index 09ceff789c..4d9ebd115c 100644 --- a/finance/src/main/kotlin/net/corda/contracts/testing/VaultFiller.kt +++ b/finance/src/main/kotlin/net/corda/contracts/testing/VaultFiller.kt @@ -21,7 +21,6 @@ import java.util.* @JvmOverloads fun ServiceHub.fillWithSomeTestDeals(dealIds: List, - revisions: Int? = 0, participants: List = emptyList()) : Vault { val freshKey = keyManagementService.freshKey() val recipient = AnonymousParty(freshKey) diff --git a/node/src/main/java/net/corda/node/shell/FlowShellCommand.java b/node/src/main/java/net/corda/node/shell/FlowShellCommand.java index 33ea738c96..8f16381e01 100644 --- a/node/src/main/java/net/corda/node/shell/FlowShellCommand.java +++ b/node/src/main/java/net/corda/node/shell/FlowShellCommand.java @@ -32,7 +32,7 @@ public class FlowShellCommand extends InteractiveShellCommand { @Command @Usage("watch information about state machines running on the node with result information") public void watch(InvocationContext context) throws Exception { - runStateMachinesView(out, context); + runStateMachinesView(out); } static void startFlow(@Usage("The class name of the flow to run, or an unambiguous substring") @Argument String name, diff --git a/node/src/main/kotlin/net/corda/node/services/identity/InMemoryIdentityService.kt b/node/src/main/kotlin/net/corda/node/services/identity/InMemoryIdentityService.kt index 227d0f5a35..fa76acf90e 100644 --- a/node/src/main/kotlin/net/corda/node/services/identity/InMemoryIdentityService.kt +++ b/node/src/main/kotlin/net/corda/node/services/identity/InMemoryIdentityService.kt @@ -63,7 +63,6 @@ class InMemoryIdentityService(identities: Iterable, // trust anchor everywhere, this will have to do. PKIXParameters(setOf(TrustAnchor(party.certificate.cert, null))) } - val validator = CertPathValidator.getInstance("PKIX") validatorParameters.isRevocationEnabled = false // TODO: val result = validator.validate(party.certPath, validatorParameters) as PKIXCertPathValidatorResult // require(trustAnchor == null || result.trustAnchor == trustAnchor) diff --git a/node/src/main/kotlin/net/corda/node/services/transactions/DistributedImmutableMap.kt b/node/src/main/kotlin/net/corda/node/services/transactions/DistributedImmutableMap.kt index 6cfed03980..1b0b528e21 100644 --- a/node/src/main/kotlin/net/corda/node/services/transactions/DistributedImmutableMap.kt +++ b/node/src/main/kotlin/net/corda/node/services/transactions/DistributedImmutableMap.kt @@ -68,7 +68,7 @@ class DistributedImmutableMap(val db: Database, tableName: Str } fun size(commit: Commit): Int { - commit.use { commit -> + commit.use { _ -> return db.transaction { map.size } } } diff --git a/node/src/main/kotlin/net/corda/node/shell/InteractiveShell.kt b/node/src/main/kotlin/net/corda/node/shell/InteractiveShell.kt index fa6bcee71e..749aff245a 100644 --- a/node/src/main/kotlin/net/corda/node/shell/InteractiveShell.kt +++ b/node/src/main/kotlin/net/corda/node/shell/InteractiveShell.kt @@ -40,7 +40,6 @@ import org.crsh.shell.ShellFactory import org.crsh.shell.impl.command.ExternalResolver import org.crsh.text.Color import org.crsh.text.RenderPrintWriter -import org.crsh.text.ui.TableElement import org.crsh.util.InterruptHandler import org.crsh.util.Utils import org.crsh.vfs.FS @@ -307,7 +306,7 @@ object InteractiveShell { // TODO Filtering on error/success when we will have some sort of flow auditing, for now it doesn't make much sense. @JvmStatic - fun runStateMachinesView(out: RenderPrintWriter, context: InvocationContext): Any? { + fun runStateMachinesView(out: RenderPrintWriter): Any? { val proxy = node.rpcOps val (stateMachines, stateMachineUpdates) = proxy.stateMachinesAndUpdates() val currentStateMachines = stateMachines.map { StateMachineUpdate.Added(it) } diff --git a/node/src/test/java/net/corda/node/services/vault/VaultQueryJavaTests.java b/node/src/test/java/net/corda/node/services/vault/VaultQueryJavaTests.java index dfeca9c12e..43f3839dcc 100644 --- a/node/src/test/java/net/corda/node/services/vault/VaultQueryJavaTests.java +++ b/node/src/test/java/net/corda/node/services/vault/VaultQueryJavaTests.java @@ -120,7 +120,7 @@ public class VaultQueryJavaTests { fillWithSomeTestLinearStates(services, 10, uid); List dealIds = Arrays.asList("123", "456", "789"); - fillWithSomeTestDeals(services, dealIds, 0); + fillWithSomeTestDeals(services, dealIds); // DOCSTART VaultJavaQueryExample2 Vault.StateStatus status = Vault.StateStatus.CONSUMED; @@ -191,7 +191,7 @@ public class VaultQueryJavaTests { fillWithSomeTestLinearStates(services, 10, uid); List dealIds = Arrays.asList("123", "456", "789"); - fillWithSomeTestDeals(services, dealIds, 0); + fillWithSomeTestDeals(services, dealIds); // DOCSTART VaultJavaQueryExample2 @SuppressWarnings("unchecked") diff --git a/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt b/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt index a268106931..0e007d2c67 100644 --- a/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt @@ -207,7 +207,7 @@ class VaultQueryTests { database.transaction { services.fillWithSomeTestLinearStates(2, UniqueIdentifier("TEST"), participants = listOf(MEGA_CORP, MINI_CORP)) - services.fillWithSomeTestDeals(listOf("456"), 3, participants = listOf(MEGA_CORP, BIG_CORP)) + services.fillWithSomeTestDeals(listOf("456"), participants = listOf(MEGA_CORP, BIG_CORP)) services.fillWithSomeTestDeals(listOf("123", "789"), participants = listOf(BIG_CORP, MINI_CORP)) // DOCSTART VaultQueryExample5 @@ -533,7 +533,7 @@ class VaultQueryTests { database.transaction { services.fillWithSomeTestLinearStates(2, UniqueIdentifier("TEST")) - services.fillWithSomeTestDeals(listOf("456"), 3) // create 3 revisions with same ID + services.fillWithSomeTestDeals(listOf("456")) // create 3 revisions with same ID services.fillWithSomeTestDeals(listOf("123", "789")) val criteria = LinearStateQueryCriteria(dealRef = listOf("456"), latestOnly = true) @@ -547,7 +547,7 @@ class VaultQueryTests { database.transaction { services.fillWithSomeTestLinearStates(2, UniqueIdentifier("TEST")) - services.fillWithSomeTestDeals(listOf("456"), 3) // specify party + services.fillWithSomeTestDeals(listOf("456")) // specify party services.fillWithSomeTestDeals(listOf("123", "789")) // DOCSTART VaultQueryExample11 diff --git a/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt b/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt index c9d92a61e3..950c680422 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt @@ -69,9 +69,9 @@ val ALICE_PUBKEY: PublicKey get() = ALICE_KEY.public val BOB_PUBKEY: PublicKey get() = BOB_KEY.public val CHARLIE_PUBKEY: PublicKey get() = CHARLIE_KEY.public -val MEGA_CORP_IDENTITY: PartyAndCertificate get() = getTestPartyAndCertificate(X509Utilities.getDevX509Name("MegaCorp"), MEGA_CORP_PUBKEY) +val MEGA_CORP_IDENTITY: PartyAndCertificate get() = getTestPartyAndCertificate(X509Utilities.getX509Name("MegaCorp","London","demo@r3.com",null), MEGA_CORP_PUBKEY) val MEGA_CORP: Party get() = MEGA_CORP_IDENTITY.party -val MINI_CORP_IDENTITY: PartyAndCertificate get() = getTestPartyAndCertificate(X509Utilities.getDevX509Name("MiniCorp"), MINI_CORP_PUBKEY) +val MINI_CORP_IDENTITY: PartyAndCertificate get() = getTestPartyAndCertificate(X509Utilities.getX509Name("MiniCorp","London","demo@r3.com",null), MINI_CORP_PUBKEY) val MINI_CORP: Party get() = MINI_CORP_IDENTITY.party val BOC_KEY: KeyPair by lazy { generateKeyPair() } @@ -82,7 +82,7 @@ val BOC_PARTY_REF = BOC.ref(OpaqueBytes.of(1)).reference val BIG_CORP_KEY: KeyPair by lazy { generateKeyPair() } val BIG_CORP_PUBKEY: PublicKey get() = BIG_CORP_KEY.public -val BIG_CORP_IDENTITY: PartyAndCertificate get() = getTestPartyAndCertificate(X509Utilities.getDevX509Name("BigCorporation"), BIG_CORP_PUBKEY) +val BIG_CORP_IDENTITY: PartyAndCertificate get() = getTestPartyAndCertificate(X509Utilities.getX509Name("BigCorporation","London","demo@r3.com",null), BIG_CORP_PUBKEY) val BIG_CORP: Party get() = BIG_CORP_IDENTITY.party val BIG_CORP_PARTY_REF = BIG_CORP.ref(OpaqueBytes.of(1)).reference diff --git a/test-utils/src/main/kotlin/net/corda/testing/driver/Driver.kt b/test-utils/src/main/kotlin/net/corda/testing/driver/Driver.kt index cc58018502..8aa09cea21 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/driver/Driver.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/driver/Driver.kt @@ -505,7 +505,7 @@ class DriverDSL( val rpcAddress = portAllocation.nextHostAndPort() val webAddress = portAllocation.nextHostAndPort() // TODO: Derive name from the full picked name, don't just wrap the common name - val name = providedName ?: X509Utilities.getDevX509Name("${oneOf(names).commonName}-${p2pAddress.port}") + val name = providedName ?: X509Utilities.getX509Name("${oneOf(names).commonName}-${p2pAddress.port}","London","demo@r3.com",null) return startNode(p2pAddress, webAddress, name, configOf( "myLegalName" to name.toString(), "p2pAddress" to p2pAddress.toString(), diff --git a/test-utils/src/main/kotlin/net/corda/testing/node/InMemoryMessagingNetwork.kt b/test-utils/src/main/kotlin/net/corda/testing/node/InMemoryMessagingNetwork.kt index c2d1cf310b..ffe15ee54a 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/node/InMemoryMessagingNetwork.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/node/InMemoryMessagingNetwork.kt @@ -130,7 +130,7 @@ class InMemoryMessagingNetwork( description: X500Name? = null, database: Database) : MessagingServiceBuilder { - return Builder(manuallyPumped, PeerHandle(id, description ?: X509Utilities.getDevX509Name("In memory node $id")), advertisedServices.map(::ServiceHandle), executor, database = database) + return Builder(manuallyPumped, PeerHandle(id, description ?: X509Utilities.getX509Name("In memory node $id","London","demo@r3.com",null)), advertisedServices.map(::ServiceHandle), executor, database = database) } interface LatencyCalculator { diff --git a/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt b/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt index 78760cf92f..53462b6223 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt @@ -120,13 +120,13 @@ abstract class NodeBasedTest { val nodeAddresses = getFreeLocalPorts("localhost", clusterSize).map { it.toString() } val masterNodeFuture = startNode( - X509Utilities.getDevX509Name("${notaryName.commonName}-0"), + X509Utilities.getX509Name("${notaryName.commonName}-0","London","demo@r3.com",null), advertisedServices = setOf(serviceInfo), configOverrides = mapOf("notaryNodeAddress" to nodeAddresses[0])) val remainingNodesFutures = (1 until clusterSize).map { startNode( - X509Utilities.getDevX509Name("${notaryName.commonName}-$it"), + X509Utilities.getX509Name("${notaryName.commonName}-$it","London","demo@r3.com",null), advertisedServices = setOf(serviceInfo), configOverrides = mapOf( "notaryNodeAddress" to nodeAddresses[it],