-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎉 Created destination-oracle-strict-encrypt (#7460)
* created destination-oracle-strict-encrypt * fixed code style * updated specNormalizationValueShouldBeCorrect test * fixed remarks * fixed remarks * fixed remarks
- Loading branch information
1 parent
ebf35eb
commit fce6056
Showing
15 changed files
with
629 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
airbyte-integrations/connectors/destination-oracle-strict-encrypt/.dockerignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* | ||
!Dockerfile | ||
!build |
12 changes: 12 additions & 0 deletions
12
airbyte-integrations/connectors/destination-oracle-strict-encrypt/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM airbyte/integration-base-java:dev | ||
|
||
WORKDIR /airbyte | ||
|
||
ENV APPLICATION destination-oracle-strict-encrypt | ||
|
||
COPY build/distributions/${APPLICATION}*.tar ${APPLICATION}.tar | ||
|
||
RUN tar xf ${APPLICATION}.tar --strip-components=1 | ||
|
||
LABEL io.airbyte.version=0.1.0 | ||
LABEL io.airbyte.name=airbyte/destination-oracle-strict-encrypt |
5 changes: 5 additions & 0 deletions
5
airbyte-integrations/connectors/destination-oracle-strict-encrypt/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Oracle Strict Encrypt Test Configuration | ||
|
||
In order to test the Oracle destination, you need to have the up and running Oracle database that has SSL enabled. | ||
|
||
This connector inherits the Oracle destination, but support SSL connections only. |
35 changes: 35 additions & 0 deletions
35
airbyte-integrations/connectors/destination-oracle-strict-encrypt/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
plugins { | ||
id 'application' | ||
id 'airbyte-docker' | ||
id 'airbyte-integration-test-java' | ||
} | ||
|
||
application { | ||
mainClass = 'io.airbyte.integrations.destination.oracle_strict_encrypt.OracleStrictEncryptDestination' | ||
applicationDefaultJvmArgs = ['-XX:MaxRAMPercentage=75.0'] | ||
} | ||
|
||
dependencies { | ||
|
||
// required so that log4j uses a standard xml parser instead of an oracle one (that gets pulled in by the oracle driver) | ||
implementation group: 'xerces', name: 'xercesImpl', version: '2.12.1' | ||
|
||
implementation project(':airbyte-db:lib') | ||
implementation project(':airbyte-integrations:bases:base-java') | ||
implementation project(':airbyte-protocol:models') | ||
implementation project(':airbyte-integrations:connectors:destination-jdbc') | ||
implementation project(':airbyte-integrations:connectors:destination-oracle') | ||
|
||
implementation "com.oracle.database.jdbc:ojdbc8-production:19.7.0.0" | ||
|
||
testImplementation project(':airbyte-test-utils') | ||
|
||
testImplementation 'org.apache.commons:commons-lang3:3.11' | ||
testImplementation 'org.testcontainers:oracle-xe:1.16.0' | ||
|
||
integrationTestJavaImplementation project(':airbyte-integrations:bases:standard-destination-test') | ||
integrationTestJavaImplementation project(':airbyte-integrations:connectors:destination-oracle') | ||
|
||
implementation files(project(':airbyte-integrations:bases:base-java').airbyteDocker.outputs) | ||
integrationTestJavaImplementation files(project(':airbyte-integrations:bases:base-normalization').airbyteDocker.outputs) | ||
} |
59 changes: 59 additions & 0 deletions
59
...irbyte/integrations/destination/oracle_strict_encrypt/OracleStrictEncryptDestination.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.oracle_strict_encrypt; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import com.google.common.collect.ImmutableMap; | ||
import io.airbyte.commons.json.Jsons; | ||
import io.airbyte.integrations.base.AirbyteMessageConsumer; | ||
import io.airbyte.integrations.base.Destination; | ||
import io.airbyte.integrations.base.IntegrationRunner; | ||
import io.airbyte.integrations.base.spec_modification.SpecModifyingDestination; | ||
import io.airbyte.integrations.destination.oracle.OracleDestination; | ||
import io.airbyte.protocol.models.AirbyteMessage; | ||
import io.airbyte.protocol.models.ConfiguredAirbyteCatalog; | ||
import io.airbyte.protocol.models.ConnectorSpecification; | ||
import java.util.function.Consumer; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class OracleStrictEncryptDestination extends SpecModifyingDestination implements Destination { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(OracleStrictEncryptDestination.class); | ||
|
||
public OracleStrictEncryptDestination() { | ||
super(OracleDestination.sshWrappedDestination()); | ||
} | ||
|
||
@Override | ||
public ConnectorSpecification modifySpec(final ConnectorSpecification originalSpec) { | ||
final ConnectorSpecification spec = Jsons.clone(originalSpec); | ||
((ObjectNode) spec.getConnectionSpecification().get("properties")).remove("encryption"); | ||
return spec; | ||
} | ||
|
||
@Override | ||
public AirbyteMessageConsumer getConsumer(JsonNode config, | ||
ConfiguredAirbyteCatalog catalog, | ||
Consumer<AirbyteMessage> outputRecordCollector) | ||
throws Exception { | ||
final JsonNode cloneConfig = Jsons.clone(config); | ||
((ObjectNode) cloneConfig).put("encryption", Jsons.jsonNode(ImmutableMap.builder() | ||
.put("encryption_method", "client_nne") | ||
.put("encryption_algorithm", "AES256") | ||
.build())); | ||
|
||
return super.getConsumer(cloneConfig, catalog, outputRecordCollector); | ||
} | ||
|
||
public static void main(final String[] args) throws Exception { | ||
final Destination destination = new OracleStrictEncryptDestination(); | ||
LOGGER.info("starting destination: {}", OracleStrictEncryptDestination.class); | ||
new IntegrationRunner(destination).run(args); | ||
LOGGER.info("completed destination: {}", OracleStrictEncryptDestination.class); | ||
} | ||
|
||
} |
199 changes: 199 additions & 0 deletions
199
...ation/java/io/airbyte/integrations/destination/oracle_strict_encrypt/OracleContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.oracle_strict_encrypt; | ||
|
||
import static java.time.temporal.ChronoUnit.SECONDS; | ||
import static java.util.Collections.singleton; | ||
|
||
import java.time.Duration; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.concurrent.Future; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.testcontainers.containers.JdbcDatabaseContainer; | ||
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
public class OracleContainer extends JdbcDatabaseContainer<OracleContainer> { | ||
|
||
public static final String NAME = "oracle"; | ||
private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("gvenzl/oracle-xe"); | ||
|
||
static final String DEFAULT_TAG = "18.4.0-slim"; | ||
static final String IMAGE = DEFAULT_IMAGE_NAME.getUnversionedPart(); | ||
|
||
private static final int ORACLE_PORT = 1521; | ||
private static final int APEX_HTTP_PORT = 8080; | ||
|
||
private static final int DEFAULT_STARTUP_TIMEOUT_SECONDS = 240; | ||
private static final int DEFAULT_CONNECT_TIMEOUT_SECONDS = 120; | ||
|
||
// Container defaults | ||
static final String DEFAULT_DATABASE_NAME = "xepdb1"; | ||
static final String DEFAULT_SID = "xe"; | ||
static final String DEFAULT_SYSTEM_USER = "system"; | ||
static final String DEFAULT_SYS_USER = "sys"; | ||
|
||
// Test container defaults | ||
static final String APP_USER = "test"; | ||
static final String APP_USER_PASSWORD = "test"; | ||
|
||
// Restricted user and database names | ||
private static final List<String> ORACLE_SYSTEM_USERS = Arrays.asList(DEFAULT_SYSTEM_USER, DEFAULT_SYS_USER); | ||
|
||
private String databaseName = DEFAULT_DATABASE_NAME; | ||
private String username = APP_USER; | ||
private String password = APP_USER_PASSWORD; | ||
private boolean usingSid = false; | ||
|
||
public OracleContainer() { | ||
this(DEFAULT_IMAGE_NAME.withTag(DEFAULT_TAG)); | ||
} | ||
|
||
public OracleContainer(final String dockerImageName) { | ||
this(DockerImageName.parse(dockerImageName)); | ||
} | ||
|
||
public OracleContainer(final DockerImageName dockerImageName) { | ||
super(dockerImageName); | ||
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); | ||
preconfigure(); | ||
} | ||
|
||
public OracleContainer(final Future<String> dockerImageName) { | ||
super(dockerImageName); | ||
preconfigure(); | ||
} | ||
|
||
private void preconfigure() { | ||
this.waitStrategy = new LogMessageWaitStrategy() | ||
.withRegEx(".*DATABASE IS READY TO USE!.*\\s") | ||
.withTimes(1) | ||
.withStartupTimeout(Duration.of(DEFAULT_STARTUP_TIMEOUT_SECONDS, SECONDS)); | ||
|
||
withConnectTimeoutSeconds(DEFAULT_CONNECT_TIMEOUT_SECONDS); | ||
addExposedPorts(ORACLE_PORT, APEX_HTTP_PORT); | ||
} | ||
|
||
@Override | ||
protected void waitUntilContainerStarted() { | ||
getWaitStrategy().waitUntilReady(this); | ||
} | ||
|
||
@Override | ||
public Set<Integer> getLivenessCheckPortNumbers() { | ||
return singleton(getMappedPort(ORACLE_PORT)); | ||
} | ||
|
||
@Override | ||
public String getDriverClassName() { | ||
return "oracle.jdbc.OracleDriver"; | ||
} | ||
|
||
@Override | ||
public String getJdbcUrl() { | ||
return isUsingSid() ? "jdbc:oracle:thin:" + "@" + getHost() + ":" + getOraclePort() + ":" + getSid() | ||
: "jdbc:oracle:thin:" + "@" + getHost() + ":" + getOraclePort() + "/" + getDatabaseName(); | ||
} | ||
|
||
@Override | ||
public String getUsername() { | ||
// An application user is tied to the database, and therefore not authenticated to connect to SID. | ||
return isUsingSid() ? DEFAULT_SYSTEM_USER : username; | ||
} | ||
|
||
@Override | ||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
@Override | ||
public String getDatabaseName() { | ||
return databaseName; | ||
} | ||
|
||
protected boolean isUsingSid() { | ||
return usingSid; | ||
} | ||
|
||
@Override | ||
public OracleContainer withUsername(final String username) { | ||
if (StringUtils.isEmpty(username)) { | ||
throw new IllegalArgumentException("Username cannot be null or empty"); | ||
} | ||
if (ORACLE_SYSTEM_USERS.contains(username.toLowerCase())) { | ||
throw new IllegalArgumentException("Username cannot be one of " + ORACLE_SYSTEM_USERS); | ||
} | ||
this.username = username; | ||
return self(); | ||
} | ||
|
||
@Override | ||
public OracleContainer withPassword(final String password) { | ||
if (StringUtils.isEmpty(password)) { | ||
throw new IllegalArgumentException("Password cannot be null or empty"); | ||
} | ||
this.password = password; | ||
return self(); | ||
} | ||
|
||
@Override | ||
public OracleContainer withDatabaseName(final String databaseName) { | ||
if (StringUtils.isEmpty(databaseName)) { | ||
throw new IllegalArgumentException("Database name cannot be null or empty"); | ||
} | ||
|
||
if (DEFAULT_DATABASE_NAME.equals(databaseName.toLowerCase())) { | ||
throw new IllegalArgumentException("Database name cannot be set to " + DEFAULT_DATABASE_NAME); | ||
} | ||
|
||
this.databaseName = databaseName; | ||
return self(); | ||
} | ||
|
||
public OracleContainer usingSid() { | ||
this.usingSid = true; | ||
return self(); | ||
} | ||
|
||
@Override | ||
public OracleContainer withUrlParam(final String paramName, final String paramValue) { | ||
throw new UnsupportedOperationException("The Oracle Database driver does not support this"); | ||
} | ||
|
||
@SuppressWarnings("SameReturnValue") | ||
public String getSid() { | ||
return DEFAULT_SID; | ||
} | ||
|
||
public Integer getOraclePort() { | ||
return getMappedPort(ORACLE_PORT); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public Integer getWebPort() { | ||
return getMappedPort(APEX_HTTP_PORT); | ||
} | ||
|
||
@Override | ||
public String getTestQueryString() { | ||
return "SELECT 1 FROM DUAL"; | ||
} | ||
|
||
@Override | ||
protected void configure() { | ||
withEnv("ORACLE_PASSWORD", password); | ||
|
||
// Only set ORACLE_DATABASE if different than the default. | ||
if (databaseName != DEFAULT_DATABASE_NAME) { | ||
withEnv("ORACLE_DATABASE", databaseName); | ||
} | ||
|
||
withEnv("APP_USER", username); | ||
withEnv("APP_USER_PASSWORD", password); | ||
} | ||
|
||
} |
Oops, something went wrong.