├── .github └── CODEOWNERS ├── src ├── main │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── java.sql.Driver │ └── java │ │ └── com │ │ └── mongodb │ │ └── jdbc │ │ ├── oidc │ │ ├── OidcTimeoutException.java │ │ ├── manualtests │ │ │ ├── TestOidcAuthFlow.java │ │ │ ├── TestRFC8252Server.java │ │ │ ├── TestOidcCallbackWithBadRefreshToken.java │ │ │ ├── TestOidcUtils.java │ │ │ ├── TestOidcCallbackWithShortTimeout.java │ │ │ ├── TestOidcCallback.java │ │ │ └── TestOidcAuthFlowAndRefresh.java │ │ ├── JdbcIdpInfo.java │ │ ├── JdbcOidcCallbackContext.java │ │ ├── JdbcOidcCallback.java │ │ └── OidcResponse.java │ │ ├── MongoJsonSchemaResult.java │ │ ├── mongosql │ │ ├── MongoSQLException.java │ │ ├── GetMongosqlTranslateVersionResult.java │ │ ├── CheckDriverVersionResult.java │ │ ├── GetNamespacesResult.java │ │ └── TranslateResult.java │ │ ├── MongoSerializationException.java │ │ ├── DataLake.java │ │ ├── MongoListTablesResult.java │ │ ├── logging │ │ ├── AutoLoggable.java │ │ ├── DisableAutoLogging.java │ │ ├── MongoSimpleFormatter.java │ │ ├── QueryDiagnostics.java │ │ └── LoggingAspect.aj │ │ ├── NoCheckStateJsonWriter.java │ │ ├── MongoRunCmdListTablesResult.java │ │ ├── Pair.java │ │ ├── MongoVersionedJsonSchema.java │ │ ├── JsonSchema.java │ │ ├── BsonExplicitCursor.java │ │ ├── MongoColumnInfo.java │ │ ├── SortableBsonDocument.java │ │ ├── BuildInfo.java │ │ ├── MongoConnectionProperties.java │ │ └── utils │ │ └── BsonUtils.java ├── test │ ├── resources │ │ ├── MongoSqlLibraryTest │ │ │ └── libmongosqltranslate.so │ │ ├── mongoJsonSchemaTest │ │ │ ├── input │ │ │ │ ├── bsonTypeAsSingleType.json │ │ │ │ ├── bsonTypeAsSetOfOneElem.json │ │ │ │ ├── bsonTypeAsSetOfSimpleTypes.json │ │ │ │ ├── flattenedAnyOfReducedToOneType.json │ │ │ │ ├── polymorphicAdditionalProperties.json │ │ │ │ ├── bsonTypeAsSetAndAnyOfToMergeWith.json │ │ │ │ ├── polymorphicItems.json │ │ │ │ ├── flattenAnyOf.json │ │ │ │ └── simpleSchema.json │ │ │ └── expectedOutput │ │ │ │ ├── bsonTypeAsSetOfOneElem.json │ │ │ │ ├── bsonTypeAsSingleType.json │ │ │ │ ├── flattenedAnyOfReducedToOneType.json │ │ │ │ ├── bsonTypeAsSetOfSimpleTypes.json │ │ │ │ ├── polymorphicItems.json │ │ │ │ ├── polymorphicAdditionalProperties.json │ │ │ │ ├── flattenAnyOf.json │ │ │ │ ├── bsonTypeAsSetAndAnyOfToMergeWith.json │ │ │ │ └── simpleSchema.json │ │ └── X509AuthenticationTest │ │ │ ├── public_key.pem │ │ │ ├── no_pem_objects.pem │ │ │ ├── no_private_key.pem │ │ │ ├── no_x509_certificate.pem │ │ │ ├── crl.pem │ │ │ ├── corrupted_key.pem │ │ │ ├── pkcs1_encrypted.pem │ │ │ ├── corrupted_x509_certificate.pem │ │ │ └── pkcs8_unencrypted.pem │ └── java │ │ └── com │ │ └── mongodb │ │ └── jdbc │ │ └── BsonUtilsTest.java └── integration-test │ └── java │ └── com │ └── mongodb │ └── jdbc │ └── integration │ ├── testharness │ ├── models │ │ ├── Tests.java │ │ ├── TestData.java │ │ ├── TestDataEntry.java │ │ └── TestEntry.java │ ├── README.md │ └── TestTypeInfo.java │ ├── AuthGSSAPIIntegrationTest.java │ ├── AuthX509IntegrationTestBase.java │ ├── AuthX509PEMContentsIntegrationTest.java │ └── AuthX509TlsCaFileIntegrationTest.java ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── deploy.gradle └── publish.sh ├── resources ├── media │ └── MongoDBAtlasJDBC.png ├── authentication_test │ ├── X509 │ │ ├── truststore.jks │ │ ├── ca.crt │ │ ├── client-unencrypted-pkcs1-string.txt │ │ ├── client-unencrypted-pkcs8-string.txt │ │ ├── client-encrypted-pkcs1-string.json │ │ ├── client-encrypted-pkcs8-string.json │ │ ├── client-unencrypted.pem │ │ ├── server.pem │ │ └── client-encrypted.pem │ └── GSSAPI │ │ ├── jaas.config │ │ └── krb5.config ├── third_party_header.txt ├── integration_test │ ├── README.md │ └── testdata │ │ ├── dbmd_variable_result_set_data.yml │ │ └── integration.yml ├── license_header.txt ├── release │ └── mongo_jdbc_compliance_report_template.md └── start_local_mdb.sh ├── mongo-jdbc-downloads_template.json ├── demo ├── build.gradle └── src │ ├── test │ └── java │ │ └── com │ │ └── mongodb │ │ └── jdbc │ │ └── utils │ │ └── MongoSQLTestUtils.java │ └── main │ └── java │ └── com │ └── mongodb │ └── jdbc │ └── demo │ └── Main.java ├── settings.gradle ├── smoketest ├── build.gradle └── src │ └── test │ └── java │ └── com │ └── mongodb │ └── jdbc │ └── smoketest │ └── SmokeTest.java ├── .gitignore ├── evergreen ├── make_docs.sh └── monitor_gradle_tasks.sh ├── gradle.properties └── gradlew.bat /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # File: ./github/CODEOWNERS 2 | /**/* @mongodb/sql-engines-team 3 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/java.sql.Driver: -------------------------------------------------------------------------------- 1 | com.mongodb.jdbc.MongoDriver 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb/mongo-jdbc-driver/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /resources/media/MongoDBAtlasJDBC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb/mongo-jdbc-driver/HEAD/resources/media/MongoDBAtlasJDBC.png -------------------------------------------------------------------------------- /resources/authentication_test/X509/truststore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb/mongo-jdbc-driver/HEAD/resources/authentication_test/X509/truststore.jks -------------------------------------------------------------------------------- /src/test/resources/MongoSqlLibraryTest/libmongosqltranslate.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb/mongo-jdbc-driver/HEAD/src/test/resources/MongoSqlLibraryTest/libmongosqltranslate.so -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/input/bsonTypeAsSingleType.json: -------------------------------------------------------------------------------- 1 | { 2 | "bsonType": "object", 3 | "properties": { 4 | "bar": { 5 | "bsonType": "int" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/input/bsonTypeAsSetOfOneElem.json: -------------------------------------------------------------------------------- 1 | { 2 | "bsonType": "object", 3 | "properties": { 4 | "bar": { 5 | "bsonType": ["int"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/expectedOutput/bsonTypeAsSetOfOneElem.json: -------------------------------------------------------------------------------- 1 | { 2 | "bsonType": "object", 3 | "properties": { 4 | "bar": { 5 | "bsonType": "int" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/expectedOutput/bsonTypeAsSingleType.json: -------------------------------------------------------------------------------- 1 | { 2 | "bsonType": "object", 3 | "properties": { 4 | "bar": { 5 | "bsonType": "int" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /resources/authentication_test/GSSAPI/jaas.config: -------------------------------------------------------------------------------- 1 | mongodb.gssapi { 2 | com.sun.security.auth.module.Krb5LoginModule required 3 | useTicketCache=true 4 | doNotPrompt=true 5 | ticketCache="/tmp/krb5cc_drivers" 6 | debug=true; 7 | }; 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /resources/authentication_test/GSSAPI/krb5.config: -------------------------------------------------------------------------------- 1 | [realms] 2 | LDAPTEST.10GEN.CC = { 3 | kdc = ldaptest.10gen.cc 4 | admin_server = ldaptest.10gen.cc 5 | } 6 | 7 | [libdefaults] 8 | rdns = false 9 | default_realm = LDAPTEST.10GEN.CC 10 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/input/bsonTypeAsSetOfSimpleTypes.json: -------------------------------------------------------------------------------- 1 | { 2 | "bsonType": "object", 3 | "properties": { 4 | "bar": { 5 | "bsonType": [ 6 | "int", 7 | "string", 8 | "double" 9 | ] 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/expectedOutput/flattenedAnyOfReducedToOneType.json: -------------------------------------------------------------------------------- 1 | { 2 | "bsonType": "object", 3 | "properties": { 4 | "bar": { 5 | "bsonType": "array", 6 | "items":{}, 7 | "additionalProperties": true 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/expectedOutput/bsonTypeAsSetOfSimpleTypes.json: -------------------------------------------------------------------------------- 1 | { 2 | "bsonType": "object", 3 | "properties": { 4 | "bar": { 5 | "anyOf": [ 6 | {"bsonType": "int"}, 7 | {"bsonType": "string"}, 8 | { 9 | "bsonType": "double" 10 | } 11 | ] 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /mongo-jdbc-downloads_template.json: -------------------------------------------------------------------------------- 1 | { 2 | "manual_link": "https://www.mongodb.com/docs/atlas/data-federation/query/query-with-sql/", 3 | "release_notes_link": "https://www.mongodb.com/docs/atlas/release-notes/sql/", 4 | "versions": [ 5 | { 6 | "version": "{RELEASE_VERSION}", 7 | "download_link": "https://repo1.maven.org/maven2/org/mongodb/mongodb-jdbc/{RELEASE_VERSION}" 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /demo/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'application' 3 | } 4 | 5 | application { 6 | mainClassName = 'com.mongodb.jdbc.demo.Main' 7 | } 8 | 9 | dependencies { 10 | runtimeOnly files(project(':').tasks.shadowJar) 11 | 12 | implementation 'org.junit.jupiter:junit-jupiter:5.7.0' 13 | compile rootProject 14 | } 15 | 16 | tasks.named('shadowJar') { 17 | dependsOn ':shadowJar' 18 | } 19 | 20 | test { 21 | exclude 'com/mongodb/jdbc/utils/**' 22 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/5.6.2/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'mongodb-jdbc' 11 | 12 | include 'demo' 13 | include 'smoketest' 14 | 15 | -------------------------------------------------------------------------------- /resources/third_party_header.txt: -------------------------------------------------------------------------------- 1 | MongoDB uses third-party libraries or other resources that may 2 | be distributed under licenses different from the MongoDB software. 3 | 4 | In the event that we accidentally fail to list a required notice, 5 | please bring it to our attention through our JIRA system at: 6 | 7 | https://jira.mongodb.org 8 | 9 | The attached notices are provided for information only. 10 | 11 | 12 | -------------------------- 13 | -------------------------------------------------------------------------------- /smoketest/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | dependencies { 6 | runtimeOnly fileTree('../build/libs/') { include '*-all.jar' } 7 | testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: junitJupiterVersion 8 | } 9 | 10 | // Ensure smoketest shadowJar depends on the main shadowJar task 11 | tasks.named('shadowJar') { 12 | dependsOn ':shadowJar' 13 | } 14 | 15 | test { 16 | useJUnitPlatform() 17 | } 18 | test.onlyIf { project.hasProperty("smoketest") } 19 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/expectedOutput/polymorphicItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "bsonType":"object", 3 | "properties":{ 4 | "bar":{ 5 | "bsonType":"object", 6 | "properties":{ 7 | "a":{ 8 | "bsonType":"array", 9 | "items":{} 10 | }, 11 | "b":{ 12 | "bsonType":"array", 13 | "items":{}, 14 | "additionalProperties":false 15 | }, 16 | "c":{ 17 | "bsonType":"objectId" 18 | } 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/input/flattenedAnyOfReducedToOneType.json: -------------------------------------------------------------------------------- 1 | { 2 | "bsonType": "object", 3 | "properties": { 4 | "bar": { 5 | "anyOf": [ 6 | { 7 | "anyOf": [ 8 | { 9 | "anyOf": [ 10 | { 11 | "bsonType": "array", 12 | "items" : {"bsonType": "int"}, 13 | "additionalProperties": true 14 | } 15 | ] 16 | } 17 | ] 18 | } 19 | ] 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /resources/integration_test/README.md: -------------------------------------------------------------------------------- 1 | ## Integration Tests Specifications 2 | 3 | 4 | For the integration tests, a specific pattern is being used to test each function. Essentially, one test is used to 5 | check the metadata results of the function. Additional tests are used to check the result sets. For 6 | example, in `dbmd_constant_result_sets.yml`, `getTypeInfo_resultset_metadata_validation` is checking the metadata of 7 | the `getTypeInfo()` function, and `getTypeInfo_returns_constant_result_set` is checking the actual results against the 8 | expected result set of the `getTypeInfo()` function. -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | 7 | # Ignore debugging helpers 8 | demo/src/test/ 9 | 10 | # Ignore local ADF directory 11 | # Still retaining old "adl" name in gitignore for older setups 12 | local_adl 13 | local_adf 14 | 15 | # Ignore generated tests 16 | resources/generated_test 17 | 18 | # Ignore mongosqltranslate libraries 19 | src/main/resources/**/libmongosqltranslate.* 20 | src/main/resources/**/mongosqltranslate.* 21 | .library_cache/ 22 | 23 | # Ignore secrets 24 | secrets-export.sh 25 | -------------------------------------------------------------------------------- /resources/integration_test/testdata/dbmd_variable_result_set_data.yml: -------------------------------------------------------------------------------- 1 | dataset: 2 | - db: integration_test 3 | collection: foo 4 | docs: 5 | - {"_id": 0, "a": 1} 6 | - {"_id": 1, "a": 2} 7 | nonuniqueIndexes: 8 | - {"a": 1} 9 | 10 | - db: integration_test 11 | collection: bar 12 | docs: 13 | - {"_id": 0, "a": 1, "b": true, "xyz": "hello"} 14 | - {"_id": 1, "a": 2, "b": null} 15 | 16 | - db: db2 17 | collection: foo 18 | docs: 19 | - {"_id": 1, "b": 100} 20 | - {"_id": 2, "b": 200} 21 | nonuniqueIndexes: 22 | - {"b": -1} 23 | -------------------------------------------------------------------------------- /evergreen/make_docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DIR="$PWD" 4 | 5 | if [[ $(lsb_release -is 2>/dev/null) == "Ubuntu" ]]; then 6 | sudo apt install texlive texlive-latex-extra texlive-fonts-recommended -y 7 | else 8 | echo "skipping installation of deps for non-Ubuntu OS" 9 | fi 10 | 11 | MDFILE="$DIR/docs/overview.md" 12 | 13 | # Define the output PDF file name 14 | OUTPUT_PDF="MongoDB_JDBC_Guide.pdf" 15 | 16 | # Use pandoc to convert the markdown file to a PDF 17 | pandoc -f gfm -V geometry:a4paper -V geometry:margin=2cm --toc -s -o "$DIR/docs/$OUTPUT_PDF" $MDFILE 18 | 19 | # Inform the user of the output file 20 | echo "PDF generated: $OUTPUT_PDF" 21 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/expectedOutput/polymorphicAdditionalProperties.json: -------------------------------------------------------------------------------- 1 | {"bsonType": "object", 2 | "properties": { 3 | "bar": { 4 | "bsonType": "object", 5 | "properties": { 6 | "a": { 7 | "bsonType": "object", 8 | "additionalProperties": true 9 | }, 10 | "b": { 11 | "bsonType": "boolean", 12 | "additionalProperties": false 13 | }, 14 | "c": { 15 | "bsonType": "string", 16 | "additionalProperties": true 17 | }, 18 | "d": { 19 | "bsonType": "date" 20 | } 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /resources/license_header.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright $YEAR-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/input/polymorphicAdditionalProperties.json: -------------------------------------------------------------------------------- 1 | {"bsonType": "object", 2 | "properties": { 3 | "bar": { 4 | "bsonType": "object", 5 | "properties": { 6 | "a": { 7 | "bsonType": "object", 8 | "additionalProperties": { 9 | "props": "val" 10 | } 11 | }, 12 | "b": { 13 | "bsonType": "boolean", 14 | "additionalProperties": false 15 | }, 16 | "c": { 17 | "bsonType": "string", 18 | "additionalProperties": true 19 | }, 20 | "d": { 21 | "bsonType": "date" 22 | } 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | group = org.mongodb 2 | artifactId = adf-java-driver 3 | mongodbDriverVersion = 5.+ 4 | junitJupiterVersion = 5.5.+ 5 | mockitoVersion = 3.0.+ 6 | googleLintVersion = 1.+ 7 | bouncyCastleVersion = 1.+ 8 | guavaVersion = 32.0.1-jre 9 | lang3Version=3.+ 10 | commonsTextVersion=1.+ 11 | nexusDomain = http://localhost:8081/nexus 12 | oauth2OIDCVersion = 11.+ 13 | snakeYamlVersion = 2.+ 14 | thymeLeafVersion = 3.1.2.RELEASE 15 | # to disable publication of both SHA-256 and SHA-512 checksums which causes error in maven release 16 | systemProp.org.gradle.internal.publish.checksums.insecure = true 17 | cyclonedxBomName = sbom_without_team_name 18 | cyclonedxBomDestination = artifacts/ssdlc 19 | thirdpartyNoticeDir = reports/licenses 20 | thirdpartyNoticeName = THIRD-PARTY-LICENSE.txt 21 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/input/bsonTypeAsSetAndAnyOfToMergeWith.json: -------------------------------------------------------------------------------- 1 | { 2 | "bsonType": "object", 3 | "properties": { 4 | "bar": { 5 | "bsonType": [ 6 | "int", 7 | "object", 8 | "string", 9 | "bool", 10 | "null" 11 | ], 12 | "anyOf": [ 13 | { 14 | "bsonType": "null" 15 | }, 16 | { 17 | "bsonType": "bool", 18 | "additionalProperties": true 19 | }, 20 | { 21 | "bsonType": "object", 22 | "properties": { 23 | "a": { "bsonType": "string" } 24 | }, 25 | "required": [ 26 | "a" 27 | ] 28 | } 29 | ], 30 | "properties": { 31 | "a": {"bsonType": "int"} 32 | }, 33 | "required": [ 34 | "a" 35 | ] 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/input/polymorphicItems.json: -------------------------------------------------------------------------------- 1 | {"bsonType": "object", 2 | "properties": { 3 | "bar": { 4 | "bsonType": "object", 5 | "properties": { 6 | "a": { 7 | "bsonType": "array", 8 | "items": {"bsonType": "date"} 9 | }, 10 | "b": { 11 | "bsonType": "array", 12 | "items": [ 13 | { 14 | "anyOf": [ 15 | { 16 | "bsonType": "string" 17 | }, 18 | { 19 | "bsonType": "null" 20 | } 21 | ] 22 | }, 23 | { 24 | "bsonType": "boolean" 25 | } 26 | ], 27 | "additionalProperties": false 28 | }, 29 | "c": {"bsonType": "objectId"} 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/resources/X509AuthenticationTest/public_key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAry7rBd+vrbN9hupIT6SU 3 | sB0wQWYz8g9DGJVrpbKyS15nsOCSUZJW22RWWepJFSRHesHhDHRkpi7WjUWr6lPB 4 | Uqz2owRUpNnzJrX3G7Qx21Fy6Rf44u6vdtJzsdV8W4SbpLTRTD+A6m0LctAelUEL 5 | GnmbS7aVeM68HphGXTATIdwylFxmKQYbuPg3qV8lPXAxw2bORMNl7EQQTztu1OfK 6 | DqT+6DCqY6g3yqB5yUJj9ENaqsURd437h+kquYuMxmJ7uTnwWCWADOTuE12AJl4i 7 | UdXZ8m858xzK4m00ygLIYq56MNwLTbsAbydXO71toRUmWAWjqZfoVA3D9scR99wK 8 | Q6ojv9sJ0zDydONoZ4UePiO/ZKEULnvrKozN63F8HXq8JKfqfjbUjM5oE+VaFySr 9 | 3mH32syOZHZOuocAC68NNnYX49ti3q61i7j1LkYw2gVn9Z+cTtsprI8fCxKxFZPo 10 | YZcDudx8Bih827jr9Nt7sR2zK9cfbCEfLvejeo/opuIsPAYCZnA4btk+XgDjte8Y 11 | 69+5/xPZG1olKrxjxQoPZOLvPspQz5nFVFgrPXhN2YVec0/ng+qndJEKGpVlnQYN 12 | rM2y0TzIsREaidWz1rfteLTlCcmgiTkWPoXvm5C1e9LhNPYsRXI4yOqJ046rtKpi 13 | uicENHXhIuAckh9mf55TilECAwEAAQ== 14 | -----END PUBLIC KEY----- 15 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/expectedOutput/flattenAnyOf.json: -------------------------------------------------------------------------------- 1 | { 2 | "bsonType": "object", 3 | "anyOf": [ 4 | { 5 | "bsonType": "symbol" 6 | }, 7 | { 8 | "bsonType": "decimal" 9 | }, 10 | { 11 | "bsonType": "regex" 12 | }, 13 | { 14 | "bsonType": "objectId" 15 | }, 16 | { 17 | "bsonType": "date" 18 | }, 19 | { 20 | "bsonType": "double" 21 | } 22 | ], 23 | "properties": { 24 | "bar": { 25 | "anyOf": [ 26 | {"bsonType": "null"}, 27 | { 28 | "bsonType": "bool", 29 | "additionalProperties": false 30 | }, 31 | {"bsonType": "int"}, 32 | { 33 | "bsonType": "bool", 34 | "additionalProperties": true 35 | }, 36 | { 37 | "bsonType": "string" 38 | } 39 | ] 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/integration-test/java/com/mongodb/jdbc/integration/testharness/models/Tests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.integration.testharness.models; 18 | 19 | import java.util.List; 20 | 21 | public class Tests { 22 | public List tests; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/oidc/OidcTimeoutException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.oidc; 18 | 19 | public class OidcTimeoutException extends Exception { 20 | public OidcTimeoutException(String message) { 21 | super(message); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/integration-test/java/com/mongodb/jdbc/integration/testharness/models/TestData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.integration.testharness.models; 18 | 19 | import java.util.List; 20 | 21 | public class TestData { 22 | public List dataset; 23 | } 24 | -------------------------------------------------------------------------------- /resources/release/mongo_jdbc_compliance_report_template.md: -------------------------------------------------------------------------------- 1 | 2 | # Mongo JDBC Driver SSDLC Compliance Report - %VERSION% 3 | 4 | **Release Creator** 5 | %AUTHOR% - %AUTHOR_EMAIL% 6 | 7 | **Process Document** 8 | https://www.mongodb.com/resources/products/capabilities/supply-chain-security-in-mongodb-s-software-development-lifecycle 9 | 10 | **Tool used to track third party vulnerabilities** 11 | Silk Security 12 | 13 | **Third-Party Dependency Information** 14 | See SBOM at URL: %SBOM_URL% 15 | 16 | **Static Analysis Findings** 17 | See report at URL: %SARIF_URL% 18 | 19 | **Signature Information** 20 | Product is signed with signatures available which can be verified by following the instructions from our [README](https://github.com/mongodb/mongo-jdbc-driver#). 21 | 22 | **Known Vulnerabilities** 23 | Any vulnerabilities that may be shown in the links referenced above have been reviewed and accepted by the appropriate reviewers. 24 | -------------------------------------------------------------------------------- /gradle/deploy.gradle: -------------------------------------------------------------------------------- 1 | afterEvaluate { 2 | task publishMaven { 3 | group = 'publishing' 4 | dependsOn ':generateLicenseReport' 5 | if (releaseVersion.endsWith('-SNAPSHOT')) { 6 | description = 'Publishes snapshots to Sonatype' 7 | println("Will publish snapshots to Sonatype") 8 | dependsOn project.tasks.named('publishToSonatype') 9 | } else { 10 | description = 'Publishes a release and uploads to Sonatype / Maven Central' 11 | println("Will publish a release and uploads to Sonatype / Maven Central") 12 | if (project.name == rootProject.name) { 13 | dependsOn project.tasks.named('publishToSonatype') 14 | project.tasks.named('publishToSonatype').configure { 15 | finalizedBy(project.tasks.named('closeAndReleaseSonatypeStagingRepository')) 16 | } 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/MongoJsonSchemaResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc; 18 | 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | public class MongoJsonSchemaResult { 23 | public int ok; 24 | public Map metadata; 25 | public MongoVersionedJsonSchema schema; 26 | public List> selectOrder; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/mongosql/MongoSQLException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.mongosql; 18 | 19 | public class MongoSQLException extends Exception { 20 | public MongoSQLException(String message) { 21 | super(message); 22 | } 23 | 24 | public MongoSQLException(String message, Throwable cause) { 25 | super(message, cause); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/MongoSerializationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc; 18 | 19 | public class MongoSerializationException extends Exception { 20 | public MongoSerializationException(String message) { 21 | super(message); 22 | } 23 | 24 | public MongoSerializationException(String message, Throwable cause) { 25 | super(message, cause); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/DataLake.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc; 18 | 19 | public class DataLake { 20 | public String version; 21 | public String mongoSQLVersion; 22 | 23 | // Override toString for logging 24 | @Override 25 | public String toString() { 26 | return "DataLake{" 27 | + "version='" 28 | + version 29 | + '\'' 30 | + ", mongoSQLVersion=" 31 | + mongoSQLVersion 32 | + '}'; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/integration-test/java/com/mongodb/jdbc/integration/testharness/models/TestDataEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.integration.testharness.models; 18 | 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | public class TestDataEntry { 23 | public String db; 24 | public String collection; 25 | public String view; 26 | public List> docs; 27 | public List> docsExtJson; 28 | public Map schema; 29 | public List> nonuniqueIndexes; 30 | } 31 | -------------------------------------------------------------------------------- /src/test/resources/X509AuthenticationTest/no_pem_objects.pem: -------------------------------------------------------------------------------- 1 | ----- NOT PEM HEADER----- 2 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDVP/HLKsZR+B1u 3 | Av/LrHBZXoUluA/Qc52/lwW/oscXQ1UnJ6eD41zVeskPQ2VZv0eJcFN7Odm4dpnE 4 | UyahjizhTFYq1j3CYRIN46IUDoJ+PdjWxyyISbbIqmefDg8sRrRLaX0i7WNMkTLe 5 | wX1AsxwA137Iqkjjo2xA8ZfX1Pj8X8ZPLetQJGrQP6H0mh3EPGshsx2fJzx5B756 6 | 1rW9P/uZ/t/qwi/eWaDAOZ6Vu7uqhsstXN1IOL6jWdT/el9nS99D0MKhQm9gxoyH 7 | 8x5gRaohG5V7XWznmKCMBqxtxXysDbUzQwdiydd7KvnCz1ZLCIEcykdJPORXxk1D 8 | Xuo5Gb8bAgMBAAECggEAEAzpJ8Fw8UN4NGSj/x71l9LOH7nCV8F6YPmLeuu6cDnm 9 | 3PSwBMFZcxuNdyLuxaBotuOa81fpcLTDu98F6QjL815gNlPIwAQeLHU/jwkZvkm5 10 | mk5q2VkyMwx/klB0r01YQNYDddw7Nv/PJEZlvurPbURkkp+3SIoic2+1RFv1xfzs 11 | jQV6ttluqAZzmtZUUEdK8MLZkClRvv4Od0ALUYDF+sNghEQ2k35dS3dmNE+BfN3n 12 | 5V+wk4gqBblZGvvbsx0iC0cj4DfjB6o21dQeWan44+xkeOUOxR0vLNt5j267KXoZ 13 | qUGrnR5BdTIHn6sIb/1Y24DVLf2+KIFWhP4h24vp2QKBgQD8ztTH9womIuAr6z10 14 | fcN31gRp0whtTtEnsYUemOklrY8HDHo+8r8gLFOUzQj2XKAOgyl+o5jIyb2R8GB6 15 | aWyddhnmX4JiiYZQKv04fJopCNiqYkJRM+pjmKG20TEi++P1ldQABQRQ54knzQEM 16 | oHD+4gbIMSc7KXN13Q0fLAeLSQKBgQDX8T8qi35irpeT0l0ASbnmgp4X8gXUf9x9 17 | dvnXilijLjMnH7U+D949qHtbaNYCinOiErWjPc/MMRJFxYluN9X9eoLoOg+OZc8L 18 | ----- END NOT PEM HEADER----- 19 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/MongoListTablesResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc; 18 | 19 | public class MongoListTablesResult { 20 | public static final String TABLE = "table"; 21 | public static final String COLLECTION = "collection"; 22 | 23 | public String name; 24 | public String type; 25 | 26 | public void setType(String type) { 27 | // If mongodb type is COLLECTION, map it as TABLE. 28 | // Otherwise, keep the type as is. 29 | this.type = type.equalsIgnoreCase(COLLECTION) ? TABLE : type; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/expectedOutput/bsonTypeAsSetAndAnyOfToMergeWith.json: -------------------------------------------------------------------------------- 1 | { 2 | "additionalProperties": false, 3 | "bsonType": "object", 4 | "properties": { 5 | "bar": { 6 | "additionalProperties": false, 7 | "anyOf": [ 8 | { 9 | "additionalProperties": false, 10 | "bsonType": "object", 11 | "properties": { 12 | "a": { 13 | "bsonType": "string" 14 | } 15 | }, 16 | "required": [ 17 | "a" 18 | ] 19 | }, 20 | { 21 | "bsonType": "bool" 22 | }, 23 | { 24 | "bsonType": "int" 25 | }, 26 | { 27 | "additionalProperties": false, 28 | "bsonType": "object", 29 | "properties": { 30 | "a": { 31 | "bsonType": "int" 32 | } 33 | }, 34 | "required": [ 35 | "a" 36 | ] 37 | }, 38 | { 39 | "bsonType": "string" 40 | }, 41 | { 42 | "bsonType": "null" 43 | }, 44 | { 45 | "bsonType": "bool", 46 | "additionalProperties": true 47 | } 48 | ] 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/logging/AutoLoggable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.logging; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Annotation for identifying all classes which should log their public method entries. Used in 26 | * conjunction with LoggingAspect to provide auto-logging of public methods entry. 27 | */ 28 | @Retention(RetentionPolicy.CLASS) 29 | @Target({ElementType.TYPE, ElementType.METHOD}) 30 | public @interface AutoLoggable {} 31 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/logging/DisableAutoLogging.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.logging; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Annotation for identifying all methods which should be excluded from autologging the method 26 | * entry. Used in conjunction with LoggingAspect to provide auto-logging of public methods entry. 27 | */ 28 | @Retention(RetentionPolicy.CLASS) 29 | @Target({ElementType.TYPE, ElementType.METHOD}) 30 | public @interface DisableAutoLogging {} 31 | -------------------------------------------------------------------------------- /gradle/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # DO NOT ECHO COMMANDS AS THEY CONTAIN SECRETS! 4 | 5 | set -o errexit # Exit the script with error if any of the commands fail 6 | set +o verbose # Command echoing off. 7 | set +o xtrace # Disable command traces before executing them. 8 | 9 | ############################################ 10 | # Main Program # 11 | ############################################ 12 | echo "${RING_FILE_GPG_BASE64}" | base64 --decode >${PROJECT_DIRECTORY}/secring.gpg 13 | 14 | trap "rm ${PROJECT_DIRECTORY}/secring.gpg; exit" EXIT HUP 15 | 16 | export ORG_GRADLE_PROJECT_nexus_token_name=${NEXUS_TOKEN_NAME} 17 | export ORG_GRADLE_PROJECT_nexus_token=${NEXUS_TOKEN} 18 | export ORG_GRADLE_PROJECT_signing_key_id=${SIGNING_KEY_ID} 19 | export ORG_GRADLE_PROJECT_signing_password=${SIGNING_PASSWORD} 20 | export ORG_GRADLE_PROJECT_signing_secretKeyRingFile=${PROJECT_DIRECTORY}/secring.gpg 21 | export ORG_GRADLE_PROJECT_nexus_url=${NEXUS_URL} 22 | export ORG_GRADLE_PROJECT_nexus_snapshot_url=${NEXUS_SNAPSHOT_URL} 23 | 24 | set -o verbose # Command echoing on. 25 | set -o xtrace # Enable command traces before executing them. 26 | echo "Publishing snapshot or release" 27 | 28 | ./gradlew ${IS_RELEASE_PROP} -version 29 | ./gradlew ${IS_RELEASE_PROP} publishMaven --info 30 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/input/flattenAnyOf.json: -------------------------------------------------------------------------------- 1 | { 2 | "bsonType": "object", 3 | "anyOf": [ 4 | {"bsonType": "double"}, 5 | { 6 | "bsonType": "date" 7 | }, 8 | { 9 | "anyOf": [ 10 | {"bsonType": "regex"}, 11 | { 12 | "anyOf": [ 13 | { 14 | "bsonType": "symbol" 15 | }, 16 | { 17 | "bsonType": "objectId" 18 | }, 19 | { 20 | "bsonType": "decimal" 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | ], 27 | "properties": { 28 | "bar": { 29 | "anyOf": [ 30 | {"bsonType": "null"}, 31 | { 32 | "bsonType": "bool", 33 | "additionalProperties": false 34 | }, 35 | { 36 | "anyOf": [ 37 | {"bsonType": "int"}, 38 | { 39 | "anyOf": [ 40 | { 41 | "bsonType": "null" 42 | }, 43 | { 44 | "bsonType": "bool", 45 | "additionalProperties": true 46 | }, 47 | { 48 | "bsonType": "string" 49 | } 50 | ] 51 | } 52 | ] 53 | } 54 | ] 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /demo/src/test/java/com/mongodb/jdbc/utils/MongoSQLTestUtils.java: -------------------------------------------------------------------------------- 1 | package com.mongodb.jdbc.utils; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.Statement; 6 | 7 | public class MongoSQLTestUtils extends TestUtils { 8 | static final String URL = "jdbc:mongodb://localhost"; 9 | public static final String TEST_DB = "integration_test"; 10 | public static final String DEFAULT_TEST_COLLECTION = "test_collection"; 11 | 12 | @Override 13 | protected Connection connect() throws Exception { 14 | // Connects to local ADF instance 15 | java.util.Properties p = new java.util.Properties(); 16 | p.setProperty("user", System.getenv("ADF_TEST_LOCAL_USER")); 17 | p.setProperty("password", System.getenv("ADF_TEST_LOCAL_PWD")); 18 | p.setProperty("authSource", System.getenv("ADF_TEST_LOCAL_AUTH_DB")); 19 | p.setProperty("database", TEST_DB); 20 | p.setProperty("ssl", "false"); 21 | Connection conn = DriverManager.getConnection(URL, p); 22 | try { 23 | Statement stmt = conn.createStatement(); 24 | stmt.executeQuery("select 1 from " + DEFAULT_TEST_COLLECTION); 25 | } catch (Exception e) { 26 | e.printStackTrace(); 27 | throw e; 28 | } 29 | 30 | return conn; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /evergreen/monitor_gradle_tasks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | GRADLE_PID=$1 5 | 6 | echo "Gradle process started with PID $GRADLE_PID" 7 | 8 | # On Amazon Linux 2 hosts, the gradlew integrationTest command was hanging indefinitely. 9 | # This monitoring approach will detect build completion or failure even when the Gradle 10 | # process doesn't terminate properly and allows the task to complete. 11 | 12 | SECONDS=0 13 | TIMEOUT=1800 # 30 minute timeout 14 | 15 | while true; do 16 | if [ -f gradle_output.log ]; then 17 | if grep -q "BUILD SUCCESSFUL" gradle_output.log 2>/dev/null; then 18 | echo "Build successful!" 19 | EXITCODE=0 20 | break 21 | fi 22 | if grep -q "BUILD FAILED" gradle_output.log 2>/dev/null; then 23 | echo "Build failed!" 24 | EXITCODE=1 25 | break 26 | fi 27 | fi 28 | 29 | if (( SECONDS > TIMEOUT )); then 30 | echo "$TIMEOUT second timeout reached. Exiting with failure." 31 | EXITCODE=1 32 | break 33 | fi 34 | 35 | # Check if Gradle process is still running 36 | if ! kill -0 $GRADLE_PID 2>/dev/null; then 37 | echo "Gradle process has finished." 38 | wait $GRADLE_PID 39 | EXITCODE=$? 40 | break 41 | fi 42 | 43 | sleep 5 44 | done 45 | 46 | cat gradle_output.log 47 | 48 | kill $GRADLE_PID 2>/dev/null || true 49 | 50 | exit $EXITCODE 51 | -------------------------------------------------------------------------------- /src/test/resources/X509AuthenticationTest/no_private_key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDbzCCAlegAwIBAgIUeENaWblo/zUIG85V7XhVSLAAIWwwDQYJKoZIhvcNAQEL 3 | BQAwRzEiMCAGA1UEAwwZRW5jcnlwdGVkIFBLQ1MxIFRlc3QgQ2VydDEUMBIGA1UE 4 | CgwLRXhhbXBsZSBPcmcxCzAJBgNVBAYTAlVTMB4XDTI1MDcyMjEzNDczNloXDTI2 5 | MDcyMjEzNDczNlowRzEiMCAGA1UEAwwZRW5jcnlwdGVkIFBLQ1MxIFRlc3QgQ2Vy 6 | dDEUMBIGA1UECgwLRXhhbXBsZSBPcmcxCzAJBgNVBAYTAlVTMIIBIjANBgkqhkiG 7 | 9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqZ/5+4YxRdA1nym7f4lbDMXtb5kj1P4HJ0SR 8 | Ia5qbMcURSu6hePNJQvuW1rVtWsQY75eeM73RN4Vy0xjmEyA2Gv80yq7+mR9mj/V 9 | KM/C2YViZf8owDb0YftURuvboLbAtXXEaIxgLe/sC9B6zzfHgaiicWRdqW01WViA 10 | y2t22jyWpEfYlbEZ3rWkRv8SJw+6fAja6UkOTdAGqHZOTsD0lfsoRTCJWW1D+oEX 11 | mBmTqH6bnfQGwCZFGsxzglVbMU+NsPxniVUfiSUZboTENOoS4FSZyN0jPOhGTezp 12 | 098BkoB98LOISqTZx4tntn4vV1f8AoaQ+gE/blSbXnSKeDOG7wIDAQABo1MwUTAd 13 | BgNVHQ4EFgQUqjE+h7wLiPvr8F5tXKF8vhBxuYYwHwYDVR0jBBgwFoAUqjE+h7wL 14 | iPvr8F5tXKF8vhBxuYYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOC 15 | AQEALwWFtkgO0Ykd49ZCLAw1BRJ1fboOFdFp9lh7Q1SNFngOYuZVTQUgw4Ab2MET 16 | 6BEeDwUKCSxsf7mwf+CQ6NFwyc0jEbHvpPXneNa4hVU3TV7uShBlItDcySGy0NIn 17 | BycoslGovhyRQrOT5SATl1gbhzAitUtvPNac+rpzASQsqubvbEbWgaaUx3wNlojj 18 | lCcmjIR3JLqj9KWbtCFGb8HyTAb7022jIoahGxSvybqZ4nLNfssJAxca5ObWwNe5 19 | T7Q2htUDheor0+IdDK1F6gsx61/LWy+m+kqrypq+KEW/JIzNK3hio2XlMUNCkNhw 20 | QkICdrhcH54jcjop6BmGBAON4g== 21 | -----END CERTIFICATE----- 22 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/NoCheckStateJsonWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc; 18 | 19 | import java.io.Writer; 20 | import org.bson.json.JsonWriter; 21 | import org.bson.json.JsonWriterSettings; 22 | 23 | /** 24 | * NoCheckStateJsonWriter will allow writing of any Json value. It does not validate it is 25 | * constructing a valid document. Useful for writing Bson Values such as a BsonArray. 26 | */ 27 | public class NoCheckStateJsonWriter extends JsonWriter { 28 | 29 | public NoCheckStateJsonWriter(Writer writer, JsonWriterSettings settings) { 30 | super(writer, settings); 31 | } 32 | 33 | @Override 34 | protected boolean checkState(State[] validStates) { 35 | return true; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/oidc/manualtests/TestOidcAuthFlow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.oidc.manualtests; 18 | 19 | import com.mongodb.MongoCredential.OidcCallbackContext; 20 | import com.mongodb.jdbc.oidc.JdbcOidcCallbackContext; 21 | import com.mongodb.jdbc.oidc.OidcAuthFlow; 22 | import java.time.Duration; 23 | 24 | public class TestOidcAuthFlow { 25 | public static void main(String[] args) { 26 | OidcAuthFlow authFlow = new OidcAuthFlow(); 27 | 28 | Duration timeout = Duration.ofMinutes(5); 29 | OidcCallbackContext callbackContext = 30 | new JdbcOidcCallbackContext(timeout, 1, null, TestOidcUtils.IDP_INFO, null); 31 | 32 | TestOidcUtils.testAuthCodeFlow(callbackContext, authFlow); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/MongoRunCmdListTablesResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc; 18 | 19 | import java.util.ArrayList; 20 | 21 | public class MongoRunCmdListTablesResult { 22 | public CursorInfo cursor; 23 | 24 | public CursorInfo getCursor() { 25 | return cursor; 26 | } 27 | 28 | public static class CursorInfo { 29 | public long id; 30 | public String ns; 31 | public ArrayList firstBatch; 32 | 33 | public long getId() { 34 | return id; 35 | } 36 | 37 | public String getNs() { 38 | return ns; 39 | } 40 | 41 | public ArrayList getFirstBatch() { 42 | return firstBatch; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/Pair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc; 18 | 19 | import java.util.Objects; 20 | 21 | public class Pair { 22 | private L left; 23 | private R right; 24 | 25 | public Pair(L left, R right) { 26 | this.left = left; 27 | this.right = right; 28 | } 29 | 30 | public L left() { 31 | return left; 32 | } 33 | 34 | public R right() { 35 | return right; 36 | } 37 | 38 | @Override 39 | public boolean equals(Object o) { 40 | if (this == o) return true; 41 | if (o == null || getClass() != o.getClass()) return false; 42 | Pair pair = (Pair) o; 43 | return Objects.equals(left, pair.left) && Objects.equals(right, pair.right); 44 | } 45 | 46 | @Override 47 | public int hashCode() { 48 | return Objects.hash(left, right); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/oidc/JdbcIdpInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.oidc; 18 | 19 | import com.mongodb.MongoCredential; 20 | import com.mongodb.lang.Nullable; 21 | import java.util.List; 22 | 23 | public class JdbcIdpInfo implements MongoCredential.IdpInfo { 24 | private final String issuer; 25 | 26 | @Nullable private final String clientId; 27 | private final List requestScopes; 28 | 29 | public JdbcIdpInfo(String issuer, String clientId, List requestScopes) { 30 | this.issuer = issuer; 31 | this.clientId = clientId; 32 | this.requestScopes = requestScopes; 33 | } 34 | 35 | public String getIssuer() { 36 | return this.issuer; 37 | } 38 | 39 | @Nullable 40 | public String getClientId() { 41 | return this.clientId; 42 | } 43 | 44 | public List getRequestScopes() { 45 | return this.requestScopes; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/MongoVersionedJsonSchema.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc; 18 | 19 | import org.bson.codecs.pojo.annotations.BsonCreator; 20 | import org.bson.codecs.pojo.annotations.BsonProperty; 21 | 22 | public class MongoVersionedJsonSchema { 23 | public Integer version; 24 | public MongoJsonSchema mongoJsonSchema; 25 | 26 | /** Empty Json schema. */ 27 | public MongoVersionedJsonSchema() {} 28 | 29 | /** 30 | * Deserialized json schema from a 'sqlgetschema' command. 31 | * 32 | * @param version The schema version. 33 | * @param schema The schema. 34 | */ 35 | @BsonCreator 36 | public MongoVersionedJsonSchema( 37 | @BsonProperty("version") final Integer version, 38 | @BsonProperty("jsonSchema") JsonSchema schema) { 39 | this.version = version; 40 | this.mongoJsonSchema = MongoJsonSchema.toSimplifiedMongoJsonSchema(schema); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/mongosql/GetMongosqlTranslateVersionResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.mongosql; 18 | 19 | import static com.mongodb.jdbc.utils.BsonUtils.JSON_WRITER_NO_INDENT_SETTINGS; 20 | 21 | import com.mongodb.jdbc.MongoDriver; 22 | import com.mongodb.jdbc.utils.BsonUtils; 23 | import org.bson.codecs.Codec; 24 | import org.bson.codecs.pojo.annotations.BsonCreator; 25 | import org.bson.codecs.pojo.annotations.BsonProperty; 26 | 27 | public class GetMongosqlTranslateVersionResult { 28 | 29 | private static final Codec CODEC = 30 | MongoDriver.getCodecRegistry().get(GetMongosqlTranslateVersionResult.class); 31 | 32 | @BsonProperty("version") 33 | public final String version; 34 | 35 | @BsonCreator 36 | public GetMongosqlTranslateVersionResult(@BsonProperty("version") String version) { 37 | this.version = version; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return BsonUtils.toString(CODEC, this, JSON_WRITER_NO_INDENT_SETTINGS); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/mongosql/CheckDriverVersionResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.mongosql; 18 | 19 | import static com.mongodb.jdbc.utils.BsonUtils.JSON_WRITER_NO_INDENT_SETTINGS; 20 | 21 | import com.mongodb.jdbc.MongoDriver; 22 | import com.mongodb.jdbc.utils.BsonUtils; 23 | import org.bson.codecs.Codec; 24 | import org.bson.codecs.pojo.annotations.BsonCreator; 25 | import org.bson.codecs.pojo.annotations.BsonProperty; 26 | 27 | public class CheckDriverVersionResult { 28 | 29 | private static final Codec CODEC = 30 | MongoDriver.getCodecRegistry().get(CheckDriverVersionResult.class); 31 | 32 | @BsonProperty("compatible") 33 | public final Boolean compatible; 34 | 35 | @BsonCreator 36 | public CheckDriverVersionResult(@BsonProperty("compatible") Boolean compatible) { 37 | this.compatible = (compatible != null) ? compatible : false; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return BsonUtils.toString(CODEC, this, JSON_WRITER_NO_INDENT_SETTINGS); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/expectedOutput/simpleSchema.json: -------------------------------------------------------------------------------- 1 | {"bsonType": "object", 2 | "properties": { 3 | "bar": { 4 | "bsonType": "object", 5 | "properties": { 6 | "a": {}, 7 | "b": {"anyOf": []}, 8 | "c": {"bsonType": "string"}, 9 | "e": {"bsonType": "int"}, 10 | "f": {"bsonType": "double"}, 11 | "g": {"bsonType": "long"}, 12 | "h": {"bsonType": "decimal"}, 13 | "i": {"bsonType": "binData"}, 14 | "j": {"bsonType": "objectId"}, 15 | "k": {"bsonType": "bool"}, 16 | "l": {"bsonType": "date"}, 17 | "m": {"bsonType": "null"}, 18 | "n": {"bsonType": "regex"}, 19 | "o": {"bsonType": "dbPointer"}, 20 | "p": {"bsonType": "javascript"}, 21 | "q": {"bsonType": "symbol"}, 22 | "r": {"bsonType": "javascriptWithScope"}, 23 | "s": {"bsonType": "timestamp"}, 24 | "t": {"bsonType": "minKey"}, 25 | "u": {"bsonType": "maxKey"}, 26 | "v": { 27 | "bsonType": "array", 28 | "items":{} 29 | }, 30 | "w": { 31 | "anyOf": [ 32 | {"bsonType": "null"}, 33 | { 34 | "bsonType": "object", 35 | "properties": {}, 36 | "required": [], 37 | "additionalProperties": true 38 | } 39 | ] 40 | }, 41 | "x": { 42 | "bsonType": "string" 43 | }, 44 | "y": { 45 | "anyOf": [ 46 | {"bsonType": "string"}, 47 | {"bsonType": "int"} 48 | ] 49 | } 50 | }, 51 | "required": ["a", "b", "c"], 52 | "additionalProperties": false 53 | } 54 | }, 55 | "required": [], 56 | "additionalProperties": false 57 | } 58 | -------------------------------------------------------------------------------- /src/test/resources/X509AuthenticationTest/no_x509_certificate.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDVP/HLKsZR+B1u 3 | Av/LrHBZXoUluA/Qc52/lwW/oscXQ1UnJ6eD41zVeskPQ2VZv0eJcFN7Odm4dpnE 4 | UyahjizhTFYq1j3CYRIN46IUDoJ+PdjWxyyISbbIqmefDg8sRrRLaX0i7WNMkTLe 5 | wX1AsxwA137Iqkjjo2xA8ZfX1Pj8X8ZPLetQJGrQP6H0mh3EPGshsx2fJzx5B756 6 | 1rW9P/uZ/t/qwi/eWaDAOZ6Vu7uqhsstXN1IOL6jWdT/el9nS99D0MKhQm9gxoyH 7 | 8x5gRaohG5V7XWznmKCMBqxtxXysDbUzQwdiydd7KvnCz1ZLCIEcykdJPORXxk1D 8 | Xuo5Gb8bAgMBAAECggEAEAzpJ8Fw8UN4NGSj/x71l9LOH7nCV8F6YPmLeuu6cDnm 9 | 3PSwBMFZcxuNdyLuxaBotuOa81fpcLTDu98F6QjL815gNlPIwAQeLHU/jwkZvkm5 10 | mk5q2VkyMwx/klB0r01YQNYDddw7Nv/PJEZlvurPbURkkp+3SIoic2+1RFv1xfzs 11 | jQV6ttluqAZzmtZUUEdK8MLZkClRvv4Od0ALUYDF+sNghEQ2k35dS3dmNE+BfN3n 12 | 5V+wk4gqBblZGvvbsx0iC0cj4DfjB6o21dQeWan44+xkeOUOxR0vLNt5j267KXoZ 13 | qUGrnR5BdTIHn6sIb/1Y24DVLf2+KIFWhP4h24vp2QKBgQD8ztTH9womIuAr6z10 14 | fcN31gRp0whtTtEnsYUemOklrY8HDHo+8r8gLFOUzQj2XKAOgyl+o5jIyb2R8GB6 15 | aWyddhnmX4JiiYZQKv04fJopCNiqYkJRM+pjmKG20TEi++P1ldQABQRQ54knzQEM 16 | oHD+4gbIMSc7KXN13Q0fLAeLSQKBgQDX8T8qi35irpeT0l0ASbnmgp4X8gXUf9x9 17 | dvnXilijLjMnH7U+D949qHtbaNYCinOiErWjPc/MMRJFxYluN9X9eoLoOg+OZc8L 18 | h5EDdPQeL82wq9zyKesUTo00saaXzMbWl7vNyRLMdz/a/u6MMFMn5xaPnLXP4mgW 19 | Xy5GwJrzQwKBgQD8omSZABKwUaHbwdVEGHnBw6ndZvrA4Ua6d/gjv4MeF/cagCmZ 20 | xlOg/yr3RH50U9PPLNvGpg4EeTZsJN8E9V2JbYAsa72MYwpKCuvKCxqzbxe2DUNg 21 | ipTsupbAbwS/hSElRnj5HApYH0k88OzfhWXmEFHetOATizTK0ABQ6lsPoQKBgCZF 22 | ZFuG83RL2yNgsgjeCCt5VMmLpErgClTWJDt2EnWBN6Gkdfu01j95P7uYne0/WnUL 23 | +dMfnldjDwj8lHnLPYq6Dr9XovAqzQIPGb1SGf3LnRnFq9fjY/1qWo5POeZHbaoU 24 | pD05eLJyJAgNDHweCG7W/uGe9X4Nc0MbxVjWw99/AoGBAJwI6NHl8YqHHHIJ3Yws 25 | Y0PeJnpygyv1glfqq94t792NSU70X1VM6/TGEjADqB0+4HNiWZxNMH9zriYtAG2+ 26 | m8krxgboKgsz+JEQtyd6avIQEaB4ljWNALy46iaHkEEKG4EePptktHbfypANamGW 27 | tLVqj5lKZHbz4Jv/Sxl3WOWG 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /src/integration-test/java/com/mongodb/jdbc/integration/testharness/README.md: -------------------------------------------------------------------------------- 1 | ### Test Generator 2 | Included in the test harness is a test generator that will generate baseline configurations for test cases based on 3 | the `description`, `db`, and either `query` or `meta_function` fields for all test cases in the 4 | `resources/integration_test/tests` directory. 5 | #### Initial Tests 6 | Create a yaml file in the `resources/integration_test/tests` directory in the following format. The required fields 7 | are `description`, `db`, and one of either `sql` or `meta_function`. 8 | ``` 9 | # test.yaml 10 | tests: 11 | - description: test_case_description 12 | db: database_to_use 13 | sql: SQL Query 14 | 15 | - description: test_case_description 16 | db: database_to_use 17 | # meta_function takes an array. Function name followed by arguments. 18 | meta_function: [Function name, arg1, arg2, ..., argn] 19 | ``` 20 | #### Running 21 | ``` 22 | ./gradlew runTestGenerator 23 | ``` 24 | Generated files will be written to the `resources/generated_test` directory with the description as the 25 | filename prefix, one file per test case. 26 | 27 | To test the generated test cases, copy the file(s) to the `resources/integration_test/tests` directory and verify it 28 | passes the integration test. Once verified, commit the file in the `resources/integration_test/tests` directory to 29 | add it to the integration test. 30 | 31 | ### Data Loader 32 | #### Running 33 | ``` 34 | ./gradlew runDataloader 35 | ``` 36 | #### YAML Fields 37 | `db`: Database to use 38 | `collection`: Collection to use 39 | `docs`: Uses standard JSON to represent collection data. This is useful for simple types such as int and string. 40 | `docsExtJson`: uses extended JSON to represent collection data. This is useful for complex types such as binData and objectid. 41 | 42 | -------------------------------------------------------------------------------- /src/test/resources/mongoJsonSchemaTest/input/simpleSchema.json: -------------------------------------------------------------------------------- 1 | {"bsonType": "object", 2 | "properties": { 3 | "bar": { 4 | "bsonType": "object", 5 | "properties": { 6 | "a": {}, 7 | "b": {"anyOf": []}, 8 | "c": {"bsonType": "string"}, 9 | "e": {"bsonType": "int"}, 10 | "f": {"bsonType": "double"}, 11 | "g": {"bsonType": "long"}, 12 | "h": {"bsonType": "decimal"}, 13 | "i": {"bsonType": "binData"}, 14 | "j": {"bsonType": "objectId"}, 15 | "k": {"bsonType": "bool"}, 16 | "l": {"bsonType": "date"}, 17 | "m": {"bsonType": "null"}, 18 | "n": {"bsonType": "regex"}, 19 | "o": {"bsonType": "dbPointer"}, 20 | "p": {"bsonType": "javascript"}, 21 | "q": {"bsonType": "symbol"}, 22 | "r": {"bsonType": "javascriptWithScope"}, 23 | "s": {"bsonType": "timestamp"}, 24 | "t": {"bsonType": "minKey"}, 25 | "u": {"bsonType": "maxKey"}, 26 | "v": { 27 | "bsonType": "array", 28 | "items": { 29 | "anyOf": [ 30 | {"bsonType": "string"}, 31 | {"bsonType": "null"} 32 | ] 33 | } 34 | }, 35 | "w": { 36 | "anyOf": [ 37 | {"bsonType": "null"}, 38 | { 39 | "bsonType": "object", 40 | "properties": {}, 41 | "required": [], 42 | "additionalProperties": true 43 | } 44 | ] 45 | }, 46 | "x": { 47 | "bsonType": ["string"] 48 | }, 49 | "y": { 50 | "bsonType": ["string", "int"] 51 | } 52 | }, 53 | "required": ["a", "b", "c"], 54 | "additionalProperties": false 55 | } 56 | }, 57 | "required": [], 58 | "additionalProperties": false 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/oidc/manualtests/TestRFC8252Server.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.oidc.manualtests; 18 | 19 | import com.mongodb.jdbc.oidc.OidcResponse; 20 | import com.mongodb.jdbc.oidc.OidcTimeoutException; 21 | import com.mongodb.jdbc.oidc.RFC8252HttpServer; 22 | import java.io.IOException; 23 | /** 24 | * Main class to start the RFC8252HttpServer and wait for the OIDC response Used for testing the 25 | * serving of the HTML pages and the OIDC response 26 | */ 27 | public class TestRFC8252Server { 28 | public static void main(String[] args) { 29 | int port = RFC8252HttpServer.DEFAULT_REDIRECT_PORT; 30 | RFC8252HttpServer server = new RFC8252HttpServer(); 31 | try { 32 | server.start(); 33 | System.out.println("Server started on port " + port); 34 | 35 | // Wait for the OIDC response 36 | OidcResponse oidcResponse = server.getOidcResponse(); 37 | System.out.println("Server Result:\n" + oidcResponse.toString()); 38 | 39 | Thread.sleep(2000); 40 | } catch (IOException | OidcTimeoutException | InterruptedException e) { 41 | e.printStackTrace(); 42 | } finally { 43 | server.stop(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/oidc/JdbcOidcCallbackContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.oidc; 18 | 19 | import com.mongodb.MongoCredential.IdpInfo; 20 | import com.mongodb.MongoCredential.OidcCallbackContext; 21 | import java.time.Duration; 22 | 23 | public class JdbcOidcCallbackContext implements OidcCallbackContext { 24 | private Duration timeout; 25 | private int version; 26 | private String refreshToken; 27 | private IdpInfo idpInfo; 28 | private String userName; 29 | 30 | public JdbcOidcCallbackContext( 31 | Duration timeout, int version, String refreshToken, IdpInfo idpInfo, String userName) { 32 | this.timeout = timeout; 33 | this.version = version; 34 | this.refreshToken = refreshToken; 35 | this.idpInfo = idpInfo; 36 | this.userName = userName; 37 | } 38 | 39 | public String getUserName() { 40 | return this.userName; 41 | } 42 | 43 | public Duration getTimeout() { 44 | return this.timeout; 45 | } 46 | 47 | public int getVersion() { 48 | return this.version; 49 | } 50 | 51 | public String getRefreshToken() { 52 | return this.refreshToken; 53 | } 54 | 55 | public IdpInfo getIdpInfo() { 56 | return this.idpInfo; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /resources/authentication_test/X509/ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 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zkPq8XbThXJw/0vbd/bEwFZ19gH3tEjdCV 18 | uYf7cj0CAwEAAaNTMFEwHQYDVR0OBBYEFGGi0J1Cws/ZD4kTzoVCa+lJWe+jMB8G 19 | A1UdIwQYMBaAFGGi0J1Cws/ZD4kTzoVCa+lJWe+jMA8GA1UdEwEB/wQFMAMBAf8w 20 | DQYJKoZIhvcNAQELBQADggIBAFXXHefGNoN6cEwcR6Nkquarc0yVUgbboSJcoKkd 21 | q7UWcmIMPg9WFKTDIU08m+jZHOY4ILqbfqzStPuz9hi6BXZKCrUkhO3uhWgRmFDS 22 | 7+oZfHdRXG18KkSjE2l4NCoflXoFSQePjQ7C6n2NJgXZJcluzCUsNiFQ9ShrRnC/ 23 | BLWbvOmw6FArzVYV+roQD26w9jXnTpZUFs3qVdXthM16Gydf87DZ8BdDl9LQfUQ9 24 | i9nQIaL3U1mPeD7p2fKgBuyToKDlcxS8VRGhTYD+njSoqBUGxWQC94fMfqVYdRo4 25 | kByDS7inOE0KN+hQStndX3ki5LY10RhDVD/c1Xz9sRki5Gr//WzYRDlBEVxsZ0fj 26 | lJbbel7WO0bSEX92ZPRfNgLNlGjq9Z1KilTuf7yLlvU0RSN8seOvFMv2rUNJqnuP 27 | l22Dtt3WvWu+InyPmYJl/kDoDpNHmX3bvVH4DaAuobswZBpNVJ3QOo3A5jO/aL8z 28 | zyCtk/cg7d2AjngOagat4qwdvmNuoCkfHUcx3LjxelaoAMVptqH5ebPqmUCjHjuQ 29 | 5zDmTrRTvcMv6kaYdo4NzO0eHS/4NnprdbAH2Njlh5QioCRCrINiMIG/M53FAvEY 30 | 2WUr5n/EVveVXyNceFpWUBgAYK4zhz1l/DFGel131bFGbz76DVzwS9Y4UjkfpvWO 31 | JTBF 32 | -----END CERTIFICATE----- 33 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/oidc/JdbcOidcCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.oidc; 18 | 19 | import com.mongodb.MongoCredential.OidcCallback; 20 | import com.mongodb.MongoCredential.OidcCallbackContext; 21 | import com.mongodb.MongoCredential.OidcCallbackResult; 22 | import com.mongodb.jdbc.logging.MongoLogger; 23 | import javax.security.auth.RefreshFailedException; 24 | 25 | public class JdbcOidcCallback implements OidcCallback { 26 | private final OidcAuthFlow oidcAuthFlow; 27 | 28 | public JdbcOidcCallback() { 29 | this.oidcAuthFlow = new OidcAuthFlow(); 30 | } 31 | 32 | public JdbcOidcCallback(MongoLogger parentLogger) { 33 | this.oidcAuthFlow = new OidcAuthFlow(parentLogger); 34 | } 35 | 36 | public OidcCallbackResult onRequest(OidcCallbackContext callbackContext) { 37 | String refreshToken = callbackContext.getRefreshToken(); 38 | if (refreshToken != null && !refreshToken.isEmpty()) { 39 | try { 40 | return oidcAuthFlow.doRefresh(callbackContext); 41 | } catch (RefreshFailedException e) { 42 | throw new RuntimeException(e); 43 | } 44 | } else { 45 | try { 46 | return oidcAuthFlow.doAuthCodeFlow(callbackContext); 47 | } catch (OidcTimeoutException e) { 48 | throw new RuntimeException(e); 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/JsonSchema.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc; 18 | 19 | import java.util.Map; 20 | import java.util.Objects; 21 | import java.util.Set; 22 | import org.bson.BsonValue; 23 | 24 | // Simple POJO for deserializing jsonschema. 25 | // For more details on jsonSchema, see https://docs.mongodb.com/manual/reference/operator/query/jsonSchema/. 26 | public class JsonSchema { 27 | 28 | public BsonValue bsonType; 29 | public Map properties; 30 | public Set anyOf; 31 | public Set required; 32 | public BsonValue items; 33 | public BsonValue additionalProperties; 34 | 35 | @Override 36 | public boolean equals(Object obj) { 37 | if (!(obj instanceof MongoJsonSchema)) { 38 | return false; 39 | } 40 | MongoJsonSchema other = (MongoJsonSchema) obj; 41 | return Objects.equals(bsonType, other.bsonType) 42 | && Objects.equals(properties, other.properties) 43 | && Objects.equals(anyOf, other.anyOf) 44 | && Objects.equals(required, other.required) 45 | && Objects.equals(items, other.items) 46 | && Objects.equals(additionalProperties, other.additionalProperties); 47 | } 48 | 49 | @Override 50 | public int hashCode() { 51 | return Objects.hash(bsonType, properties, anyOf, required, items, additionalProperties); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/oidc/manualtests/TestOidcCallbackWithBadRefreshToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.oidc.manualtests; 18 | 19 | import com.mongodb.MongoCredential.OidcCallback; 20 | import com.mongodb.MongoCredential.OidcCallbackContext; 21 | import com.mongodb.MongoCredential.OidcCallbackResult; 22 | import com.mongodb.jdbc.oidc.JdbcOidcCallback; 23 | import com.mongodb.jdbc.oidc.JdbcOidcCallbackContext; 24 | import javax.security.auth.RefreshFailedException; 25 | 26 | public class TestOidcCallbackWithBadRefreshToken { 27 | 28 | public static void main(String[] args) { 29 | OidcCallback oidcCallback = new JdbcOidcCallback(); 30 | 31 | String badRefreshToken = "bad-refresh-token"; 32 | OidcCallbackContext context = 33 | new JdbcOidcCallbackContext(null, 1, badRefreshToken, TestOidcUtils.IDP_INFO, null); 34 | 35 | try { 36 | OidcCallbackResult result = oidcCallback.onRequest(context); 37 | System.out.println("This should not print, bad refresh token expected to fail."); 38 | System.out.println(result); 39 | } catch (Exception e) { 40 | if (e.getCause() instanceof RefreshFailedException) { 41 | System.err.println( 42 | "Expected RefreshFailedException occurred: " + e.getCause().getMessage()); 43 | } else { 44 | System.err.println("Unexpected error: " + e.getMessage()); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/integration-test/java/com/mongodb/jdbc/integration/testharness/models/TestEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.integration.testharness.models; 18 | 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | public class TestEntry { 23 | public String description; 24 | public String db; 25 | public String sql; 26 | public List meta_function; 27 | public String skip_reason; 28 | public Integer row_count; 29 | public Boolean row_count_gte; 30 | public Boolean ordered; 31 | public List duplicated_columns_names; 32 | public List expected_result; 33 | public List> expected_result_extended_json; 34 | public List expected_sql_type; 35 | public List expected_bson_type; 36 | public List expected_catalog_name; 37 | public List expected_column_class_name; 38 | public List expected_column_label; 39 | public List expected_column_display_size; 40 | public List expected_precision; 41 | public List expected_scale; 42 | public List expected_schema_name; 43 | public List expected_is_auto_increment; 44 | public List expected_is_case_sensitive; 45 | public List expected_is_currency; 46 | public List expected_is_definitely_writable; 47 | public List expected_is_nullable; 48 | public List expected_is_read_only; 49 | public List expected_is_searchable; 50 | public List expected_is_signed; 51 | public List expected_is_writable; 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/com/mongodb/jdbc/BsonUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc; 18 | 19 | import static org.junit.jupiter.api.Assertions.*; 20 | 21 | import com.mongodb.jdbc.utils.BsonUtils; 22 | import org.bson.BsonDocument; 23 | import org.bson.BsonInt32; 24 | import org.bson.BsonString; 25 | import org.junit.jupiter.api.Test; 26 | 27 | class BsonUtilsTest { 28 | 29 | @Test 30 | void testSerializeDeserialize() throws MongoSerializationException { 31 | BsonDocument originalDoc = 32 | new BsonDocument("name", new BsonString("Test")) 33 | .append("value", new BsonInt32(123)) 34 | .append("nested", new BsonDocument("key", new BsonString("value"))); 35 | 36 | byte[] serialized = BsonUtils.serialize(originalDoc); 37 | assertNotNull(serialized, "Serialized byte array should not be null"); 38 | assertTrue(serialized.length > 0, "Serialized byte array should have content"); 39 | 40 | BsonDocument deserializedDoc = BsonUtils.deserialize(serialized); 41 | assertNotNull(deserializedDoc, "Deserialized document should not be null"); 42 | assertEquals( 43 | originalDoc, 44 | deserializedDoc, 45 | "Original and deserialized documents should be equal"); 46 | } 47 | 48 | @Test 49 | void testSerializeNullDocument() { 50 | assertThrows( 51 | MongoSerializationException.class, 52 | () -> BsonUtils.serialize(null), 53 | "Serializing a null document should throw MongoSerializationException"); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/oidc/OidcResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.oidc; 18 | 19 | public class OidcResponse { 20 | private String code; 21 | private String state; 22 | private String error; 23 | private String errorDescription; 24 | 25 | public String getCode() { 26 | return code; 27 | } 28 | 29 | public String getState() { 30 | return state; 31 | } 32 | 33 | public String getError() { 34 | return error; 35 | } 36 | 37 | public String getErrorDescription() { 38 | return errorDescription; 39 | } 40 | 41 | public void setCode(String code) { 42 | this.code = code; 43 | } 44 | 45 | public void setState(String state) { 46 | this.state = state; 47 | } 48 | 49 | public void setError(String error) { 50 | this.error = error; 51 | } 52 | 53 | public void setErrorDescription(String errorDescription) { 54 | this.errorDescription = errorDescription; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | StringBuilder sb = new StringBuilder(); 60 | if (code != null) { 61 | sb.append("Code: ").append(code).append("\n"); 62 | } 63 | if (state != null) { 64 | sb.append("State: ").append(state).append("\n"); 65 | } 66 | if (error != null) { 67 | sb.append("Error: ").append(error).append("\n"); 68 | } 69 | if (errorDescription != null) { 70 | sb.append("Error Description: ").append(errorDescription).append("\n"); 71 | } 72 | return sb.toString(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/test/resources/X509AuthenticationTest/crl.pem: -------------------------------------------------------------------------------- 1 | Certificate Revocation List (CRL): 2 | Version 2 (0x1) 3 | Signature Algorithm: sha256WithRSAEncryption 4 | Issuer: /CN=CDriver CA/OU=Drivers/O=MongoDB/L=Reykjavik/ST=Reykjavik/C=IS 5 | Last Update: Apr 14 20:38:24 2016 GMT 6 | Next Update: May 14 20:38:24 2016 GMT 7 | CRL extensions: 8 | X509v3 CRL Number: 9 | 4096 10 | Revoked Certificates: 11 | Serial Number: 070144 12 | Revocation Date: Apr 14 20:38:24 2016 GMT 13 | Signature Algorithm: sha256WithRSAEncryption 14 | 77:1e:77:ec:37:f0:50:55:5b:da:9d:87:3e:4a:0c:72:d3:f7: 15 | 48:5c:27:18:10:cb:cc:cc:07:78:b6:d0:1f:0b:e1:b7:e7:28: 16 | ac:1e:a5:f7:65:c4:2c:73:65:14:a3:4a:98:3c:51:b6:d1:fc: 17 | 62:56:7a:bf:94:93:ce:fa:25:cf:de:ff:b9:05:79:5d:11:31: 18 | f2:17:8d:56:31:2a:4f:97:dc:a7:21:e1:5a:03:4f:86:a7:ec: 19 | 10:d6:5e:77:72:89:21:d8:7e:11:af:f3:50:19:36:55:e6:de: 20 | 14:1c:3e:d9:30:c3:dc:ac:b2:91:a1:45:56:46:38:a0:fa:2e: 21 | d8:65:e1:19:d1:f7:a3:25:b1:57:f1:54:05:13:87:78:0a:dd: 22 | 46:6d:dc:18:1b:4c:4e:d5:17:15:a8:fc:9d:39:51:e7:b4:48: 23 | 24:ac:28:c1:0e:1d:f0:ac:f9:4e:a2:61:b9:4d:4e:7d:e3:8b: 24 | 2a:10:46:63:2c:13:65:68:c4:b3:23:f5:30:26:c2:a8:ea:ac: 25 | 0f:8c:a0:8a:37:d3:27:88:f1:d4:95:38:8f:30:91:7b:9e:d8: 26 | ed:8d:9c:61:02:a0:5f:9b:97:69:06:05:b7:c2:ef:40:b4:1a: 27 | 8c:4c:ec:5f:8a:0e:1f:bb:fe:81:41:eb:3f:16:f5:75:03:06: 28 | 8b:c3:64:a2 29 | -----BEGIN X509 CRL----- 30 | MIIB4DCByQIBATANBgkqhkiG9w0BAQsFADBuMRMwEQYDVQQDEwpDRHJpdmVyIENB 31 | MRAwDgYDVQQLEwdEcml2ZXJzMRAwDgYDVQQKEwdNb25nb0RCMRIwEAYDVQQHEwlS 32 | ZXlramF2aWsxEjAQBgNVBAgTCVJleWtqYXZpazELMAkGA1UEBhMCSVMXDTE2MDQx 33 | NDIwMzgyNFoXDTE2MDUxNDIwMzgyNFowFjAUAgMHAUQXDTE2MDQxNDIwMzgyNFqg 34 | DzANMAsGA1UdFAQEAgIQADANBgkqhkiG9w0BAQsFAAOCAQEAdx537DfwUFVb2p2H 35 | PkoMctP3SFwnGBDLzMwHeLbQHwvht+corB6l92XELHNlFKNKmDxRttH8YlZ6v5ST 36 | zvolz97/uQV5XREx8heNVjEqT5fcpyHhWgNPhqfsENZed3KJIdh+Ea/zUBk2Vebe 37 | FBw+2TDD3KyykaFFVkY4oPou2GXhGdH3oyWxV/FUBROHeArdRm3cGBtMTtUXFaj8 38 | nTlR57RIJKwowQ4d8Kz5TqJhuU1OfeOLKhBGYywTZWjEsyP1MCbCqOqsD4ygijfT 39 | J4jx1JU4jzCRe57Y7Y2cYQKgX5uXaQYFt8LvQLQajEzsX4oOH7v+gUHrPxb1dQMG 40 | i8Nkog== 41 | -----END X509 CRL----- 42 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/logging/MongoSimpleFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.logging; 18 | 19 | import java.io.PrintWriter; 20 | import java.io.StringWriter; 21 | import java.util.Date; 22 | import java.util.logging.Formatter; 23 | import java.util.logging.LogRecord; 24 | 25 | public class MongoSimpleFormatter extends Formatter { 26 | private final String format = "[%1$tF %1$tT.%1$tL] [%4$s] %2$s: %5$s %6$s %n"; 27 | private final Date date = new Date(); 28 | 29 | @Override 30 | public String format(LogRecord record) { 31 | date.setTime(record.getMillis()); 32 | String source; 33 | if (record.getSourceClassName() != null) { 34 | source = record.getSourceClassName(); 35 | if (record.getSourceMethodName() != null) { 36 | source += " " + record.getSourceMethodName(); 37 | } 38 | } else { 39 | source = record.getLoggerName(); 40 | } 41 | String message = formatMessage(record); 42 | String throwable = ""; 43 | if (record.getThrown() != null) { 44 | StringWriter sw = new StringWriter(); 45 | PrintWriter pw = new PrintWriter(sw); 46 | pw.println(); 47 | record.getThrown().printStackTrace(pw); 48 | pw.close(); 49 | throwable = sw.toString(); 50 | } 51 | return String.format( 52 | format, 53 | date, 54 | source, 55 | record.getLoggerName(), 56 | record.getLevel().getLocalizedName(), 57 | message, 58 | throwable); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/BsonExplicitCursor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc; 18 | 19 | import com.mongodb.ServerAddress; 20 | import com.mongodb.ServerCursor; 21 | import com.mongodb.client.MongoCursor; 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | import org.bson.BsonDocument; 25 | 26 | /** 27 | * BsonExplicitCursor allows for creating an instance of MongoCursor from an explicit list of BSON 28 | * docs. Useful for testing or for any place static results are necessary. 29 | */ 30 | public class BsonExplicitCursor implements MongoCursor { 31 | private List docs; 32 | private int rowNum = 0; 33 | 34 | public static final BsonExplicitCursor EMPTY_CURSOR = new BsonExplicitCursor(new ArrayList<>()); 35 | 36 | public BsonExplicitCursor(List docs) { 37 | this.docs = docs; 38 | } 39 | 40 | @Override 41 | public void close() {} 42 | 43 | @Override 44 | public ServerAddress getServerAddress() { 45 | return new ServerAddress("127.0.0.1"); 46 | } 47 | 48 | @Override 49 | public ServerCursor getServerCursor() { 50 | return null; 51 | } 52 | 53 | @Override 54 | public boolean hasNext() { 55 | return rowNum < docs.size(); 56 | } 57 | 58 | @Override 59 | public BsonDocument next() { 60 | return docs.get(rowNum++); 61 | } 62 | 63 | @Override 64 | public int available() { 65 | return docs.size() - rowNum; 66 | } 67 | 68 | @Override 69 | public BsonDocument tryNext() { 70 | if (hasNext()) { 71 | return next(); 72 | } 73 | return null; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/oidc/manualtests/TestOidcUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.oidc.manualtests; 18 | 19 | import com.mongodb.MongoCredential.IdpInfo; 20 | import com.mongodb.MongoCredential.OidcCallbackContext; 21 | import com.mongodb.MongoCredential.OidcCallbackResult; 22 | import com.mongodb.jdbc.oidc.JdbcIdpInfo; 23 | import com.mongodb.jdbc.oidc.OidcAuthFlow; 24 | import java.util.Collections; 25 | import java.util.List; 26 | 27 | public class TestOidcUtils { 28 | 29 | public static String OIDC_ISSUER = "https://mongodb-dev.okta.com/oauth2/ausqrxbcr53xakaRR357"; 30 | public static String OIDC_CLIENT_ID = "0oarvap2r7PmNIBsS357"; 31 | public static final List OPENID_SCOPE = Collections.singletonList("openid"); 32 | 33 | public static final IdpInfo IDP_INFO = 34 | new JdbcIdpInfo(OIDC_ISSUER, OIDC_CLIENT_ID, OPENID_SCOPE); 35 | 36 | public static OidcCallbackResult testAuthCodeFlow( 37 | OidcCallbackContext callbackContext, OidcAuthFlow authFlow) { 38 | 39 | try { 40 | OidcCallbackResult result = authFlow.doAuthCodeFlow(callbackContext); 41 | if (result != null) { 42 | System.out.println("Access Token: " + result.getAccessToken()); 43 | System.out.println("Refresh Token: " + result.getRefreshToken()); 44 | return result; 45 | } else { 46 | System.out.println("Authentication failed."); 47 | } 48 | } catch (Exception e) { 49 | System.err.println( 50 | "An error occurred while running the OIDC authentication flow: " 51 | + e.getMessage()); 52 | e.printStackTrace(); 53 | } 54 | return null; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/oidc/manualtests/TestOidcCallbackWithShortTimeout.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.oidc.manualtests; 18 | 19 | import com.mongodb.MongoCredential.OidcCallback; 20 | import com.mongodb.MongoCredential.OidcCallbackContext; 21 | import com.mongodb.MongoCredential.OidcCallbackResult; 22 | import com.mongodb.jdbc.oidc.JdbcOidcCallback; 23 | import com.mongodb.jdbc.oidc.JdbcOidcCallbackContext; 24 | import com.mongodb.jdbc.oidc.OidcTimeoutException; 25 | import java.time.Duration; 26 | 27 | public class TestOidcCallbackWithShortTimeout { 28 | 29 | public static void main(String[] args) { 30 | OidcCallback oidcCallback = new JdbcOidcCallback(); 31 | 32 | Duration shortTimeout = Duration.ofSeconds(2); // intentionally short to trigger timeout 33 | OidcCallbackContext context = 34 | new JdbcOidcCallbackContext(shortTimeout, 1, null, TestOidcUtils.IDP_INFO, null); 35 | 36 | try { 37 | OidcCallbackResult result = oidcCallback.onRequest(context); 38 | // Timeout is expected when user input is required as it should take longer than 2 second. 39 | // It may pass if the user is already signed in and credentials are saved in the browser. 40 | System.out.println( 41 | "This should not print, timeout expected. Sign out of the IdP or clear the browser cache " 42 | + "to trigger a timeout."); 43 | System.out.println(result); 44 | } catch (Exception e) { 45 | if (e.getCause() instanceof OidcTimeoutException) { 46 | System.err.println( 47 | "Expected OidcTimeoutException occurred: " + e.getCause().getMessage()); 48 | } else { 49 | System.err.println("Unexpected error: " + e.getMessage()); 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/logging/QueryDiagnostics.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.logging; 18 | 19 | import static com.mongodb.jdbc.utils.BsonUtils.JSON_WRITER_NO_INDENT_SETTINGS; 20 | 21 | import com.mongodb.jdbc.MongoDriver; 22 | import com.mongodb.jdbc.MongoJsonSchema; 23 | import com.mongodb.jdbc.utils.BsonUtils; 24 | import org.bson.BsonArray; 25 | import org.bson.BsonDocument; 26 | import org.bson.codecs.Codec; 27 | import org.bson.codecs.pojo.annotations.BsonProperty; 28 | 29 | public class QueryDiagnostics { 30 | private static final Codec CODEC = 31 | MongoDriver.getCodecRegistry().get(QueryDiagnostics.class); 32 | 33 | @BsonProperty private String sqlQuery; 34 | @BsonProperty private BsonDocument queryCatalog; 35 | @BsonProperty private MongoJsonSchema resultSetSchema; 36 | @BsonProperty private BsonArray pipeline; 37 | 38 | public void setSqlQuery(String sqlQuery) { 39 | this.sqlQuery = sqlQuery; 40 | } 41 | 42 | public void setQueryCatalog(BsonDocument queryCatalog) { 43 | this.queryCatalog = queryCatalog; 44 | } 45 | 46 | public void setResultSetSchema(MongoJsonSchema resultSetSchema) { 47 | this.resultSetSchema = resultSetSchema; 48 | } 49 | 50 | public void setPipeline(BsonArray pipeline) { 51 | this.pipeline = pipeline; 52 | } 53 | 54 | public String getSqlQuery() { 55 | return sqlQuery; 56 | } 57 | 58 | public BsonDocument getQueryCatalog() { 59 | return queryCatalog; 60 | } 61 | 62 | public MongoJsonSchema getResultSetSchema() { 63 | return resultSetSchema; 64 | } 65 | 66 | public BsonArray getPipeline() { 67 | return pipeline; 68 | } 69 | 70 | @Override 71 | public String toString() { 72 | return BsonUtils.toString(CODEC, this, JSON_WRITER_NO_INDENT_SETTINGS); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/mongosql/GetNamespacesResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.mongosql; 18 | 19 | import static com.mongodb.jdbc.utils.BsonUtils.JSON_WRITER_NO_INDENT_SETTINGS; 20 | 21 | import com.mongodb.jdbc.MongoDriver; 22 | import com.mongodb.jdbc.utils.BsonUtils; 23 | import java.util.List; 24 | import org.bson.codecs.Codec; 25 | import org.bson.codecs.pojo.annotations.BsonCreator; 26 | import org.bson.codecs.pojo.annotations.BsonProperty; 27 | 28 | public class GetNamespacesResult { 29 | 30 | private static final Codec CODEC = 31 | MongoDriver.getCodecRegistry().get(GetNamespacesResult.class); 32 | 33 | @BsonProperty("namespaces") 34 | public final List namespaces; 35 | 36 | @BsonCreator 37 | public GetNamespacesResult(@BsonProperty("namespaces") List namespaces) { 38 | this.namespaces = namespaces; 39 | } 40 | 41 | public static class Namespace { 42 | private static final Codec CODEC = 43 | MongoDriver.getCodecRegistry().get(Namespace.class); 44 | 45 | @BsonProperty("database") 46 | public final String database; 47 | 48 | @BsonProperty("collection") 49 | public final String collection; 50 | 51 | @BsonCreator 52 | public Namespace( 53 | @BsonProperty("database") String database, 54 | @BsonProperty("collection") String collection) { 55 | this.database = database; 56 | this.collection = collection; 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return BsonUtils.toString(CODEC, this, JSON_WRITER_NO_INDENT_SETTINGS); 62 | } 63 | } 64 | 65 | @Override 66 | public String toString() { 67 | return BsonUtils.toString(CODEC, this, JSON_WRITER_NO_INDENT_SETTINGS); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/MongoColumnInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc; 18 | 19 | import org.apache.commons.lang3.builder.ToStringBuilder; 20 | import org.apache.commons.lang3.builder.ToStringStyle; 21 | import org.bson.BsonType; 22 | 23 | public class MongoColumnInfo { 24 | private final String datasource; 25 | private final String field; 26 | private final BsonTypeInfo bsonTypeInfo; 27 | private final boolean isPolymorphic; 28 | private final int nullable; 29 | 30 | MongoColumnInfo(String datasource, String field, BsonTypeInfo bsonTypeInfo, int nullability) { 31 | this.datasource = datasource; 32 | this.field = field; 33 | this.bsonTypeInfo = bsonTypeInfo; 34 | this.nullable = nullability; 35 | this.isPolymorphic = bsonTypeInfo == BsonTypeInfo.BSON_BSON; 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 41 | } 42 | 43 | public boolean isPolymorphic() { 44 | return isPolymorphic; 45 | } 46 | 47 | public BsonType getBsonTypeEnum() { 48 | return bsonTypeInfo.getBsonType(); 49 | } 50 | 51 | public String getBsonTypeName() { 52 | return bsonTypeInfo.getBsonName(); 53 | } 54 | 55 | public int getJDBCType() { 56 | return bsonTypeInfo.getJdbcType(); 57 | } 58 | 59 | public int getNullability() { 60 | return nullable; 61 | } 62 | 63 | public String getColumnName() { 64 | return field; 65 | } 66 | 67 | public String getColumnAlias() { 68 | return field; 69 | } 70 | 71 | public String getTableName() { 72 | return datasource; 73 | } 74 | 75 | public String getTableAlias() { 76 | return datasource; 77 | } 78 | 79 | public String getDatabase() { 80 | return ""; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/oidc/manualtests/TestOidcCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.oidc.manualtests; 18 | 19 | import com.mongodb.MongoCredential.OidcCallback; 20 | import com.mongodb.MongoCredential.OidcCallbackContext; 21 | import com.mongodb.MongoCredential.OidcCallbackResult; 22 | import com.mongodb.jdbc.oidc.JdbcOidcCallback; 23 | import com.mongodb.jdbc.oidc.JdbcOidcCallbackContext; 24 | 25 | public class TestOidcCallback { 26 | 27 | public static void main(String[] args) { 28 | OidcCallback oidcCallback = new JdbcOidcCallback(); 29 | 30 | OidcCallbackContext initialContext = 31 | new JdbcOidcCallbackContext(null, 1, null, TestOidcUtils.IDP_INFO, null); 32 | try { 33 | OidcCallbackResult initialResult = oidcCallback.onRequest(initialContext); 34 | if (initialResult != null) { 35 | System.out.println("Access Token: " + initialResult.getAccessToken()); 36 | System.out.println("Refresh Token: " + initialResult.getRefreshToken()); 37 | } else { 38 | System.out.println("Authentication failed."); 39 | } 40 | OidcCallbackContext refreshContext = 41 | new JdbcOidcCallbackContext( 42 | null, 1, initialResult.getRefreshToken(), TestOidcUtils.IDP_INFO, null); 43 | OidcCallbackResult refreshResult = oidcCallback.onRequest(refreshContext); 44 | if (refreshResult != null) { 45 | System.out.println("Refreshed Access Token: " + refreshResult.getAccessToken()); 46 | System.out.println("Refreshed Refresh Token: " + refreshResult.getRefreshToken()); 47 | } else { 48 | System.out.println("Refresh token flow failed."); 49 | } 50 | } catch (Exception e) { 51 | System.err.println("Error during OIDC callback test: " + e.getMessage()); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/mongosql/TranslateResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.mongosql; 18 | 19 | import static com.mongodb.jdbc.utils.BsonUtils.JSON_WRITER_NO_INDENT_SETTINGS; 20 | 21 | import com.mongodb.jdbc.JsonSchema; 22 | import com.mongodb.jdbc.MongoDriver; 23 | import com.mongodb.jdbc.MongoJsonSchema; 24 | import com.mongodb.jdbc.utils.BsonUtils; 25 | import java.util.List; 26 | import org.bson.BsonDocument; 27 | import org.bson.codecs.Codec; 28 | import org.bson.codecs.pojo.annotations.BsonCreator; 29 | import org.bson.codecs.pojo.annotations.BsonProperty; 30 | 31 | public class TranslateResult { 32 | 33 | private static final Codec CODEC = 34 | MongoDriver.getCodecRegistry().get(TranslateResult.class); 35 | 36 | public final String targetDb; 37 | public final String targetCollection; 38 | public final List pipeline; 39 | public final MongoJsonSchema resultSetSchema; 40 | public final List> selectOrder; 41 | 42 | @BsonCreator 43 | public TranslateResult( 44 | @BsonProperty("target_db") String targetDb, 45 | @BsonProperty("target_collection") String targetCollection, 46 | @BsonProperty("pipeline") List pipeline, 47 | @BsonProperty("result_set_schema") JsonSchema resultSetSchema, 48 | @BsonProperty("select_order") List> selectOrder) { 49 | this.targetDb = targetDb; 50 | this.targetCollection = targetCollection; 51 | this.pipeline = pipeline; 52 | this.resultSetSchema = 53 | (resultSetSchema != null) 54 | ? MongoJsonSchema.toSimplifiedMongoJsonSchema(resultSetSchema) 55 | : null; 56 | this.selectOrder = selectOrder; 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return BsonUtils.toString(CODEC, this, JSON_WRITER_NO_INDENT_SETTINGS); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/oidc/manualtests/TestOidcAuthFlowAndRefresh.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.oidc.manualtests; 18 | 19 | import com.mongodb.MongoCredential.OidcCallbackContext; 20 | import com.mongodb.MongoCredential.OidcCallbackResult; 21 | import com.mongodb.jdbc.oidc.JdbcOidcCallbackContext; 22 | import com.mongodb.jdbc.oidc.OidcAuthFlow; 23 | import java.time.Duration; 24 | 25 | public class TestOidcAuthFlowAndRefresh { 26 | public static void main(String[] args) { 27 | OidcAuthFlow authFlow = new OidcAuthFlow(); 28 | 29 | Duration timeout = Duration.ofMinutes(5); 30 | OidcCallbackContext callbackContext = 31 | new JdbcOidcCallbackContext(timeout, 1, null, TestOidcUtils.IDP_INFO, null); 32 | 33 | OidcCallbackResult result = TestOidcUtils.testAuthCodeFlow(callbackContext, authFlow); 34 | if (result != null) { 35 | // get refresh token from the AuthCodeFLow result 36 | OidcCallbackContext refreshContext = 37 | new JdbcOidcCallbackContext( 38 | timeout, 1, result.getRefreshToken(), TestOidcUtils.IDP_INFO, null); 39 | try { 40 | OidcCallbackResult refreshResult = authFlow.doRefresh(refreshContext); 41 | if (refreshResult != null) { 42 | System.out.println("Refreshed Access Token: " + refreshResult.getAccessToken()); 43 | System.out.println( 44 | "Refreshed Refresh Token: " + refreshResult.getRefreshToken()); 45 | } else { 46 | System.out.println("Refresh token flow failed."); 47 | } 48 | } catch (Exception e) { 49 | System.err.println( 50 | "An error occurred while running the refresh token flow: " 51 | + e.getMessage()); 52 | e.printStackTrace(); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/SortableBsonDocument.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc; 18 | 19 | import java.util.List; 20 | import org.bson.BsonDocument; 21 | 22 | public class SortableBsonDocument extends BsonDocument implements Comparable { 23 | 24 | static class SortSpec { 25 | String key; 26 | ValueType type; 27 | 28 | SortSpec(String key, ValueType type) { 29 | this.key = key; 30 | this.type = type; 31 | } 32 | } 33 | 34 | enum ValueType { 35 | String, 36 | Int, 37 | Boolean, 38 | } 39 | 40 | List sortSpecs; 41 | BsonDocument nestedDocValue; 42 | 43 | SortableBsonDocument(List sortSpecs, String key, BsonDocument docValue) { 44 | super(key, docValue); 45 | 46 | this.sortSpecs = sortSpecs; 47 | this.nestedDocValue = docValue; 48 | } 49 | 50 | @Override 51 | public int compareTo(SortableBsonDocument o) { 52 | int r = 0; 53 | for (SortSpec sortSpec : this.sortSpecs) { 54 | switch (sortSpec.type) { 55 | case String: 56 | r = 57 | this.nestedDocValue 58 | .getString(sortSpec.key) 59 | .compareTo(o.nestedDocValue.getString(sortSpec.key)); 60 | break; 61 | case Int: 62 | r = 63 | this.nestedDocValue 64 | .getInt32(sortSpec.key) 65 | .compareTo(o.nestedDocValue.getInt32(sortSpec.key)); 66 | break; 67 | case Boolean: 68 | r = 69 | this.nestedDocValue 70 | .getBoolean(sortSpec.key) 71 | .compareTo(o.nestedDocValue.getBoolean(sortSpec.key)); 72 | break; 73 | } 74 | 75 | if (r != 0) { 76 | return r; 77 | } 78 | } 79 | 80 | return r; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/BuildInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc; 18 | 19 | import java.util.List; 20 | import java.util.Set; 21 | import org.bson.codecs.pojo.annotations.BsonCreator; 22 | import org.bson.codecs.pojo.annotations.BsonProperty; 23 | 24 | public class BuildInfo { 25 | private String fullVersion; 26 | private List versionArray; 27 | public Set modules; 28 | public int ok; 29 | 30 | public DataLake dataLake; 31 | 32 | @BsonCreator 33 | public BuildInfo( 34 | @BsonProperty("version") String version, 35 | @BsonProperty("versionArray") List versionArray, 36 | @BsonProperty("modules") Set modules, 37 | @BsonProperty("ok") int ok, 38 | @BsonProperty("dataLake") DataLake dataLake) 39 | throws IndexOutOfBoundsException { 40 | this.fullVersion = version; 41 | this.versionArray = versionArray; 42 | if (dataLake != null) { 43 | this.fullVersion += "." + dataLake.version + "." + dataLake.mongoSQLVersion; 44 | } 45 | this.dataLake = dataLake; 46 | this.ok = ok; 47 | this.modules = modules; 48 | } 49 | 50 | public String getFullVersion() { 51 | return this.fullVersion; 52 | } 53 | 54 | public int getMajorVersion() throws IndexOutOfBoundsException { 55 | return this.versionArray.get(0); 56 | } 57 | 58 | public int getMinorVersion() throws IndexOutOfBoundsException { 59 | return this.versionArray.get(1); 60 | } 61 | 62 | // Override toString for logging 63 | @Override 64 | public String toString() { 65 | return "BuildInfo{" 66 | + "fullVersion='" 67 | + fullVersion 68 | + '\'' 69 | + ", versionArray=" 70 | + versionArray 71 | + ", majorVersion=" 72 | + this.getMajorVersion() 73 | + ", minorVersion=" 74 | + this.getMinorVersion() 75 | + ", modules=" 76 | + modules 77 | + ", ok=" 78 | + ok 79 | + ", dataLake=" 80 | + dataLake 81 | + '}'; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/integration-test/java/com/mongodb/jdbc/integration/AuthGSSAPIIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.integration; 18 | 19 | import static org.junit.jupiter.api.Assertions.*; 20 | 21 | import java.sql.*; 22 | import java.util.Properties; 23 | import org.junit.jupiter.api.BeforeEach; 24 | import org.junit.jupiter.api.Test; 25 | 26 | public class AuthGSSAPIIntegrationTest { 27 | private String mongoUri; 28 | 29 | @BeforeEach 30 | public void setUp() { 31 | mongoUri = System.getenv("MONGODB_URI"); 32 | if (mongoUri == null || mongoUri.isEmpty()) { 33 | throw new RuntimeException("MONGODB_URI must be set for GSSAPI test"); 34 | } 35 | } 36 | 37 | @Test 38 | public void testGSSAPIConnectionBasicSucceeds() { 39 | Properties props = new Properties(); 40 | props.setProperty("database", "test"); 41 | props.setProperty("jaasconfigpath", "./resources/authentication_test/GSSAPI/jaas.config"); 42 | props.setProperty("gssapilogincontextname", "mongodb.gssapi"); 43 | props.setProperty("gssapiserverauth", "true"); 44 | 45 | try (Connection conn = DriverManager.getConnection(mongoUri, props)) { 46 | DatabaseMetaData dbmd = conn.getMetaData(); 47 | ResultSet catalogs = dbmd.getCatalogs(); 48 | while (catalogs.next()) { 49 | System.out.println("Catalog: " + catalogs.getString(1)); 50 | } 51 | fail("Should not succeed - expected $documents error"); 52 | 53 | } catch (SQLException e) { 54 | // Traverse the cause chain 55 | Throwable current = e; 56 | boolean hasDocumentsError = false; 57 | 58 | while (current != null) { 59 | String msg = current.getMessage(); 60 | System.out.println("Error Message: " + msg); 61 | if (msg != null && msg.contains("$documents")) { 62 | hasDocumentsError = true; 63 | break; 64 | } 65 | current = current.getCause(); 66 | } 67 | 68 | assertTrue( 69 | hasDocumentsError, 70 | "Expected error to contain '$documents' in the exception chain"); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/integration-test/java/com/mongodb/jdbc/integration/AuthX509IntegrationTestBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.integration; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertNotNull; 20 | 21 | import java.sql.Connection; 22 | import java.sql.DriverManager; 23 | import java.sql.SQLException; 24 | import java.util.Properties; 25 | import javax.net.ssl.*; 26 | import org.junit.jupiter.api.BeforeEach; 27 | 28 | public abstract class AuthX509IntegrationTestBase { 29 | protected static final String LOCAL_PORT_ENV_VAR = "LOCAL_MDB_PORT_ENT"; 30 | protected static final String PASSWORD_ENV_VAR = "ADF_TEST_LOCAL_PWD"; 31 | protected static final String X509_CERT_PATH_PROPERTY = "x509PemPath"; 32 | 33 | protected String mongoPort; 34 | protected String passwordEnv; 35 | 36 | @BeforeEach 37 | public void setUp() { 38 | mongoPort = System.getenv(LOCAL_PORT_ENV_VAR); 39 | assertNotNull(mongoPort, "Environment variable " + LOCAL_PORT_ENV_VAR + " must be set"); 40 | passwordEnv = System.getenv(PASSWORD_ENV_VAR); 41 | } 42 | 43 | protected Connection connectWithX509(String pemPath, String passphrase) throws SQLException { 44 | return connectWithX509(pemPath, passphrase, null, null); 45 | } 46 | 47 | protected Connection connectWithX509( 48 | String pemPath, String passphrase, String tlsCaFile, String uriOption) 49 | throws SQLException { 50 | String uri = 51 | "jdbc:mongodb://localhost:" 52 | + mongoPort 53 | + "/?authSource=$external&authMechanism=MONGODB-X509&tls=true"; 54 | 55 | if (uriOption != null) { 56 | uri = uri + "&" + uriOption; 57 | } 58 | 59 | Properties properties = new Properties(); 60 | properties.setProperty("database", "test"); 61 | 62 | if (pemPath != null) { 63 | properties.setProperty(X509_CERT_PATH_PROPERTY, pemPath); 64 | } 65 | if (passphrase != null) { 66 | properties.setProperty("password", passphrase); 67 | } 68 | if (tlsCaFile != null) { 69 | properties.setProperty("tlscafile", tlsCaFile); 70 | } 71 | 72 | return DriverManager.getConnection(uri, properties); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/integration-test/java/com/mongodb/jdbc/integration/testharness/TestTypeInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.integration.testharness; 18 | 19 | import java.lang.reflect.Field; 20 | import java.sql.DatabaseMetaData; 21 | import java.sql.Types; 22 | 23 | public class TestTypeInfo { 24 | private static final String COLUMN_NO_NULLS = "columnNoNulls"; 25 | private static final String COLUMN_NULLABLE = "columnNullable"; 26 | private static final String COLUMN_NULLABLE_UNKNOWN = "columnNullableUnknown"; 27 | 28 | public static int typesStringToInt(String type) throws IllegalAccessException { 29 | for (Field field : Types.class.getFields()) { 30 | if (field.getName().equalsIgnoreCase(type)) { 31 | return (field.getInt(new Object())); 32 | } 33 | } 34 | throw new IllegalArgumentException("unknown type: " + type); 35 | } 36 | 37 | public static String typesIntToString(int type) throws IllegalAccessException { 38 | for (Field field : Types.class.getFields()) { 39 | if (type == field.getInt(new Object())) { 40 | return (field.getName()); 41 | } 42 | } 43 | throw new IllegalArgumentException("unknown type: " + type); 44 | } 45 | 46 | public static int nullableStringToInt(String type) { 47 | if (type.toUpperCase().equals(COLUMN_NO_NULLS.toUpperCase())) { 48 | return DatabaseMetaData.columnNoNulls; 49 | } else if (type.toUpperCase().equals(COLUMN_NULLABLE.toUpperCase())) { 50 | return DatabaseMetaData.columnNullable; 51 | } else if (type.toUpperCase().equals(COLUMN_NULLABLE_UNKNOWN.toUpperCase())) { 52 | return DatabaseMetaData.columnNullableUnknown; 53 | } 54 | throw new IllegalArgumentException("unknown nullable type: " + type); 55 | } 56 | 57 | public static String nullableIntToString(int type) { 58 | switch (type) { 59 | case DatabaseMetaData.columnNoNulls: 60 | return COLUMN_NO_NULLS; 61 | case DatabaseMetaData.columnNullable: 62 | return COLUMN_NULLABLE; 63 | case DatabaseMetaData.columnNullableUnknown: 64 | return COLUMN_NULLABLE_UNKNOWN; 65 | } 66 | throw new IllegalArgumentException("unknown nullable type: " + type); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/logging/LoggingAspect.aj: -------------------------------------------------------------------------------- 1 | package com.mongodb.jdbc.logging; 2 | 3 | import com.mongodb.MongoException; 4 | import java.sql.SQLException; 5 | import java.util.Locale; 6 | import java.util.Properties; 7 | import java.util.logging.Level; 8 | import org.aspectj.lang.JoinPoint; 9 | import org.bson.BsonValue; 10 | 11 | public aspect LoggingAspect perthis(execution(com.mongodb.jdbc.*.new(..))) 12 | { 13 | private MongoLogger logger = null; 14 | 15 | pointcut setLogger(MongoLogger logger): set(MongoLogger *.*) && args(logger) && !within(LoggingAspect) ; 16 | 17 | // Around setLogger() advice 18 | Object around(MongoLogger arg): setLogger(arg) { 19 | this.logger = arg; 20 | return proceed(arg); 21 | } 22 | 23 | before() : (execution(public * @AutoLoggable com.mongodb.jdbc.*.*(..))|| 24 | execution(@AutoLoggable public * com.mongodb.jdbc.*.*(..))) && 25 | !@annotation(com.mongodb.jdbc.logging.DisableAutoLogging) && 26 | !within(LoggingAspect) { 27 | if (null != logger) { 28 | final StringBuilder b = new StringBuilder(thisJoinPoint.getSignature().getName()); 29 | Object[] params = thisJoinPoint.getArgs(); 30 | if (params.length > 0) { 31 | b.append("("); 32 | for (int i = 0; i < params.length; i++) { 33 | // Obfuscate String and BsonValue parameters 34 | if (params[i] instanceof String) { 35 | b.append("***"); 36 | } 37 | else if (params[i] instanceof BsonValue) { 38 | b.append("Bson"); 39 | char bsonTypeName[] = 40 | ((BsonValue)params[i]).getBsonType().toString().toLowerCase().toCharArray(); 41 | bsonTypeName[0] = Character.toUpperCase(bsonTypeName[0]); 42 | b.append(bsonTypeName.toString()); 43 | b.append("{***}"); 44 | } 45 | else if (params[i] instanceof Properties) { 46 | b.append(((Properties)params[i]).stringPropertyNames()); 47 | } 48 | else 49 | { 50 | b.append(params[i]); 51 | } 52 | b.append(", "); 53 | } 54 | b.delete(b.length()-2, b.length()); 55 | b.append(")"); 56 | } 57 | else 58 | { 59 | b.append("()"); 60 | } 61 | logger.logMethodEntry(thisJoinPoint.getSignature().getDeclaringTypeName(), b.toString()); 62 | } 63 | } 64 | 65 | after () throwing (Exception e) : execution(* *.*(..)) && !within(LoggingAspect) 66 | { 67 | if (null != logger) { 68 | logger.logError( 69 | thisJoinPoint.getSignature().getDeclaringTypeName(), 70 | "Error in " + thisJoinPoint.getSignature().toShortString(), 71 | e); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /demo/src/main/java/com/mongodb/jdbc/demo/Main.java: -------------------------------------------------------------------------------- 1 | package com.mongodb.jdbc.demo; 2 | 3 | import java.sql.*; 4 | import java.util.TimeZone; 5 | import java.util.Calendar; 6 | import java.util.GregorianCalendar; 7 | 8 | public class Main { 9 | // JDBC driver name and database URL 10 | static final String JDBC_DRIVER = "com.mongodb.jdbc.MongoDriver"; 11 | static final String URL = "jdbc:mongodb://mhuser:pencil@localhost:27017/admin"; 12 | private static final TimeZone UTC = TimeZone.getTimeZone("UTC"); 13 | 14 | // Data used for test, in the test.test and test2.test collections: 15 | // 16 | //{ "values" : [ 17 | // { "database" : "myDB", "table" : "foo", "tableAlias" : "foo", "column" : "a", "columnAlias" : "a", "value" : 1 }, 18 | // { "database" : "myDB", "table" : "foo", "tableAlias" : "foo", "column" : "b", "columnAlias" : "b", "value" : "hello" } ] 19 | // } 20 | //{ "values" : [ 21 | // { "database" : "myDB", "table" : "foo", "tableAlias" : "foo", "column" : "a", "columnAlias" : "a", "value" : 42 }, 22 | // { "database" : "myDB", "table" : "foo", "tableAlias" : "foo", "column" : "b", "columnAlias" : "b", "value" : "hello 2" } ] 23 | // } 24 | // 25 | public static void main(String[] args) { 26 | 27 | try{ 28 | java.util.Properties p = new java.util.Properties(); 29 | // These properties will be added to the URI. 30 | // Uncomment if you wish to specify user and password. 31 | // p.setProperty("user", "user"); 32 | // p.setProperty("password", "foo"); 33 | p.setProperty("database", "test"); 34 | System.out.println("Connecting to database test..."); 35 | Connection conn = DriverManager.getConnection(URL, p); 36 | 37 | DatabaseMetaData dbmd = conn.getMetaData(); 38 | System.out.println(dbmd.getDriverVersion()); 39 | System.out.println(dbmd.getDriverMajorVersion()); 40 | System.out.println(dbmd.getDriverMinorVersion()); 41 | // System.out.println("Creating statement..."); 42 | // Statement stmt = conn.createStatement(); 43 | // ResultSet rs = stmt.executeQuery("select * from foo"); 44 | // System.out.println("++++++ Showing contents for test.foo ++++++++"); 45 | // displayResultSet(rs); 46 | } catch (Exception e) { 47 | throw new RuntimeException(e); 48 | } 49 | } 50 | 51 | public static void displayResultSet(ResultSet rs) throws java.sql.SQLException { 52 | Calendar c = new GregorianCalendar(); 53 | c.setTimeZone(UTC); 54 | while(rs.next()){ 55 | //Retrieve by column name 56 | double a = rs.getDouble("a"); 57 | String as = rs.getString("a"); 58 | String b = rs.getString("b"); 59 | java.sql.Timestamp bd; 60 | try { 61 | bd = rs.getTimestamp("b", c); 62 | System.out.println("b as a Timestamp is: " + bd); 63 | } catch (SQLException e) { 64 | System.out.println(e); 65 | } catch (Exception e) { 66 | throw new RuntimeException(e); 67 | } 68 | ResultSetMetaData metaData = rs.getMetaData(); 69 | System.out.println("a is: " + a + " as double" 70 | + " b is: " + b + " as string"); 71 | System.out.println("a as a string is: " + as); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/test/resources/X509AuthenticationTest/corrupted_key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN ENCRYPTED PRIVATE KEY----- 2 | MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQplXHthJ0thahnh9q 3 | WsaHkgICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEHrp0wm+fG+e62QA 4 | bNNxAO8EggTQGM49+86ih55/HZ2JcFY5+zTAk+lxf3fjW94ARDjsZg0zJKnALFHv 5 | arRsX+1XdRX4LrCe9DECPA5XMMmyQ4mYM3oBcMEYT+gkMhmuc9f5YSOAKPEHL+6E 6 | Q3hUmQQgajQL+YTMIDy2c5dEiLxq1jnQccwihXblRcK9ZZWZNZPlL7Txf9spnL6J 7 | c4OgdR6/hy+9CHtXX/rfJrsxmKySmetGxaNgIofxdPSYpPE94X18ynS+SBpoHdQU 8 | A0FMpC0cB3mEsrCtdg5QF32XjycU17BkReuCi1Q4DBGBEvSHsiwGjtK2B/lXO9++ 9 | HpUP+Rzm/t2Ptb4uYS1fSICja43uHUBn7j4Jzq2l0SqwTXkXe/DGmPNPM8u5lQxv 10 | QNn6pxyEMhGmhEza6xsEJs9YZrTI5FpHBAUwSgyJ1Chu42IQ8c3OIiDVcTtzUmkp 11 | zGVF2kxQS6rK4g2IuKJlMCKdRb0cGnOQKOLRWlCwdk//pjM1zHUWYEXFeYEvydrz 12 | I3hJcj+ZODE9LVOtIrCZBR/PRW+HQergcxKT4zdPk7n4o0Ll9cg8Ls1niO+coEQY 13 | gKi2CI3j/Fu+1oy8jzRRDMmmi9+3aFW1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uShBlItDcySGy0NIn 46 | BycoslGovhyRQrOT5SATl1gbhzAitUtvPNac+rpzASQsqubvbEbWgaaUx3wNlojj 47 | lCcmjIR3JLqj9KWbtCFGb8HyTAb7022jIoahGxSvybqZ4nLNfssJAxca5ObWwNe5 48 | T7Q2htUDheor0+IdDK1F6gsx61/LWy+m+kqrypq+KEW/JIzNK3hio2XlMUNCkNhw 49 | QkICdrhcH54jcjop6BmGBAON4g== 50 | -----END CERTIFICATE----- 51 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /resources/start_local_mdb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Usage start_local_mdb.sh [x509_cert_dir] [--x509] 4 | 5 | # architecture: "arm64" or "x64" 6 | # 7 | # This script will download each version of mongodb, start a mongod 8 | # for each, and create a user for each. With --x509 flag, it will 9 | # set up X.509 authentication. 10 | 11 | # Usage: download_and_extract_tgz 12 | download_and_extract_tgz() { 13 | tgz_file="$2.tgz" 14 | full_url="$1$tgz_file" 15 | 16 | echo "downloading $3 from $full_url" 17 | curl -O $full_url 18 | 19 | echo "extracting $tgz_file" 20 | tar zxvf $tgz_file 21 | } 22 | 23 | # Usage: download_mongod 24 | # type: "community" or "enterprise" 25 | download_mongod() { 26 | root_url="https://$1/linux/" 27 | download_and_extract_tgz $root_url $2 $3 28 | } 29 | 30 | # Usage: download_mongosh 31 | # architecture: "arm64" or "x64" 32 | download_mongosh() { 33 | root_url="https://downloads.mongodb.com/compass/" 34 | file_name="mongosh-2.3.0-linux-$1" 35 | download_and_extract_tgz $root_url $file_name "mongosh" 36 | 37 | # copy mongosh to the current directory and ensure it is executable 38 | cp $file_name/bin/mongosh . 39 | chmod +x mongosh 40 | } 41 | 42 | # Usage: start_mdb_and_create_user 43 | # type: "community" or "enterprise" 44 | start_mdb_and_create_user() { 45 | echo "starting mongodb $1 on port $2" 46 | db_path="$1_db" 47 | mkdir -p $db_path 48 | $5/bin/mongod --dbpath $db_path --port $2 & 49 | 50 | echo "waiting 5 seconds to allow mongod to finish starting before connecting" 51 | sleep 5 52 | 53 | echo "creating user for $1" 54 | ./mongosh test --port $2 --eval "db.createUser({user: '$3', pwd: '$4', roles: ['readWrite']})" 55 | } 56 | 57 | # Usage: start_mdb_with_x509 <$x509_cert_dir> 58 | start_mdb_with_x509() { 59 | local type=$1 60 | local port=$2 61 | local mongod_dir=$3 62 | local x509_cert_dir="$4" 63 | local db_path="${type}_db" 64 | 65 | echo "Starting MongoDB $type with initial configuration on port $port" 66 | mkdir -p $db_path 67 | $mongod_dir/bin/mongod --dbpath $db_path --port $port & 68 | 69 | echo "Waiting 5 seconds for MongoDB to start..." 70 | sleep 5 71 | 72 | echo "Creating X.509 user..." 73 | ./mongosh --port $port \ 74 | --eval 'db.getSiblingDB("$external").runCommand({ 75 | createUser: "OU=eng,O=mongodb,L=NY,ST=NY,C=US", 76 | roles: [ 77 | { role: "readWrite", db: "test" }, 78 | { role: "userAdminAnyDatabase", db: "admin" } 79 | ] 80 | })' 81 | 82 | echo "Stopping MongoDB to restart with auth..." 83 | $mongod_dir/bin/mongod --dbpath $db_path --shutdown 84 | sleep 5 85 | 86 | echo "Starting MongoDB with X.509 authentication enabled..." 87 | $mongod_dir/bin/mongod \ 88 | --dbpath $db_path \ 89 | --port $port \ 90 | --tlsMode requireTLS \ 91 | --tlsCertificateKeyFile "$x509_cert_dir/server.pem" \ 92 | --tlsCAFile "$x509_cert_dir/ca.crt" \ 93 | --bind_ip localhost & 94 | 95 | echo "MongoDB started with X.509 authentication enabled on port $port" 96 | } 97 | 98 | # Parse command line arguments 99 | community_mdb_version="$1" 100 | enterprise_mdb_version="$2" 101 | arch="$3" 102 | x509_cert_dir="$4" 103 | x509_mode=false 104 | 105 | if [ "$5" = "--x509" ]; then 106 | x509_mode=true 107 | fi 108 | 109 | community_base_url="fastdl.mongodb.org" 110 | enterprise_base_url="downloads.mongodb.com" 111 | 112 | download_mongod $community_base_url $community_mdb_version "community" 113 | download_mongod $enterprise_base_url $enterprise_mdb_version "enterprise" 114 | 115 | download_mongosh $arch 116 | 117 | if [ "$x509_mode" = true ]; then 118 | start_mdb_with_x509 "enterprise" $LOCAL_MDB_PORT_ENT $enterprise_mdb_version $x509_cert_dir 119 | else 120 | start_mdb_and_create_user "community" $LOCAL_MDB_PORT_COM $LOCAL_MDB_USER $LOCAL_MDB_PWD $community_mdb_version 121 | start_mdb_and_create_user "enterprise" $LOCAL_MDB_PORT_ENT $LOCAL_MDB_USER $LOCAL_MDB_PWD $enterprise_mdb_version 122 | fi 123 | -------------------------------------------------------------------------------- /src/test/resources/X509AuthenticationTest/pkcs1_encrypted.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIGQjCCBCqgAwIBAgIURtstyWKhi50cMJPZKvEsuXBuwX0wDQYJKoZIhvcNAQEL 3 | BQAwcjELMAkGA1UEBhMCSVMxEjAQBgNVBAgMCVJleWtqYXZpazESMBAGA1UEBwwJ 4 | UmV5a2phdmlrMRAwDgYDVQQKDAdNb25nb0RCMRAwDgYDVQQLDAdEcml2ZXJzMRcw 5 | FQYDVQQDDA5Ecml2ZXIgVGVzdCBDQTAeFw0yMzA2MTQyMTI2NTFaFw00MzA2MTQy 6 | MTI2NTFaMGsxCzAJBgNVBAYTAklTMRIwEAYDVQQIDAlSZXlramF2aWsxEjAQBgNV 7 | BAcMCVJleWtqYXZpazEQMA4GA1UECgwHTW9uZ29EQjEQMA4GA1UECwwHRHJpdmVy 8 | czEQMA4GA1UEAwwHQ0RyaXZlcjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC 9 | ggIBAJ2JPc7vE51/8eiOcWgMJujbwWN9BlDZ9J3McjaqE0Z9NXOTzAVUzgrLBFjb 10 | UV+grCSTPyoVk6O4k+MdnyQ6p7dTg9TX6mBwhe4guUc/FCezhEPE8SPo24Ajlep+ 11 | VVBnx3mNkGf/lYZOQc5dV0M4xMblfy9bSwVIxJVS0MiL9ShTQmdM4lxSdsEZjnPJ 12 | 5XHcazFpy6emh0NPpeIgWXtK/DBa89QRGo7FpfaDph0HLGFNNVYoEvS1Co412ll+ 13 | kztyNv816T6sX2OPKeIXJsu+UnH55vJRmCu12MLV1Sqf5XIwR0J/ga2UAr946BlH 14 | hWxhA567Sj0MtL2CobNMRdzkl+aZ7EgWN0qfORkYsypPadjROV9RxvWNLLN1474/ 15 | Bf0Ly8UQ5scVQHTaPWE06Sh+SPT3mFZrLbhM4yOAQsxRxw4+Df39QjymDbBi076Z 16 | nVMsOkxBtJHAeyD+JOg1uGMIDEBAHlKKiHNXrqPqg9RJIcAb9NhNerQujOrZAbdj 17 | 0/3/Vp3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xTMrXfGMTXaT+Za 33 | nUU9c43JoQKIC/5c5i0QCGgalJHdFTQqGIxZlqkppDSN1aQVVkBHOUmssAYBlpJ3 34 | 7U5Q6sx2hDCQpo6N+UEBx3oMcdYcTZlq+AxskFVNGZ6oZHVrVEHaAYrmxMy2cP/9 35 | Fh1PU8IrAAPkeBDUOsG/wR1yj2GIlQ== 36 | -----END CERTIFICATE----- 37 | -----BEGIN RSA PRIVATE KEY----- 38 | Proc-Type: 4,ENCRYPTED 39 | DEK-Info: AES-256-CBC,1B3E10F7B0ECE34A114DB6D57C6756BF 40 | 41 | kXWLwHliySMz2zi/TrSQJbemoSciY3yyhS7KmVdEdmWFIjaJCPYNW0HMiTR2Gslk 42 | RL/GF+9FWChXwvdsyRpWZX8c13JVPOgRUGcny+00R35ELNC/+3uRUcmp5egaGmgA 43 | QNiU4A2FIFBmKW3tLdd6m/sI6V0yqCimzSPBIxeIaYKUgj2Af26+GWOq5Vg9D78T 44 | MHue4rosM6H6qA1huJpOxqJHGKks7JXsMPBt5loOopje5062cju2atHJN4kBSB9i 45 | 0d3LJPV388/dZjf1y6zIT6c5gZCODoNmpygdPE8VIF+B2w8v8h7iQqwmNZXrUVg5 46 | DYY+yeK8sbgCC3S3XQ3igMIe00MU4NK8f/masqJKKYhoZvlzsrcw3s9rS08TT1kW 47 | L15wKghW0Trgv8II6418Vf+RrV8PZSqnueonFB3JawFUzMxZns1dhhNyquO1XDsU 48 | ArfOmmDWfCa60kK/4j8ZrnrCVlWih8u4sCnJ7uPuRKCwhcq0GzLTWqa9mrjcbq1z 49 | qcKKjFTSXhAFGYC18tYEMCDtxk6XZwxA1/4xM/kjqZP7YAfFPa33AKQasbscTEAT 50 | uzAbmI068RwrCF5C7DA6ETOyu8uIeZsX44JvZGMGQzKFpAP1ES5eIc2QzisNSiHD 51 | SnHLrbi+s101eiEpVG63nvD0hw5MwzavJWea6PMxiJUcsafIdd+qZmwuSkyLfl7p 52 | BFu8FfRdyeuIj8CQdP8EifYJKYulsWykY+XY0pqy2kWDvkMQiFGrrJdGFBgv+VKM 53 | yz9v+w93mZ0d5hsDrldqoblF56/rO3RmDdnCEO1hqZVybja2VQtg79YkogVVnDKl 54 | 7QrsgmuckVfNZa/5RmDzvLJlxoEmgbNLM9XrEYn8GXfi3wl6Vg4CNx0VyDJStU8O 55 | +MvJ99u1rJlb+/uysJt3PoPzVK4k8tvGGQ9EsxCTd7eoMVCsF0cKbrYz34Dwe9q7 56 | McIP6JPuO88CfZm/aR8Iq6VPRseNwWulltnAK8QNZxSVkQwiK2eoaSdEalEFfLaR 57 | PHNGv9ezqwjw7LAGWIrcjw+i5QxWflhjGaw+jQ8QZfQqWec1WXICqDDadSydjBII 58 | J8yYRCglk40aH8a28A29jb4v7LcIz1l1LzqPx30dILB4mNfVUhKPalEw3GytXrmf 59 | Vv9F5dbFx7qxAKTMe3g4+PLYlD2ZCisHqDzxx2PLA7OLypzIUuwEvq9cssYnYsXh 60 | q9MUJiBhixCU68kwdsMam74C3FIjLFbBXah5j3VCLAr4n5/305Xy8ZvEdriNUQRP 61 | UMNJTPmHgTaDwxRRXN7Ekhke1GSUYrCbBb+nrMof+VFcZGseYDWwFdKtomFe2Kd7 62 | 24orZH67qVerjj0C2dyfJAxBedhyix0IbmoR3hsx17qmUz7YEZWMmPM/p+sY1FKh 63 | XI7bzFpP2lBooX/bliTkhxASBxG16Ue4b4stzUs2yajxvmu9Mu1xT96+gsFZlVAa 64 | +QPsyQ2+ZdftC5Tfooi1aFz03Tc0wQQynJsJkUU8uDNWwB3AAIOmTKjMsk63CoJV 65 | HIureCMOb6IfDK15bwvd4pa7rFMjfntMiXRLFcsg3RfZXIAA/nwXNK/CHBqoF1Hv 66 | -----END RSA PRIVATE KEY----- 67 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/MongoConnectionProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc; 18 | 19 | import com.mongodb.ConnectionString; 20 | import java.io.File; 21 | import java.util.logging.Level; 22 | 23 | public class MongoConnectionProperties { 24 | private ConnectionString connectionString; 25 | private String database; 26 | private Level logLevel; 27 | private File logDir; 28 | private String clientInfo; 29 | private boolean extJsonMode; 30 | private String x509PemPath; 31 | private String jaasConfigPath; 32 | private String gssNativeMode; 33 | private final String gssApiLoginContextName; 34 | private final String gssApiServerAuth; 35 | private String tlsCaFile; 36 | 37 | public MongoConnectionProperties( 38 | ConnectionString connectionString, 39 | String database, 40 | Level logLevel, 41 | File logDir, 42 | String clientInfo, 43 | boolean extJsonMode, 44 | String jaasConfigPath, 45 | String gssNativeMode, 46 | String gssApiLoginContextName, 47 | String gssApiServerAuth, 48 | String tlsCaFile, 49 | String x509PemPath) { 50 | this.connectionString = connectionString; 51 | this.database = database; 52 | this.logLevel = logLevel; 53 | this.logDir = logDir; 54 | this.clientInfo = clientInfo; 55 | this.extJsonMode = extJsonMode; 56 | this.x509PemPath = (x509PemPath != null) ? x509PemPath.trim() : null; 57 | this.jaasConfigPath = (jaasConfigPath != null) ? jaasConfigPath.trim() : null; 58 | this.gssNativeMode = gssNativeMode != null ? gssNativeMode : null; 59 | this.gssApiLoginContextName = gssApiLoginContextName; 60 | this.gssApiServerAuth = gssApiServerAuth; 61 | this.tlsCaFile = tlsCaFile; 62 | } 63 | 64 | public ConnectionString getConnectionString() { 65 | return connectionString; 66 | } 67 | 68 | public String getDatabase() { 69 | return database; 70 | } 71 | 72 | public Level getLogLevel() { 73 | return logLevel; 74 | } 75 | 76 | public File getLogDir() { 77 | return logDir; 78 | } 79 | 80 | public String getClientInfo() { 81 | return clientInfo; 82 | } 83 | 84 | public boolean getExtJsonMode() { 85 | return extJsonMode; 86 | } 87 | 88 | public String getTlsCaFile() { 89 | return tlsCaFile; 90 | } 91 | 92 | public String getX509PemPath() { 93 | return x509PemPath; 94 | } 95 | 96 | public String getJaasConfigPath() { 97 | return jaasConfigPath; 98 | } 99 | 100 | public String getGssNativeMode() { 101 | return gssNativeMode; 102 | } 103 | 104 | public String getGssApiLoginContextName() { 105 | return gssApiLoginContextName; 106 | } 107 | 108 | public String getGssApiServerAuth() { 109 | return gssApiServerAuth; 110 | } 111 | 112 | /* 113 | * Generate a unique key for the connection properties. This key is used to identify the connection properties in the 114 | * connection cache. Properties that do not differentiate a specific client such as the log level are not included in the key. 115 | */ 116 | public Integer generateKey() { 117 | StringBuilder keyBuilder = new StringBuilder(); 118 | keyBuilder.append(connectionString.toString()); 119 | if (clientInfo != null) { 120 | keyBuilder.append(":clientInfo=").append(clientInfo); 121 | } 122 | if (tlsCaFile != null) { 123 | keyBuilder.append(":tlsCaFile=").append(tlsCaFile); 124 | } 125 | return keyBuilder.toString().hashCode(); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /src/main/java/com/mongodb/jdbc/utils/BsonUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.utils; 18 | 19 | import com.mongodb.jdbc.MongoSerializationException; 20 | import com.mongodb.jdbc.NoCheckStateJsonWriter; 21 | import java.io.IOException; 22 | import java.io.StringWriter; 23 | import java.nio.ByteBuffer; 24 | import org.bson.BsonBinaryReader; 25 | import org.bson.BsonBinaryWriter; 26 | import org.bson.BsonDocument; 27 | import org.bson.BsonDocumentWriter; 28 | import org.bson.codecs.*; 29 | import org.bson.io.BasicOutputBuffer; 30 | import org.bson.json.JsonMode; 31 | import org.bson.json.JsonWriter; 32 | import org.bson.json.JsonWriterSettings; 33 | 34 | /** Utility class for BSON serialization and deserialization. */ 35 | public class BsonUtils { 36 | public static final JsonWriterSettings JSON_WRITER_SETTINGS = 37 | JsonWriterSettings.builder().outputMode(JsonMode.RELAXED).indent(true).build(); 38 | 39 | public static final JsonWriterSettings JSON_WRITER_NO_INDENT_SETTINGS = 40 | JsonWriterSettings.builder().outputMode(JsonMode.RELAXED).indent(false).build(); 41 | 42 | /** 43 | * Serializes a BsonDocument into a BSON byte array. 44 | * 45 | * @param doc The BsonDocument to serialize. 46 | * @return BSON byte array. 47 | * @throws MongoSerializationException If serialization fails. 48 | */ 49 | public static byte[] serialize(BsonDocument doc) throws MongoSerializationException { 50 | if (doc == null) { 51 | throw new MongoSerializationException("Cannot serialize a null BsonDocument."); 52 | } 53 | try (BasicOutputBuffer buffer = new BasicOutputBuffer(); 54 | BsonBinaryWriter writer = new BsonBinaryWriter(buffer)) { 55 | BsonDocumentCodec codec = new BsonDocumentCodec(); 56 | codec.encode(writer, doc, EncoderContext.builder().build()); 57 | writer.flush(); 58 | return buffer.toByteArray(); 59 | } catch (RuntimeException e) { 60 | throw new MongoSerializationException("Failed to serialize BSON.", e); 61 | } 62 | } 63 | 64 | /** 65 | * Deserializes a BSON byte array into a BsonDocument. 66 | * 67 | * @param bytes The BSON byte array. 68 | * @return The deserialized BsonDocument. 69 | * @throws MongoSerializationException If deserialization fails. 70 | */ 71 | public static BsonDocument deserialize(byte[] bytes) throws MongoSerializationException { 72 | try (BsonBinaryReader reader = new BsonBinaryReader(ByteBuffer.wrap(bytes))) { 73 | BsonDocumentCodec codec = new BsonDocumentCodec(); 74 | return codec.decode(reader, DecoderContext.builder().build()); 75 | } catch (RuntimeException e) { 76 | throw new MongoSerializationException("Failed to deserialize BSON.", e); 77 | } 78 | } 79 | 80 | public static String toString(Codec codec, T val, JsonWriterSettings settings) { 81 | try (StringWriter writer = new StringWriter(); 82 | JsonWriter jsonWriter = new NoCheckStateJsonWriter(writer, settings)) { 83 | codec.encode(jsonWriter, val, EncoderContext.builder().build()); 84 | writer.flush(); 85 | 86 | return writer.toString(); 87 | } catch (IOException e) { 88 | throw new RuntimeException(e); 89 | } 90 | } 91 | 92 | public static String toString(Codec codec, T val) { 93 | return toString(codec, val, JSON_WRITER_SETTINGS); 94 | } 95 | 96 | public static BsonDocument toBsonDocument(Codec codec, T val) { 97 | BsonDocument doc = new BsonDocument(); 98 | try (BsonDocumentWriter writer = new BsonDocumentWriter(doc); ) { 99 | codec.encode(writer, val, EncoderContext.builder().build()); 100 | writer.flush(); 101 | } 102 | return doc; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /resources/integration_test/testdata/integration.yml: -------------------------------------------------------------------------------- 1 | dataset: 2 | - db: integration_test 3 | collection: class 4 | docs: 5 | - {_id: 0, studentid: 10329, name: "John", enrolled: true, startdate: 2000-01-01 } 6 | - {_id: 1, studentid: 342, name: "Jane", enrolled: false, startdate: 2000-02-01} 7 | - {_id: 2, studentid: 303, name: "Mike", enrolled: true, startdate: 2000-01-01} 8 | - {_id: 3, studentid: 204323, name: "Mary", enrolled: false, startdate: 2000-03-01} 9 | - {_id: 4, studentid: 10, name: "Pete", enrolled: false, startdate: 2000-01-01} 10 | 11 | - db: integration_test 12 | collection: grades 13 | docs: 14 | - {_id: 0, studentid: 303, testid: 3, score: 84.5} 15 | - {_id: 1, studentid: 10329, testid: 3, score: 97.4} 16 | - {_id: 2, studentid: 342, testid: 3, score: 89.3} 17 | - {_id: 3, studentid: 204323, testid: 3, score: 91.9} 18 | - {_id: 4, studentid: 303, testid: 5, score: 87.5} 19 | - {_id: 5, studentid: 10329, testid: 5, score: 74.4} 20 | - {_id: 6, studentid: 342, testid: 5, score: 80.1} 21 | - {_id: 7, studentid: 204323, testid: 5, score: 83.3} 22 | - {_id: 8, studentid: 200, testid: 5, score: 78.5} 23 | 24 | - db: integration_test 25 | collection: anyof_collection 26 | docs: 27 | - { _id: 0, a: 3 } 28 | - { _id: 1, a: 3000000000 } 29 | - { _id: 2, a: 4.5 } 30 | schema: { 31 | "bsonType":[ 32 | "object" 33 | ], 34 | "properties":{ 35 | "a":{ 36 | "bsonType":[ 37 | "long", 38 | "double", 39 | "int" 40 | ] 41 | }, 42 | "_id":{ 43 | "bsonType":[ 44 | "int" 45 | ] 46 | } 47 | } 48 | } 49 | 50 | - db: integration_test 51 | collection: any_collection 52 | docs: 53 | - { _id: 0, b: 3 } 54 | - { _id: 1, b: "b" } 55 | - { _id: 2, b: 4.5 } 56 | schema: { 57 | "bsonType":[ 58 | "object" 59 | ], 60 | "required":[ 61 | "b" 62 | ], 63 | "properties":{ 64 | "_id":{ 65 | "bsonType":[ 66 | "int" 67 | ] 68 | } 69 | } 70 | } 71 | 72 | - db: integration_test 73 | collection: null_and_missing 74 | docs: 75 | - { _id: 0, "a": !!org.bson.BsonTimestamp 1} 76 | - { _id: 1, "a": null } 77 | - { _id: 2 } 78 | 79 | - db: integration_test 80 | collection: a_non_lexicographic_field_order 81 | docs: 82 | - { _id: 4, "c": 7, "b": 6, "a":5, "A":1, "B": 2, "C": 3 } 83 | 84 | - db: integration_test 85 | collection: b_non_lexicographic_field_order 86 | docs: 87 | - { "a": 9, _id: 8 } 88 | 89 | - db: integration_test 90 | collection: types_other 91 | docsExtJson: 92 | - { 93 | _id: 0, 94 | array: [ 1, 2, 3, "$oid": "000000000000000000000003", "$timestamp": { "t": 200, "i": 0 }], 95 | dbPointer: { "$dbPointer": { "$ref": "namespace", "$id": { "$oid": "000000000000000000000001" }}}, 96 | javascript: { "$code": "function(){ }" }, 97 | javascriptWithScope: { "$code": "function(){ }", "$scope": { "foo": "bar" }}, 98 | maxKey: { "$maxKey": 1 }, 99 | minKey: { "$minKey": 1 }, 100 | object: { "foo": "bar", "objId": { "$oid": "000000000000000000000002" }, "value": 3, 101 | "time": { "$timestamp": { "t": 200, "i": 0 }}}, 102 | objectId: { "$oid": "000000000000000000000001" }, 103 | regularExpression: { "$regularExpression": { pattern: "a(bc)*", "options": "" }}, 104 | symbol: { "$symbol": "symbol" }, 105 | timestamp: { "$timestamp": { "t": 100, "i": 0 }} 106 | # Skip reason: SQL-395 107 | # undefined: {"$undefined":true}, 108 | } 109 | 110 | - db: integration_test 111 | collection: uuid 112 | docsExtJson: 113 | - _id: 0 114 | uuid: { "$uuid": "71bf369b-2c60-4e6f-b23f-f9e88167cc96" } 115 | type: "standard" 116 | - _id: 1 117 | uuid: { "$binary": { "base64": "b05gLJs2v3GWzGeB6Pk/sg==", "subType": "03" } } 118 | type: "javalegacy" 119 | - _id: 2 120 | uuid: { "$binary": { "base64": "mza/cWAsb06yP/nogWfMlg==", "subType": "03" } } 121 | type: "csharplegacy" 122 | - _id: 3 123 | uuid: { "$binary": { "base64": "cb82myxgTm+yP/nogWfMlg==", "subType": "03" } } 124 | type: "pythonlegacy" 125 | 126 | - db: integration_test 127 | view: baz 128 | -------------------------------------------------------------------------------- /smoketest/src/test/java/com/mongodb/jdbc/smoketest/SmokeTest.java: -------------------------------------------------------------------------------- 1 | package com.mongodb.jdbc.smoketest; 2 | 3 | import org.junit.jupiter.api.AfterEach; 4 | import org.junit.jupiter.api.BeforeEach; 5 | import org.junit.jupiter.api.Test; 6 | import static org.junit.jupiter.api.Assertions.assertTrue; 7 | 8 | import java.sql.Connection; 9 | import java.sql.DatabaseMetaData; 10 | import java.sql.DriverManager; 11 | import java.sql.ResultSet; 12 | import java.sql.SQLException; 13 | import java.sql.Statement; 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | import java.util.Properties; 17 | 18 | /** 19 | * SmokeTest runs a test on built artifacts to verify that connection, 20 | * metadata retrieval, and querying is successful 21 | */ 22 | public class SmokeTest { 23 | static final String URL = "jdbc:mongodb://localhost"; 24 | static final String DB = "integration_test"; 25 | 26 | // Connection and simple query to use for sanity check. 27 | private Map connections = new HashMap<>(); 28 | 29 | public static Connection getADFInstanceConnection(String url, String db) 30 | throws SQLException { 31 | Properties p = new java.util.Properties(); 32 | p.setProperty("user", System.getenv("ADF_TEST_LOCAL_USER")); 33 | p.setProperty("password", System.getenv("ADF_TEST_LOCAL_PWD")); 34 | p.setProperty("authSource", System.getenv("ADF_TEST_LOCAL_AUTH_DB")); 35 | p.setProperty("ssl", "false"); 36 | p.setProperty("database", db); 37 | return DriverManager.getConnection(URL, p); 38 | } 39 | 40 | private Connection getDirectRemoteInstanceConnection() throws SQLException { 41 | String mongoHost = System.getenv("SRV_TEST_HOST"); 42 | String mongoURI = 43 | "mongodb+srv://" 44 | + mongoHost 45 | + "/?readPreference=secondaryPreferred&connectTimeoutMS=300000"; 46 | String fullURI = "jdbc:" + mongoURI; 47 | 48 | String user = System.getenv("SRV_TEST_USER"); 49 | String pwd = System.getenv("SRV_TEST_PWD"); 50 | String authSource = System.getenv("SRV_TEST_AUTH_DB"); 51 | 52 | Properties p = new java.util.Properties(); 53 | p.setProperty("user", user); 54 | p.setProperty("password", pwd); 55 | p.setProperty("authSource", authSource); 56 | p.setProperty("database", "test"); 57 | 58 | return DriverManager.getConnection(fullURI, p); 59 | } 60 | 61 | @BeforeEach 62 | public void setupConnection() throws SQLException { 63 | Connection adfConnection = getADFInstanceConnection(URL, DB); 64 | connections.put(adfConnection, "SELECT * from class"); 65 | 66 | DatabaseMetaData metadata = adfConnection.getMetaData(); 67 | String driverVersion = metadata.getDriverVersion(); 68 | System.out.println("Running smoke test with driver version: " + driverVersion); 69 | 70 | try { 71 | Connection directConnection = getDirectRemoteInstanceConnection(); 72 | connections.put(directConnection, "Select * from accounts limit 5"); 73 | } catch (SQLException e) { 74 | System.err.println("Failed to connect to direct remote instance: " + e.getMessage()); 75 | throw e; 76 | } 77 | } 78 | 79 | @AfterEach 80 | protected void cleanupTest() throws SQLException { 81 | for (Connection conn : connections.keySet()) { 82 | conn.close(); 83 | } 84 | } 85 | 86 | @Test 87 | public void databaseMetadataTest() throws SQLException { 88 | System.out.println("Running databaseMetadataTest"); 89 | for (Connection conn : connections.keySet()) { 90 | DatabaseMetaData dbMetadata = conn.getMetaData(); 91 | System.out.println(dbMetadata.getDriverName()); 92 | System.out.println(dbMetadata.getDriverVersion()); 93 | 94 | ResultSet rs = dbMetadata.getColumns(null, "%", "%", "%"); 95 | rowsReturnedCheck(rs); 96 | } 97 | } 98 | 99 | @Test 100 | public void queryTest() throws SQLException { 101 | System.out.println("Running queryTest"); 102 | for (Map.Entry entry : connections.entrySet()) { 103 | try (Statement stmt = entry.getKey().createStatement()) { 104 | ResultSet rs = stmt.executeQuery(entry.getValue()); 105 | rowsReturnedCheck(rs); 106 | } 107 | } 108 | } 109 | 110 | public static void rowsReturnedCheck(ResultSet rs) throws SQLException { 111 | int actualCount = 0; 112 | while (rs.next()) { 113 | actualCount++; 114 | } 115 | System.out.println("Rows returned count: " + actualCount); 116 | assertTrue(actualCount >= 1, "No rows returned in result set"); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /resources/authentication_test/X509/client-unencrypted-pkcs1-string.txt: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY-----MIIJKAIBAAKCAgEAry7rBd+vrbN9hupIT6SUsB0wQWYz8g9DGJVrpbKyS15nsOCSUZJW22RWWepJFSRHesHhDHRkpi7WjUWr6lPBUqz2owRUpNnzJrX3G7Qx21Fy6Rf44u6vdtJzsdV8W4SbpLTRTD+A6m0LctAelUELGnmbS7aVeM68HphGXTATIdwylFxmKQYbuPg3qV8lPXAxw2bORMNl7EQQTztu1OfKDqT+6DCqY6g3yqB5yUJj9ENaqsURd437h+kquYuMxmJ7uTnwWCWADOTuE12AJl4iUdXZ8m858xzK4m00ygLIYq56MNw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rLTDjYleQoy1+EUPEpqZkV3EOVt7XXKg6CIJbQOWq8ReyuW6yDsw6sMy8KFvL+4Uy3a1klsZ0l04WG2e6vYAqma8FhFf7RCQeEMyKD4sUsB2GO6uE/CaFR4SRMnx6za3pB3isTeX1XfRLx+Y216eGIbjXNhOuIjfT0KbqZNx+87OXQB2q2HaiZ6kwI/djYdDvJP9dSY9TTmTjSboiVWl+v3x4jZhShayOKLM3r7l8ZWQItkuGNIX2LGOPaE/YZtLyx8RZklvmRpHrZ49NcDDrQx8dBvUx03thMk3ZhjXI7ObA4jQOMuGpfGVl2F2lKyMRTNXuBjNzWFRvCg== -----END CERTIFICATE----- -------------------------------------------------------------------------------- /resources/authentication_test/X509/client-unencrypted-pkcs8-string.txt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- MIIFXjCCA0agAwIBAgIUTb4om5bTQuSJLyIi7x6 fr14WjhAwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAk5ZMQswCQYDVQQHDAJOWTEQMA4GA1UECgwHbW9uZ29kYjEMMAoG A1UECwwDZW5nMB4XDTI0MTEyNTE3MzY1MVoXDTI1MTEyNTE3MzY1MVowRzELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAk5ZMQswCQYDVQQHDAJOWTEQMA4GA1UECgwHbW9uZ29kYjEMMAoGA1UECwwDZW5nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAry7rBd+vrbN9hupIT6SUsB0wQWYz8g9DGJVrpbKyS15nsOCSUZJW22RWWepJFSRHesHhDHRkpi7WjUWr6lPBUqz2owRUpNnzJrX3G7Qx21Fy6Rf44u6vdtJzsdV8W4SbpLTRTD+A6m0LctAelUELGnmbS7aVeM68HphGXTATIdwylFxmKQYbuPg3qV8lPXAxw2bORMNl7EQQTztu1OfKDqT+6DCqY6g3yqB5yUJj9ENaqsURd437h+kquYuMxmJ7uTnwWCWADOTuE12AJl4iUdXZ8m858xzK4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StsJDeZ3xCCaGvlaxIFuyXKgJVgDPxD3qXjY6VMMoudnihbV6Q== -----END PRIVATE KEY----- 2 | -------------------------------------------------------------------------------- /src/integration-test/java/com/mongodb/jdbc/integration/AuthX509PEMContentsIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.integration; 18 | 19 | import static org.junit.jupiter.api.Assertions.*; 20 | 21 | import java.io.IOException; 22 | import java.nio.file.Files; 23 | import java.nio.file.Paths; 24 | import java.sql.Connection; 25 | import java.sql.SQLException; 26 | import org.junit.jupiter.api.Test; 27 | 28 | public class AuthX509PEMContentsIntegrationTest extends AuthX509IntegrationTestBase { 29 | 30 | /** 31 | * Tests that a raw unencrypted PEM certificate provided in the 'password' field can be used to 32 | * successfully authenticate via X.509. 33 | */ 34 | @Test 35 | public void testPEMContentsUnencryptedPkcs8InPasswordField() throws SQLException, IOException { 36 | // Load the one-line raw unencrypted PEM string 37 | String filePath = "resources/authentication_test/X509/client-unencrypted-pkcs8-string.txt"; 38 | String pemContent = new String(Files.readAllBytes(Paths.get(filePath))); 39 | try (Connection connection = connectWithX509(null, pemContent)) { 40 | assertNotNull( 41 | connection, "Connection with inline unencrypted PKCS#8 PEM should succeed"); 42 | connection.getMetaData().getDriverVersion(); 43 | } catch (Exception e) { 44 | throw new RuntimeException("Failed to connect with inline unencrypted PKCS#8 PEM", e); 45 | } 46 | } 47 | 48 | /** 49 | * Tests that an encrypted PEM certificate provided in the 'password' field, where the PEM is 50 | * stored in JSON format, can be used to successfully authenticate via X.509. 51 | */ 52 | @Test 53 | public void testPEMContentsEncryptedPkcs8JsonInPasswordField() throws Exception { 54 | // Load the one-line encrypted PEM string stored in JSON format 55 | String filePath = "resources/authentication_test/X509/client-encrypted-pkcs8-string.json"; 56 | String pemContent = new String(Files.readAllBytes(Paths.get(filePath))); 57 | try (Connection connection = connectWithX509(null, pemContent)) { 58 | assertNotNull(connection, "Connection with inline encrypted PKCS#8 PEM should succeed"); 59 | connection.getMetaData().getDriverVersion(); 60 | } catch (Exception e) { 61 | throw new RuntimeException("Failed to connect with inline encrypted PKCS#8 PEM", e); 62 | } 63 | } 64 | 65 | /** 66 | * Tests that a raw unencrypted PKCS#1 PEM certificate provided in the 'password' field can be 67 | * used to successfully authenticate via X.509. 68 | */ 69 | @Test 70 | public void testPEMContentsUnencryptedPkcs1InPasswordField() throws SQLException, IOException { 71 | // Load the one-line raw unencrypted PEM string 72 | String filePath = "resources/authentication_test/X509/client-unencrypted-pkcs1-string.txt"; 73 | String pemContent = new String(Files.readAllBytes(Paths.get(filePath))); 74 | try (Connection connection = connectWithX509(null, pemContent)) { 75 | assertNotNull( 76 | connection, "Connection with inline unencrypted PKCS#1 PEM should succeed"); 77 | connection.getMetaData().getDriverVersion(); 78 | } catch (Exception e) { 79 | throw new RuntimeException("Failed to connect with inline unencrypted PKCS#1 PEM", e); 80 | } 81 | } 82 | 83 | /** 84 | * Tests that a raw encrypted PKCS#1 PEM certificate provided in the 'password' field can be 85 | * used to successfully authenticate via X.509. 86 | */ 87 | @Test 88 | public void testPEMContentsEncryptedPkcs1JsonInPasswordField() 89 | throws SQLException, IOException { 90 | // Load the one-line raw encrypted PEM string 91 | String filePath = "resources/authentication_test/X509/client-encrypted-pkcs1-string.json"; 92 | String pemContent = new String(Files.readAllBytes(Paths.get(filePath))); 93 | try (Connection connection = connectWithX509(null, pemContent)) { 94 | assertNotNull(connection, "Connection with inline encrypted PKCS#1 PEM should succeed"); 95 | connection.getMetaData().getDriverVersion(); 96 | } catch (Exception e) { 97 | throw new RuntimeException("Failed to connect with inline encrypted PKCS#1 PEM", e); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /resources/authentication_test/X509/client-encrypted-pkcs1-string.json: -------------------------------------------------------------------------------- 1 | { "pem": "-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: AES-256-CBC,DAAB80CB82BFDBEC4FAE8C9C77032A6E NbatMA9167rM+zpupQAkxqIVnUPxuevc7zHRN8LYxEW07SvP/d4uaZOgJZ06gH0x wY91hgzlI+k1WSChG0aF6A6EXINiJE4vssNa38uFX95gUW01iDd6AgcRslDVfsDQ r2Szjw/6c7aM/HMwBcYjLvD5Bb7/++cGcXlRn7yURochifjn6agB4pncgPnEI2Yi TMAxhAiBxg0MJAFLxZMy6EtYlV+Z7L34pkJI33YRtzy01tymk3n7A4NSJwPUsZZa 33yOvlEAd5bWyAXh7qsY4xCD7bhRut1lu2RU2Qrn/KNXt7rCQZKLquavJ7vyxGal 8JV2rTOySTM/UukjDi3x5hwRPvtDnZ96q8AWQyANmBx71odxe+5cq+vt7QHoLlP+ AwcYxMAhSTEQL8IfzvtdNlspQjxUHWr4c3nzOd+DA6t2ZIcrCtzUTFVg/kQ+LFJ6 xDuYlcfIfCRLSAyCvyMKCzmyMI3Rdyykp7uqNO8IhCqAr9D0FUutbtqJ/IiUCgxO luZYDTtxfsdHHn6gqPQghkGFfXBXpypwmk7raPd8/l0uVs0Ov5ld6uK9kub+ah6m 6VjJC3kyShq0/7OAeiIwYANlqWPJz3p/Zj0gg+On038mostOXxELUhgcRhqt2DFs F5USlldbDBRIKAewbgfSMRidQ53p0UeEQa93NxWKveOaUxXRgGRA90jXEn2eGRDV qsQ9ZuEk963AcRA1klb78LCGjhH7Rb8Zw3YJmahvHLQr6IAMbpVtuOM8ZiKAoGac dEHebzw1pgLySXu/OOgXAgvH79vWFWNHPpuJA0JEad0fIXZu4P6J1J8hO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spQz5nFVFgrPXhN2YVec0/ng+qndJEKGpVlnQYNrM2y0TzIsREaidWz1rfteLTlCcmgiTkWPoXvm5C1e9LhNPYsRXI4yOqJ046rtKpiuicENHXhIuAckh9mf55TilECAwEAAaNCMEAwHQYDVR0OBBYEFPzTvfJYswlqZdfAGoPMzUWHc2GWMB8GA1UdIwQYMBaAFGGi0J1Cws/ZD4kTzoVCa+lJWe+jMA0GCSqGSIb3DQEBCwUAA4ICAQAs2TUbazXNMDRWjUeYRhvXgN1nRJCWNuYqFym2BykIl02j4YADWUA4RT6ZGWj/BYIz9oOns53/3O5E/doWl/ZuUzYy+SslX0/62Cn/3oPqaSu/4EGoY7fA7bNLMh/mZ0rD3toufN1bJcoj7OpB54vaM43uLfjIwhd3vjetHshaSNjrDXKSSsfarc8xWn0EozmN3V9TPNv6OT7B4O5eSgJTyxjtxAzgiZ2/KOBj7cHZxVhWL/dV7wuFdFURnU+u/BLxZ9bDvw8Mr7tbN4i19oDICMws45mFTT3vrCYjYGk2eCQ0gCraddONmW5JhCkqBgmnj0W6smPS0cpHqy0XcPsY+sGOBH9rLTDjYleQoy1+EUPEpqZkV3EOVt7XXKg6CIJbQOWq8ReyuW6yDsw6sMy8KFvL+4Uy3a1klsZ0l04WG2e6vYAqma8FhFf7RCQeEMyKD4sUsB2GO6uE/CaFR4SRMnx6za3pB3isTeX1XfRLx+Y216eGIbjXNhOuIjfT0KbqZNx+87OXQB2q2HaiZ6kwI/djYdDvJP9dSY9TTmTjSboiVWl+v3x4jZhShayOKLM3r7l8ZWQItkuGNIX2LGOPaE/YZtLyx8RZklvmRpHrZ49NcDDrQx8dBvUx03thMk3ZhjXI7ObA4jQOMuGpfGVl2F2lKyMRTNXuBjNzWFRvCg== -----END CERTIFICATE-----", "passphrase": "foo" } -------------------------------------------------------------------------------- /src/integration-test/java/com/mongodb/jdbc/integration/AuthX509TlsCaFileIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present MongoDB, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.mongodb.jdbc.integration; 18 | 19 | import static org.junit.jupiter.api.Assertions.*; 20 | 21 | import java.sql.Connection; 22 | import java.sql.SQLException; 23 | import java.sql.SQLTimeoutException; 24 | import org.junit.jupiter.api.Test; 25 | 26 | // Integration tests for X.509 authentication with TLS CA file configuration. 27 | public class AuthX509TlsCaFileIntegrationTest extends AuthX509IntegrationTestBase { 28 | /** 29 | * Tests that a connection fails when the TLS CA file is not provided. This verifies that the 30 | * client cannot connect without proper CA configuration. 31 | */ 32 | @Test 33 | public void testTlsCaFilePropertyUnsetFails() throws SQLException { 34 | assertThrows( 35 | SQLTimeoutException.class, 36 | () -> { 37 | try (Connection connection = 38 | connectWithX509( 39 | "resources/authentication_test/X509/client-unencrypted.pem", 40 | null, 41 | null, 42 | null)) { 43 | connection.getMetaData().getDriverVersion(); 44 | } 45 | }); 46 | } 47 | 48 | /** 49 | * Tests that a connection succeeds when the TLS CA file is explicitly set as a property. This 50 | * verifies the basic functionality of CA file authentication. 51 | */ 52 | @Test 53 | public void testTlsCaFilePropertySetSucceeds() throws SQLException { 54 | String caFilePath = "resources/authentication_test/X509/ca.crt"; 55 | 56 | java.io.File caFile = new java.io.File(caFilePath); 57 | assertTrue(caFile.exists(), "CA file at " + caFilePath + " does not exist"); 58 | 59 | try (Connection connection = 60 | connectWithX509( 61 | "resources/authentication_test/X509/client-unencrypted.pem", 62 | null, 63 | caFilePath, 64 | null)) { 65 | assertNotNull(connection, "Connection should succeed with valid CA file"); 66 | connection.getMetaData().getDriverVersion(); 67 | } 68 | } 69 | 70 | /** 71 | * Tests that a connection succeeds when the TLS CA file is specified as a URI option. This 72 | * verifies the alternative configuration method for CA files. 73 | */ 74 | @Test 75 | public void testTlsCaFileUriOptionSetSucceeds() throws SQLException { 76 | String caFilePath = "resources/authentication_test/X509/ca.crt"; 77 | 78 | java.io.File caFile = new java.io.File(caFilePath); 79 | assertTrue(caFile.exists(), "CA file at " + caFilePath + " does not exist"); 80 | 81 | try (Connection connection = 82 | connectWithX509( 83 | "resources/authentication_test/X509/client-unencrypted.pem", 84 | null, 85 | null, 86 | "tlscafile=" + caFilePath)) { 87 | assertNotNull(connection, "Connection should succeed with valid CA file"); 88 | connection.getMetaData().getDriverVersion(); 89 | } 90 | } 91 | 92 | /** 93 | * Tests that a connection succeeds when the TLS CA file contains multiple certificates. This 94 | * verifies support for CA bundles containing multiple certificates. 95 | */ 96 | @Test 97 | public void testTlsCaFileWithMultipleCertificatesSucceeds() throws SQLException { 98 | String caFilePath = 99 | "src/test/resources/X509AuthenticationTest/multiple_x509_certificates.pem"; 100 | 101 | java.io.File caFile = new java.io.File(caFilePath); 102 | assertTrue(caFile.exists(), "CA file at " + caFilePath + " does not exist"); 103 | 104 | try (Connection connection = 105 | connectWithX509( 106 | "resources/authentication_test/X509/client-unencrypted.pem", 107 | null, 108 | caFilePath, 109 | null)) { 110 | assertNotNull(connection, "Connection should succeed with valid CA file"); 111 | connection.getMetaData().getDriverVersion(); 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /resources/authentication_test/X509/client-encrypted-pkcs8-string.json: -------------------------------------------------------------------------------- 1 | { "pem": "-----BEGIN ENCRYPTED PRIVATE KEY----- MIIJtTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQcIFIU6c4QP6/5Q8SuxISsAICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEJgBjLPyF2K5xFSYGaepcjcEgglQ8Vz3ItB0JLsQphvG0o7RBUFDMOkmzoTW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DV4z5agoDi2ANQuL/kKHZZrDJb0YhgQxOAmChYPge5sBvf7/4uH0unmrNotQd75315lufduaiYS6Ck6uZC1p9uL7jSKb0w+EhMQUNLfF009hMcygykBh16a4em30xELUTVW4/hu0QN7LW3C1NLmSdpXkN9NBehrXE2eQOo3NlAsiDwLu3Kh4uytsJqyqRJUO2xzarz1ZQhAM3pjTUQ4eMMOviqHTTOV2ShReYiLBcPEaa0+g5NqoJ3do2mO5HHKOkapn8f9nbBpNXjkzqJTcTESaUbeS6aU7Dd652pOQMTd6Y59sd7wdkpy9tekScenzCJmxqnishLMjSMUtA7uvevCL8KtJZwqWq+rNuHbrkWvHaN/VLGVGhfR+9wD8nZ2gGnE3rMKoX0dLQMoDGyESerDt1au7tf1UIkzfsyZkO8DOme65wmwzkpm0dAZcxL6XyXhLjX14YMKYqO9WpOmjN0798HWx3ohOptM15GrturSeSvlZI3bvoghyrKktQOHURN+m23kUojSiPNSbcR8qrfnBK47nG3HM37QYhEYqr5txjHib4wZ9NxeDrvcqqdYKnLadSuxITt1EDEXbky3iaCvMaYH9gU0KEcWioXof48kMagzTCV3LYlcSB8DsV1/GncWUMxrRJQyVw/LXNY8otb+tja4n8/F/QggBvLYmMFAJUgjeXoJeK5g7YHokpOgCZllf1k+ghiyp2xezEKntMPe3M0Q3wuZ2uIFAcqGE52gBpoSWg3fgX5bRs2c8yNkz6m7dr1H9OCqfPIOZT2uoPKo5Mysdx9N1wCNSiO0LGtT5WBO3SHDP6A1bmTPziIL92gwn0M3aI+qeZlNmJywYak0yK2RwSJ77rUbir6aefB2GsFExDmFxDI5DQIHvAzutxEX87NzgOOzhV+7ITAyMElgivHi9zyxvLicLLT90F2Uvpi7wFZgOkcYSWG37dwwXJztagzExMC0SkmbwpQBQJLCF8= -----END ENCRYPTED PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIIFXjCCA0agAwIBAgIUTb4om5bTQuSJLyIi7x6 fr14WjhAwDQYJKoZIhvcNAQELBQAwRzELMAkGA1UE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YRhvXgN1nRJCWNuYqFym2BykIl02j4YADWUA4RT6ZGWj/BYIz9oOns53/3O5E/doWl/ZuUzYy+SslX0/62Cn/3oPqaSu/4EGoY7fA7bNLMh/mZ0rD3toufN1bJcoj7OpB54vaM43uLfjIwhd3vjetHshaSNjrDXKSSsfarc8xWn0EozmN3V9TPNv6OT7B4O5eSgJTyxjtxAzgiZ2/KOBj7cHZxVhWL/dV7wuFdFURnU+u/BLxZ9bDvw8Mr7tbN4i19oDICMws45mFTT3vrCYjYGk2eCQ0gCraddONmW5JhCkqBgmnj0W6smPS0cpHqy0XcPsY+sGOBH9rLTDjYleQoy1+EUPEpqZkV3EOVt7XXKg6CIJbQOWq8ReyuW6yDsw6sMy8KFvL+4Uy3a1klsZ0l04WG2e6vYAqma8FhFf7RCQeEMyKD4sUsB2GO6uE/CaFR4SRMnx6za3pB3isTeX1XfRLx+Y216eGIbjXNhOuIjfT0KbqZNx+87OXQB2q2HaiZ6kwI/djYdDvJP9dSY9TTmTjSboiVWl+v3x4jZhShayOKLM3r7l8ZWQItkuGNIX2LGOPaE/YZtLyx8RZklvmRpHrZ49NcDDrQx8dBvUx03thMk3ZhjXI7ObA4jQOMuGpfGVl2F2lKyMRTNXuBjNzWFRvCg== -----END CERTIFICATE-----", "passphrase": "foo" } -------------------------------------------------------------------------------- /src/test/resources/X509AuthenticationTest/corrupted_x509_certificate.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCvLusF36+ts32G 3 | 6khPpJSwHTBBZjPyD0MYlWulsrJLXmew4JJRklbbZFZZ6kkVJEd6weEMdGSmLtaN 4 | RavqU8FSrPajBFSk2fMmtfcbtDHbUXLpF/ji7q920nOx1XxbhJuktNFMP4DqbQty 5 | 0B6VQQsaeZtLtpV4zrwemEZdMBMh3DKUXGYpBhu4+DepXyU9cDHDZs5Ew2XsRBBP 6 | O27U58oOpP7oMKpjq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rTwn 38 | 2J+x7sgaQWVqG30t6oOcLxO7shvsiKt/uZSQHjvQC29F70h3glTtfNwPpNLEbfrm 39 | i3DmLJvicCMPO2NxKZdRRudmVBqDoI21/PAfEa7SOnYcbyv2fE48VK2YCwT2ZkTr 40 | trHw1HSbxVmm1AdM7OkCFwqHBwPPIV1IhqKSMkUCggEAWsDyctHGItqa4nhsEad8 41 | f7MQiQuTxTaeYqIdxSArHGqQ7JbJy+h9wBIFZjd0LauN2/0LDp+P+K5J+XajnxmW 42 | 6heUP0w4Vv5cAcwgtoq65T1LIJiU7BIotBd81JudJjAsr3UN0VPWEF5J1BKkG7VI 43 | Snvxvnt8ds1YH0nl65OIH6eznsofzmLn/wd2DYjjgS5d60u6AyqzTto/pG2qRTJs 44 | 3HPzDpp23QYHAtaFtD+mxl/wrUDriK6REgdeky9PICh3fJQv0shDe4PX88v3iLFh 45 | gKVkbUX0HdUNOaicuOKJiRlAfTM1jHXuDD5P0XVowg5//YcWla9numbZGDJ98Ih7 46 | JQKCAQEAxdsQ3Wlmb+DX78/ofPgHL+R5Arszv+yI05IcmRno+MiSj0bvYiO5+/jN 47 | 1X/CaSRm9UviG6o+7vrMpw2/xq1UAC7P8JPTLWWyShW7yHX9H6nU87yhpxO4oOm+ 48 | hTONsaDut87lbBn3quvMMfeBt71BZ8Ie01Mszh9sWXwHVCEWgDomo2Dg7scRF7Ew 49 | E9Q+bPv0ylnkBEry/XVomGMBzlcQ7OBrMCGCxWZQnPW+1cWDApEPufXjKoalGIIl 50 | vrd+Gc6BZKoL4Cfp9hszEyz18uWgzcP78K/emmZWgLhyStsJDeZ3xCCaGvlaxIFu 51 | yXKgJVgDPxD3qXjY6VMMoudnihbV6Q== 52 | -----END PRIVATE KEY----- 53 | -----BEGIN CERTIFICATE----- 54 | MIIFXjCCA0agAwIBAgIUTb4om5bTQuSJLyIi7x6fr14WjhAwDQYJKoZIhvcNAQEL 55 | BQAwRzELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAk5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jMA0GCSqGSIb3DQEBCwUAA4IC 72 | AQAs2TUbazXNMDRWjUeYRhvXgN1nRJCWNuYqFym2BykIl02j4YADWUA4RT6ZGWj/ 73 | BYIz9oOns53/3O5E/doWl/ZuUzYy+SslX0/62Cn/3oPqaSu/4EGoY7fA7bNLMh/m 74 | Z0rD3toufN1bJcoj7OpB54vaM43uLfjIwhd3vjetHshaSNjrDXKSSsfarc8xWn0E 75 | ozmN3V9TPNv6OT7B4O5eSgJTyxjtxAzgiZ2/KOBj7cHZxVhWL/dV7wuFdFURnU+u 76 | /BLxZ9bDvw8Mr7tbN4i19oDICMws45mFTT3vrCYjYGk2eCQ0gCraddONmW5JhCkq 77 | Bgmnj0W6smPS0cpHqy0XcPsY+sGOBH9rLTDjYleQoy1+EUPEpqZkV3EOVt7XXKg6 78 | CIJbQOWq8ReyuW6yDsw6sMy8KFvL+4Uy3a1klsZ0l04WG2e6vYAqma8FhFf7RCQe 79 | EMyKD4sUsB2GO6uE/CaFR4SRMnx6za3pB3isTeX1XfRLx+Y216eGIbjXNhOuIjfT 80 | KLM3r7l8ZWQItkuGNIX2LGOPaE/YZtLyx8RZklvmRpHrZ49NcDDrQx8dBvUx03th 81 | Mk3ZhjXI7ObA4jQOMuGpfGVl2F2lKyMRTNXuBjNzWFRvCg== 82 | -----END CERTIFICATE----- 83 | -------------------------------------------------------------------------------- /resources/authentication_test/X509/client-unencrypted.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCvLusF36+ts32G 3 | 6khPpJSwHTBBZjPyD0MYlWulsrJLXmew4JJRklbbZFZZ6kkVJEd6weEMdGSmLtaN 4 | RavqU8FSrPajBFSk2fMmtfcbtDHbUXLpF/ji7q920nOx1XxbhJuktNFMP4DqbQty 5 | 0B6VQQsaeZtLtpV4zrwemEZdMBMh3DKUXGYpBhu4+DepXyU9cDHDZs5Ew2XsRBBP 6 | O27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g/QqV4OQxftotls+rTwn 38 | 2J+x7sgaQWVqG30t6oOcLxO7shvsiKt/uZSQHjvQC29F70h3glTtfNwPpNLEbfrm 39 | i3DmLJvicCMPO2NxKZdRRudmVBqDoI21/PAfEa7SOnYcbyv2fE48VK2YCwT2ZkTr 40 | trHw1HSbxVmm1AdM7OkCFwqHBwPPIV1IhqKSMkUCggEAWsDyctHGItqa4nhsEad8 41 | f7MQiQuTxTaeYqIdxSArHGqQ7JbJy+h9wBIFZjd0LauN2/0LDp+P+K5J+XajnxmW 42 | 6heUP0w4Vv5cAcwgtoq65T1LIJiU7BIotBd81JudJjAsr3UN0VPWEF5J1BKkG7VI 43 | Snvxvnt8ds1YH0nl65OIH6eznsofzmLn/wd2DYjjgS5d60u6AyqzTto/pG2qRTJs 44 | 3HPzDpp23QYHAtaFtD+mxl/wrUDriK6REgdeky9PICh3fJQv0shDe4PX88v3iLFh 45 | gKVkbUX0HdUNOaicuOKJiRlAfTM1jHXuDD5P0XVowg5//YcWla9numbZGDJ98Ih7 46 | JQKCAQEAxdsQ3Wlmb+DX78/ofPgHL+R5Arszv+yI05IcmRno+MiSj0bvYiO5+/jN 47 | 1X/CaSRm9UviG6o+7vrMpw2/xq1UAC7P8JPTLWWyShW7yHX9H6nU87yhpxO4oOm+ 48 | hTONsaDut87lbBn3quvMMfeBt71BZ8Ie01Mszh9sWXwHVCEWgDomo2Dg7scRF7Ew 49 | E9Q+bPv0ylnkBEry/XVomGMBzlcQ7OBrMCGCxWZQnPW+1cWDApEPufXjKoalGIIl 50 | vrd+Gc6BZKoL4Cfp9hszEyz18uWgzcP78K/emmZWgLhyStsJDeZ3xCCaGvlaxIFu 51 | yXKgJVgDPxD3qXjY6VMMoudnihbV6Q== 52 | -----END PRIVATE KEY----- 53 | -----BEGIN CERTIFICATE----- 54 | MIIFXjCCA0agAwIBAgIUTb4om5bTQuSJLyIi7x6fr14WjhAwDQYJKoZIhvcNAQEL 55 | BQAwRzELMAkGA1UEBhMCVVMxCzA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kTzoVCa+lJWe+jMA0GCSqGSIb3DQEBCwUAA4IC 72 | AQAs2TUbazXNMDRWjUeYRhvXgN1nRJCWNuYqFym2BykIl02j4YADWUA4RT6ZGWj/ 73 | BYIz9oOns53/3O5E/doWl/ZuUzYy+SslX0/62Cn/3oPqaSu/4EGoY7fA7bNLMh/m 74 | Z0rD3toufN1bJcoj7OpB54vaM43uLfjIwhd3vjetHshaSNjrDXKSSsfarc8xWn0E 75 | ozmN3V9TPNv6OT7B4O5eSgJTyxjtxAzgiZ2/KOBj7cHZxVhWL/dV7wuFdFURnU+u 76 | /BLxZ9bDvw8Mr7tbN4i19oDICMws45mFTT3vrCYjYGk2eCQ0gCraddONmW5JhCkq 77 | Bgmnj0W6smPS0cpHqy0XcPsY+sGOBH9rLTDjYleQoy1+EUPEpqZkV3EOVt7XXKg6 78 | CIJbQOWq8ReyuW6yDsw6sMy8KFvL+4Uy3a1klsZ0l04WG2e6vYAqma8FhFf7RCQe 79 | EMyKD4sUsB2GO6uE/CaFR4SRMnx6za3pB3isTeX1XfRLx+Y216eGIbjXNhOuIjfT 80 | 0KbqZNx+87OXQB2q2HaiZ6kwI/djYdDvJP9dSY9TTmTjSboiVWl+v3x4jZhShayO 81 | KLM3r7l8ZWQItkuGNIX2LGOPaE/YZtLyx8RZklvmRpHrZ49NcDDrQx8dBvUx03th 82 | Mk3ZhjXI7ObA4jQOMuGpfGVl2F2lKyMRTNXuBjNzWFRvCg== 83 | -----END CERTIFICATE----- 84 | -------------------------------------------------------------------------------- /src/test/resources/X509AuthenticationTest/pkcs8_unencrypted.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCvLusF36+ts32G 3 | 6khPpJSwHTBBZjPyD0MYlWulsrJLXmew4JJRklbbZFZZ6kkVJEd6weEMdGSmLtaN 4 | RavqU8FSrPajBFSk2fMmtfcbtDHbUXLpF/ji7q920nOx1Xxb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DxsN4mYCBKg2h/Jlac7uAfDcpS+prWSas1QopQ3eUMM0G 37 | rJL2isaXdYfX9xboPzmlV1EpZpx1JyLEDX5wzJmte2wIg/QqV4OQxftotls+rTwn 38 | 2J+x7sgaQWVqG30t6oOcLxO7shvsiKt/uZSQHjvQC29F70h3glTtfNwPpNLEbfrm 39 | i3DmLJvicCMPO2NxKZdRRudmVBqDoI21/PAfEa7SOnYcbyv2fE48VK2YCwT2ZkTr 40 | trHw1HSbxVmm1AdM7OkCFwqHBwPPIV1IhqKSMkUCggEAWsDyctHGItqa4nhsEad8 41 | f7MQiQuTxTaeYqIdxSArHGqQ7JbJy+h9wBIFZjd0LauN2/0LDp+P+K5J+XajnxmW 42 | 6heUP0w4Vv5cAcwgtoq65T1LIJiU7BIotBd81JudJjAsr3UN0VPWEF5J1BKkG7VI 43 | Snvxvnt8ds1YH0nl65OIH6eznsofzmLn/wd2DYjjgS5d60u6AyqzTto/pG2qRTJs 44 | 3HPzDpp23QYHAtaFtD+mxl/wrUDriK6REgdeky9PICh3fJQv0shDe4PX88v3iLFh 45 | gKVkbUX0HdUNOaicuOKJiRlAfTM1jHXuDD5P0XVowg5//YcWla9numbZGDJ98Ih7 46 | JQKCAQEAxdsQ3Wlmb+DX78/ofPgHL+R5Arszv+yI05IcmRno+MiSj0bvYiO5+/jN 47 | 1X/CaSRm9UviG6o+7vrMpw2/xq1UAC7P8JPTLWWyShW7yHX9H6nU87yhpxO4oOm+ 48 | hTONsaDut87lbBn3quvMMfeBt71BZ8Ie01Mszh9sWXwHVCEWgDomo2Dg7scRF7Ew 49 | E9Q+bPv0ylnkBEry/XVomGMBzlcQ7OBrMCGCxWZQnPW+1cWDApEPufXjKoalGIIl 50 | vrd+Gc6BZKoL4Cfp9hszEyz18uWgzcP78K/emmZWgLhyStsJDeZ3xCCaGvlaxIFu 51 | yXKgJVgDPxD3qXjY6VMMoudnihbV6Q== 52 | -----END PRIVATE KEY----- 53 | -----BEGIN CERTIFICATE----- 54 | MII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ilECAwEAAaNCMEAwHQYDVR0OBBYEFPzTvfJYswlqZdfAGoPMzUWHc2GWMB8G 71 | A1UdIwQYMBaAFGGi0J1Cws/ZD4kTzoVCa+lJWe+jMA0GCSqGSIb3DQEBCwUAA4IC 72 | AQAs2TUbazXNMDRWjUeYRhvXgN1nRJCWNuYqFym2BykIl02j4YADWUA4RT6ZGWj/ 73 | BYIz9oOns53/3O5E/doWl/ZuUzYy+SslX0/62Cn/3oPqaSu/4EGoY7fA7bNLMh/m 74 | Z0rD3toufN1bJcoj7OpB54vaM43uLfjIwhd3vjetHshaSNjrDXKSSsfarc8xWn0E 75 | ozmN3V9TPNv6OT7B4O5eSgJTyxjtxAzgiZ2/KOBj7cHZxVhWL/dV7wuFdFURnU+u 76 | /BLxZ9bDvw8Mr7tbN4i19oDICMws45mFTT3vrCYjYGk2eCQ0gCraddONmW5JhCkq 77 | Bgmnj0W6smPS0cpHqy0XcPsY+sGOBH9rLTDjYleQoy1+EUPEpqZkV3EOVt7XXKg6 78 | CIJbQOWq8ReyuW6yDsw6sMy8KFvL+4Uy3a1klsZ0l04WG2e6vYAqma8FhFf7RCQe 79 | EMyKD4sUsB2GO6uE/CaFR4SRMnx6za3pB3isTeX1XfRLx+Y216eGIbjXNhOuIjfT 80 | 0KbqZNx+87OXQB2q2HaiZ6kwI/djYdDvJP9dSY9TTmTjSboiVWl+v3x4jZhShayO 81 | KLM3r7l8ZWQItkuGNIX2LGOPaE/YZtLyx8RZklvmRpHrZ49NcDDrQx8dBvUx03th 82 | Mk3ZhjXI7ObA4jQOMuGpfGVl2F2lKyMRTNXuBjNzWFRvCg== 83 | -----END CERTIFICATE----- 84 | -------------------------------------------------------------------------------- /resources/authentication_test/X509/server.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCWJ41t0dYtMGDE 3 | 3cpNdsQVkyceOzFvyIJD6NgOuEBbcKhyuom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 51 | T7klrEJ8hBzC0J77eZfIqnjbsw50rg== 52 | -----END PRIVATE KEY----- 53 | -----BEGIN CERTIFICATE----- 54 | MIIFmTCCA4GgAwIBAgIUTb4om5bTQuSJLyIi7x6fr14WjhEwDQYJKoZIhvcNAQEL 55 | BQAwRzELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAk5ZMQswCQYDVQQHDAJOWTEQMA4G 56 | A1UECgwHbW9uZ29kYjEMMAoGA1UECwwDZW5nMB4XDTI0MTEyNTE3NDAyMFoXDTI1 57 | MTEyNTE3NDAyMFowZjELMAkGA1UEBhMCVVMxDjAMBgNVBAgMBVN0YXRlMQ0wCwYD 58 | VQQHDARDaXR5MRUwEwYDVQQKDAxPcmdhbml6YXRpb24xDTALBgNVBAsMBFVuaXQx 59 | EjAQBgNVBAMMCWxvY2FsaG9zdDCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC 60 | ggIBAJYnjW3R1i0wYMTdyk12xBWTJx47MW/IgkPo2A64QFtwqHK6iYiD+sWiq05B 61 | pE8ZPtoqlni98db9qzSB5tzmajItE5aHnnexc6N38W6OF63gbguDqfSkZRO5lK3m 62 | T7ckK6tcTeKkAntMlpsjr/gKEIaYSk4FK2ROVrRIF2ubCJdNbjrUMc2fU7VVdo5j 63 | DErmIw4f1faCPkn+PoZfHPir0T+KE0TESHRRRpAvpWNvSy7vrxM3PM6yp7D3UWry 64 | O2Gc5WoTurml4bZOYf+mnmGQpHAdV0aYTdqD070491O7e9FdaIyzVyWDv9x77iQY 65 | E9wPB+mz1dPxoamOYQryHA/9XSFcljeddVnwbKmt6RQwxZ52nk1ZXxo8m/TQcrnd 66 | 9/NeQtKer1j6l/Vi0eSTXm+uD8A32UtuJBqvD0fZsqqtQ1PYqJFlY2fXu9h/2hEy 67 | uHW2zVoPX2sg2GRzMFQbgzBG51/Zl5090HULfih0gimULjNgNe81orW9/st9F5xp 68 | VPDaacMMWqjyuEIJ0146B5MGKSBKm1i1nvQobktDZiDWai+d3T1AYTHB0HeXrV3S 69 | AlBukqzEf4qtU4rxaVelrDq5FHXw9y9V2OEJtYlr8hk2rJWqPjcw0gY6QaDG8Jmg 70 | /Biotnx904vHYAgvtZzjVUSRMmweIlWkN9pvYhBTLSJIFoaXAgMBAAGjXjBcMBoG 71 | A1UdEQQTMBGCCWxvY2FsaG9zdIcEfwAAATAdBgNVHQ4EFgQU2ugGd/w9PIA3xJ53 72 | Rtgw1UhuAnIwHwYDVR0jBBgwFoAUYaLQnULCz9kPiRPOhUJr6UlZ76MwDQYJKoZI 73 | hvcNAQELBQADggIBAGtH+ScSErE9pkrnWmKv/RmhU93ucr8U0U+Cn8CQIwbpepNP 74 | J3l8wj4tTpjh/sXZfXMGmlCpblfJ9JTMNjjxEQ3BhYKSuWI6m9goeOKvCLe+Ida0 75 | D5VKGxtfduF0REJ3jXss+hh6mugLsr7WBKvjZpUHgOELPy3w87kTM8u3S2p5cG1I 76 | lNccxQmdsNCl73+AWKPSgBKNC3u3X7TWKPirTyVeawarn4pH5Lk7/NnOL324lp/1 77 | c02z4Me7FyreO05vME8w/4/Mb8I9OFH/B0P0UNd50ToHavFZrCEBUje50zzL/fRO 78 | sGb0wImX0Ee2Jh7Z6im59rxco3oYMa7jJ2Swdgsw9XjDv9LU3cGMyBYansM9gkGK 79 | E+obVEDHZG3doVA0ttV2wIWhuLIH00igSK4SaUqhn/FOEorIRGUP1c6Ns7+hZRgM 80 | /aAb4nPTS5AT8ua349opearSiAgOKt0AH4UtEEzr3KllbYDpqZFR6P+jzJR068UF 81 | wl5YdC7kK/YuixjNGkDNBK34nZ2Sg3l1ANG30ch8Xrm7xeqIDm7BsCgftqlvdcML 82 | 6c5R0EOwK+B05ZCGx4E1sqGPUo6Lr0PjY8y3S2cwkK3TSJ8T0FV0quGYHZn0zUe4 83 | zb2NGr6qOGnMC+cK5sbdU/OUmcGj15gRzqK+DWfOI89/uln39hN8PfvbYjpz 84 | -----END CERTIFICATE----- 85 | -------------------------------------------------------------------------------- /resources/authentication_test/X509/client-encrypted.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN ENCRYPTED PRIVATE KEY----- 2 | MIIJtTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQUjijUatETENAlNB+ 3 | Z1UTgQICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEGeKrpA4jW+Ua4VP 4 | EBmmdGoEgglQEVCoUeSchSa/tOA0kBmByM8qNzd7iksIhSjE4Le7bUGT75bA98iT 5 | YQyYeVYM8k/sJ5YFMduZiENNEhjGC6cbu4LzhgoDF/w+12/prncBE9WlKgdvZWsG 6 | cHr2wB9NVNwmc7sfFjVT9MEgku6xKh8Yznwm604FNaU1qHZTSVXuT3KGB/CBMofk 7 | SxMJdx13Y5u9zksR4yIikmVj42jtdZT+RMRBjasO1vkRdGo9MhemBBVbq/o60V32 8 | /5WyXhOWjAv5hcMZqHO9ch3DT8W1JSiLjBMj7Y+jfhYq30sgbf3HMbVe2R/2Bp34 9 | eZ0J8of6ZIcYC0gJC14a/wFTO7YxU0cq1fHEMJijbRHWI2RH1MvMwlY91h5H4dMJ 10 | Uao90s7qmX+X9Uyscouca6ljdrCixxfMPYp14jfz0rc2YEBY19Bh25GZHHmHigDT 11 | ngaG429TraUI68DN8YJopXfoaxYXwGlThhdcphQw94UJa1U9SXXJbLskYJpvlTDX 12 | a6N9wVk2Jp11Ayu3GfwjwunQoxr34+185NJLLt/gElQYTcZC12FzwD4+a4mmaKmN 13 | 49Zc4ZkgqAsa9bOeluZR5H/PhBTn6Yxv/AdRkh8oSsXEFKmD3Ds+11LO8I7sFSDE 14 | K3oIZBLkXEXHzsb4A44Hoq9SX92fwshpT9/58dK4KmujD3c6N04wQbcM2GF1Bs77 15 | SiN/gmMVDDvI7ID3wp1TK96sf7A66xiSlvgplva2Fh7SsslyzAmw722nQUijzqoj 16 | WD5klHnfbBAZJ7HcZ3Azqfjf3lEXQEInfpV4ad54JEiSORQaPiBR22SccOXar0OM 17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ZS5Zsuy7iMPDyTufhEpJKdd7BA/tM8SFNauQR+7E0elg 49 | jWj+f9uaLWj6omMtDwa2fo+gtR/RZc4A5QZ5KDVa8Fo69MUlxSqlBeIcSMrSBHOv 50 | PJmRyqtHdmgFKP+xIuudTxQIRVZL8/UbwasfKKidefYWCmXmgSXqv7pRku/jzdwU 51 | UwI3rhN7Ua0cXAOLaylefd3N179cJJUm6C73tqiWD+zwa/KW5tWWdnsKkjDBXGx4 52 | tzsFNlxS1s6TVeWMxavCCS0l5UlVJ5rrGq8yq+aoDktLCSAnmT0z3lPhvno9S7dA 53 | ZJoyMrif0EzphdkopkfjxKBSMzKXhKhEbSe9EVkmhaOpc7dg5SK5gso= 54 | -----END ENCRYPTED PRIVATE KEY----- 55 | -----BEGIN CERTIFICATE----- 56 | MIIFXjCCA0agAwIBAgIUTb4om5bTQuSJLyIi7x6fr14WjhAwDQYJKoZIhvcNAQEL 57 | BQAwRzELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAk5ZMQswCQYDVQQHDAJOWTEQMA4G 58 | A1UECgwHbW9uZ29kYjEMMAoGA1UECwwDZW5nMB4XDTI0MTEyNTE3MzY1MVoXDTI1 59 | MTEyNTE3MzY1MVowRzELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAk5ZMQswCQYDVQQH 60 | DAJOWTEQMA4GA1UECgwHbW9uZ29kYjEMMAoGA1UECwwDZW5nMIICIjANBgkqhkiG 61 | 9w0BAQEFAAOCAg8AMIICCgKCAgEAry7rBd+vrbN9hupIT6SUsB0wQWYz8g9DGJVr 62 | pbKyS15nsOCSUZJW22RWWepJFSRHesHhDHRkpi7WjUWr6lPBUqz2owRUpNnzJrX3 63 | G7Qx21Fy6Rf44u6vdtJzsdV8W4SbpLTRTD+A6m0LctAelUELGnmbS7aVeM68HphG 64 | XTATIdwylFxmKQYbuPg3qV8lPXAxw2bORMNl7EQQTztu1OfKDqT+6DCqY6g3yqB5 65 | yUJj9ENaqsURd437h+kquYuMxmJ7uTn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SRMnx6za3pB3isTeX1XfRLx+Y216eGIbjXNhOuIjfT 82 | 0KbqZNx+87OXQB2q2HaiZ6kwI/djYdDvJP9dSY9TTmTjSboiVWl+v3x4jZhShayO 83 | KLM3r7l8ZWQItkuGNIX2LGOPaE/YZtLyx8RZklvmRpHrZ49NcDDrQx8dBvUx03th 84 | Mk3ZhjXI7ObA4jQOMuGpfGVl2F2lKyMRTNXuBjNzWFRvCg== 85 | -----END CERTIFICATE----- 86 | 87 | --------------------------------------------------------------------------------