Merge pull request #5683 from corda/bugfix/CORDA-3396-fixed-blob-inspector-npe

CORDA-3396 fixed blob inspector npe
This commit is contained in:
Ivan Schasny 2019-11-08 10:56:16 +00:00 committed by GitHub
commit 703318b5a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -252,7 +252,7 @@ object JacksonSupport {
writeObjectField("issuerUniqueID", value.issuerUniqueID)
writeObjectField("subjectUniqueID", value.subjectUniqueID)
writeObjectField("keyUsage", value.keyUsage?.asList()?.mapIndexedNotNull { i, flag -> if (flag) keyUsages[i] else null })
writeObjectField("extendedKeyUsage", value.extendedKeyUsage.map { keyPurposeIds[it] ?: it })
writeObjectField("extendedKeyUsage", value.extendedKeyUsage?.map { keyPurposeIds[it] ?: it })
jsonObject("basicConstraints") {
val isCa = value.basicConstraints != -1
writeBooleanField("isCA", isCa)

View File

@ -12,6 +12,7 @@ import com.nhaarman.mockito_kotlin.any
import com.nhaarman.mockito_kotlin.doReturn
import com.nhaarman.mockito_kotlin.mock
import com.nhaarman.mockito_kotlin.whenever
import com.nhaarman.mockito_kotlin.spy
import net.corda.client.jackson.internal.childrenAs
import net.corda.client.jackson.internal.valueAs
import net.corda.core.contracts.*
@ -638,6 +639,14 @@ class JacksonSupportTest(@Suppress("unused") private val name: String, factory:
assertThat(json["encoded"].binaryValue()).isEqualTo(cert.encoded)
}
@Test
fun `X509Certificate serialization when extendedKeyUsage is null`() {
val cert: X509Certificate = spy(MINI_CORP.identity.certificate)
whenever(cert.extendedKeyUsage).thenReturn(null)
// should work even if extendedKeyUsage is null
mapper.valueToTree<ObjectNode>(cert)
}
@Test
fun `X509Certificate deserialization`() {
val cert: X509Certificate = MINI_CORP.identity.certificate

View File

@ -79,6 +79,11 @@ class BlobInspector : CordaCliWrapper("blob-inspector", "Convert AMQP serialised
mapper.writeValue(out, deserialized)
ExitCodes.SUCCESS
} catch (e: Exception) {
print("Unexpected exception: ${e.message}")
if (verbose) {
println()
e.printStackTrace(System.out)
}
ExitCodes.FAILURE
} finally {
_contextSerializationEnv.set(null)