From 82c592ff4a37b5e8bdd1cd933f696c23d4901ac2 Mon Sep 17 00:00:00 2001 From: Lukas Sembera Date: Wed, 4 Oct 2023 14:41:44 +0000 Subject: [PATCH] SNOW-926149 Fix issues while using snowflake-jdbc-fips --- pom.xml | 25 +++++++++++++++++++ scripts/process_licenses.py | 4 +++ .../net/snowflake/ingest/utils/Utils.java | 14 +++++------ .../java/net/snowflake/ingest/TestUtils.java | 2 +- .../streaming/internal/FlushServiceTest.java | 2 +- .../SnowflakeStreamingIngestClientTest.java | 14 +++++------ .../internal/datatypes/BinaryIT.java | 2 +- 7 files changed, 46 insertions(+), 17 deletions(-) diff --git a/pom.xml b/pom.xml index dbf156690..a78b00670 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,7 @@ + 1.74 1.9.13 1.15 3.2.2 @@ -274,6 +275,16 @@ audience-annotations ${yetus.version} + + org.bouncycastle + bcpkix-jdk18on + ${bouncycastle.version} + + + org.bouncycastle + bcprov-jdk18on + ${bouncycastle.version} + org.codehaus.jackson jackson-core-asl @@ -449,6 +460,15 @@ org.apache.parquet parquet-hadoop + + + org.bouncycastle + bcpkix-jdk18on + + + org.bouncycastle + bcprov-jdk18on + org.slf4j slf4j-api @@ -758,6 +778,7 @@ The MIT License EDL 1.0 The Go license + Bouncy Castle Licence test,provided,system true @@ -929,6 +950,10 @@ com.nimbusds ${shadeBase}.com.nimbusds + + org.bouncycastle + ${shadeBase}.org.bouncycastle + net.jcip ${shadeBase}.net.jcip diff --git a/scripts/process_licenses.py b/scripts/process_licenses.py index a17c34843..bb43fbbf0 100644 --- a/scripts/process_licenses.py +++ b/scripts/process_licenses.py @@ -30,6 +30,7 @@ EDL_10_LICENSE = "EDL 1.0" MIT_LICENSE = "The MIT License" GO_LICENSE = "The Go license" +BOUNCY_CASTLE_LICENSE = "Bouncy Castle Licence " # The SDK does not need to include licenses of dependencies, which aren't shaded IGNORED_DEPENDENCIES = {"net.snowflake:snowflake-jdbc", "org.slf4j:slf4j-api"} @@ -57,6 +58,9 @@ "org.apache.parquet:parquet-format-structures": APACHE_LICENSE, "com.github.luben:zstd-jni": BSD_2_CLAUSE_LICENSE, "io.airlift:aircompressor": APACHE_LICENSE, + "org.bouncycastle:bcpkix-jdk18on": BOUNCY_CASTLE_LICENSE, + "org.bouncycastle:bcutil-jdk18on": BOUNCY_CASTLE_LICENSE, + "org.bouncycastle:bcprov-jdk18on": BOUNCY_CASTLE_LICENSE, } diff --git a/src/main/java/net/snowflake/ingest/utils/Utils.java b/src/main/java/net/snowflake/ingest/utils/Utils.java index ca39fed0d..c79c399e8 100644 --- a/src/main/java/net/snowflake/ingest/utils/Utils.java +++ b/src/main/java/net/snowflake/ingest/utils/Utils.java @@ -26,14 +26,14 @@ import java.util.Map; import java.util.Properties; import net.snowflake.client.core.SFSessionProperty; -import net.snowflake.client.jdbc.internal.org.bouncycastle.asn1.pkcs.PrivateKeyInfo; -import net.snowflake.client.jdbc.internal.org.bouncycastle.jce.provider.BouncyCastleProvider; -import net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.PEMParser; -import net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter; -import net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8DecryptorProviderBuilder; -import net.snowflake.client.jdbc.internal.org.bouncycastle.operator.InputDecryptorProvider; -import net.snowflake.client.jdbc.internal.org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfo; import org.apache.commons.codec.binary.Base64; +import org.bouncycastle.asn1.pkcs.PrivateKeyInfo; +import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.bouncycastle.openssl.PEMParser; +import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter; +import org.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8DecryptorProviderBuilder; +import org.bouncycastle.operator.InputDecryptorProvider; +import org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfo; /** Contains Ingest related utility functions */ public class Utils { diff --git a/src/test/java/net/snowflake/ingest/TestUtils.java b/src/test/java/net/snowflake/ingest/TestUtils.java index b2ebe1bdd..16011d730 100644 --- a/src/test/java/net/snowflake/ingest/TestUtils.java +++ b/src/test/java/net/snowflake/ingest/TestUtils.java @@ -41,12 +41,12 @@ import net.snowflake.client.jdbc.internal.apache.http.client.utils.URIBuilder; import net.snowflake.client.jdbc.internal.fasterxml.jackson.databind.ObjectMapper; import net.snowflake.client.jdbc.internal.fasterxml.jackson.databind.node.ObjectNode; -import net.snowflake.client.jdbc.internal.org.bouncycastle.jce.provider.BouncyCastleProvider; import net.snowflake.ingest.streaming.InsertValidationResponse; import net.snowflake.ingest.streaming.SnowflakeStreamingIngestChannel; import net.snowflake.ingest.utils.Constants; import net.snowflake.ingest.utils.Utils; import org.apache.commons.codec.binary.Base64; +import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.junit.Assert; public class TestUtils { diff --git a/src/test/java/net/snowflake/ingest/streaming/internal/FlushServiceTest.java b/src/test/java/net/snowflake/ingest/streaming/internal/FlushServiceTest.java index 0b8e8b4cd..faa5e1902 100644 --- a/src/test/java/net/snowflake/ingest/streaming/internal/FlushServiceTest.java +++ b/src/test/java/net/snowflake/ingest/streaming/internal/FlushServiceTest.java @@ -39,13 +39,13 @@ import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; -import net.snowflake.client.jdbc.internal.org.bouncycastle.jce.provider.BouncyCastleProvider; import net.snowflake.ingest.streaming.OpenChannelRequest; import net.snowflake.ingest.utils.Constants; import net.snowflake.ingest.utils.Cryptor; import net.snowflake.ingest.utils.ErrorCode; import net.snowflake.ingest.utils.ParameterProvider; import net.snowflake.ingest.utils.SFException; +import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/net/snowflake/ingest/streaming/internal/SnowflakeStreamingIngestClientTest.java b/src/test/java/net/snowflake/ingest/streaming/internal/SnowflakeStreamingIngestClientTest.java index ec9f671bb..fe45b1e95 100644 --- a/src/test/java/net/snowflake/ingest/streaming/internal/SnowflakeStreamingIngestClientTest.java +++ b/src/test/java/net/snowflake/ingest/streaming/internal/SnowflakeStreamingIngestClientTest.java @@ -40,13 +40,6 @@ import net.snowflake.client.jdbc.internal.apache.http.client.methods.HttpPost; import net.snowflake.client.jdbc.internal.apache.http.impl.client.CloseableHttpClient; import net.snowflake.client.jdbc.internal.google.common.collect.Sets; -import net.snowflake.client.jdbc.internal.org.bouncycastle.asn1.nist.NISTObjectIdentifiers; -import net.snowflake.client.jdbc.internal.org.bouncycastle.jce.provider.BouncyCastleProvider; -import net.snowflake.client.jdbc.internal.org.bouncycastle.openssl.jcajce.JcaPEMWriter; -import net.snowflake.client.jdbc.internal.org.bouncycastle.operator.OperatorCreationException; -import net.snowflake.client.jdbc.internal.org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfoBuilder; -import net.snowflake.client.jdbc.internal.org.bouncycastle.pkcs.jcajce.JcaPKCS8EncryptedPrivateKeyInfoBuilder; -import net.snowflake.client.jdbc.internal.org.bouncycastle.pkcs.jcajce.JcePKCSPBEOutputEncryptorBuilder; import net.snowflake.ingest.TestUtils; import net.snowflake.ingest.connection.RequestBuilder; import net.snowflake.ingest.streaming.OpenChannelRequest; @@ -59,6 +52,13 @@ import net.snowflake.ingest.utils.SFException; import net.snowflake.ingest.utils.SnowflakeURL; import net.snowflake.ingest.utils.Utils; +import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; +import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.bouncycastle.openssl.jcajce.JcaPEMWriter; +import org.bouncycastle.operator.OperatorCreationException; +import org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfoBuilder; +import org.bouncycastle.pkcs.jcajce.JcaPKCS8EncryptedPrivateKeyInfoBuilder; +import org.bouncycastle.pkcs.jcajce.JcePKCSPBEOutputEncryptorBuilder; import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; diff --git a/src/test/java/net/snowflake/ingest/streaming/internal/datatypes/BinaryIT.java b/src/test/java/net/snowflake/ingest/streaming/internal/datatypes/BinaryIT.java index d9e6e3ddd..2a5023a3a 100644 --- a/src/test/java/net/snowflake/ingest/streaming/internal/datatypes/BinaryIT.java +++ b/src/test/java/net/snowflake/ingest/streaming/internal/datatypes/BinaryIT.java @@ -1,6 +1,6 @@ package net.snowflake.ingest.streaming.internal.datatypes; -import net.snowflake.client.jdbc.internal.org.bouncycastle.util.encoders.Hex; +import org.bouncycastle.util.encoders.Hex; import org.junit.Test; public class BinaryIT extends AbstractDataTypeTest {