mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
Fixed various compiler warnings, mostly removing unused parameters and replacing calls to getDevX509Name with getX509Name with specific data, this should be a nullop. Remainign compiler warnings will require changing semantics of code
This commit is contained in:
parent
a6853be035
commit
aab536646f
@ -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.
|
||||
|
@ -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<out Any>) : PropertySerializer(name, readMethod) {
|
||||
class DescribedTypePropertySerializer(name: String, readMethod: Method, private val lazyTypeSerializer: () -> AMQPSerializer<Any>) : 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<out Any> by lazy { lazyTypeSerializer() }
|
||||
private val typeSerializer: AMQPSerializer<Any> by lazy { lazyTypeSerializer() }
|
||||
|
||||
override fun writeClassInfo(output: SerializationOutput) {
|
||||
typeSerializer.writeClassInfo(output)
|
||||
|
@ -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<Type, AMQPSerializer<out Any>>()
|
||||
private val serializersByDescriptor = ConcurrentHashMap<Any, AMQPSerializer<out Any>>()
|
||||
private val serializersByType = ConcurrentHashMap<Type, AMQPSerializer<Any>>()
|
||||
private val serializersByDescriptor = ConcurrentHashMap<Any, AMQPSerializer<Any>>()
|
||||
private val customSerializers = CopyOnWriteArrayList<CustomSerializer<out Any>>()
|
||||
|
||||
/**
|
||||
@ -46,7 +46,7 @@ class SerializerFactory(val whitelist: ClassWhitelist = AllWhitelist) {
|
||||
* restricted type processing).
|
||||
*/
|
||||
@Throws(NotSerializableException::class)
|
||||
fun get(actualType: Class<*>?, declaredType: Type): AMQPSerializer<out Any> {
|
||||
fun get(actualType: Class<*>?, declaredType: Type): AMQPSerializer<Any> {
|
||||
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<out Any> {
|
||||
fun get(typeDescriptor: Any, schema: Schema): AMQPSerializer<Any> {
|
||||
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<out Any> {
|
||||
private fun makeClassSerializer(clazz: Class<*>): AMQPSerializer<Any> {
|
||||
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<out Any>? {
|
||||
internal fun findCustomSerializer(clazz: Class<*>): AMQPSerializer<Any>? {
|
||||
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<out Any> {
|
||||
private fun makeMapSerializer(declaredType: ParameterizedType): AMQPSerializer<Any> {
|
||||
val rawType = declaredType.rawType as Class<*>
|
||||
rawType.checkNotUnorderedHashMap()
|
||||
return MapSerializer(declaredType, this)
|
||||
|
@ -17,13 +17,13 @@ class X509NameConstraintsTest {
|
||||
|
||||
private fun makeKeyStores(subjectName: X500Name, nameConstraints: NameConstraints): Pair<KeyStore, KeyStore> {
|
||||
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)
|
||||
|
@ -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)
|
||||
|
@ -135,7 +135,7 @@ class X500NameGenerator : Generator<X500Name>(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>(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())
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import java.util.*
|
||||
|
||||
@JvmOverloads
|
||||
fun ServiceHub.fillWithSomeTestDeals(dealIds: List<String>,
|
||||
revisions: Int? = 0,
|
||||
participants: List<AbstractParty> = emptyList()) : Vault<DealState> {
|
||||
val freshKey = keyManagementService.freshKey()
|
||||
val recipient = AnonymousParty(freshKey)
|
||||
|
@ -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<TableElement> 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,
|
||||
|
@ -63,7 +63,6 @@ class InMemoryIdentityService(identities: Iterable<PartyAndCertificate>,
|
||||
// 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)
|
||||
|
@ -68,7 +68,7 @@ class DistributedImmutableMap<K : Any, V : Any>(val db: Database, tableName: Str
|
||||
}
|
||||
|
||||
fun size(commit: Commit<Commands.Size>): Int {
|
||||
commit.use { commit ->
|
||||
commit.use { _ ->
|
||||
return db.transaction { map.size }
|
||||
}
|
||||
}
|
||||
|
@ -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<TableElement>): Any? {
|
||||
fun runStateMachinesView(out: RenderPrintWriter): Any? {
|
||||
val proxy = node.rpcOps
|
||||
val (stateMachines, stateMachineUpdates) = proxy.stateMachinesAndUpdates()
|
||||
val currentStateMachines = stateMachines.map { StateMachineUpdate.Added(it) }
|
||||
|
@ -120,7 +120,7 @@ public class VaultQueryJavaTests {
|
||||
fillWithSomeTestLinearStates(services, 10, uid);
|
||||
|
||||
List<String> 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<String> dealIds = Arrays.asList("123", "456", "789");
|
||||
fillWithSomeTestDeals(services, dealIds, 0);
|
||||
fillWithSomeTestDeals(services, dealIds);
|
||||
|
||||
// DOCSTART VaultJavaQueryExample2
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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(),
|
||||
|
@ -130,7 +130,7 @@ class InMemoryMessagingNetwork(
|
||||
description: X500Name? = null,
|
||||
database: Database)
|
||||
: MessagingServiceBuilder<InMemoryMessaging> {
|
||||
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 {
|
||||
|
@ -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],
|
||||
|
Loading…
Reference in New Issue
Block a user