├── .github └── workflows │ └── run-tests.yaml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── SECURITY.md ├── THIRD_PARTY_LICENSES.txt ├── ojdbc-provider-aws ├── README.md ├── THIRD_PARTY_LICENSES.txt ├── example-aws-secretsmanager-wallet.properties ├── example-aws-secretsmanager.properties ├── example-test.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── oracle │ │ │ └── jdbc │ │ │ └── provider │ │ │ └── aws │ │ │ ├── AwsResourceFactory.java │ │ │ ├── authentication │ │ │ ├── AwsAuthenticationMethod.java │ │ │ └── AwsCredentialsFactory.java │ │ │ ├── configuration │ │ │ ├── AwsConfigurationParameters.java │ │ │ ├── AwsJsonSecretsManagerProvider.java │ │ │ ├── AwsS3ConfigurationProvider.java │ │ │ └── AwsSecretsManagerConfigurationProvider.java │ │ │ ├── resource │ │ │ ├── AwsResourceProvider.java │ │ │ ├── AwsSecretsManagerResourceParameterNames.java │ │ │ ├── SecretsManagerConnectionStringProvider.java │ │ │ ├── SecretsManagerPasswordProvider.java │ │ │ ├── SecretsManagerSEPSProvider.java │ │ │ ├── SecretsManagerSecretProvider.java │ │ │ ├── SecretsManagerTCPSProvider.java │ │ │ └── SecretsManagerUsernameProvider.java │ │ │ ├── s3 │ │ │ └── S3Factory.java │ │ │ └── secrets │ │ │ ├── AwsSecretExtractor.java │ │ │ └── SecretsManagerFactory.java │ └── resources │ │ └── META-INF │ │ └── services │ │ ├── oracle.jdbc.spi.ConnectionStringProvider │ │ ├── oracle.jdbc.spi.OracleConfigurationProvider │ │ ├── oracle.jdbc.spi.OracleConfigurationSecretProvider │ │ ├── oracle.jdbc.spi.PasswordProvider │ │ ├── oracle.jdbc.spi.TlsConfigurationProvider │ │ └── oracle.jdbc.spi.UsernameProvider │ └── test │ └── java │ └── oracle │ └── provider │ └── aws │ ├── AwsTestProperty.java │ ├── configuration │ ├── AwsS3ConfigurationProviderTest.java │ └── AwsSecretsManagerConfigurationProviderTest.java │ └── resource │ ├── SecretsManagerConnectionStringProviderTest.java │ ├── SecretsManagerPasswordProviderTest.java │ ├── SecretsManagerSepsProviderTest.java │ ├── SecretsManagerTcpsProviderTest.java │ └── SecretsManagerUsernameProviderTest.java ├── ojdbc-provider-azure ├── README.md ├── THIRD_PARTY_LICENSES.txt ├── example-key-vault-wallet.properties ├── example-key-vault.properties ├── example-test.properties ├── example-token.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── oracle │ │ │ └── jdbc │ │ │ └── provider │ │ │ └── azure │ │ │ ├── AzureResourceFactory.java │ │ │ ├── authentication │ │ │ ├── AzureAuthenticationMethod.java │ │ │ └── TokenCredentialFactory.java │ │ │ ├── configuration │ │ │ ├── AzureAppConfigurationProvider.java │ │ │ ├── AzureAppConfigurationURLParser.java │ │ │ ├── AzureConfigurationParameters.java │ │ │ ├── AzureVaultJsonProvider.java │ │ │ ├── AzureVaultSecretProvider.java │ │ │ └── AzureVaultURLParser.java │ │ │ ├── keyvault │ │ │ └── KeyVaultSecretFactory.java │ │ │ ├── oauth │ │ │ └── AccessTokenFactory.java │ │ │ └── resource │ │ │ ├── AzureResourceProvider.java │ │ │ ├── AzureTokenProvider.java │ │ │ ├── KeyVaultConnectionStringProvider.java │ │ │ ├── KeyVaultPasswordProvider.java │ │ │ ├── KeyVaultSEPSProvider.java │ │ │ ├── KeyVaultSecretProvider.java │ │ │ ├── KeyVaultTCPSProvider.java │ │ │ └── KeyVaultUserNameProvider.java │ └── resources │ │ └── META-INF │ │ └── services │ │ ├── oracle.jdbc.spi.AccessTokenProvider │ │ ├── oracle.jdbc.spi.ConnectionStringProvider │ │ ├── oracle.jdbc.spi.OracleConfigurationProvider │ │ ├── oracle.jdbc.spi.OracleConfigurationSecretProvider │ │ ├── oracle.jdbc.spi.PasswordProvider │ │ ├── oracle.jdbc.spi.TlsConfigurationProvider │ │ └── oracle.jdbc.spi.UsernameProvider │ └── test │ └── java │ └── oracle │ └── jdbc │ └── provider │ └── azure │ ├── AzureTestProperty.java │ ├── authentication │ └── TokenCredentialFactoryTest.java │ ├── configuration │ ├── AzureAppConfigurationProviderTest.java │ ├── AzureAppConfigurationProviderURLParserTest.java │ ├── AzureVaultJsonProviderTest.java │ └── AzureVaultSecretProviderTest.java │ └── resource │ ├── AzureResourceProviderTestUtil.java │ ├── AzureTokenProviderTest.java │ ├── KeyVaultConnectionStringProviderTest.java │ ├── KeyVaultPasswordProviderTest.java │ ├── KeyVaultSEPSProviderTest.java │ ├── KeyVaultTCPSProviderTest.java │ └── KeyVaultUsernameProviderTest.java ├── ojdbc-provider-common ├── README.md ├── THIRD_PARTY_LICENSES.txt ├── pom.xml └── src │ ├── main │ └── java │ │ └── oracle │ │ └── jdbc │ │ └── provider │ │ ├── cache │ │ ├── CacheController.java │ │ └── CachedResourceFactory.java │ │ ├── configuration │ │ └── JsonSecretUtil.java │ │ ├── factory │ │ ├── AbstractResource.java │ │ ├── ExpiringResource.java │ │ ├── PermanentResource.java │ │ ├── Resource.java │ │ └── ResourceFactory.java │ │ ├── oauth │ │ └── AccessTokenCacheFactory.java │ │ ├── parameter │ │ ├── Parameter.java │ │ ├── ParameterImpl.java │ │ ├── ParameterSet.java │ │ ├── ParameterSetBuilder.java │ │ ├── ParameterSetBuilderImpl.java │ │ ├── ParameterSetImpl.java │ │ ├── ParameterSetParser.java │ │ ├── ParameterSetParserImpl.java │ │ └── UriParameters.java │ │ ├── resource │ │ ├── AbstractResourceProvider.java │ │ └── ResourceParameter.java │ │ └── util │ │ ├── CommonParameters.java │ │ ├── FileUtils.java │ │ ├── JsonWebTokenParser.java │ │ ├── PemData.java │ │ ├── ResourceParameterUtils.java │ │ ├── TNSNames.java │ │ ├── TlsUtils.java │ │ ├── Wallet.java │ │ └── WalletUtils.java │ └── test │ └── java │ └── oracle │ └── jdbc │ └── provider │ ├── TestProperties.java │ ├── cache │ ├── CacheControllerTest.java │ └── CachedResourceFactoryTest.java │ ├── factory │ ├── TestResource.java │ └── TestResourceFactory.java │ ├── oauth │ └── AccessTokenCacheFactoryTest.java │ ├── parameter │ ├── ParameterSetParserTest.java │ └── ParameterSetTest.java │ ├── resource │ └── ResourceProviderTestUtil.java │ └── util │ └── PemDataTest.java ├── ojdbc-provider-gcp ├── README.md ├── THIRD_PARTY_LICENSES.txt ├── example-secret-manager-wallet.properties ├── example-test.properties ├── example-vault.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── oracle │ │ │ └── jdbc │ │ │ └── provider │ │ │ └── gcp │ │ │ ├── configuration │ │ │ ├── GcpCloudStorageConfigurationProvider.java │ │ │ ├── GcpConfigurationParameters.java │ │ │ ├── GcpJsonSecretManagerProvider.java │ │ │ └── GcpSecretManagerConfigurationProvider.java │ │ │ ├── objectstorage │ │ │ └── GcpCloudStorageFactory.java │ │ │ ├── resource │ │ │ ├── GcpSecretManagerConnectionStringProvider.java │ │ │ ├── GcpSecretManagerPasswordProvider.java │ │ │ ├── GcpSecretManagerProvider.java │ │ │ ├── GcpSecretManagerSEPSProvider.java │ │ │ ├── GcpSecretManagerTCPSProvider.java │ │ │ └── GcpSecretManagerUsernameProvider.java │ │ │ └── secrets │ │ │ └── GcpSecretManagerFactory.java │ └── resources │ │ └── META-INF │ │ └── services │ │ ├── oracle.jdbc.spi.ConnectionStringProvider │ │ ├── oracle.jdbc.spi.OracleConfigurationProvider │ │ ├── oracle.jdbc.spi.OracleConfigurationSecretProvider │ │ ├── oracle.jdbc.spi.PasswordProvider │ │ ├── oracle.jdbc.spi.TlsConfigurationProvider │ │ └── oracle.jdbc.spi.UsernameProvider │ └── test │ └── java │ └── oracle │ └── provider │ └── gcp │ ├── GcpTestProperty.java │ ├── configuration │ ├── GcpCloudStorageProviderTest.java │ └── GcpSecretManagerConfigurationProviderTest.java │ └── resource │ ├── GcpSecretManagerConnectionStringProviderTest.java │ ├── GcpSecretManagerPasswordProviderTest.java │ ├── GcpSecretManagerSEPSProviderTest.java │ ├── GcpSecretManagerTCPSProviderTest.java │ └── GcpSecretManagerUsernameProviderTest.java ├── ojdbc-provider-hashicorp ├── README.md ├── example-test.properties ├── example-vault-dedicated-wallet.properties ├── example-vault-dedicated.properties ├── example-vault-secrets-wallet.properties ├── example-vault-secrets.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── oracle │ │ │ └── jdbc │ │ │ └── provider │ │ │ └── hashicorp │ │ │ ├── hcpvaultdedicated │ │ │ ├── DedicatedVaultResourceFactory.java │ │ │ ├── authentication │ │ │ │ ├── AbstractDedicatedVaultAuthentication.java │ │ │ │ ├── AppRoleAuthentication.java │ │ │ │ ├── AutoDetectAuthentication.java │ │ │ │ ├── CachedToken.java │ │ │ │ ├── DedicatedVaultAuthenticationMethod.java │ │ │ │ ├── DedicatedVaultParameters.java │ │ │ │ ├── DedicatedVaultToken.java │ │ │ │ ├── DedicatedVaultTokenFactory.java │ │ │ │ ├── GitHubAuthentication.java │ │ │ │ ├── UserpassAuthentication.java │ │ │ │ └── VaultTokenAuthentication.java │ │ │ ├── configuration │ │ │ │ ├── DedicatedVaultJsonSecretProvider.java │ │ │ │ └── DedicatedVaultSecretsManagerConfigurationProvider.java │ │ │ ├── resource │ │ │ │ ├── HcpVaultDedicatedConnectionStringProvider.java │ │ │ │ ├── HcpVaultDedicatedPasswordProvider.java │ │ │ │ ├── HcpVaultDedicatedResourceParameterNames.java │ │ │ │ ├── HcpVaultDedicatedResourceProvider.java │ │ │ │ ├── HcpVaultDedicatedSEPSProvider.java │ │ │ │ ├── HcpVaultDedicatedSecretProvider.java │ │ │ │ ├── HcpVaultDedicatedTCPSProvider.java │ │ │ │ └── HcpVaultDedicatedUsernameProvider.java │ │ │ └── secrets │ │ │ │ └── DedicatedVaultSecretsManagerFactory.java │ │ │ ├── hcpvaultsecret │ │ │ ├── HcpVaultResourceFactory.java │ │ │ ├── authentication │ │ │ │ ├── AbstractHcpVaultAuthentication.java │ │ │ │ ├── AutoDetectAuthentication.java │ │ │ │ ├── CliCredentialsFileAuthentication.java │ │ │ │ ├── ClientCredentialsAuthentication.java │ │ │ │ ├── HcpVaultAuthenticationMethod.java │ │ │ │ ├── HcpVaultCredentialsFileAuthenticator.java │ │ │ │ ├── HcpVaultOAuthClient.java │ │ │ │ ├── HcpVaultSecretParameters.java │ │ │ │ ├── HcpVaultSecretToken.java │ │ │ │ └── HcpVaultTokenFactory.java │ │ │ ├── configuration │ │ │ │ ├── HcpVaultJsonVaultProvider.java │ │ │ │ └── HcpVaultSecretsManagerConfigurationProvider.java │ │ │ ├── resource │ │ │ │ ├── HcpVaultSecretConnectionStringProvider.java │ │ │ │ ├── HcpVaultSecretPasswordProvider.java │ │ │ │ ├── HcpVaultSecretProvider.java │ │ │ │ ├── HcpVaultSecretResourceParameterNames.java │ │ │ │ ├── HcpVaultSecretResourceProvider.java │ │ │ │ ├── HcpVaultSecretSEPSProvider.java │ │ │ │ ├── HcpVaultSecretTCPSProvider.java │ │ │ │ └── HcpVaultSecretUsernameProvider.java │ │ │ └── secrets │ │ │ │ ├── HcpVaultApiClient.java │ │ │ │ └── HcpVaultSecretsManagerFactory.java │ │ │ └── util │ │ │ ├── AbstractVaultResourceProvider.java │ │ │ ├── HttpUtil.java │ │ │ ├── JsonUtil.java │ │ │ └── Parameterutil.java │ └── resources │ │ └── META-INF │ │ └── services │ │ ├── oracle.jdbc.spi.ConnectionStringProvider │ │ ├── oracle.jdbc.spi.OracleConfigurationProvider │ │ ├── oracle.jdbc.spi.OracleConfigurationSecretProvider │ │ ├── oracle.jdbc.spi.PasswordProvider │ │ ├── oracle.jdbc.spi.TlsConfigurationProvider │ │ └── oracle.jdbc.spi.UsernameProvider │ └── test │ └── java │ └── oracle │ └── jdbc │ └── provider │ └── hashicorp │ ├── hcpvaultdedicated │ ├── DedicatedVaultTestProperty.java │ ├── HcpVaultDedicatedTestUtil.java │ ├── configuration │ │ └── DedicatedVaultConfigurationProviderTest.java │ └── resource │ │ ├── HcpVaultDedicatedConnectionStringProviderTest.java │ │ ├── HcpVaultDedicatedPasswordProviderTest.java │ │ ├── HcpVaultDedicatedSEPSProviderTest.java │ │ ├── HcpVaultDedicatedTCPSProviderTest.java │ │ └── HcpVaultDedicatedUsernameProviderTest.java │ └── hcpvaultsecret │ ├── HcpVaultTestProperty.java │ ├── HcpVaultTestUtil.java │ ├── configuration │ └── HcpVaultConfigurationProviderTest.java │ └── resource │ ├── HcpVaultConnectionStringProviderTest.java │ ├── HcpVaultPasswordProviderTest.java │ ├── HcpVaultSEPSProviderTest.java │ ├── HcpVaultTCPSProviderTest.java │ └── HcpVaultUsernameProviderTest.java ├── ojdbc-provider-jackson-oson ├── README.md ├── THIRD_PARTY_LICENSES.txt ├── example-test.properties ├── file.json ├── pom.xml └── src │ ├── main │ ├── java │ │ └── oracle │ │ │ └── jdbc │ │ │ └── provider │ │ │ └── oson │ │ │ ├── JacksonOsonConverter.java │ │ │ ├── JacksonOsonProvider.java │ │ │ ├── OsonFactory.java │ │ │ ├── OsonGenerator.java │ │ │ ├── OsonModule.java │ │ │ ├── OsonParser.java │ │ │ ├── Util.java │ │ │ ├── deser │ │ │ ├── OsonBigIntegerDeserializer.java │ │ │ ├── OsonBooleanDeserializer.java │ │ │ ├── OsonByteDeserializer.java │ │ │ ├── OsonConverterArrayDeserializer.java │ │ │ ├── OsonConverterDeserializer.java │ │ │ ├── OsonDateDeserializer.java │ │ │ ├── OsonDurationDeserializer.java │ │ │ ├── OsonLocalDateDeserializer.java │ │ │ ├── OsonLocalDateTimeDeserializer.java │ │ │ ├── OsonOffsetDateTimeDeserializer.java │ │ │ ├── OsonPeriodDeserializer.java │ │ │ ├── OsonSerializableDeserializer.java │ │ │ ├── OsonSqlDateDeserializer.java │ │ │ ├── OsonTimeStampDeserializer.java │ │ │ ├── OsonUUIDDeserializer.java │ │ │ └── OsonYearDeserializer.java │ │ │ └── ser │ │ │ ├── OsonBigIntegerSerializer.java │ │ │ ├── OsonByteSerializer.java │ │ │ ├── OsonConverterArraySerializer.java │ │ │ ├── OsonConverterSerializer.java │ │ │ ├── OsonDateSerializer.java │ │ │ ├── OsonDurationSerializer.java │ │ │ ├── OsonEnumSerializer.java │ │ │ ├── OsonLocalDateSerializer.java │ │ │ ├── OsonLocalDateTimeSerializer.java │ │ │ ├── OsonOffsetDateTimeSerializer.java │ │ │ ├── OsonPeriodSerializer.java │ │ │ ├── OsonSerializableSerializer.java │ │ │ └── OsonYearSerializer.java │ └── resources │ │ └── META-INF │ │ └── services │ │ ├── com.fasterxml.jackson.databind.Module │ │ └── oracle.jdbc.spi.JsonProvider │ └── test │ └── java │ └── oracle │ └── jdbc │ └── provider │ └── oson │ ├── OsonTestProperty.java │ ├── model │ ├── AnnonationTest.java │ ├── AnnotationTestInstances.java │ ├── ConverterEntity.java │ ├── ConverterEntityInstance.java │ ├── Converters.java │ ├── Employee.java │ ├── EmployeeInstances.java │ ├── Organisation.java │ ├── OrganisationInstances.java │ └── Phone.java │ └── test │ ├── AnnotationOSONTest.java │ ├── DBTest.java │ ├── EncondingTest.java │ ├── ListTypeTest.java │ ├── MultiThreadTest.java │ ├── SerializerTest.java │ └── SerializerTestConverter.java ├── ojdbc-provider-oci ├── README.md ├── THIRD_PARTY_LICENSES.txt ├── example-adb.properties ├── example-test.properties ├── example-token.properties ├── example-vault-wallet.properties ├── example-vault.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── oracle │ │ │ └── jdbc │ │ │ └── provider │ │ │ └── oci │ │ │ ├── OciResourceFactory.java │ │ │ ├── Ocid.java │ │ │ ├── authentication │ │ │ ├── AuthenticationDetailsFactory.java │ │ │ ├── AuthenticationMethod.java │ │ │ ├── InteractiveAuthentication.java │ │ │ └── InteractiveAuthenticationDetails.java │ │ │ ├── configuration │ │ │ ├── OciConfigurationParameters.java │ │ │ ├── OciDatabaseToolsConnectionProvider.java │ │ │ ├── OciObjectStorageProvider.java │ │ │ ├── OciVaultJsonProvider.java │ │ │ └── OciVaultSecretProvider.java │ │ │ ├── database │ │ │ ├── WalletFactory.java │ │ │ └── WalletPasswordGenerator.java │ │ │ ├── databasetools │ │ │ └── DatabaseToolsConnectionFactory.java │ │ │ ├── oauth │ │ │ └── AccessTokenFactory.java │ │ │ ├── objectstorage │ │ │ └── ObjectFactory.java │ │ │ ├── resource │ │ │ ├── DatabaseConnectionStringProvider.java │ │ │ ├── DatabaseTlsProvider.java │ │ │ ├── DataplaneTokenProvider.java │ │ │ ├── OciResourceProvider.java │ │ │ ├── VaultConnectionStringProvider.java │ │ │ ├── VaultPasswordProvider.java │ │ │ ├── VaultSEPSProvider.java │ │ │ ├── VaultTCPSProvider.java │ │ │ └── VaultUsernameProvider.java │ │ │ └── vault │ │ │ ├── Secret.java │ │ │ └── SecretFactory.java │ └── resources │ │ └── META-INF │ │ └── services │ │ ├── oracle.jdbc.spi.AccessTokenProvider │ │ ├── oracle.jdbc.spi.ConnectionStringProvider │ │ ├── oracle.jdbc.spi.OracleConfigurationProvider │ │ ├── oracle.jdbc.spi.OracleConfigurationSecretProvider │ │ ├── oracle.jdbc.spi.PasswordProvider │ │ ├── oracle.jdbc.spi.TlsConfigurationProvider │ │ └── oracle.jdbc.spi.UsernameProvider │ └── test │ └── java │ └── oracle │ └── jdbc │ └── provider │ └── oci │ ├── AuthenticationDetailsFactoryTest.java │ ├── OciTestProperty.java │ ├── configuration │ ├── OciDatabaseToolsConnectionProviderTest.java │ ├── OciObjectStorageProviderTest.java │ └── OciVaultJsonProviderTest.java │ └── resource │ ├── DatabaseConnectionStringProviderTest.java │ ├── DatabaseTlsProviderTest.java │ ├── DataplaneTokenProviderTest.java │ ├── VaultConnectionStringProviderTest.java │ ├── VaultPasswordProviderTest.java │ ├── VaultSEPSProviderTest.java │ ├── VaultTCPSProviderTest.java │ └── VaultUsernameProviderTest.java ├── ojdbc-provider-opentelemetry ├── README.md ├── THIRD_PARTY_LICENSES.txt ├── pom.xml └── src │ ├── main │ ├── java │ │ └── oracle │ │ │ └── jdbc │ │ │ └── provider │ │ │ └── opentelemetry │ │ │ ├── OpenTelemetryTraceEventListener.java │ │ │ ├── OpenTelemetryTraceEventListenerMBean.java │ │ │ └── OpenTelemetryTraceEventListenerProvider.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── oracle.jdbc.spi.TraceEventListenerProvider │ └── test │ └── java │ └── oracle │ └── jdbc │ └── provider │ └── opentelemetry │ └── OpenTelemetryTraceEventListenerTest.java ├── ojdbc-provider-samples ├── example-configuration.properties ├── pom.xml └── src │ └── main │ └── java │ └── oracle │ └── jdbc │ └── provider │ ├── Configuration.java │ ├── aws │ ├── configuration │ │ ├── AwsS3Example.java │ │ └── AwsSecretsManagerConfigurationExample.java │ └── resource │ │ ├── SimpleConnectionStringProviderExample.java │ │ ├── SimplePasswordProviderExample.java │ │ ├── SimpleSEPSWalletProviderExample.java │ │ ├── SimpleTCPSWalletProviderExample.java │ │ └── SimpleUsernameProviderExample.java │ ├── azure │ └── configuration │ │ ├── SimpleAzureAppConfigExample.java │ │ ├── SimpleAzureVaultJsonExample.java │ │ └── resource │ │ ├── PasswordProviderAzureExample.java │ │ ├── SimpleConnectionStringProviderAzureExample.java │ │ ├── SimpleSEPSWalletProviderAzureExample.java │ │ ├── SimpleSEPSWalletProviderWithIndexExample.java │ │ ├── SimpleTCPSWalletProviderAzureExample.java │ │ └── UsernameProviderAzureExample.java │ ├── gcp │ ├── configuration │ │ ├── CloudStorageExample.java │ │ ├── SecretManagerExample.java │ │ ├── SimpleCloudStorageExample.java │ │ └── SimpleSecretManagerExample.java │ └── resource │ │ ├── SimpleConnectionStringProviderExample.java │ │ ├── SimpleSEPSWalletProviderExample.java │ │ ├── SimpleSEPSWalletProviderWithIndexExample.java │ │ ├── SimpleSecretManagerUsernameProviderExample.java │ │ ├── SimpleTCPSWalletProviderExample.java │ │ ├── SimpleVaultSecretPasswordResourceExample.java │ │ └── VaultSecretPasswordResourceExample.java │ ├── hashicorp │ ├── hcpvaultdedicated │ │ ├── configuration │ │ │ └── SimpleVaultDedicatedJsonExample.java │ │ └── resource │ │ │ ├── SimpleConnectionStringProviderExample.java │ │ │ ├── SimplePasswordProviderExample.java │ │ │ ├── SimpleSEPSWalletProviderExample.java │ │ │ ├── SimpleTCPSWalletProviderExample.java │ │ │ └── SimpleUsernameProviderExample.java │ └── hcpvaultsecret │ │ ├── configuration │ │ └── SimpleVaultSecretsJsonExample.java │ │ └── resource │ │ ├── SimpleConnectionStringProviderExample.java │ │ ├── SimplePasswordProviderExample.java │ │ ├── SimpleSEPSWalletProviderExample.java │ │ ├── SimpleTCPSWalletProviderExample.java │ │ └── SimpleUsernameProviderExample.java │ ├── oci │ └── configuration │ │ ├── SimpleDatabaseToolsConnectionExample.java │ │ ├── SimpleObjectStorageExample.java │ │ ├── SimpleVaultJsonExample.java │ │ └── resource │ │ ├── SimpleConnectionStringProviderExample.java │ │ ├── SimpleDatabaseConnectionStringProviderExample.java │ │ ├── SimpleDatabaseTlsProviderExample.java │ │ ├── SimpleSEPSWalletProviderExample.java │ │ ├── SimpleSEPSWalletProviderWithIndexExample.java │ │ ├── SimpleTCPSWalletProviderExample.java │ │ ├── SimpleVaultSecretPasswordProviderExample.java │ │ └── SimpleVaultSecretUsernameProviderExample.java │ └── oson │ └── sample │ ├── AccessJsonColumnUsingHibernate.java │ ├── AccessJsonColumnUsingJacksonObjectNode.java │ ├── AccessJsonColumnUsingPOJO.java │ ├── AccessJsonColumnUsingPOJOAndJsonProvider.java │ ├── JacksonOsonSampleUtil.java │ ├── NestedStructurePOJO.java │ └── model │ ├── Emp.java │ ├── Image.java │ ├── JsonOsonSample.java │ ├── Movie.java │ └── Phone.java └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | **/.DS_Store 3 | 4 | # Maven 5 | **/target/ 6 | 7 | # IntelliJ 8 | *.iml 9 | .idea 10 | out/ 11 | 12 | # Eclipse 13 | .project 14 | .settings 15 | .classpath 16 | 17 | # Assume all properties file might contain security sensitive information, 18 | # such as a password. The first expression below excludes them all. 19 | # The second expression overrides the first one to allow example properties 20 | # files. Example files follow a naming convention; They have a prefix of: 21 | # "example-" 22 | **/*.properties 23 | !**/example-*.properties 24 | 25 | # Vim 26 | **/*.swp 27 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to this repository 2 | 3 | We welcome your contributions! There are multiple ways to contribute. 4 | 5 | ## Opening issues 6 | 7 | For bugs or enhancement requests, please file a GitHub issue unless it's 8 | security related. When filing a bug remember that the better written the bug is, 9 | the more likely it is to be fixed. If you think you've found a security 10 | vulnerability, do not raise a GitHub issue and follow the instructions in our 11 | [security policy](./SECURITY.md). 12 | 13 | ## Contributing code 14 | 15 | We welcome your code contributions. Before submitting code via a pull request, 16 | you will need to have signed the [Oracle Contributor Agreement][OCA] (OCA) and 17 | your commits need to include the following line using the name and e-mail 18 | address you used to sign the OCA: 19 | 20 | ```text 21 | Signed-off-by: Your Name 22 | ``` 23 | 24 | This can be automatically added to pull requests by committing with `--sign-off` 25 | or `-s`, e.g. 26 | 27 | ```text 28 | git commit --signoff 29 | ``` 30 | 31 | Only pull requests from committers that can be verified as having signed the OCA 32 | can be accepted. 33 | 34 | ## Pull request process 35 | 36 | 1. Ensure there is an issue created to track and discuss the fix or enhancement 37 | you intend to submit. 38 | 1. Fork this repository. 39 | 1. Create a branch in your fork to implement the changes. We recommend using 40 | the issue number as part of your branch name, e.g. `1234-fixes`. 41 | 1. Ensure that any documentation is updated with the changes that are required 42 | by your change. 43 | 1. Ensure that any samples are updated if the base image has been changed. 44 | 1. Submit the pull request. *Do not leave the pull request blank*. Explain exactly 45 | what your changes are meant to do and provide simple steps on how to validate. 46 | your changes. Ensure that you reference the issue you created as well. 47 | 1. We will assign the pull request to 2-3 people for review before it is merged. 48 | 49 | ## Code of conduct 50 | 51 | Follow the [Golden Rule](https://en.wikipedia.org/wiki/Golden_Rule). If you'd 52 | like more specific guidelines, see the [Contributor Covenant Code of Conduct][COC]. 53 | 54 | [OCA]: https://oca.opensource.oracle.com 55 | [COC]: https://www.contributor-covenant.org/version/1/4/code-of-conduct/ -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023 Oracle and/or its affiliates. 2 | 3 | The Universal Permissive License (UPL), Version 1.0 4 | 5 | Subject to the condition set forth below, permission is hereby granted to any 6 | person obtaining a copy of this software, associated documentation and/or data 7 | (collectively the "Software"), free of charge and under any and all copyright 8 | rights in the Software, and any and all patent rights owned or freely 9 | licensable by each licensor hereunder covering either (i) the unmodified 10 | Software as contributed to or provided by such licensor, or (ii) the Larger 11 | Works (as defined below), to deal in both 12 | 13 | (a) the Software, and 14 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 15 | one is included with the Software (each a "Larger Work" to which the Software 16 | is contributed by such licensors), 17 | 18 | without restriction, including without limitation the rights to copy, create 19 | derivative works of, display, perform, and distribute the Software and make, 20 | use, sell, offer for sale, import, export, have made, and have sold the 21 | Software and the Larger Work(s), and to sublicense the foregoing rights on 22 | either these or other terms. 23 | 24 | This license is subject to the following condition: 25 | The above copyright notice and either this complete permission notice or at 26 | a minimum a reference to the UPL must be included in all copies or 27 | substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 35 | SOFTWARE. -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting security vulnerabilities 2 | 3 | Oracle values the independent security research community and believes that 4 | responsible disclosure of security vulnerabilities helps us ensure the security 5 | and privacy of all our users. 6 | 7 | Please do NOT raise a GitHub Issue to report a security vulnerability. If you 8 | believe you have found a security vulnerability, please submit a report to 9 | [secalert_us@oracle.com][1] preferably with a proof of concept. Please review 10 | some additional information on [how to report security vulnerabilities to Oracle][2]. 11 | We encourage people who contact Oracle Security to use email encryption using 12 | [our encryption key][3]. 13 | 14 | We ask that you do not use other channels or contact the project maintainers 15 | directly. 16 | 17 | Non-vulnerability related security issues including ideas for new or improved 18 | security features are welcome on GitHub Issues. 19 | 20 | ## Security updates, alerts and bulletins 21 | 22 | Security updates will be released on a regular cadence. Many of our projects 23 | will typically release security fixes in conjunction with the 24 | Oracle Critical Patch Update program. Additional 25 | information, including past advisories, is available on our [security alerts][4] 26 | page. 27 | 28 | ## Security-related information 29 | 30 | We will provide security related information such as a threat model, considerations 31 | for secure use, or any known security issues in our documentation. Please note 32 | that labs and sample code are intended to demonstrate a concept and may not be 33 | sufficiently hardened for production use. 34 | 35 | [1]: mailto:secalert_us@oracle.com 36 | [2]: https://www.oracle.com/corporate/security-practices/assurance/vulnerability/reporting.html 37 | [3]: https://www.oracle.com/security-alerts/encryptionkey.html 38 | [4]: https://www.oracle.com/security-alerts/ 39 | -------------------------------------------------------------------------------- /ojdbc-provider-aws/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | Oracle JDBC AWS Providers 6 | 7 | ojdbc-provider-aws 8 | jar 9 | 10 | 11 | com.oracle.database.jdbc 12 | ojdbc-extensions 13 | 1.0.5 14 | 15 | 16 | 17 | 18 | 19 | software.amazon.awssdk 20 | bom 21 | 2.28.11 22 | pom 23 | import 24 | 25 | 26 | 27 | 28 | 29 | 30 | com.oracle.database.jdbc 31 | ojdbc-provider-common 32 | 33 | 34 | com.oracle.database.jdbc 35 | ojdbc8 36 | 37 | 38 | software.amazon.awssdk 39 | s3 40 | 41 | 42 | commons-io 43 | commons-io 44 | 45 | 46 | com.github.tomakehurst 47 | wiremock-jre8 48 | 49 | 50 | 51 | 52 | software.amazon.awssdk 53 | auth 54 | 55 | 56 | commons-io 57 | commons-io 58 | 59 | 60 | com.github.tomakehurst 61 | wiremock-jre8 62 | 63 | 64 | 65 | 66 | software.amazon.awssdk 67 | secretsmanager 68 | 69 | 70 | 71 | com.oracle.database.jdbc 72 | ojdbc-provider-common 73 | tests 74 | test-jar 75 | 76 | 77 | org.junit.jupiter 78 | junit-jupiter-api 79 | 80 | 81 | org.junit.jupiter 82 | junit-jupiter-engine 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /ojdbc-provider-aws/src/main/java/oracle/jdbc/provider/aws/authentication/AwsAuthenticationMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | package oracle.jdbc.provider.aws.authentication; 39 | 40 | /** 41 | * A method of authentication using the AWS SDK. 42 | */ 43 | public enum AwsAuthenticationMethod { 44 | 45 | /** Authentication using {@link software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider} */ 46 | DEFAULT, 47 | } -------------------------------------------------------------------------------- /ojdbc-provider-aws/src/main/java/oracle/jdbc/provider/aws/resource/AwsSecretsManagerResourceParameterNames.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.aws.resource; 40 | 41 | /** 42 | * Centralized parameter name constants used by AWS Secrets Manager resource providers. 43 | */ 44 | public final class AwsSecretsManagerResourceParameterNames { 45 | 46 | private AwsSecretsManagerResourceParameterNames() {} 47 | 48 | /** The AWS region where the secret is located (e.g., eu-north-1). */ 49 | public static final String AWS_REGION = "awsRegion"; 50 | 51 | /** The name of the secret stored in AWS Secrets Manager. */ 52 | public static final String SECRET_NAME = "secretName"; 53 | 54 | /** Optional field name to extract from a JSON secret. */ 55 | public static final String FIELD_NAME = "fieldName"; 56 | 57 | /** The alias used to retrieve a connection string from tnsnames.ora. */ 58 | public static final String TNS_ALIAS = "tnsAlias"; 59 | 60 | /** Optional password used to decrypt the wallet (for PKCS12 or encrypted PEM). */ 61 | public static final String WALLET_PASSWORD = "walletPassword"; 62 | 63 | /** The wallet format: SSO, PKCS12, or PEM. */ 64 | public static final String TYPE = "type"; 65 | 66 | /** Index of the credential set in the wallet */ 67 | public static final String CONNECTION_STRING_INDEX = "connectionStringIndex"; 68 | } 69 | -------------------------------------------------------------------------------- /ojdbc-provider-aws/src/main/java/oracle/jdbc/provider/aws/resource/SecretsManagerPasswordProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.aws.resource; 40 | 41 | import oracle.jdbc.spi.PasswordProvider; 42 | import java.util.Map; 43 | 44 | /** 45 | *

46 | * A provider of password managed as secrets by AWS Secrets Manager. 47 | * This class inherits parameters and behavior from {@link SecretsManagerSecretProvider} 48 | * and {@link AwsResourceProvider}. 49 | *

50 | * This class implements the {@link PasswordProvider} SPI defined by Oracle JDBC. 51 | * It is designed to be located and instantiated by {@link java.util.ServiceLoader}. 52 | *

53 | */ 54 | public class SecretsManagerPasswordProvider 55 | extends SecretsManagerSecretProvider 56 | implements PasswordProvider { 57 | 58 | /** 59 | * A public no-arg constructor used by {@link java.util.ServiceLoader} to 60 | * construct an instance of this provider. 61 | */ 62 | public SecretsManagerPasswordProvider() { 63 | super("secrets-manager-password"); 64 | } 65 | 66 | /** 67 | * Retrieves a password stored as a secret in AWS Secrets Manager. 68 | * 69 | * @param parameterValues A map of parameter names and values required for 70 | * retrieving the secret. Must not be null. 71 | * @return The secret value as a char array. Not null. 72 | */ 73 | @Override 74 | public char[] getPassword(Map parameterValues) { 75 | return getSecret(parameterValues).toCharArray(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /ojdbc-provider-aws/src/main/java/oracle/jdbc/provider/aws/resource/SecretsManagerUsernameProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.aws.resource; 40 | 41 | import oracle.jdbc.spi.UsernameProvider; 42 | import java.util.Map; 43 | 44 | /** 45 | *

46 | * A provider of username managed as secrets by AWS Secrets Manager. 47 | * This class inherits parameters and behavior from {@link SecretsManagerSecretProvider} 48 | * and {@link AwsResourceProvider}. 49 | *

50 | * This class implements the {@link UsernameProvider} SPI defined by Oracle JDBC. 51 | * It is designed to be located and instantiated by {@link java.util.ServiceLoader}. 52 | *

53 | */ 54 | public class SecretsManagerUsernameProvider 55 | extends SecretsManagerSecretProvider 56 | implements UsernameProvider { 57 | 58 | /** 59 | * A public no-arg constructor used by {@link java.util.ServiceLoader} to 60 | * construct an instance of this provider. 61 | */ 62 | public SecretsManagerUsernameProvider() { 63 | super("secrets-manager-username"); 64 | } 65 | 66 | /** 67 | * Retrieves a username stored as a secret in AWS Secrets Manager. 68 | * 69 | * @param parameterValues A map of parameter names and values required for 70 | * retrieving the secret. Must not be null. 71 | * @return The secret value as the database username. Not null. 72 | */ 73 | @Override 74 | public String getUsername(Map parameterValues) { 75 | return getSecret(parameterValues); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /ojdbc-provider-aws/src/main/resources/META-INF/services/oracle.jdbc.spi.ConnectionStringProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.aws.resource.SecretsManagerConnectionStringProvider -------------------------------------------------------------------------------- /ojdbc-provider-aws/src/main/resources/META-INF/services/oracle.jdbc.spi.OracleConfigurationProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.aws.configuration.AwsS3ConfigurationProvider 2 | oracle.jdbc.provider.aws.configuration.AwsSecretsManagerConfigurationProvider -------------------------------------------------------------------------------- /ojdbc-provider-aws/src/main/resources/META-INF/services/oracle.jdbc.spi.OracleConfigurationSecretProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.aws.configuration.AwsJsonSecretsManagerProvider -------------------------------------------------------------------------------- /ojdbc-provider-aws/src/main/resources/META-INF/services/oracle.jdbc.spi.PasswordProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.aws.resource.SecretsManagerPasswordProvider 2 | oracle.jdbc.provider.aws.resource.SecretsManagerSEPSProvider -------------------------------------------------------------------------------- /ojdbc-provider-aws/src/main/resources/META-INF/services/oracle.jdbc.spi.TlsConfigurationProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.aws.resource.SecretsManagerTCPSProvider -------------------------------------------------------------------------------- /ojdbc-provider-aws/src/main/resources/META-INF/services/oracle.jdbc.spi.UsernameProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.aws.resource.SecretsManagerUsernameProvider 2 | oracle.jdbc.provider.aws.resource.SecretsManagerSEPSProvider -------------------------------------------------------------------------------- /ojdbc-provider-aws/src/test/java/oracle/provider/aws/AwsTestProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | package oracle.provider.aws; 39 | 40 | public enum AwsTestProperty { 41 | AWS_S3_URL, 42 | AWS_SECRETS_MANAGER_URL, 43 | AWS_REGION, 44 | DB_CREDENTIALS_SECRET_NAME, 45 | TNSNAMES_SECRET_NAME, 46 | TNS_ALIAS, 47 | PKCS12_WALLET_SECRET_NAME, 48 | WALLET_PASSWORD, 49 | SSO_WALLET_SECRET_NAME, 50 | PEM_WALLET_SECRET_NAME, 51 | PKCS12_SEPS_WALLET_SECRET_NAME, 52 | SSO_SEPS_WALLET_SECRET_NAME 53 | } 54 | -------------------------------------------------------------------------------- /ojdbc-provider-azure/example-token.properties: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Copyright (c) 2023 Oracle and/or its affiliates. 3 | # 4 | # The Universal Permissive License (UPL), Version 1.0 5 | # 6 | # Subject to the condition set forth below, permission is hereby granted to any 7 | # person obtaining a copy of this software, associated documentation and/or data 8 | # (collectively the "Software"), free of charge and under any and all copyright 9 | # rights in the Software, and any and all patent rights owned or freely 10 | # licensable by each licensor hereunder covering either (i) the unmodified 11 | # Software as contributed to or provided by such licensor, or (ii) the Larger 12 | # Works (as defined below), to deal in both 13 | # 14 | # (a) the Software, and 15 | # (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | # one is included with the Software (each a "Larger Work" to which the Software 17 | # is contributed by such licensors), 18 | # 19 | # without restriction, including without limitation the rights to copy, create 20 | # derivative works of, display, perform, and distribute the Software and make, 21 | # use, sell, offer for sale, import, export, have made, and have sold the 22 | # Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | # either these or other terms. 24 | # 25 | # This license is subject to the following condition: 26 | # The above copyright notice and either this complete permission notice or at 27 | # a minimum a reference to the UPL must be included in all copies or 28 | # substantial portions of the Software. 29 | # 30 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | # SOFTWARE. 37 | ################################################################################ 38 | 39 | # An example of a connection properties file that configures Oracle JDBC to 40 | # login using an OAUTH access token issued by Azure's Active Directory service. 41 | # 42 | # This file can be located by Oracle JDBC using the "oracle.jdbc.config.file" 43 | # connection property. For details, see: 44 | # https://docs.oracle.com/en/database/oracle/oracle-database/23/jajdb/oracle/jdbc/OracleConnection.html#CONNECTION_PROPERTY_CONFIG_FILE 45 | 46 | # Configures the Azure OAUTH Token Provider. The application ID URI of the 47 | # database is configured as an environment variables or JVM system properties 48 | # named "DATABASE_APP_ID_URI". 49 | oracle.jdbc.provider.accessToken=ojdbc-provider-azure-token 50 | oracle.jdbc.provider.accessToken.scope=${DATABASE_APP_ID_URI}/.default 51 | -------------------------------------------------------------------------------- /ojdbc-provider-azure/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | Oracle JDBC Azure Providers 6 | 7 | ojdbc-provider-azure 8 | jar 9 | 10 | 11 | com.oracle.database.jdbc 12 | ojdbc-extensions 13 | 1.0.5 14 | 15 | 16 | 17 | 18 | 19 | com.azure 20 | azure-sdk-bom 21 | 1.2.30 22 | pom 23 | import 24 | 25 | 26 | 27 | 28 | 29 | 30 | com.oracle.database.jdbc 31 | ojdbc-provider-common 32 | 33 | 34 | com.azure 35 | azure-core 36 | 37 | 38 | com.azure 39 | azure-identity 40 | 41 | 42 | com.azure 43 | azure-data-appconfiguration 44 | 45 | 46 | com.azure 47 | azure-security-keyvault-secrets 48 | 49 | 53 | 54 | com.oracle.database.jdbc 55 | ojdbc-provider-common 56 | tests 57 | test-jar 58 | 59 | 60 | org.junit.jupiter 61 | junit-jupiter-api 62 | 63 | 64 | org.junit.jupiter 65 | junit-jupiter-engine 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /ojdbc-provider-azure/src/main/java/oracle/jdbc/provider/azure/resource/KeyVaultPasswordProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.azure.resource; 40 | 41 | import oracle.jdbc.spi.PasswordProvider; 42 | 43 | import java.util.Map; 44 | 45 | /** 46 | *

47 | * A provider of passwords managed as secrets by Azure's Key Vault service. This 48 | * class inherits common parameters and behavior from 49 | * {@link KeyVaultSecretProvider} and {@link AzureResourceProvider}. 50 | *

51 | * This class implements the {@link PasswordProvider} SPI defined by Oracle 52 | * JDBC. It is designed to be located and instantiated by 53 | * {@link java.util.ServiceLoader}. 54 | *

55 | */ 56 | public final class KeyVaultPasswordProvider 57 | extends KeyVaultSecretProvider 58 | implements PasswordProvider { 59 | 60 | /** 61 | * A public no-arg constructor used by {@link java.util.ServiceLoader} to 62 | * construct an instance of this provider. 63 | */ 64 | public KeyVaultPasswordProvider() { 65 | super("key-vault-password"); 66 | } 67 | 68 | @Override 69 | public char[] getPassword(Map parameterValues) { 70 | return getSecret(parameterValues).toCharArray(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /ojdbc-provider-azure/src/main/java/oracle/jdbc/provider/azure/resource/KeyVaultUserNameProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.azure.resource; 40 | 41 | import oracle.jdbc.spi.PasswordProvider; 42 | import oracle.jdbc.spi.UsernameProvider; 43 | 44 | import java.util.Map; 45 | 46 | /** 47 | *

48 | * A provider of usernames managed as secrets by Azure's Key Vault service. This 49 | * class inherits common parameters and behavior from 50 | * {@link KeyVaultSecretProvider} and {@link AzureResourceProvider}. 51 | *

52 | * This class implements the {@link PasswordProvider} SPI defined by Oracle 53 | * JDBC. It is designed to be located and instantiated by 54 | * {@link java.util.ServiceLoader}. 55 | *

56 | */ 57 | public class KeyVaultUserNameProvider 58 | extends KeyVaultSecretProvider 59 | implements UsernameProvider { 60 | 61 | /** 62 | * A public no-arg constructor used by {@link java.util.ServiceLoader} to 63 | * construct an instance of this provider. 64 | */ 65 | public KeyVaultUserNameProvider() { 66 | super("key-vault-username"); 67 | } 68 | 69 | @Override 70 | public String getUsername(Map parameterValues) { 71 | return getSecret(parameterValues); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /ojdbc-provider-azure/src/main/resources/META-INF/services/oracle.jdbc.spi.AccessTokenProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.azure.resource.AzureTokenProvider 2 | -------------------------------------------------------------------------------- /ojdbc-provider-azure/src/main/resources/META-INF/services/oracle.jdbc.spi.ConnectionStringProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.azure.resource.KeyVaultConnectionStringProvider 2 | -------------------------------------------------------------------------------- /ojdbc-provider-azure/src/main/resources/META-INF/services/oracle.jdbc.spi.OracleConfigurationProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.azure.configuration.AzureAppConfigurationProvider 2 | oracle.jdbc.provider.azure.configuration.AzureVaultJsonProvider 3 | -------------------------------------------------------------------------------- /ojdbc-provider-azure/src/main/resources/META-INF/services/oracle.jdbc.spi.OracleConfigurationSecretProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.azure.configuration.AzureVaultSecretProvider -------------------------------------------------------------------------------- /ojdbc-provider-azure/src/main/resources/META-INF/services/oracle.jdbc.spi.PasswordProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.azure.resource.KeyVaultPasswordProvider 2 | oracle.jdbc.provider.azure.resource.KeyVaultSEPSProvider 3 | -------------------------------------------------------------------------------- /ojdbc-provider-azure/src/main/resources/META-INF/services/oracle.jdbc.spi.TlsConfigurationProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.azure.resource.KeyVaultTCPSProvider -------------------------------------------------------------------------------- /ojdbc-provider-azure/src/main/resources/META-INF/services/oracle.jdbc.spi.UsernameProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.azure.resource.KeyVaultUserNameProvider 2 | oracle.jdbc.provider.azure.resource.KeyVaultSEPSProvider 3 | -------------------------------------------------------------------------------- /ojdbc-provider-common/README.md: -------------------------------------------------------------------------------- 1 | # Oracle JDBC Providers Common Module 2 | This module contains common code that is shared by all providers in this 3 | project. The API of this module is mainly designed only for other modules 4 | in this project to consume. The only exceptions to this are described in the 5 | remaining sections of this document. All other APIs of this module are not 6 | stable, and may become inaccessible in a later release. 7 | 8 | ## Clearing Cached Resources 9 | Most providers in this project will cache the resources they request from a 10 | cloud service. Cached resources can be cleared by calling the 11 | `clearAllCaches()` method of the `oracle.jdbc.provider.cache.CacheController` 12 | contained in this module. 13 | -------------------------------------------------------------------------------- /ojdbc-provider-common/THIRD_PARTY_LICENSES.txt: -------------------------------------------------------------------------------- 1 | === Public License Template === 2 | 3 | ------------------------------ Top-Level License ------------------------------- 4 | SPDX:UPL-1.0 5 | 6 | ---------------------------------- Copyright ----------------------------------- 7 | Copyright (c) 2023 Oracle and/or its affiliates. 8 | Copyright (c) 2023 Oracle and/or its affiliates. Released under the Universal Permissive License v1.0 as shown at . 9 | 10 | ----------------------------------- Licenses ----------------------------------- 11 | == SPDX:UPL-1.0 12 | 13 | The Universal Permissive License (UPL), Version 1.0 14 | 15 | Copyright (c) 16 | 17 | The Universal Permissive License (UPL), Version 1.0 18 | 19 | Subject to the condition set forth below, permission is hereby granted to any person obtaining a copy of this software, associated documentation and/or data (collectively the "Software"), free of charge and under any and all copyright rights in the Software, and any and all patent rights owned or freely licensable by each licensor hereunder covering either (i) the unmodified Software as contributed to or provided by such licensor, or (ii) the Larger Works (as defined below), to deal in both 20 | 21 | (a) the Software, and 22 | 23 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if one is included with the Software (each a “Larger Work” to which the Software is contributed by such licensors), 24 | 25 | without restriction, including without limitation the rights to copy, create derivative works of, display, perform, and distribute the Software and make, use, sell, offer for sale, import, export, have made, and have sold the Software and the Larger Work(s), and to sublicense the foregoing rights on either these or other terms. 26 | 27 | This license is subject to the following condition: 28 | 29 | The above copyright notice and either this complete permission notice or at a minimum a reference to the UPL must be included in all copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | 33 | === ATTRIBUTION-HELPER-GENERATED: 34 | === Attribution helper version: {Major:0 Minor:11 GitVersion: GitCommit: GitTreeState:dirty BuildDate:1970-01-01T00:00:00Z GoVersion:go1.19.1 Compiler:gc Platform:darwin/amd64} 35 | -------------------------------------------------------------------------------- /ojdbc-provider-common/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | Oracle JDBC Providers Common Module 7 | 8 | ojdbc-provider-common 9 | jar 10 | 11 | 12 | com.oracle.database.jdbc 13 | ojdbc-extensions 14 | 1.0.5 15 | 16 | 17 | 18 | 19 | com.oracle.database.jdbc 20 | ojdbc8 21 | 22 | 23 | com.oracle.database.security 24 | oraclepki 25 | 26 | 27 | org.junit.jupiter 28 | junit-jupiter-api 29 | 30 | 31 | org.junit.jupiter 32 | junit-jupiter-engine 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.apache.maven.plugins 40 | maven-jar-plugin 41 | 3.3.0 42 | 43 | 44 | 45 | 51 | test-jar 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /ojdbc-provider-common/src/main/java/oracle/jdbc/provider/configuration/JsonSecretUtil.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/ojdbc-extensions/2b9ab6be59aa4608dde5589cf34fb8d7052fb0fa/ojdbc-provider-common/src/main/java/oracle/jdbc/provider/configuration/JsonSecretUtil.java -------------------------------------------------------------------------------- /ojdbc-provider-common/src/main/java/oracle/jdbc/provider/factory/AbstractResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.factory; 40 | 41 | /** 42 | * Abstract class implementing basic operations of the {@link Resource} 43 | * interface, designed for inheritance by concrete subclasses. 44 | */ 45 | abstract class AbstractResource implements Resource { 46 | 47 | /** Object representing the specific content of a resource */ 48 | private final T content; 49 | 50 | /** 51 | * {@code true} if the resource contains security sensitive information, or 52 | * {@code false if not}. 53 | */ 54 | private final boolean sensitive; 55 | 56 | /** 57 | * Constructs a new resource wrapper around the given {@code content}. 58 | * 59 | * @param content Specific object representation the resource's content 60 | * @param sensitive {@code true} if the resource contains security sensitive 61 | * information, or {@code false if not}. 62 | */ 63 | AbstractResource(T content, boolean sensitive) { 64 | this.content = content; 65 | this.sensitive = sensitive; 66 | } 67 | 68 | @Override 69 | public final T getContent() { 70 | return content; 71 | } 72 | 73 | @Override 74 | public final boolean isSensitive() { 75 | return sensitive; 76 | } 77 | 78 | @Override 79 | public abstract boolean isValid(); 80 | 81 | } 82 | -------------------------------------------------------------------------------- /ojdbc-provider-common/src/main/java/oracle/jdbc/provider/factory/ExpiringResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.factory; 40 | 41 | import java.time.OffsetDateTime; 42 | 43 | /** A {@link Resource} that expires at a fixed time */ 44 | final class ExpiringResource extends AbstractResource { 45 | 46 | /** The time at which the resource expires */ 47 | private final OffsetDateTime expireTime; 48 | 49 | /** Constructs a new resource that expires at a given {@code expireTime} */ 50 | ExpiringResource( 51 | T value, OffsetDateTime expireTime, boolean isSensitive) { 52 | super(value, isSensitive); 53 | this.expireTime = expireTime; 54 | } 55 | 56 | /** 57 | * {@inheritDoc} 58 | * 59 | * @return {@code true} until the current time is later than the expiration 60 | * time of this resource 61 | */ 62 | @Override 63 | public boolean isValid() { 64 | return OffsetDateTime.now().isBefore(expireTime); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /ojdbc-provider-common/src/main/java/oracle/jdbc/provider/factory/PermanentResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.factory; 40 | 41 | /** A {@link Resource} that never expires or becomes invalid */ 42 | final class PermanentResource extends AbstractResource { 43 | 44 | PermanentResource(T value, boolean isSensitive) { 45 | super(value, isSensitive); 46 | } 47 | 48 | /** 49 | * {@inheritDoc} 50 | * @return {@code true}, as this resource never becomes invalid. 51 | */ 52 | @Override 53 | public boolean isValid() { 54 | return true; 55 | } 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /ojdbc-provider-common/src/main/java/oracle/jdbc/provider/factory/ResourceFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.factory; 40 | 41 | import oracle.jdbc.provider.parameter.Parameter; 42 | import oracle.jdbc.provider.parameter.ParameterSet; 43 | 44 | /** 45 | *

46 | * A factory for creating resources that are requested from an external service. 47 | * Requests are parameterized by a {@link ParameterSet}. Implementations of 48 | * {@link ResourceFactory} must define the particular {@link Parameter} objects 49 | * that they recognize. 50 | *

51 | * This interface is intended to decouple provider code from any proprietary 52 | * classes that might be defined by the SDK of one particular service. 53 | *

54 | */ 55 | public interface ResourceFactory { 56 | 57 | /** 58 | * Returns a resource requested from an external service. Subclasses should 59 | * declare the {@link Parameter} objects they recognize in the 60 | * {@code parameterSet}. 61 | * 62 | * @param parameterSet The set of parameters that configure the request. Not 63 | * null. 64 | * @return The requested resource. Not null. 65 | * @throws IllegalStateException If the request fails to return a resource. 66 | * @throws IllegalArgumentException If the {@code parameterSet} does not 67 | * include a required parameter, or does not represent a valid configuration. 68 | */ 69 | Resource request(ParameterSet parameterSet) 70 | throws IllegalStateException, IllegalArgumentException; 71 | 72 | } 73 | -------------------------------------------------------------------------------- /ojdbc-provider-common/src/main/java/oracle/jdbc/provider/parameter/ParameterImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.parameter; 40 | 41 | import java.util.Arrays; 42 | import java.util.Collection; 43 | import java.util.Collections; 44 | 45 | /** Implementation of the {@code Parameter} interface */ 46 | final class ParameterImpl implements Parameter { 47 | 48 | private final Collection attributes; 49 | 50 | ParameterImpl(Attribute... attributes) { 51 | this.attributes = Collections.unmodifiableList( 52 | Arrays.asList(attributes.clone())); 53 | } 54 | 55 | @Override 56 | public Collection getAttributes() { 57 | return attributes; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /ojdbc-provider-common/src/main/java/oracle/jdbc/provider/parameter/ParameterSetBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.parameter; 40 | 41 | /** 42 | * A builder that builds an instance of {@link ParameterSetImpl}. 43 | */ 44 | public interface ParameterSetBuilder { 45 | 46 | /** 47 | * Adds a parameter with a given name and value. If the value is null, the 48 | * ParameterSet will behave as if no value has been set for the parameter. 49 | * Calling this method with a null value allows the ParameterSet to create 50 | * error messages that identify the {@code name} of missing parameters. 51 | * 52 | * @param The type of value that is assigned to the parameter 53 | * @param name The parameter name. Not null. 54 | * @param parameter The parameter that is assigned with the {@code name} and 55 | * {@code value} in this set. Not null. 56 | * @param value The value, or null if the parameter is not configured with a 57 | * value. 58 | * @return A reference to this object 59 | */ 60 | ParameterSetBuilder add(String name, Parameter parameter, T value); 61 | 62 | /** 63 | * Returns a {@code ParameterSet} populated with all parameter values added 64 | * to this builder. 65 | * 66 | * @return A {@code ParameterSet} populated with all parameter values added 67 | * to this builder 68 | */ 69 | ParameterSet build(); 70 | } 71 | -------------------------------------------------------------------------------- /ojdbc-provider-common/src/main/java/oracle/jdbc/provider/parameter/ParameterSetBuilderImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.parameter; 40 | 41 | import java.util.HashMap; 42 | import java.util.Map; 43 | 44 | /** Implementation of the {@code ParameterBuilder} interface */ 45 | final class ParameterSetBuilderImpl implements ParameterSetBuilder { 46 | 47 | /** Values of parameters added to this builder */ 48 | private final Map, Object> parameterValues = new HashMap<>(); 49 | 50 | /** Names of parameters added to this builder */ 51 | private final Map, String> parameterNames = new HashMap<>(); 52 | 53 | @Override 54 | public ParameterSetBuilder add(String name, Parameter parameter, T value) { 55 | if (value != null) { 56 | parameterValues.put(parameter, value); 57 | } 58 | parameterNames.put(parameter, name); 59 | return this; 60 | } 61 | 62 | @Override 63 | public ParameterSet build() { 64 | return new ParameterSetImpl(parameterValues, parameterNames); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /ojdbc-provider-common/src/main/java/oracle/jdbc/provider/util/ResourceParameterUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.util; 40 | 41 | import oracle.jdbc.provider.resource.ResourceParameter; 42 | 43 | import java.util.stream.Stream; 44 | 45 | /** 46 | * A utility class for manipulating {@link ResourceParameter} arrays. 47 | */ 48 | public final class ResourceParameterUtils { 49 | 50 | private ResourceParameterUtils() {} 51 | 52 | /** 53 | * Combines two arrays of resource parameters into a single array. 54 | * This method is useful when you need to merge parameters from different 55 | * sources into a unified set. 56 | * 57 | * @param baseParams The first array of resource parameters to combine. 58 | * @param additionalParams The second array of resource parameters to combine. 59 | * @return A new array containing all elements from both input arrays. 60 | * 61 | */ 62 | public static ResourceParameter[] combineParameters( 63 | ResourceParameter[] baseParams, ResourceParameter[] additionalParams) { 64 | return Stream.concat( 65 | Stream.of(baseParams), 66 | Stream.of(additionalParams)) 67 | .toArray(ResourceParameter[]::new); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /ojdbc-provider-common/src/test/java/oracle/jdbc/provider/factory/TestResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | package oracle.jdbc.provider.factory; 39 | 40 | public class TestResource implements Resource { 41 | 42 | private final String value; 43 | 44 | private boolean isValid = true; 45 | 46 | public TestResource(String value) { 47 | this.value = value; 48 | } 49 | 50 | public void setValid(boolean isValid) { 51 | this.isValid = isValid; 52 | } 53 | 54 | @Override 55 | public String getContent() { 56 | return value; 57 | } 58 | 59 | @Override 60 | public boolean isSensitive() { 61 | return false; 62 | } 63 | 64 | @Override 65 | public boolean isValid() { 66 | return isValid; 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return value; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /ojdbc-provider-gcp/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | Oracle JDBC GCP Providers 8 | 9 | ojdbc-provider-gcp 10 | jar 11 | 12 | 13 | com.oracle.database.jdbc 14 | ojdbc-extensions 15 | 1.0.5 16 | 17 | 18 | 19 | 20 | 21 | com.google.cloud 22 | libraries-bom 23 | 26.54.0 24 | pom 25 | import 26 | 27 | 28 | 29 | 30 | 31 | 32 | com.oracle.database.jdbc 33 | ojdbc-provider-common 34 | 35 | 36 | com.oracle.database.jdbc 37 | ojdbc8 38 | 39 | 40 | com.google.cloud 41 | google-cloud-secretmanager 42 | 43 | 44 | com.google.cloud 45 | google-cloud-storage 46 | 47 | 48 | 49 | 50 | 51 | com.oracle.database.jdbc 52 | ojdbc-provider-common 53 | tests 54 | test-jar 55 | 56 | 57 | com.oracle.database.jdbc 58 | ojdbc-provider-common 59 | tests 60 | test-jar 61 | 62 | 63 | org.junit.jupiter 64 | junit-jupiter-api 65 | 66 | 67 | org.junit.jupiter 68 | junit-jupiter-engine 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /ojdbc-provider-gcp/src/main/java/oracle/jdbc/provider/gcp/resource/GcpSecretManagerPasswordProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | package oracle.jdbc.provider.gcp.resource; 39 | 40 | import java.util.Map; 41 | 42 | import com.google.protobuf.ByteString; 43 | 44 | import oracle.jdbc.spi.PasswordProvider; 45 | 46 | /** 47 | *

48 | * A provider of passwords from the GCP Secret Manager service. 49 | *

50 | *

51 | * This class implements the {@link PasswordProvider} SPI defined by 52 | * Oracle JDBC. It is designed to be located and instantiated by 53 | * {@link java.util.ServiceLoader}. 54 | *

55 | */ 56 | public class GcpSecretManagerPasswordProvider extends GcpSecretManagerProvider implements PasswordProvider { 57 | 58 | public GcpSecretManagerPasswordProvider() { 59 | super("secretmanager-password"); 60 | } 61 | 62 | @Override 63 | public char[] getPassword(Map parameterValues) { 64 | ByteString secret = getSecret(parameterValues); 65 | String password = secret.toStringUtf8(); 66 | return password.toCharArray(); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /ojdbc-provider-gcp/src/main/java/oracle/jdbc/provider/gcp/resource/GcpSecretManagerUsernameProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | package oracle.jdbc.provider.gcp.resource; 39 | 40 | import java.nio.charset.Charset; 41 | import java.util.Map; 42 | 43 | import oracle.jdbc.spi.UsernameProvider; 44 | 45 | /** 46 | *

47 | * A provider of usernames from the GCP Secret Manager service. 48 | *

49 | *

50 | * This class implements the {@link UsernameProvider} SPI defined by 51 | * Oracle JDBC. It is designed to be located and instantiated by 52 | * {@link java.util.ServiceLoader}. 53 | *

54 | */ 55 | public class GcpSecretManagerUsernameProvider extends GcpSecretManagerProvider implements UsernameProvider { 56 | 57 | public GcpSecretManagerUsernameProvider() { 58 | super("secretmanager-username"); 59 | } 60 | 61 | @Override 62 | public String getUsername(Map parameterValues) { 63 | return getSecret(parameterValues).toStringUtf8(); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /ojdbc-provider-gcp/src/main/resources/META-INF/services/oracle.jdbc.spi.ConnectionStringProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.gcp.resource.GcpSecretManagerConnectionStringProvider 2 | -------------------------------------------------------------------------------- /ojdbc-provider-gcp/src/main/resources/META-INF/services/oracle.jdbc.spi.OracleConfigurationProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.gcp.configuration.GcpCloudStorageConfigurationProvider 2 | oracle.jdbc.provider.gcp.configuration.GcpSecretManagerConfigurationProvider 3 | -------------------------------------------------------------------------------- /ojdbc-provider-gcp/src/main/resources/META-INF/services/oracle.jdbc.spi.OracleConfigurationSecretProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.gcp.configuration.GcpJsonSecretManagerProvider -------------------------------------------------------------------------------- /ojdbc-provider-gcp/src/main/resources/META-INF/services/oracle.jdbc.spi.PasswordProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.gcp.resource.GcpSecretManagerPasswordProvider 2 | oracle.jdbc.provider.gcp.resource.GcpSecretManagerSEPSProvider 3 | -------------------------------------------------------------------------------- /ojdbc-provider-gcp/src/main/resources/META-INF/services/oracle.jdbc.spi.TlsConfigurationProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.gcp.resource.GcpSecretManagerTCPSProvider -------------------------------------------------------------------------------- /ojdbc-provider-gcp/src/main/resources/META-INF/services/oracle.jdbc.spi.UsernameProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.gcp.resource.GcpSecretManagerUsernameProvider 2 | oracle.jdbc.provider.gcp.resource.GcpSecretManagerSEPSProvider 3 | -------------------------------------------------------------------------------- /ojdbc-provider-gcp/src/test/java/oracle/provider/gcp/GcpTestProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.provider.gcp; 40 | 41 | /** 42 | * Names of properties that configure GCP tests. Descriptions and examples of 43 | * each property can be found in the "example-test.properties" file within the 44 | * root directory of the project. 45 | */ 46 | public enum GcpTestProperty { 47 | 48 | GCP_OBJECT_STORAGE_URL, 49 | 50 | SECRET_VERSION_NAME_CONFIG, 51 | 52 | GCP_SECRET_MANAGER_USERNAME_SECRET_VERSION, 53 | 54 | GCP_SECRET_MANAGER_PASSWORD_SECRET_VERSION, 55 | 56 | GCP_PKCS12_TLS_WALLET_SECRET_VERSION_NAME, 57 | 58 | GCP_PKCS12_TLS_WALLET_PASSWORD, 59 | 60 | GCP_SSO_TLS_WALLET_SECRET_VERSION_NAME, 61 | 62 | GCP_PEM_TLS_WALLET_SECRET_VERSION_NAME, 63 | 64 | GCP_PEM_TLS_WALLET_PASSWORD, 65 | 66 | GCP_CORRUPTED_TLS_WALLET_SECRET_VERSION_NAME, 67 | 68 | GCP_PKCS12_SEPS_SECRET_VERSION_NAME, 69 | 70 | GCP_PKCS12_SEPS_WALLET_PASSWORD, 71 | 72 | GCP_SEPS_CONNECTION_STRING_INDEX, 73 | 74 | GCP_SSO_SEPS_SECRET_VERSION_NAME, 75 | 76 | GCP_CORRUPTED_SEPS_WALLET_SECRET_VERSION_NAME, 77 | 78 | GCP_SECRET_MANAGER_TNS_NAMES_SECRET_VERSION, 79 | 80 | GCP_SECRET_MANAGER_TNS_ALIAS_SECRET_NAME, 81 | 82 | GCP_NON_BASE64_TNS_NAMES_SECRET_VERSION; 83 | } 84 | -------------------------------------------------------------------------------- /ojdbc-provider-gcp/src/test/java/oracle/provider/gcp/configuration/GcpCloudStorageProviderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | package oracle.provider.gcp.configuration; 39 | 40 | import static org.junit.jupiter.api.Assertions.assertTrue; 41 | 42 | import java.sql.SQLException; 43 | import java.util.Properties; 44 | 45 | import oracle.provider.gcp.GcpTestProperty; 46 | import org.junit.jupiter.api.Test; 47 | 48 | import oracle.jdbc.provider.TestProperties; 49 | import oracle.jdbc.spi.OracleConfigurationProvider; 50 | 51 | public class GcpCloudStorageProviderTest { 52 | 53 | 54 | static { 55 | OracleConfigurationProvider.allowedProviders.add("gcpstorage"); 56 | } 57 | 58 | private static final OracleConfigurationProvider PROVIDER = OracleConfigurationProvider.find("gcpstorage"); 59 | 60 | @Test 61 | public void testDefaultAuthentication() throws SQLException { 62 | String location = TestProperties.getOrAbort(GcpTestProperty.GCP_OBJECT_STORAGE_URL); 63 | Properties properties = PROVIDER 64 | .getConnectionProperties(location); 65 | assertTrue(properties.containsKey("URL"), "Contains property URL"); 66 | assertTrue(properties.containsKey("user"), "Contains property user"); 67 | assertTrue(properties.containsKey("password"), "Contains property password"); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /ojdbc-provider-gcp/src/test/java/oracle/provider/gcp/configuration/GcpSecretManagerConfigurationProviderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | package oracle.provider.gcp.configuration; 39 | 40 | import static org.junit.jupiter.api.Assertions.assertTrue; 41 | 42 | import java.sql.SQLException; 43 | import java.util.Properties; 44 | 45 | import oracle.provider.gcp.GcpTestProperty; 46 | import org.junit.jupiter.api.Test; 47 | 48 | import oracle.jdbc.provider.TestProperties; 49 | import oracle.jdbc.spi.OracleConfigurationProvider; 50 | 51 | public class GcpSecretManagerConfigurationProviderTest { 52 | 53 | static { 54 | OracleConfigurationProvider.allowedProviders.add("gcpsecretmanager"); 55 | } 56 | 57 | private static final OracleConfigurationProvider PROVIDER = OracleConfigurationProvider.find("gcpsecretmanager"); 58 | 59 | @Test 60 | public void testGetProperties() throws SQLException { 61 | String secretVersionName = 62 | TestProperties.getOrAbort(GcpTestProperty.SECRET_VERSION_NAME_CONFIG); 63 | Properties properties = PROVIDER 64 | .getConnectionProperties(secretVersionName); 65 | assertTrue(properties.containsKey("URL"), "Contains property URL"); 66 | assertTrue(properties.containsKey("user"), "Contains property user"); 67 | assertTrue(properties.containsKey("password"), "Contains property password"); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | Oracle JDBC Hashicorp Providers 7 | 8 | ojdbc-provider-hashicorp 9 | jar 10 | 11 | 12 | com.oracle.database.jdbc 13 | ojdbc-extensions 14 | 1.0.5 15 | 16 | 17 | 18 | 19 | com.oracle.database.jdbc 20 | ojdbc-provider-common 21 | 22 | 23 | 24 | com.oracle.database.jdbc 25 | ojdbc-provider-common 26 | tests 27 | test-jar 28 | 29 | 30 | org.junit.jupiter 31 | junit-jupiter-api 32 | 33 | 34 | org.junit.jupiter 35 | junit-jupiter-engine 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/hcpvaultdedicated/DedicatedVaultResourceFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.hashicorp.hcpvaultdedicated; 40 | 41 | import oracle.jdbc.provider.factory.Resource; 42 | import oracle.jdbc.provider.factory.ResourceFactory; 43 | import oracle.jdbc.provider.hashicorp.hcpvaultdedicated.authentication.DedicatedVaultToken; 44 | import oracle.jdbc.provider.hashicorp.hcpvaultdedicated.authentication.DedicatedVaultTokenFactory; 45 | import oracle.jdbc.provider.parameter.ParameterSet; 46 | 47 | /** 48 | * Common super class for ResourceFactory implementations that request 49 | * a resource from Vault using HashiCredentials. 50 | */ 51 | public abstract class DedicatedVaultResourceFactory implements ResourceFactory { 52 | 53 | @Override 54 | public final Resource request(ParameterSet parameterSet) { 55 | // Retrieve the Vault credentials from the credentials factory 56 | DedicatedVaultToken credentials = DedicatedVaultTokenFactory 57 | .getInstance() 58 | .request(parameterSet) 59 | .getContent(); 60 | 61 | try { 62 | return request(credentials, parameterSet); 63 | } catch (Exception e) { 64 | throw new IllegalStateException( 65 | "Request failed with parameters: " + parameterSet, e); 66 | } 67 | } 68 | 69 | public abstract Resource request( 70 | DedicatedVaultToken credentials, ParameterSet parameterSet); 71 | } 72 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/hcpvaultdedicated/authentication/DedicatedVaultToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.hashicorp.hcpvaultdedicated.authentication; 40 | 41 | /** 42 | *

43 | * Holds the credentials required for authenticating with Dedicated 44 | * HashiCorp Vault. 45 | *

46 | * This class encapsulates credentials used for making secure 47 | * requests to the Vault API. 48 | *

49 | */ 50 | public final class DedicatedVaultToken { 51 | 52 | private final String vaultToken; 53 | 54 | /** 55 | * Constructs a new {@code DedicatedVaultCredentials} object with 56 | * the provided Vault token. 57 | * 58 | * @param vaultToken the token used to authenticate API requests to 59 | * the Vault. Must not be null or empty. 60 | * @throws IllegalArgumentException if {@code vaultToken} is null or empty. 61 | */ 62 | public DedicatedVaultToken(String vaultToken) { 63 | if (vaultToken == null || vaultToken.isEmpty()) { 64 | throw new IllegalArgumentException("Vault token must not be null or empty."); 65 | } 66 | this.vaultToken = vaultToken; 67 | } 68 | /** 69 | * Returns the Vault token used for authentication. 70 | * 71 | * @return the Vault token as a {@link String}. 72 | */ 73 | public String getVaultToken() { 74 | return vaultToken; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/hcpvaultdedicated/authentication/VaultTokenAuthentication.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.hashicorp.hcpvaultdedicated.authentication; 40 | 41 | import oracle.jdbc.driver.oauth.OpaqueAccessToken; 42 | import oracle.jdbc.provider.parameter.ParameterSet; 43 | 44 | import java.util.Map; 45 | 46 | import static oracle.jdbc.provider.hashicorp.hcpvaultdedicated.authentication.DedicatedVaultParameters.*; 47 | 48 | /** 49 | * Handles authentication using a Vault token for HashiCorp Vault. 50 | */ 51 | public class VaultTokenAuthentication extends AbstractDedicatedVaultAuthentication { 52 | 53 | /** 54 | * Singleton instance of {@link VaultTokenAuthentication}. 55 | */ 56 | public static final VaultTokenAuthentication INSTANCE = new VaultTokenAuthentication(); 57 | 58 | private VaultTokenAuthentication() { 59 | // Private constructor to prevent external instantiation 60 | } 61 | 62 | @Override 63 | public CachedToken generateToken(ParameterSet parameterSet) { 64 | String vaultToken = parameterSet.getRequired(VAULT_TOKEN); 65 | return new CachedToken(OpaqueAccessToken.create(vaultToken.toCharArray(), null)); 66 | } 67 | 68 | @Override 69 | public Map generateCacheKey(ParameterSet parameterSet) { 70 | return parameterSet.filterParameters(new String[]{PARAM_VAULT_ADDR, PARAM_VAULT_TOKEN}); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/hcpvaultdedicated/resource/HcpVaultDedicatedPasswordProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.hashicorp.hcpvaultdedicated.resource; 40 | 41 | import oracle.jdbc.spi.PasswordProvider; 42 | 43 | import java.util.Map; 44 | 45 | /** 46 | *

47 | * A provider for retrieving passwords securely stored in HashiCorp Vault Dedicated. 48 | * This provider fetches the password from the Vault and returns it as a character array. 49 | *

50 | *

51 | * This class implements the {@link PasswordProvider} SPI defined by Oracle JDBC 52 | * and is designed to be instantiated via {@link java.util.ServiceLoader}. 53 | *

54 | */ 55 | public class HcpVaultDedicatedPasswordProvider 56 | extends HcpVaultDedicatedSecretProvider 57 | implements PasswordProvider { 58 | 59 | /** 60 | * A public no-arg constructor used by {@link java.util.ServiceLoader} to 61 | * construct an instance of this provider. 62 | */ 63 | public HcpVaultDedicatedPasswordProvider() { 64 | super("password"); 65 | } 66 | 67 | @Override 68 | public char[] getPassword(Map parameterValues) { 69 | return getSecret(parameterValues).toCharArray(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/hcpvaultdedicated/resource/HcpVaultDedicatedResourceParameterNames.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.hashicorp.hcpvaultdedicated.resource; 40 | 41 | /** 42 | * Centralized parameter name constants used by HCP Vault Dedicated resource providers. 43 | */ 44 | public class HcpVaultDedicatedResourceParameterNames { 45 | 46 | private HcpVaultDedicatedResourceParameterNames() {} 47 | 48 | public static final String VAULT_ADDR = "vaultAddr"; 49 | public static final String VAULT_NAMESPACE = "vaultNamespace"; 50 | public static final String VAULT_USERNAME = "vaultUsername"; 51 | public static final String VAULT_PASSWORD = "vaultPassword"; 52 | public static final String VAULT_TOKEN = "vaultToken"; 53 | public static final String ROLE_ID = "roleId"; 54 | public static final String SECRET_ID = "secretId"; 55 | public static final String USERPASS_AUTH_PATH = "userPassAuthPath"; 56 | public static final String APPROLE_AUTH_PATH = "appRoleAuthPath"; 57 | public static final String GITHUB_TOKEN = "githubToken"; 58 | public static final String GITHUB_AUTH_PATH = "githubAuthPath"; 59 | 60 | public static final String SECRET_PATH = "secretPath"; 61 | public static final String FIELD_NAME = "fieldName"; 62 | 63 | public static final String TNS_ALIAS = "tnsAlias"; 64 | public static final String CONNECTION_STRING_INDEX = "connectionStringIndex"; 65 | public static final String WALLET_PASSWORD = "walletPassword"; 66 | public static final String TYPE = "type"; 67 | } 68 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/hcpvaultdedicated/resource/HcpVaultDedicatedUsernameProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.hashicorp.hcpvaultdedicated.resource; 40 | 41 | import oracle.jdbc.spi.UsernameProvider; 42 | 43 | import java.util.Map; 44 | 45 | /** 46 | *

47 | * A provider for securely retrieving a username stored as a secret 48 | * in HashiCorp Vault Dedicated. 49 | *

50 | *

51 | * This class implements the {@link UsernameProvider} SPI defined by 52 | * Oracle JDBC and is designed to be instantiated via {@link java.util.ServiceLoader}. 53 | *

54 | */ 55 | public class HcpVaultDedicatedUsernameProvider 56 | extends HcpVaultDedicatedSecretProvider 57 | implements UsernameProvider { 58 | 59 | /** 60 | * A public no-arg constructor used by {@link java.util.ServiceLoader} to 61 | * construct an instance of this provider. 62 | */ 63 | public HcpVaultDedicatedUsernameProvider() { 64 | super("username"); 65 | } 66 | 67 | @Override 68 | public String getUsername(Map parameterValues) { 69 | return getSecret(parameterValues); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/hcpvaultsecret/HcpVaultResourceFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.hashicorp.hcpvaultsecret; 40 | 41 | import oracle.jdbc.provider.factory.Resource; 42 | import oracle.jdbc.provider.factory.ResourceFactory; 43 | import oracle.jdbc.provider.hashicorp.hcpvaultsecret.authentication.HcpVaultSecretToken; 44 | import oracle.jdbc.provider.hashicorp.hcpvaultsecret.authentication.HcpVaultTokenFactory; 45 | import oracle.jdbc.provider.parameter.ParameterSet; 46 | 47 | public abstract class HcpVaultResourceFactory implements ResourceFactory { 48 | 49 | @Override 50 | public final Resource request(ParameterSet parameterSet) { 51 | HcpVaultSecretToken credentials = HcpVaultTokenFactory 52 | .getInstance() 53 | .request(parameterSet) 54 | .getContent(); 55 | 56 | try { 57 | return request(credentials, parameterSet); 58 | } catch (Exception e) { 59 | throw new IllegalStateException( 60 | "Request failed with parameters: " + parameterSet, e); 61 | } 62 | } 63 | 64 | public abstract Resource request( 65 | HcpVaultSecretToken credentials, ParameterSet parameterSet); 66 | } 67 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/hcpvaultsecret/authentication/AbstractHcpVaultAuthentication.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.hashicorp.hcpvaultsecret.authentication; 40 | 41 | import oracle.jdbc.provider.parameter.ParameterSet; 42 | 43 | import java.util.Map; 44 | 45 | /** 46 | * Base class for HCP Vault Secrets authentication strategies. 47 | *

48 | * Subclasses must implement methods to generate an access token and a cache key. 49 | *

50 | */ 51 | public abstract class AbstractHcpVaultAuthentication { 52 | 53 | /** 54 | * Generates an HCP Vault Secrets token based on the provided parameters. 55 | * 56 | * @param parameterSet the parameters for the authentication request. 57 | * @return the generated {@link HcpVaultSecretToken}. 58 | */ 59 | public abstract HcpVaultSecretToken generateToken(ParameterSet parameterSet); 60 | 61 | /** 62 | * Generates a cache key for the authentication request. 63 | * 64 | * @param parameterSet the parameters for the authentication request. 65 | * @return a {@link ParameterSet} to be used as a cache key. 66 | */ 67 | public abstract Map generateCacheKey(ParameterSet parameterSet); 68 | 69 | } 70 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/hcpvaultsecret/authentication/HcpVaultSecretToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.hashicorp.hcpvaultsecret.authentication; 40 | 41 | /** 42 | * Represents the credentials required to authenticate with HCP Vault Secrets. 43 | *

44 | * This class holds the API token obtained from the client_credentials OAuth2 flow. 45 | *

46 | */ 47 | public final class HcpVaultSecretToken { 48 | private final String hcpApiToken; 49 | 50 | /** 51 | * Constructs a new {@code HcpVaultSecretToken} object with 52 | * the provided API token. 53 | * 54 | * @param hcpApiToken the token used to authenticate API requests to 55 | * the HCP Vault Secret. Must not be null or empty. 56 | * @throws IllegalArgumentException if {@code hcpApiToken} is null or empty. 57 | */ 58 | public HcpVaultSecretToken(String hcpApiToken) { 59 | if (hcpApiToken == null || hcpApiToken.isEmpty()) { 60 | throw new IllegalArgumentException("HCP API token must not be null or empty."); 61 | } 62 | this.hcpApiToken = hcpApiToken; 63 | } 64 | 65 | /** 66 | * Returns the HCP API token used for authentication. 67 | * 68 | * @return the HCP API token as a {@link String}. 69 | */ 70 | public String getHcpApiToken() { 71 | return hcpApiToken; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/hcpvaultsecret/resource/HcpVaultSecretPasswordProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.hashicorp.hcpvaultsecret.resource; 40 | 41 | import oracle.jdbc.spi.PasswordProvider; 42 | 43 | import java.util.Map; 44 | 45 | /** 46 | *

47 | * A provider for retrieving password securely stored in HCP Vault Secrets. 48 | * This provider fetches the password from the Vault and returns it as a character array. 49 | *

50 | *

51 | * This class implements the {@link PasswordProvider} SPI defined by Oracle JDBC 52 | * and is designed to be instantiated via {@link java.util.ServiceLoader}. 53 | *

54 | */ 55 | public class HcpVaultSecretPasswordProvider 56 | extends HcpVaultSecretProvider 57 | implements PasswordProvider { 58 | 59 | /** 60 | * A public no-arg constructor used by {@link java.util.ServiceLoader} to 61 | * construct an instance of this provider. 62 | */ 63 | public HcpVaultSecretPasswordProvider() { 64 | super("password"); 65 | } 66 | 67 | @Override 68 | public char[] getPassword(Map parameterValues) { 69 | return getSecret(parameterValues).toCharArray(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/hcpvaultsecret/resource/HcpVaultSecretResourceParameterNames.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.hashicorp.hcpvaultsecret.resource; 40 | 41 | /** 42 | * Centralized parameter name constants used by HCP Vault Secret resource providers. 43 | */ 44 | public final class HcpVaultSecretResourceParameterNames { 45 | 46 | private HcpVaultSecretResourceParameterNames() {} 47 | 48 | public static final String ORG_ID = "orgId"; 49 | public static final String PROJECT_ID = "projectId"; 50 | public static final String APP_NAME = "appName"; 51 | public static final String CLIENT_ID = "clientId"; 52 | public static final String CLIENT_SECRET = "clientSecret"; 53 | public static final String CREDENTIALS_FILE = "credentialsFile"; 54 | 55 | public static final String SECRET_NAME = "secretName"; 56 | public static final String TNS_ALIAS = "tnsAlias"; 57 | public static final String CONNECTION_STRING_INDEX = "connectionStringIndex"; 58 | public static final String WALLET_PASSWORD = "walletPassword"; 59 | public static final String TYPE = "type"; 60 | } 61 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/hcpvaultsecret/resource/HcpVaultSecretUsernameProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.hashicorp.hcpvaultsecret.resource; 40 | 41 | import oracle.jdbc.spi.UsernameProvider; 42 | 43 | import java.util.Map; 44 | 45 | /** 46 | *

47 | * A provider for securely retrieving a username stored as a secret 48 | * in HashiCorp HCP Vault Secrets. 49 | *

50 | *

51 | * This class implements the {@link UsernameProvider} SPI defined by 52 | * Oracle JDBC and is designed to be instantiated via {@link java.util.ServiceLoader}. 53 | *

54 | */ 55 | public class HcpVaultSecretUsernameProvider 56 | extends HcpVaultSecretProvider 57 | implements UsernameProvider { 58 | 59 | /** 60 | * A public no-arg constructor used by {@link java.util.ServiceLoader} to 61 | * construct an instance of this provider. 62 | */ 63 | public HcpVaultSecretUsernameProvider() { 64 | super("username"); 65 | } 66 | 67 | @Override 68 | public String getUsername(Map parameterValues) { 69 | return getSecret(parameterValues); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/util/Parameterutil.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.hashicorp.util; 40 | 41 | /** 42 | * Utility class for parameter resolution. 43 | */ 44 | public final class Parameterutil { 45 | 46 | private Parameterutil() { 47 | // Prevent instantiation. 48 | } 49 | 50 | /** 51 | * Returns the fallback value for the given key by checking system properties first, 52 | * then environment variables. 53 | * 54 | * @param key the key to look up 55 | * @return the fallback value, or null if not found 56 | */ 57 | public static String getFallback(String key) { 58 | return System.getProperty(key, System.getenv(key)); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/resources/META-INF/services/oracle.jdbc.spi.ConnectionStringProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.hashicorp.hcpvaultdedicated.resource.HcpVaultDedicatedConnectionStringProvider 2 | oracle.jdbc.provider.hashicorp.hcpvaultsecret.resource.HcpVaultSecretConnectionStringProvider -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/resources/META-INF/services/oracle.jdbc.spi.OracleConfigurationProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.hashicorp.hcpvaultdedicated.configuration.DedicatedVaultSecretsManagerConfigurationProvider 2 | oracle.jdbc.provider.hashicorp.hcpvaultsecret.configuration.HcpVaultSecretsManagerConfigurationProvider -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/resources/META-INF/services/oracle.jdbc.spi.OracleConfigurationSecretProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.hashicorp.hcpvaultdedicated.configuration.DedicatedVaultJsonSecretProvider 2 | oracle.jdbc.provider.hashicorp.hcpvaultsecret.configuration.HcpVaultJsonVaultProvider -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/resources/META-INF/services/oracle.jdbc.spi.PasswordProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.hashicorp.hcpvaultdedicated.resource.HcpVaultDedicatedPasswordProvider 2 | oracle.jdbc.provider.hashicorp.hcpvaultdedicated.resource.HcpVaultDedicatedSEPSProvider 3 | oracle.jdbc.provider.hashicorp.hcpvaultsecret.resource.HcpVaultSecretPasswordProvider 4 | oracle.jdbc.provider.hashicorp.hcpvaultsecret.resource.HcpVaultSecretSEPSProvider 5 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/resources/META-INF/services/oracle.jdbc.spi.TlsConfigurationProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.hashicorp.hcpvaultdedicated.resource.HcpVaultDedicatedTCPSProvider 2 | oracle.jdbc.provider.hashicorp.hcpvaultsecret.resource.HcpVaultSecretTCPSProvider -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/main/resources/META-INF/services/oracle.jdbc.spi.UsernameProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.hashicorp.hcpvaultdedicated.resource.HcpVaultDedicatedUsernameProvider 2 | oracle.jdbc.provider.hashicorp.hcpvaultdedicated.resource.HcpVaultDedicatedSEPSProvider 3 | oracle.jdbc.provider.hashicorp.hcpvaultsecret.resource.HcpVaultSecretUsernameProvider 4 | oracle.jdbc.provider.hashicorp.hcpvaultsecret.resource.HcpVaultSecretSEPSProvider -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/test/java/oracle/jdbc/provider/hashicorp/hcpvaultdedicated/DedicatedVaultTestProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.hashicorp.hcpvaultdedicated; 40 | 41 | /** 42 | * Enumeration of test properties for Dedicated Vault. 43 | */ 44 | public enum DedicatedVaultTestProperty { 45 | DEDICATED_VAULT_SECRET_PATH, 46 | 47 | DEDICATED_VAULT_SECRET_PATH_WITH_MULTIPLE_KEYS, 48 | 49 | KEY, 50 | 51 | VAULT_TOKEN, 52 | 53 | VAULT_ADDR, 54 | 55 | VAULT_USERNAME, 56 | 57 | VAULT_PASSWORD, 58 | 59 | VAULT_NAMESPACE, 60 | 61 | ROLE_ID, 62 | 63 | SECRET_ID, 64 | 65 | PASSWORD_SECRET_PATH, 66 | 67 | TNSNAMES_SECRET_PATH, 68 | 69 | TNSNAMES_ALIAS, 70 | 71 | GITHUB_TOKEN, 72 | 73 | WALLET_SECRET_PATH, 74 | 75 | WALLET_PASSWORD 76 | } 77 | -------------------------------------------------------------------------------- /ojdbc-provider-hashicorp/src/test/java/oracle/jdbc/provider/hashicorp/hcpvaultsecret/HcpVaultTestProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2025 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.hashicorp.hcpvaultsecret; 40 | 41 | /** 42 | * Enumeration of test properties for HCP Vault. 43 | */ 44 | public enum HcpVaultTestProperty { 45 | HCP_APP_NAME, 46 | 47 | HCP_ORG_ID, 48 | 49 | HCP_PROJECT_ID, 50 | 51 | HCP_CLIENT_ID, 52 | 53 | HCP_CLIENT_SECRET, 54 | 55 | SECRET_NAME, 56 | 57 | SECRET_NAME_WITH_MULTIPLE_KEYS, 58 | 59 | KEY, 60 | 61 | CONNECTION_STRING_BASE64, 62 | 63 | CONNECTION_STRING_PLAIN_TEXT, 64 | 65 | TNSNAMES_ALIAS, 66 | 67 | USERNAME_SECRET_NAME, 68 | 69 | WALLET_P12_SECRET_NAME, 70 | 71 | WALLET_PASSWORD, 72 | 73 | WALLET_SSO_SECRET_NAME, 74 | 75 | WALLET_PEM_SECRET_NAME, 76 | 77 | WALLET_SECRET_PKCS12_NAME, 78 | 79 | WALLET_SECRET_SSO_NAME, 80 | 81 | HCP_CREDENTIALS_FILE 82 | } 83 | -------------------------------------------------------------------------------- /ojdbc-provider-jackson-oson/file.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/ojdbc-extensions/2b9ab6be59aa4608dde5589cf34fb8d7052fb0fa/ojdbc-provider-jackson-oson/file.json -------------------------------------------------------------------------------- /ojdbc-provider-jackson-oson/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | Oracle Jackson OSON Provider 7 | 8 | 9 | com.oracle.database.jdbc 10 | ojdbc-extensions 11 | 1.0.5 12 | 13 | 14 | ojdbc-provider-jackson-oson 15 | 16 | 2.18.1 17 | 3.1.0 18 | 19 | 20 | 21 | 22 | com.oracle.database.jdbc 23 | ojdbc-provider-common 24 | 1.0.5 25 | 26 | 27 | com.oracle.database.jdbc 28 | ojdbc8 29 | 30 | 31 | com.fasterxml.jackson.datatype 32 | jackson-datatype-jsr310 33 | ${jackson-version} 34 | 35 | 36 | jakarta.persistence 37 | jakarta.persistence-api 38 | ${jakarta-persistence-api} 39 | 40 | 41 | 42 | org.junit.jupiter 43 | junit-jupiter-api 44 | test 45 | 46 | 47 | org.junit.jupiter 48 | junit-jupiter-engine 49 | test 50 | 51 | 52 | org.junit.jupiter 53 | junit-jupiter-params 54 | test 55 | 56 | 57 | com.oracle.database.jdbc 58 | ojdbc-provider-common 59 | tests 60 | test-jar 61 | 62 | 63 | 64 | 65 | 66 | 67 | org.apache.maven.plugins 68 | maven-surefire-plugin 69 | 70 | 71 | ${project.groupId} 72 | ${project.artifactId} 73 | ${project.version} 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /ojdbc-provider-jackson-oson/src/main/resources/META-INF/services/com.fasterxml.jackson.databind.Module: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.oson.OsonModule -------------------------------------------------------------------------------- /ojdbc-provider-jackson-oson/src/main/resources/META-INF/services/oracle.jdbc.spi.JsonProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.oson.JacksonOsonProvider -------------------------------------------------------------------------------- /ojdbc-provider-jackson-oson/src/test/java/oracle/jdbc/provider/oson/OsonTestProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.oson; 40 | 41 | /** 42 | * Properties that are read from the test.properties file in order to run the 43 | * tests of the oson provider. 44 | */ 45 | public enum OsonTestProperty { 46 | JACKSON_OSON_URL, 47 | JACKSON_OSON_USERNAME, 48 | JACKSON_OSON_PASSWORD 49 | } 50 | -------------------------------------------------------------------------------- /ojdbc-provider-jackson-oson/src/test/java/oracle/jdbc/provider/oson/model/Organisation.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | package oracle.jdbc.provider.oson.model; 39 | 40 | import java.util.List; 41 | import java.util.Objects; 42 | 43 | /** 44 | * POJO to test Large objects with Nesting. 45 | */ 46 | public class Organisation { 47 | private String organisationName; 48 | private List employees; 49 | 50 | public String getOrganisationName() { 51 | return organisationName; 52 | } 53 | 54 | public void setOrganisationName(String organisationName) { 55 | this.organisationName = organisationName; 56 | } 57 | 58 | public Organisation(String organisationName, List employees) { 59 | this.organisationName = organisationName; 60 | this.employees = employees; 61 | } 62 | 63 | public Organisation() { 64 | } 65 | 66 | public List getEmployees() { 67 | return employees; 68 | } 69 | 70 | public void setEmployees(List employees) { 71 | this.employees = employees; 72 | } 73 | 74 | @Override 75 | public boolean equals(Object o) { 76 | if (this == o) return true; 77 | if (o == null || getClass() != o.getClass()) return false; 78 | Organisation that = (Organisation) o; 79 | return Objects.equals(organisationName, that.organisationName) && Objects.equals(employees, that.employees); 80 | } 81 | 82 | @Override 83 | public int hashCode() { 84 | return Objects.hash(organisationName, employees); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /ojdbc-provider-oci/example-adb.properties: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Copyright (c) 2023 Oracle and/or its affiliates. 3 | # 4 | # The Universal Permissive License (UPL), Version 1.0 5 | # 6 | # Subject to the condition set forth below, permission is hereby granted to any 7 | # person obtaining a copy of this software, associated documentation and/or data 8 | # (collectively the "Software"), free of charge and under any and all copyright 9 | # rights in the Software, and any and all patent rights owned or freely 10 | # licensable by each licensor hereunder covering either (i) the unmodified 11 | # Software as contributed to or provided by such licensor, or (ii) the Larger 12 | # Works (as defined below), to deal in both 13 | # 14 | # (a) the Software, and 15 | # (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | # one is included with the Software (each a "Larger Work" to which the Software 17 | # is contributed by such licensors), 18 | # 19 | # without restriction, including without limitation the rights to copy, create 20 | # derivative works of, display, perform, and distribute the Software and make, 21 | # use, sell, offer for sale, import, export, have made, and have sold the 22 | # Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | # either these or other terms. 24 | # 25 | # This license is subject to the following condition: 26 | # The above copyright notice and either this complete permission notice or at 27 | # a minimum a reference to the UPL must be included in all copies or 28 | # substantial portions of the Software. 29 | # 30 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | # SOFTWARE. 37 | ################################################################################ 38 | 39 | # An example of a connection properties file that configures Oracle JDBC to 40 | # obtain a connection string and TLS keys and certificates from OCI's Database 41 | # Service. 42 | # 43 | # This file can be located by Oracle JDBC using the "oracle.jdbc.config.file" 44 | # connection property. For details, see: 45 | # https://docs.oracle.com/en/database/oracle/oracle-database/23/jajdb/oracle/jdbc/OracleConnection.html#CONNECTION_PROPERTY_CONFIG_FILE 46 | 47 | # Configures the OCI Database Connection String Provider. The OCID of the database 48 | # is configured as an environment variable or JVM system property named 49 | # "DATABASE_OCID": 50 | oracle.jdbc.provider.connectionString=ojdbc-provider-oci-database-connection-string 51 | oracle.jdbc.provider.connectionString.ocid=${DATABASE_OCID} 52 | 53 | # Configures the OCI Database TLS Provider. Again, the OCID of the database 54 | # is configured as an environment variable or JVM system property named 55 | # "DATABASE_OCID": 56 | oracle.jdbc.provider.tlsConfiguration=ojdbc-provider-oci-database-tls 57 | oracle.jdbc.provider.tlsConfiguration.ocid=${DATABASE_OCID} 58 | -------------------------------------------------------------------------------- /ojdbc-provider-oci/example-token.properties: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Copyright (c) 2023 Oracle and/or its affiliates. 3 | # 4 | # The Universal Permissive License (UPL), Version 1.0 5 | # 6 | # Subject to the condition set forth below, permission is hereby granted to any 7 | # person obtaining a copy of this software, associated documentation and/or data 8 | # (collectively the "Software"), free of charge and under any and all copyright 9 | # rights in the Software, and any and all patent rights owned or freely 10 | # licensable by each licensor hereunder covering either (i) the unmodified 11 | # Software as contributed to or provided by such licensor, or (ii) the Larger 12 | # Works (as defined below), to deal in both 13 | # 14 | # (a) the Software, and 15 | # (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | # one is included with the Software (each a "Larger Work" to which the Software 17 | # is contributed by such licensors), 18 | # 19 | # without restriction, including without limitation the rights to copy, create 20 | # derivative works of, display, perform, and distribute the Software and make, 21 | # use, sell, offer for sale, import, export, have made, and have sold the 22 | # Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | # either these or other terms. 24 | # 25 | # This license is subject to the following condition: 26 | # The above copyright notice and either this complete permission notice or at 27 | # a minimum a reference to the UPL must be included in all copies or 28 | # substantial portions of the Software. 29 | # 30 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | # SOFTWARE. 37 | ################################################################################ 38 | 39 | # An example of a connection properties file that configures Oracle JDBC to 40 | # login using an OAUTH access token issued by OCI's Dataplane service. 41 | # 42 | # This file can be located by Oracle JDBC using the "oracle.jdbc.config.file" 43 | # connection property. For details, see: 44 | # https://docs.oracle.com/en/database/oracle/oracle-database/23/jajdb/oracle/jdbc/OracleConnection.html#CONNECTION_PROPERTY_CONFIG_FILE 45 | 46 | # Configures the OCI OAUTH Token Provider. The OCID of the database and its 47 | # compartment are configured as an environment variables or JVM system 48 | # properties named "DATABASE_OCID" and "COMPARTMENT_OCID": 49 | oracle.jdbc.provider.accessToken=ojdbc-provider-oci-token 50 | oracle.jdbc.provider.accessToken.scope=urn:oracle:db::id::${COMPARTMENT_OCID}::${DATABASE_OCID} 51 | -------------------------------------------------------------------------------- /ojdbc-provider-oci/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | Oracle JDBC OCI Providers 6 | 7 | ojdbc-provider-oci 8 | jar 9 | 10 | 11 | com.oracle.database.jdbc 12 | ojdbc-extensions 13 | 1.0.5 14 | 15 | 16 | 17 | 18 | 19 | com.oracle.oci.sdk 20 | oci-java-sdk-bom 21 | 3.48.0 22 | pom 23 | import 24 | 25 | 26 | 27 | 28 | 29 | 30 | com.oracle.database.jdbc 31 | ojdbc-provider-common 32 | 33 | 34 | com.oracle.database.jdbc 35 | ojdbc8 36 | 37 | 38 | com.oracle.oci.sdk 39 | oci-java-sdk-common 40 | 41 | 42 | com.oracle.oci.sdk 43 | oci-java-sdk-databasetools 44 | 45 | 46 | com.oracle.oci.sdk 47 | oci-java-sdk-objectstorage 48 | 49 | 50 | com.oracle.oci.sdk 51 | oci-java-sdk-secrets 52 | 53 | 54 | com.oracle.oci.sdk 55 | oci-java-sdk-identitydataplane 56 | 57 | 58 | com.oracle.oci.sdk 59 | oci-java-sdk-database 60 | 61 | 62 | com.oracle.oci.sdk 63 | oci-java-sdk-common-httpclient-jersey 64 | runtime 65 | 66 | 67 | 71 | 72 | com.oracle.database.jdbc 73 | ojdbc-provider-common 74 | tests 75 | test-jar 76 | 77 | 78 | org.junit.jupiter 79 | junit-jupiter-api 80 | 81 | 82 | org.junit.jupiter 83 | junit-jupiter-engine 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /ojdbc-provider-oci/src/main/java/oracle/jdbc/provider/oci/Ocid.java: -------------------------------------------------------------------------------- 1 | package oracle.jdbc.provider.oci; 2 | 3 | import com.oracle.bmc.Region; 4 | 5 | import java.util.regex.Matcher; 6 | import java.util.regex.Pattern; 7 | 8 | /** 9 | * Represents a general Oracle Cloud ID (OCID) class, which contains an 10 | * ocid string as its content. It parses out a region from the provided 11 | * ocid string during construction. 12 | **/ 13 | public final class Ocid { 14 | 15 | /** The ocid string */ 16 | private final String content; 17 | 18 | /** The parsed region extracted from the ocid string */ 19 | private final Region region; 20 | 21 | /** The regular expression of ocid */ 22 | private static final String REGEX = "ocid1\\.[^.]+\\.[^.]+\\.([^.]*)\\..+"; 23 | 24 | /** The pattern of ocid */ 25 | private static final Pattern PATTERN = Pattern.compile(REGEX); 26 | 27 | public Ocid(String content) { 28 | this.content = content; 29 | this.region = parseRegion(content); 30 | } 31 | 32 | /** 33 | * Returns a {@link Region} which is parsed from the ocid string. If 34 | * the region part is empty. The method will return null instead of 35 | * throwing an exception. 36 | * The format of Oracle Cloud ID (OCID) is documented as follows: 37 | *
38 |    * ocid1...[REGION][.FUTURE USE].
39 |    * 
40 | * @see Resource Identifiers 41 | * @return an {@code Region} which is extracted from the ocid string 42 | **/ 43 | private static Region parseRegion(String content) { 44 | Matcher matcher = PATTERN.matcher(content); 45 | if (matcher.matches()) { 46 | String regionCode = matcher.group(1); 47 | if (regionCode.equals("")) { 48 | return null; 49 | } 50 | return Region.fromRegionCode(matcher.group(1)); 51 | } 52 | throw new IllegalStateException( 53 | "Fail to parse region from the OCID: " + content); 54 | } 55 | 56 | public Region getRegion() { 57 | return region; 58 | } 59 | 60 | public String getContent() { 61 | return content; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /ojdbc-provider-oci/src/main/java/oracle/jdbc/provider/oci/configuration/OciVaultJsonProvider.java: -------------------------------------------------------------------------------- 1 | package oracle.jdbc.provider.oci.configuration; 2 | 3 | import oracle.jdbc.driver.configuration.OracleConfigurationParsableProvider; 4 | import oracle.jdbc.provider.oci.vault.SecretFactory; 5 | import oracle.jdbc.provider.parameter.ParameterSet; 6 | import oracle.jdbc.util.OracleConfigurationCache; 7 | 8 | import java.io.ByteArrayInputStream; 9 | import java.io.InputStream; 10 | import java.util.Base64; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | /** 15 | * A provider for JSON payload which contains configuration from OCI Vault. 16 | * See {@link #getInputStream(String)} for the spec of the JSON payload. 17 | **/ 18 | public class OciVaultJsonProvider extends OracleConfigurationParsableProvider { 19 | 20 | /** 21 | * {@inheritDoc} 22 | *

23 | * Returns the JSON payload stored in OCI Vault Secret. 24 | *

The {@code secretOcid} is an OCID of Vault Secret which can be 25 | * acquired on the OCI Web Console. The Json payload is stored in the Secret 26 | * Contents of Vault Secret. 27 | *

28 | * @param secretOcid the OCID of secret used by this provider to retrieve 29 | * JSON payload from OCI 30 | * @return JSON payload 31 | **/ 32 | @Override 33 | public InputStream getInputStream(String secretOcid) { 34 | final String valueFieldName = "value"; 35 | Map optionsWithOcid = new HashMap<>(options); 36 | optionsWithOcid.put(valueFieldName, secretOcid); 37 | 38 | ParameterSet parameters = 39 | OciConfigurationParameters.getParser() 40 | .parseNamedValues(optionsWithOcid); 41 | 42 | String secretContent = SecretFactory.getInstance() 43 | .request(parameters) 44 | .getContent() 45 | .getBase64Secret(); 46 | 47 | InputStream inputStream = new ByteArrayInputStream( 48 | Base64.getDecoder().decode(secretContent)); 49 | return inputStream; 50 | } 51 | 52 | /** 53 | * {@inheritDoc} 54 | * Returns type of this provider, which is a unique identifier for the 55 | * Service Provider Interface. 56 | * 57 | * @return type of this provider 58 | */ 59 | @Override 60 | public String getType() { 61 | return "ocivault"; 62 | } 63 | 64 | @Override 65 | public String getParserType(String arg0) { 66 | return "json"; 67 | } 68 | 69 | /** 70 | * {@inheritDoc} 71 | * @return cache of this provider which is used to store configuration 72 | */ 73 | @Override 74 | public OracleConfigurationCache getCache() { 75 | return CACHE; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /ojdbc-provider-oci/src/main/java/oracle/jdbc/provider/oci/resource/VaultPasswordProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.oci.resource; 40 | 41 | import oracle.jdbc.provider.resource.ResourceParameter; 42 | import oracle.jdbc.spi.PasswordProvider; 43 | 44 | import java.util.Map; 45 | 46 | import static oracle.jdbc.provider.oci.vault.SecretFactory.OCID; 47 | 48 | /** 49 | *

50 | * A provider of passwords from the OCI Vault service. 51 | *

52 | * This class implements the {@link PasswordProvider} SPI defined by 53 | * Oracle JDBC. It is designed to be located and instantiated by 54 | * {@link java.util.ServiceLoader}. 55 | *

56 | */ 57 | public final class VaultPasswordProvider 58 | extends OciResourceProvider 59 | implements PasswordProvider { 60 | 61 | private static final ResourceParameter[] PARAMETERS = { 62 | new ResourceParameter("ocid", OCID) 63 | }; 64 | 65 | /** 66 | * A public no-arg constructor used by {@link java.util.ServiceLoader} to 67 | * construct an instance of this provider. 68 | */ 69 | public VaultPasswordProvider() { 70 | super("vault-password", PARAMETERS); 71 | } 72 | 73 | @Override 74 | public char[] getPassword(Map parameterValues) { 75 | return getVaultSecret(parameterValues) 76 | .toCharArray(); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /ojdbc-provider-oci/src/main/java/oracle/jdbc/provider/oci/resource/VaultUsernameProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | package oracle.jdbc.provider.oci.resource; 39 | 40 | import oracle.jdbc.provider.oci.vault.Secret; 41 | import oracle.jdbc.provider.resource.ResourceParameter; 42 | import oracle.jdbc.spi.UsernameProvider; 43 | 44 | import java.util.Map; 45 | 46 | import static oracle.jdbc.provider.oci.vault.SecretFactory.OCID; 47 | 48 | /** 49 | *

50 | * A provider of passwords from the Oracle Cloud Infrastructure (OCI) Vault 51 | * service. 52 | *

53 | * This class implements the {@link UsernameProvider} SPI defined by 54 | * Oracle JDBC. It is designed to be located and instantiated by 55 | * {@link java.util.ServiceLoader}. 56 | *

57 | */ 58 | public class VaultUsernameProvider 59 | extends OciResourceProvider 60 | implements UsernameProvider{ 61 | 62 | private static final ResourceParameter[] PARAMETERS = { 63 | new ResourceParameter("ocid", OCID) 64 | }; 65 | 66 | /** 67 | * A public no-arg constructor used by {@link java.util.ServiceLoader} to 68 | * construct an instance of this provider. 69 | */ 70 | public VaultUsernameProvider() { 71 | super("vault-username", PARAMETERS); 72 | } 73 | 74 | @Override 75 | public String getUsername(Map parameterValues) { 76 | 77 | Secret secret = getVaultSecret(parameterValues); 78 | 79 | return new String(secret.toCharArray()); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /ojdbc-provider-oci/src/main/resources/META-INF/services/oracle.jdbc.spi.AccessTokenProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.oci.resource.DataplaneTokenProvider -------------------------------------------------------------------------------- /ojdbc-provider-oci/src/main/resources/META-INF/services/oracle.jdbc.spi.ConnectionStringProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.oci.resource.DatabaseConnectionStringProvider 2 | oracle.jdbc.provider.oci.resource.VaultConnectionStringProvider -------------------------------------------------------------------------------- /ojdbc-provider-oci/src/main/resources/META-INF/services/oracle.jdbc.spi.OracleConfigurationProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.oci.configuration.OciObjectStorageProvider 2 | oracle.jdbc.provider.oci.configuration.OciDatabaseToolsConnectionProvider 3 | oracle.jdbc.provider.oci.configuration.OciVaultJsonProvider -------------------------------------------------------------------------------- /ojdbc-provider-oci/src/main/resources/META-INF/services/oracle.jdbc.spi.OracleConfigurationSecretProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.oci.configuration.OciVaultSecretProvider 2 | -------------------------------------------------------------------------------- /ojdbc-provider-oci/src/main/resources/META-INF/services/oracle.jdbc.spi.PasswordProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.oci.resource.VaultPasswordProvider 2 | oracle.jdbc.provider.oci.resource.VaultSEPSProvider -------------------------------------------------------------------------------- /ojdbc-provider-oci/src/main/resources/META-INF/services/oracle.jdbc.spi.TlsConfigurationProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.oci.resource.DatabaseTlsProvider 2 | oracle.jdbc.provider.oci.resource.VaultTCPSProvider -------------------------------------------------------------------------------- /ojdbc-provider-oci/src/main/resources/META-INF/services/oracle.jdbc.spi.UsernameProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.oci.resource.VaultUsernameProvider 2 | oracle.jdbc.provider.oci.resource.VaultSEPSProvider 3 | -------------------------------------------------------------------------------- /ojdbc-provider-oci/src/test/java/oracle/jdbc/provider/oci/configuration/OciVaultJsonProviderTest.java: -------------------------------------------------------------------------------- 1 | package oracle.jdbc.provider.oci.configuration; 2 | 3 | import oracle.jdbc.provider.TestProperties; 4 | import oracle.jdbc.provider.oci.OciTestProperty; 5 | import oracle.jdbc.spi.OracleConfigurationProvider; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import java.sql.SQLException; 9 | import java.util.Properties; 10 | 11 | import static org.junit.jupiter.api.Assertions.*; 12 | 13 | /** 14 | * Verifies the {@link OciVaultJsonProvider} as implementing behavior 15 | * specified by its JavaDoc. 16 | */ 17 | 18 | public class OciVaultJsonProviderTest { 19 | 20 | static { 21 | OracleConfigurationProvider.allowedProviders.add("ocivault"); 22 | } 23 | 24 | private static final OracleConfigurationProvider PROVIDER = 25 | OracleConfigurationProvider.find("ocivault"); 26 | 27 | /** 28 | * Verifies the AUTHENTICATION=OCI_DEFAULT parameter setting. 29 | * This test will fail if (~/.oci/config) or (~/.oraclebmc/config) or the 30 | * environmental variable OCI_CONFIG_FILE is not set. 31 | */ 32 | @Test 33 | public void testDefaultAuthentication() throws SQLException { 34 | String baseUrl = 35 | TestProperties.getOrAbort(OciTestProperty.OCI_PASSWORD_PAYLOAD_OCID); 36 | String[] options = new String[] {"AUTHENTICATION=OCI_DEFAULT"}; 37 | String url = composeUrl(baseUrl, options); 38 | verifyProperties(url); 39 | } 40 | 41 | /** 42 | * Verifies the AUTHENTICATION=OCI_DEFAULT parameter setting with key option. 43 | */ 44 | @Test 45 | public void testDefaultAuthenticationWithKeyOption() throws SQLException { 46 | String baseUrl = 47 | TestProperties.getOrAbort(OciTestProperty.OCI_PASSWORD_PAYLOAD_OCID_MULTIPLE_KEYS); 48 | String[] options = new String[] { 49 | "AUTHENTICATION=OCI_DEFAULT", 50 | "key=" + TestProperties.getOrAbort(OciTestProperty.OCI_PASSWORD_PAYLOAD_OCID_KEY)}; 51 | String url = composeUrl(baseUrl, options); 52 | verifyProperties(url); 53 | } 54 | 55 | /** Verifies a properties object returned with a given URL. */ 56 | private static void verifyProperties(String url) throws SQLException { 57 | Properties properties = PROVIDER.getConnectionProperties(url); 58 | 59 | assertNotNull(properties); 60 | } 61 | 62 | private static String composeUrl(String baseUrl, String... options) { 63 | return String.format("%s?%s", baseUrl, String.join("&", options)); 64 | } 65 | } -------------------------------------------------------------------------------- /ojdbc-provider-opentelemetry/README.md: -------------------------------------------------------------------------------- 1 | # Oracle JDBC Open Telemetry Provider 2 | 3 | This module contains a provider for integration between Oracle JDBC and 4 | Open Telemetry. 5 | 6 | This provider implements the TraceEventListener interface provided by the JDBC 7 | driver which will be notified whenever events are generated in the driver and 8 | will publish these events into Open Telemetry. These events include: 9 | * roundtrips to the database server 10 | * AC begin and sucess 11 | * VIP down event 12 | 13 | The following attributes are added the the traces for each event: 14 | * **Roundtrips** 15 | * Connection ID 16 | * Database Operation 17 | * Database User 18 | * Database Tenant 19 | * SQL ID 20 | * Original SQL Text *(only present if sensitive data is enabled)* 21 | * Actual SQL Text *(only present if sensitive data is enabled)* 22 | * **AC begin and success** 23 | * Error Message 24 | * Error code 25 | * SQL state 26 | * Current replay retry count 27 | * **VIP down event** 28 | * Error message 29 | * VIP address 30 | * Protocol *(only present if sensitive data is enabled)* 31 | * Host *(only present if sensitive data is enabled)* 32 | * Port *(only present if sensitive data is enabled)* 33 | * Service name *(only present if sensitive data is enabled)* 34 | * SID *(only present if sensitive data is enabled)* 35 | * Connection data *(only present if sensitive data is enabled)* 36 | 37 | ## Installation 38 | 39 | This provider is distributed as single jar on the Maven Central Repository. The 40 | jar is compiled for JDK 8, and is forward compatible with later JDK versions. 41 | The coordinates for the latest release are: 42 | 43 | ```xml 44 | 45 | com.oracle.database.jdbc 46 | ojdbc-provider-opentelemetry 47 | 1.0.5 48 | 49 | ``` 50 | 51 | ## Usage 52 | 53 | To use the Oracle JDBC provider for Open Telemetry just add the artifact to the 54 | application's classpath and set the following connection property : 55 | 56 | ```java 57 | oracle.jdbc.provider.traceEventListener=open-telemetry-trace-event-listener-provider 58 | ``` 59 | 60 | ## Configuration 61 | 62 | The Oracle JDBC provider for Open Telemetry can be configured using system properties 63 | or a MBean. Two parameters can be configured: 64 | * **Enabled**: when enabled (*true*) traces will be exported to Open 65 | Telemetry. This property is **enabled by default**. 66 | * **Sensitive data enabled**: when enabled (*true*) attributes containing 67 | sensitive information like SQL statements and connection URL will be included 68 | in the traces. This property is **disabled by default**. 69 | 70 | The system properties are "oracle.jdbc.provider.opentelemetry.enabled" and 71 | "oracle.jdbc.provider.opentelemetry.sensitive-enabled" respectively and the MBean 72 | with object name "com.oracle.jdbc.extension.opentelemetry:type=OpenTelemetryTraceEventListener" 73 | exposes two attributes "Enabled" and "SensitiveDataEnabled". 74 | 75 | The sample code below shows how to retrieve the value of an attribute: 76 | ```java 77 | ObjectName objectName = new ObjectName( 78 | "com.oracle.jdbc.extension.opentelemetry:type=OpenTelemetryTraceEventListener"); 79 | MBeanServer server = ManagementFactory.getPlatformMBeanServer(); 80 | boolean isEnabled = Boolean.valueOf(server.getAttribute(objectName, "Enabled").toString()) 81 | .booleanValue(); 82 | ``` -------------------------------------------------------------------------------- /ojdbc-provider-opentelemetry/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | Oracle JDBC Open Telemetry Provider 6 | 7 | com.oracle.database.jdbc 8 | ojdbc-provider-opentelemetry 9 | jar 10 | 11 | 12 | com.oracle.database.jdbc 13 | ojdbc-extensions 14 | 1.0.5 15 | 16 | 17 | 18 | 1.44.1 19 | 20 | 21 | 22 | 23 | com.oracle.database.jdbc 24 | ojdbc8 25 | 26 | 27 | io.opentelemetry 28 | opentelemetry-api 29 | ${opentelemetry.version} 30 | 31 | 32 | org.mockito 33 | mockito-core 34 | test 35 | 36 | 37 | org.junit.jupiter 38 | junit-jupiter-engine 39 | test 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /ojdbc-provider-opentelemetry/src/main/java/oracle/jdbc/provider/opentelemetry/OpenTelemetryTraceEventListenerMBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2023 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | 39 | package oracle.jdbc.provider.opentelemetry; 40 | 41 | /** 42 | * MBean interface for the OpenTelemetryTraceEventListener, it exposes two 43 | * attributes: Enabled and SensitiveDataEnabled. 44 | */ 45 | public interface OpenTelemetryTraceEventListenerMBean { 46 | void setEnabled(boolean enabled); 47 | 48 | void setSensitiveDataEnabled(boolean enabled); 49 | 50 | boolean isEnabled(); 51 | 52 | boolean isSensitiveDataEnabled(); 53 | } 54 | -------------------------------------------------------------------------------- /ojdbc-provider-opentelemetry/src/main/resources/META-INF/services/oracle.jdbc.spi.TraceEventListenerProvider: -------------------------------------------------------------------------------- 1 | oracle.jdbc.provider.opentelemetry.OpenTelemetryTraceEventListenerProvider -------------------------------------------------------------------------------- /ojdbc-provider-samples/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | Oracle JDBC Provider Code Samples 6 | 7 | ojdbc-provider-samples 8 | ${project.parent.version} 9 | jar 10 | 11 | 12 | com.oracle.database.jdbc 13 | ojdbc-extensions 14 | 1.0.5 15 | 16 | 17 | 18 | 11 19 | 11 20 | 21 | 22 | 23 | 24 | com.oracle.database.jdbc 25 | ojdbc-provider-azure 26 | ${project.parent.version} 27 | 28 | 29 | com.oracle.database.jdbc 30 | ojdbc-provider-oci 31 | ${project.parent.version} 32 | 33 | 34 | com.oracle.database.jdbc 35 | ojdbc-provider-gcp 36 | ${project.parent.version} 37 | 38 | 39 | com.oracle.database.jdbc 40 | ojdbc-provider-jackson-oson 41 | ${project.parent.version} 42 | 43 | 44 | com.oracle.database.jdbc 45 | ojdbc-provider-aws 46 | ${project.parent.version} 47 | 48 | 49 | com.oracle.database.jdbc 50 | ojdbc-provider-hashicorp 51 | ${project.parent.version} 52 | 53 | 54 | com.oracle.database.security 55 | oraclepki 56 | runtime 57 | 58 | 59 | org.hibernate.orm 60 | hibernate-core 61 | 6.6.0.Final 62 | 63 | 64 | javax.xml.bind 65 | jaxb-api 66 | 2.3.1 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oci/configuration/resource/SimpleDatabaseConnectionStringProviderExample.java: -------------------------------------------------------------------------------- 1 | package oracle.jdbc.provider.oci.configuration.resource; 2 | 3 | import oracle.jdbc.datasource.impl.OracleDataSource; 4 | 5 | import java.sql.Connection; 6 | import java.sql.ResultSet; 7 | import java.sql.SQLException; 8 | import java.sql.Statement; 9 | import java.util.Properties; 10 | 11 | /** 12 | * Example demonstrating how to configure Oracle JDBC with the Database 13 | * Connection String Provider to retrieve connection strings and TLS 14 | * configuration for a secure connection to an Oracle Autonomous Database 15 | *

16 | * The connection string and TLS credentials are securely retrieved based on the 17 | * Autonomous Database OCID. 18 | *

19 | */ 20 | public class SimpleDatabaseConnectionStringProviderExample { 21 | private static final String JDBC_URL_PREFIX = "jdbc:oracle:thin:@"; 22 | private static final String DB_PASSWORD = "password"; 23 | private static final String DB_USER = "username"; 24 | 25 | 26 | public static void main(String[] args) throws SQLException { 27 | try { 28 | OracleDataSource ds = new OracleDataSource(); 29 | ds.setURL(JDBC_URL_PREFIX); 30 | ds.setUser(DB_USER); 31 | ds.setPassword(DB_PASSWORD); 32 | 33 | Properties connectionProps = new Properties(); 34 | connectionProps.put("oracle.jdbc.provider.connectionString", 35 | "ojdbc-provider-oci-database-connection-string"); 36 | connectionProps.put("oracle.jdbc.provider.connectionString.ocid", 37 | "ocid1.autonomousdatabase.oc1.phx.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); 38 | 39 | connectionProps.put("oracle.jdbc.provider.tlsConfiguration", 40 | "ojdbc-provider-oci-database-tls"); 41 | connectionProps.put("oracle.jdbc.provider.tlsConfiguration.ocid", 42 | "ocid1.autonomousdatabase.oc1.phx.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); 43 | 44 | ds.setConnectionProperties(connectionProps); 45 | 46 | try (Connection cn = ds.getConnection()) { 47 | Statement st = cn.createStatement(); 48 | ResultSet rs = st.executeQuery("SELECT 'Hello, db' FROM sys.dual"); 49 | if (rs.next()) 50 | System.out.println(rs.getString(1)); 51 | } 52 | } catch (SQLException e) { 53 | throw new RuntimeException(e); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oci/configuration/resource/SimpleDatabaseTlsProviderExample.java: -------------------------------------------------------------------------------- 1 | package oracle.jdbc.provider.oci.configuration.resource; 2 | 3 | import oracle.jdbc.datasource.impl.OracleDataSource; 4 | 5 | import java.sql.*; 6 | import java.util.Properties; 7 | 8 | /** 9 | * Example demonstrating how to use the Database TLS Provider 10 | * with Oracle JDBC to establish a secure TLS connection to an 11 | * Oracle Autonomous Database. 12 | */ 13 | public class SimpleDatabaseTlsProviderExample { 14 | private static final String DB_URL = "(description=(retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=your_db_host))(connect_data=(service_name=your_service_name))(security=(ssl_server_dn_match=yes)))"; 15 | private static final String JDBC_URL = "jdbc:oracle:thin:@" + DB_URL; 16 | private static final String USERNAME = "DB_USERNAME"; 17 | private static final String PASSWORD = "DB_PASSWORD"; 18 | 19 | 20 | public static void main(String[] args) { 21 | try { 22 | OracleDataSource ds = new OracleDataSource(); 23 | ds.setURL(JDBC_URL); 24 | ds.setUser(USERNAME); 25 | ds.setPassword(PASSWORD); 26 | 27 | Properties connectionProps = new Properties(); 28 | connectionProps.put("oracle.jdbc.provider.tlsConfiguration", 29 | "ojdbc-provider-oci-database-tls"); 30 | connectionProps.put("oracle.jdbc.provider.tlsConfiguration.ocid", 31 | "ocid1.autonomousdatabase.oc1.phx.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); 32 | 33 | 34 | ds.setConnectionProperties(connectionProps); 35 | try (Connection cn = ds.getConnection()) { 36 | String connectionString = cn.getMetaData().getURL(); 37 | System.out.println("Connected to: " + connectionString); 38 | 39 | Statement st = cn.createStatement(); 40 | ResultSet rs = st.executeQuery("SELECT 'Hello, db' FROM sys.dual"); 41 | if (rs.next()) 42 | System.out.println(rs.getString(1)); 43 | } 44 | } catch (SQLException e) { 45 | throw new RuntimeException(e); 46 | } 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oci/configuration/resource/SimpleSEPSWalletProviderExample.java: -------------------------------------------------------------------------------- 1 | package oracle.jdbc.provider.oci.configuration.resource; 2 | 3 | import oracle.jdbc.datasource.impl.OracleDataSource; 4 | 5 | import java.sql.*; 6 | import java.util.Properties; 7 | 8 | /** 9 | * A standalone example that configures Oracle JDBC to be provided with the 10 | * connection properties retrieved from an OCI Vault SEPS Wallet. 11 | *

12 | * This example demonstrates how to use the SEPS Wallet Provider with Oracle JDBC 13 | * to connect to an Oracle Autonomous Database (ADB) in Oracle Cloud Infrastructure (OCI). 14 | * It retrieves the database credentials from a Secure External Password Store 15 | * (SEPS) wallet stored in OCI Vault. 16 | *

17 | *

18 | * The SEPS wallet securely stores encrypted database credentials. 19 | *

20 | * 21 | */ 22 | public class SimpleSEPSWalletProviderExample { 23 | private static final String DB_URL = "(description=(retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=your_db_host))(connect_data=(service_name=your_service_name))(security=(ssl_server_dn_match=yes)))"; 24 | private static final String JDBC_URL = "jdbc:oracle:thin:@" + DB_URL; 25 | 26 | 27 | public static void main(String[] args) { 28 | try { 29 | OracleDataSource ds = new OracleDataSource(); 30 | ds.setURL(JDBC_URL); 31 | 32 | Properties connectionProps = new Properties(); 33 | connectionProps.put("oracle.jdbc.provider.username", "ojdbc-provider-oci-vault-seps"); 34 | connectionProps.put("oracle.jdbc.provider.password", "ojdbc-provider-oci-vault-seps"); 35 | 36 | // Set the OCID of your SEPS wallet stored in OCI Vault 37 | connectionProps.put("oracle.jdbc.provider.username.ocid", 38 | "ocid1.vaultsecret.oc1.phx.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); 39 | connectionProps.put("oracle.jdbc.provider.password.ocid", 40 | "ocid1.vaultsecret.oc1.phx.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); 41 | 42 | // TLS Configuration Provider 43 | connectionProps.put("oracle.jdbc.provider.tlsConfiguration", "ojdbc-provider-oci-database-tls"); 44 | connectionProps.put("oracle.jdbc.provider.tlsConfiguration.ocid", 45 | "ocid1.autonomousdatabase.oc1.phx.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); 46 | 47 | ds.setConnectionProperties(connectionProps); 48 | 49 | try (Connection cn = ds.getConnection()) { 50 | String connectionString = cn.getMetaData().getURL(); 51 | System.out.println("Connected to: " + connectionString); 52 | 53 | Statement st = cn.createStatement(); 54 | ResultSet rs = st.executeQuery("SELECT 'Hello, db' FROM sys.dual"); 55 | if (rs.next()) 56 | System.out.println(rs.getString(1)); 57 | } 58 | } catch (SQLException e) { 59 | throw new RuntimeException(e); 60 | } 61 | } 62 | } 63 | 64 | 65 | -------------------------------------------------------------------------------- /ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oci/configuration/resource/SimpleSEPSWalletProviderWithIndexExample.java: -------------------------------------------------------------------------------- 1 | package oracle.jdbc.provider.oci.configuration.resource; 2 | 3 | import oracle.jdbc.datasource.impl.OracleDataSource; 4 | 5 | import java.sql.Connection; 6 | import java.sql.ResultSet; 7 | import java.sql.SQLException; 8 | import java.sql.Statement; 9 | import java.util.Properties; 10 | 11 | /** 12 | * A standalone example that configures Oracle JDBC to be provided with a 13 | * specified connection string index to retrieve credentials from an OCI 14 | * Vault SEPS wallet. 15 | *

16 | * This example demonstrates how to use the SEPS Wallet Provider with Oracle JDBC 17 | * to connect to an Oracle Autonomous Database (ADB) in Oracle Cloud Infrastructure (OCI). 18 | * It retrieves the database credentials from a Secure External Password Store 19 | * (SEPS) wallet stored in OCI Vault and specifying a connection string index 20 | * to select a specific credential set. 21 | *

22 | *

23 | * The SEPS wallet securely stores encrypted database credentials. 24 | *

25 | * 26 | */ 27 | public class SimpleSEPSWalletProviderWithIndexExample { 28 | private static final String DB_URL = "(description=(retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=your_db_host))(connect_data=(service_name=your_service_name))(security=(ssl_server_dn_match=yes)))"; 29 | private static final String JDBC_URL = "jdbc:oracle:thin:@" + DB_URL; 30 | 31 | 32 | public static void main(String[] args) { 33 | try { 34 | OracleDataSource ds = new OracleDataSource(); 35 | ds.setURL(JDBC_URL); 36 | 37 | Properties connectionProps = new Properties(); 38 | connectionProps.put("oracle.jdbc.provider.username", "ojdbc-provider-oci-vault-seps"); 39 | connectionProps.put("oracle.jdbc.provider.password", "ojdbc-provider-oci-vault-seps"); 40 | 41 | // Set the OCID of your SEPS wallet stored in OCI Vault 42 | connectionProps.put("oracle.jdbc.provider.username.ocid", 43 | "ocid1.vaultsecret.oc1.phx.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); 44 | connectionProps.put("oracle.jdbc.provider.password.ocid", 45 | "ocid1.vaultsecret.oc1.phx.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); 46 | 47 | // TLS Configuration Provider 48 | connectionProps.put("oracle.jdbc.provider.tlsConfiguration", 49 | "ojdbc-provider-oci-database-tls"); 50 | connectionProps.put("oracle.jdbc.provider.tlsConfiguration.ocid", 51 | "ocid1.autonomousdatabase.oc1.phx.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); 52 | 53 | // Specify the connection string index 54 | connectionProps.put("oracle.jdbc.provider.username.connectionStringIndex","1"); 55 | connectionProps.put("oracle.jdbc.provider.password.connectionStringIndex","1"); 56 | 57 | ds.setConnectionProperties(connectionProps); 58 | 59 | try (Connection cn = ds.getConnection()) { 60 | String connectionString = cn.getMetaData().getURL(); 61 | System.out.println("Connected to: " + connectionString); 62 | 63 | Statement st = cn.createStatement(); 64 | ResultSet rs = st.executeQuery("SELECT 'Hello, db' FROM sys.dual"); 65 | if (rs.next()) 66 | System.out.println(rs.getString(1)); 67 | } 68 | } catch (SQLException e) { 69 | throw new RuntimeException(e); 70 | } 71 | } 72 | } 73 | 74 | 75 | -------------------------------------------------------------------------------- /ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oci/configuration/resource/SimpleTCPSWalletProviderExample.java: -------------------------------------------------------------------------------- 1 | package oracle.jdbc.provider.oci.configuration.resource; 2 | 3 | import oracle.jdbc.datasource.impl.OracleDataSource; 4 | 5 | import java.sql.*; 6 | import java.util.Properties; 7 | 8 | /** 9 | * Example demonstrating how to configure Oracle JDBC with the TCPS Wallet 10 | * Provider to establish a secure TLS connection to an Oracle Autonomous 11 | * Database in OCI. 12 | *

13 | * The wallet is retrieved from OCI Vault to enable secure TLS communication. 14 | *

15 | */ 16 | public class SimpleTCPSWalletProviderExample { 17 | private static final String DB_URL = "(description=(retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=your_db_host))(connect_data=(service_name=your_service_name))(security=(ssl_server_dn_match=yes)))"; 18 | private static final String JDBC_URL = "jdbc:oracle:thin:@" + DB_URL; 19 | private static final String USERNAME = "DB_USER"; 20 | private static final String PASSWORD = "DB_PASSWORD"; 21 | 22 | 23 | public static void main(String[] args) throws SQLException { 24 | try { 25 | OracleDataSource ds = new OracleDataSource(); 26 | ds.setURL(JDBC_URL); 27 | ds.setUser(USERNAME); 28 | ds.setPassword(PASSWORD); 29 | 30 | Properties connectionProps = new Properties(); 31 | connectionProps.put("oracle.jdbc.provider.tlsConfiguration", "ojdbc-provider-oci-vault-tls"); 32 | connectionProps.put("oracle.jdbc.provider.tlsConfiguration.ocid", 33 | "ocid1.vaultsecret.oc1.phx.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); 34 | connectionProps.put("oracle.jdbc.provider.tlsConfiguration.type", "SSO"); 35 | ds.setConnectionProperties(connectionProps); 36 | 37 | try (Connection cn = ds.getConnection()) { 38 | String connectionString = cn.getMetaData().getURL(); 39 | System.out.println("Connected to: " + connectionString); 40 | 41 | Statement st = cn.createStatement(); 42 | ResultSet rs = st.executeQuery("SELECT 'Hello, db' FROM sys.dual"); 43 | if (rs.next()) 44 | System.out.println(rs.getString(1)); 45 | } 46 | } catch (SQLException e) { 47 | throw new RuntimeException(e); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oci/configuration/resource/SimpleVaultSecretPasswordProviderExample.java: -------------------------------------------------------------------------------- 1 | package oracle.jdbc.provider.oci.configuration.resource; 2 | 3 | import oracle.jdbc.datasource.impl.OracleDataSource; 4 | 5 | import java.sql.*; 6 | import java.util.Properties; 7 | 8 | /** 9 | * Example demonstrating how to use the Vault Password Provider 10 | * with Oracle JDBC to securely retrieve a database password from OCI Vault. 11 | *

12 | * This example shows how to configure Oracle JDBC to retrieve the password. 13 | *

14 | */ 15 | public class SimpleVaultSecretPasswordProviderExample { 16 | private static final String DB_URL = "(description=(retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=your_db_host))(connect_data=(service_name=your_service_name))(security=(ssl_server_dn_match=yes)))"; 17 | private static final String JDBC_URL = "jdbc:oracle:thin:@" + DB_URL; 18 | 19 | 20 | public static void main(String[] args) throws SQLException { 21 | try { 22 | OracleDataSource ds = new OracleDataSource(); 23 | ds.setURL(JDBC_URL); 24 | ds.setUser("DB_USER"); 25 | 26 | Properties connectionProps = new Properties(); 27 | connectionProps.put("oracle.jdbc.provider.password","ojdbc-provider-oci-vault-password"); 28 | connectionProps.put("oracle.jdbc.provider.password.ocid", 29 | "ocid1.vaultsecret.oc1.phx.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); 30 | connectionProps.put("oracle.jdbc.provider.tlsConfiguration", "ojdbc-provider-oci-database-tls"); 31 | connectionProps.put("oracle.jdbc.provider.tlsConfiguration.ocid", 32 | "ocid1.autonomousdatabase.oc1.phx.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); 33 | ds.setConnectionProperties(connectionProps); 34 | 35 | try (Connection cn = ds.getConnection()) { 36 | String connectionString = cn.getMetaData().getURL(); 37 | System.out.println("Connected to: " + connectionString); 38 | 39 | Statement st = cn.createStatement(); 40 | ResultSet rs = st.executeQuery("SELECT 'Hello, db' FROM sys.dual"); 41 | if (rs.next()) 42 | System.out.println(rs.getString(1)); 43 | } 44 | } catch (SQLException e) { 45 | throw new RuntimeException(e); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oci/configuration/resource/SimpleVaultSecretUsernameProviderExample.java: -------------------------------------------------------------------------------- 1 | package oracle.jdbc.provider.oci.configuration.resource; 2 | 3 | import oracle.jdbc.datasource.impl.OracleDataSource; 4 | 5 | import java.sql.Connection; 6 | import java.sql.ResultSet; 7 | import java.sql.SQLException; 8 | import java.sql.Statement; 9 | import java.util.Properties; 10 | 11 | /** 12 | * Example demonstrating how to use the Vault Username Provider 13 | * with Oracle JDBC to securely retrieve a database username from OCI Vault. 14 | *

15 | * This example shows how to configure Oracle JDBC to retrieve the username. 16 | *

17 | */ 18 | public class SimpleVaultSecretUsernameProviderExample { 19 | private static final String DB_URL = "(description=(retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=your_db_host))(connect_data=(service_name=your_service_name))(security=(ssl_server_dn_match=yes)))"; 20 | private static final String JDBC_URL = "jdbc:oracle:thin:@" + DB_URL; 21 | 22 | 23 | public static void main(String[] args) throws SQLException { 24 | try { 25 | OracleDataSource ds = new OracleDataSource(); 26 | ds.setURL(JDBC_URL); 27 | ds.setPassword("DB_PASSWORD"); 28 | 29 | Properties connectionProps = new Properties(); 30 | connectionProps.put("oracle.jdbc.provider.username","ojdbc-provider-oci-vault-username"); 31 | connectionProps.put("oracle.jdbc.provider.username.ocid", 32 | "ocid1.vaultsecret.oc1.phx.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); 33 | connectionProps.put("oracle.jdbc.provider.tlsConfiguration", "ojdbc-provider-oci-database-tls"); 34 | connectionProps.put("oracle.jdbc.provider.tlsConfiguration.ocid", 35 | "ocid1.vaultsecret.oc1.phx.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); 36 | ds.setConnectionProperties(connectionProps); 37 | 38 | try (Connection cn = ds.getConnection()) { 39 | String connectionString = cn.getMetaData().getURL(); 40 | System.out.println("Connected to: " + connectionString); 41 | 42 | Statement st = cn.createStatement(); 43 | ResultSet rs = st.executeQuery("SELECT 'Hello, db' FROM sys.dual"); 44 | if (rs.next()) 45 | System.out.println(rs.getString(1)); 46 | } 47 | } catch (SQLException e) { 48 | throw new RuntimeException(e); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oson/sample/model/Emp.java: -------------------------------------------------------------------------------- 1 | package oracle.jdbc.provider.oson.sample.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | import java.math.BigDecimal; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Objects; 9 | 10 | /** 11 | * Sample Emp Pojo. 12 | */ 13 | public class Emp { 14 | 15 | String name; 16 | 17 | String job; 18 | 19 | BigDecimal salary; 20 | 21 | @JsonProperty("e-mail") 22 | String email; 23 | 24 | List phoneNumbers = new ArrayList<>(); 25 | 26 | public Emp() { 27 | } 28 | 29 | public Emp(String name, String job, BigDecimal salary, String email, List phones) { 30 | this.name = name; 31 | this.job = job; 32 | this.salary = salary; 33 | this.email = email; 34 | phoneNumbers.addAll(phones); 35 | } 36 | 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | public void setName(String name) { 42 | this.name = name; 43 | } 44 | 45 | public String getJob() { 46 | return job; 47 | } 48 | 49 | public void setJob(String job) { 50 | this.job = job; 51 | } 52 | 53 | public BigDecimal getSalary() { 54 | return salary; 55 | } 56 | 57 | public void setSalary(BigDecimal salary) { 58 | this.salary = salary; 59 | } 60 | 61 | public String getEmail() { 62 | return email; 63 | } 64 | 65 | public void setEmail(String email) { 66 | this.email = email; 67 | } 68 | 69 | public List getPhoneNumbers() { 70 | return this.phoneNumbers; 71 | } 72 | 73 | public void setPhoneNumbers(List phones) { 74 | this.phoneNumbers = phones; 75 | } 76 | 77 | @Override 78 | public String toString() { 79 | return "Emp \n{\n" + 80 | " name=" + name + ",\n" + 81 | " job=" + job + ",\n" + 82 | " salary=" + salary + ",\n" + 83 | " email=" + email + ",\n" + 84 | " phoneNumbers=" + phoneNumbers + "\n" + 85 | '}'; 86 | } 87 | 88 | @Override 89 | public boolean equals(Object o) { 90 | if (this == o) return true; 91 | if (o == null || getClass() != o.getClass()) return false; 92 | Emp emp = (Emp) o; 93 | return Objects.equals(name, emp.name) && Objects.equals(job, emp.job) && Objects.equals(salary, emp.salary) && Objects.equals(email, emp.email) && Objects.equals(phoneNumbers, emp.phoneNumbers); 94 | } 95 | 96 | @Override 97 | public int hashCode() { 98 | return Objects.hash(name, job, salary, email, phoneNumbers); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oson/sample/model/Image.java: -------------------------------------------------------------------------------- 1 | package oracle.jdbc.provider.oson.sample.model; 2 | 3 | import java.util.Objects; 4 | 5 | public class Image { 6 | public String location; 7 | public String description; 8 | 9 | public Image() {} 10 | public Image (String location, String description) { 11 | this.description = description; 12 | this.location = location; 13 | } 14 | 15 | @Override 16 | public boolean equals(Object o) { 17 | if (this == o) return true; 18 | if (o == null || getClass() != o.getClass()) return false; 19 | Image image = (Image) o; 20 | return location.equals(image.location) && description.equals(image.description); 21 | } 22 | 23 | @Override 24 | public int hashCode() { 25 | return Objects.hash(location, description); 26 | } 27 | } -------------------------------------------------------------------------------- /ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oson/sample/model/JsonOsonSample.java: -------------------------------------------------------------------------------- 1 | package oracle.jdbc.provider.oson.sample.model; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.Id; 6 | import jakarta.persistence.Table; 7 | import org.hibernate.annotations.JdbcTypeCode; 8 | import org.hibernate.type.SqlTypes; 9 | 10 | @Entity(name = "JsonOsonSample") 11 | @Table(name = "jackson_oson_sample") 12 | public class JsonOsonSample { 13 | 14 | @Id 15 | private int id; 16 | 17 | @JdbcTypeCode(SqlTypes.JSON) 18 | @Column(name="json_value") 19 | private Emp emp; 20 | 21 | public int getId() { 22 | return id; 23 | } 24 | 25 | public Emp getEmp() { 26 | return emp; 27 | } 28 | 29 | public void setId(int id) { 30 | this.id = id; 31 | } 32 | 33 | public void setEmp(Emp emp) { 34 | this.emp = emp; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oson/sample/model/Movie.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | package oracle.jdbc.provider.oson.sample.model; 39 | 40 | import java.math.BigDecimal; 41 | import java.time.OffsetDateTime; 42 | import java.util.List; 43 | import java.util.Objects; 44 | 45 | import com.fasterxml.jackson.annotation.JsonProperty; 46 | 47 | public class Movie { 48 | @JsonProperty("_id") 49 | public int id; 50 | public String title; 51 | public String genre; 52 | public BigDecimal gross; 53 | public OffsetDateTime released; 54 | public List image; 55 | 56 | public Movie() {} 57 | public Movie(int id, String title, String genre, BigDecimal gross, OffsetDateTime released, List image) { 58 | this.id = id; 59 | this.title = title; 60 | this.genre = genre; 61 | this.gross = gross; 62 | this.released = released; 63 | this.image = image; 64 | } 65 | 66 | @Override 67 | public boolean equals(Object o) { 68 | if (this == o) return true; 69 | if (o == null || getClass() != o.getClass()) return false; 70 | Movie movie = (Movie) o; 71 | return id == movie.id 72 | && title.equals(movie.title) 73 | && genre.equals(movie.genre) 74 | && gross.compareTo(movie.gross) == 0 75 | && released.isEqual(movie.released) 76 | && image.equals(movie.image); 77 | } 78 | 79 | @Override 80 | public int hashCode() { 81 | return Objects.hash(id, title, genre, gross, released, image); 82 | } 83 | } 84 | 85 | 86 | -------------------------------------------------------------------------------- /ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oson/sample/model/Phone.java: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2024 Oracle and/or its affiliates. 3 | ** 4 | ** The Universal Permissive License (UPL), Version 1.0 5 | ** 6 | ** Subject to the condition set forth below, permission is hereby granted to any 7 | ** person obtaining a copy of this software, associated documentation and/or data 8 | ** (collectively the "Software"), free of charge and under any and all copyright 9 | ** rights in the Software, and any and all patent rights owned or freely 10 | ** licensable by each licensor hereunder covering either (i) the unmodified 11 | ** Software as contributed to or provided by such licensor, or (ii) the Larger 12 | ** Works (as defined below), to deal in both 13 | ** 14 | ** (a) the Software, and 15 | ** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | ** one is included with the Software (each a "Larger Work" to which the Software 17 | ** is contributed by such licensors), 18 | ** 19 | ** without restriction, including without limitation the rights to copy, create 20 | ** derivative works of, display, perform, and distribute the Software and make, 21 | ** use, sell, offer for sale, import, export, have made, and have sold the 22 | ** Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | ** either these or other terms. 24 | ** 25 | ** This license is subject to the following condition: 26 | ** The above copyright notice and either this complete permission notice or at 27 | ** a minimum a reference to the UPL must be included in all copies or 28 | ** substantial portions of the Software. 29 | ** 30 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | ** SOFTWARE. 37 | */ 38 | package oracle.jdbc.provider.oson.sample.model; 39 | 40 | import java.util.Objects; 41 | 42 | public class Phone { 43 | 44 | public enum Type {MOBILE, HOME, WORK} 45 | 46 | String number; 47 | 48 | Type type; 49 | 50 | public Phone() { 51 | } 52 | 53 | public Phone(String number, Type type) { 54 | this.number = number; 55 | this.type = type; 56 | } 57 | 58 | public String getNumber() { 59 | return number; 60 | } 61 | 62 | public void setNumber(String number) { 63 | this.number = number; 64 | } 65 | 66 | public Type getType() { 67 | return type; 68 | } 69 | 70 | public void setType(Type type) { 71 | this.type = type; 72 | } 73 | 74 | @Override 75 | public String toString() { 76 | return "Phone {" + 77 | "number='" + number + '\'' + 78 | ", type=" + type + 79 | '}'; 80 | } 81 | 82 | @Override 83 | public boolean equals(Object o) { 84 | if (this == o) return true; 85 | if (o == null || getClass() != o.getClass()) return false; 86 | Phone phone = (Phone) o; 87 | return Objects.equals(number, phone.number) && type == phone.type; 88 | } 89 | 90 | @Override 91 | public int hashCode() { 92 | return Objects.hash(number, type); 93 | } 94 | } 95 | --------------------------------------------------------------------------------