Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KSM-501 - Java SDK: Switched to non srtict JSON parser and bumping deps versions #579

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions sdk/java/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ version = "16.6.3"

plugins {
`java-library`
kotlin("jvm") version "1.9.20"
kotlin("plugin.serialization") version "1.9.20"
kotlin("jvm") version "1.9.23"
kotlin("plugin.serialization") version "1.9.23"
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
Expand Down Expand Up @@ -42,18 +42,18 @@ repositories {

dependencies {
// Align versions of all Kotlin components
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.9.20"))
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.9.23"))

// Use the Kotlin JDK 8 standard library.
api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.20")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.9.20")
api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.23")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.9.23")

// Use the Kotlin test library.
testImplementation("org.jetbrains.kotlin:kotlin-test:1.9.20")
testImplementation("org.jetbrains.kotlin:kotlin-test:1.9.23")

// Use the Kotlin JUnit integration.
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.9.20")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.9.23")

testImplementation("org.bouncycastle:bc-fips:1.0.2.4")
// testImplementation("org.bouncycastle:bcprov-jdk15on:1.70")
Expand Down
2 changes: 1 addition & 1 deletion sdk/java/core/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip

zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -800,21 +800,23 @@ private fun decryptRecord(record: SecretsManagerResponseRecord, recordKey: ByteA

// When SDK is behind/ahead of record/field type definitions then
// strict mapping between JSON attributes and object properties
// will fail on any unknown field/key so just skip the record with proper error message
// will fail on any unknown field/key - currently just log the error
// and continue without the field - nb! field will be lost on save
var recordData: KeeperRecordData? = null
try {
val recordData = Json.decodeFromString<KeeperRecordData>(bytesToString(decryptedRecord))
return KeeperRecord(recordKey, record.recordUid, null, null, record.innerFolderUid, recordData, record.revision, files)
recordData = Json.decodeFromString<KeeperRecordData>(bytesToString(decryptedRecord))
} catch (e: Exception) {
// New/missing field: Polymorphic serializer was not found for class discriminator 'UNKNOWN'...
// New/missing field property (field def updated): Encountered unknown key 'UNKNOWN'.
// Avoid 'ignoreUnknownKeys = true' to prevent erasing new properties on save/update
println("Skipped record ${record.recordUid}\n"+
println("Record ${record.recordUid} has unexpected data properties (ignored).\n"+
" Error parsing record type - KSM SDK is behind/ahead of record/field type definitions." +
" Please upgrade to latest version. If you need assistance please email [email protected]")
println(e.message)
//println(e.message)
recordData = nonStrictJson.decodeFromString<KeeperRecordData>(bytesToString(decryptedRecord))
}

return null
return if (recordData != null) KeeperRecord(recordKey, record.recordUid, null, null, record.innerFolderUid, recordData, record.revision, files) else null
}

@ExperimentalSerializationApi
Expand Down
Loading