Skip to content

Commit

Permalink
cdk-java: move JdbcSSLConnectionUtils to core submodule, refactor Str…
Browse files Browse the repository at this point in the history
…ing constants (#42030)
  • Loading branch information
stephane-airbyte authored Sep 26, 2024
1 parent d5380b0 commit adea83d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions airbyte-cdk/java/airbyte-cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ corresponds to that version.

| Version | Date | Pull Request | Subject |
|:-----------|:-----------|:------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 0.47.0 | 2024-09-26 | [\#42030](https://github.com/airbytehq/airbyte/pull/42030) | minor refactor |
| 0.46.1 | 2024-09-20 | [\#45700](https://github.com/airbytehq/airbyte/pull/45700) | Destinations: Fix bug in parsing jsonschema |
| 0.46.0 | 2024-09-18 | [\#45432](https://github.com/airbytehq/airbyte/pull/45432) | upgrade all libraries to latest version |
| 0.45.1 | 2024-09-17 | [\#45638](https://github.com/airbytehq/airbyte/pull/45638) | upgrade apache mina sshd to 2.13.2 to handle openssh tcpkeepalive requests |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright (c) 2023 Airbyte, Inc., all rights reserved.
* Copyright (c) 2024 Airbyte, Inc., all rights reserved.
*/
package io.airbyte.cdk.integrations.source.jdbc

package io.airbyte.cdk.db.jdbc

import com.fasterxml.jackson.databind.JsonNode
import io.airbyte.cdk.db.jdbc.JdbcUtils
import io.airbyte.cdk.db.util.SSLCertificateUtils.keyStoreFromCertificate
import io.airbyte.cdk.db.util.SSLCertificateUtils.keyStoreFromClientCertificate
import io.airbyte.cdk.db.util.SSLCertificateUtils
import io.github.oshai.kotlinlogging.KotlinLogging
import java.io.IOException
import java.net.MalformedURLException
Expand Down Expand Up @@ -153,7 +152,7 @@ class JdbcSSLConnectionUtils {
val clientKeyPassword = getOrGeneratePassword(encryption)
try {
val caCertKeyStoreUri =
keyStoreFromCertificate(
SSLCertificateUtils.keyStoreFromCertificate(
encryption[PARAM_CA_CERTIFICATE].asText(),
clientKeyPassword,
null,
Expand Down Expand Up @@ -214,7 +213,7 @@ class JdbcSSLConnectionUtils {
val clientKeyPassword = getOrGeneratePassword(encryption)
try {
val clientCertKeyStoreUri =
keyStoreFromClientCertificate(
SSLCertificateUtils.keyStoreFromClientCertificate(
encryption[PARAM_CLIENT_CERTIFICATE].asText(),
encryption[PARAM_CLIENT_KEY].asText(),
clientKeyPassword,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,14 @@ constructor(
const val GLOBAL_HEARTBEAT_INTERVAL_DEFAULT_IN_MILLIS: Long = 2000
const val IDLE_TIMEOUT_KEY: String = "idle_timeout"
const val IDLE_TIMEOUT_DEFAULT_INFINITE: Long = 0
const val TUNNEL_METHOD_KEY = "tunnel_method"

const val TIMEOUT_MILLIS: Int = 15000 // 15 seconds

@JvmStatic
fun getInstance(config: JsonNode, hostKey: List<String>, portKey: List<String>): SshTunnel {
val tunnelMethod =
Jsons.getOptional(config, "tunnel_method", "tunnel_method")
Jsons.getOptional(config, TUNNEL_METHOD_KEY, TUNNEL_METHOD_KEY)
.map { method: JsonNode ->
TunnelMethod.valueOf(method.asText().trim { it <= ' ' })
}
Expand All @@ -429,12 +430,12 @@ constructor(
null,
null,
tunnelMethod,
Strings.safeTrim(Jsons.getStringOrNull(config, "tunnel_method", "tunnel_host")),
Jsons.getIntOrZero(config, "tunnel_method", "tunnel_port"),
Strings.safeTrim(Jsons.getStringOrNull(config, "tunnel_method", "tunnel_user")),
Strings.safeTrim(Jsons.getStringOrNull(config, "tunnel_method", "ssh_key")),
Strings.safeTrim(Jsons.getStringOrNull(config, TUNNEL_METHOD_KEY, "tunnel_host")),
Jsons.getIntOrZero(config, TUNNEL_METHOD_KEY, "tunnel_port"),
Strings.safeTrim(Jsons.getStringOrNull(config, TUNNEL_METHOD_KEY, "tunnel_user")),
Strings.safeTrim(Jsons.getStringOrNull(config, TUNNEL_METHOD_KEY, "ssh_key")),
Strings.safeTrim(
Jsons.getStringOrNull(config, "tunnel_method", "tunnel_user_password")
Jsons.getStringOrNull(config, TUNNEL_METHOD_KEY, "tunnel_user_password")
),
Strings.safeTrim(Jsons.getStringOrNull(config, hostKey)),
Jsons.getIntOrZero(config, portKey),
Expand Down Expand Up @@ -479,7 +480,7 @@ constructor(
@Throws(Exception::class)
fun getInstance(config: JsonNode, endPointKey: String): SshTunnel {
val tunnelMethod =
Jsons.getOptional(config, "tunnel_method", "tunnel_method")
Jsons.getOptional(config, TUNNEL_METHOD_KEY, TUNNEL_METHOD_KEY)
.map { method: JsonNode ->
TunnelMethod.valueOf(method.asText().trim { it <= ' ' })
}
Expand All @@ -493,12 +494,12 @@ constructor(
endPointKey,
Jsons.getStringOrNull(config, endPointKey),
tunnelMethod,
Strings.safeTrim(Jsons.getStringOrNull(config, "tunnel_method", "tunnel_host")),
Jsons.getIntOrZero(config, "tunnel_method", "tunnel_port"),
Strings.safeTrim(Jsons.getStringOrNull(config, "tunnel_method", "tunnel_user")),
Strings.safeTrim(Jsons.getStringOrNull(config, "tunnel_method", "ssh_key")),
Strings.safeTrim(Jsons.getStringOrNull(config, TUNNEL_METHOD_KEY, "tunnel_host")),
Jsons.getIntOrZero(config, TUNNEL_METHOD_KEY, "tunnel_port"),
Strings.safeTrim(Jsons.getStringOrNull(config, TUNNEL_METHOD_KEY, "tunnel_user")),
Strings.safeTrim(Jsons.getStringOrNull(config, TUNNEL_METHOD_KEY, "ssh_key")),
Strings.safeTrim(
Jsons.getStringOrNull(config, "tunnel_method", "tunnel_user_password")
Jsons.getStringOrNull(config, TUNNEL_METHOD_KEY, "tunnel_user_password")
),
null,
0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.46.1
version=0.47.0
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private val log = KotlinLogging.logger {}
object JsonSchemas {
private const val JSON_SCHEMA_ENUM_KEY = "enum"
private const val JSON_SCHEMA_TYPE_KEY = "type"
private const val JSON_SCHEMA_PROPERTIES_KEY = "properties"
const val JSON_SCHEMA_PROPERTIES_KEY = "properties"
private const val JSON_SCHEMA_ITEMS_KEY = "items"

// all JSONSchema types.
Expand Down

0 comments on commit adea83d

Please sign in to comment.