src/main/java/org/embulk/input/PostgreSQLInputPlugin.java in embulk-input-postgresql-0.6.0 vs src/main/java/org/embulk/input/PostgreSQLInputPlugin.java in embulk-input-postgresql-0.6.1

- old
+ new

@@ -2,11 +2,10 @@ import java.util.Properties; import java.sql.Connection; import java.sql.Driver; import java.sql.SQLException; -import com.google.common.base.Throwables; import org.embulk.config.Config; import org.embulk.config.ConfigDefault; import org.embulk.input.jdbc.AbstractJdbcInputPlugin; import org.embulk.input.postgresql.PostgreSQLInputConnection; @@ -36,10 +35,14 @@ public String getDatabase(); @Config("schema") @ConfigDefault("\"public\"") public String getSchema(); + + @Config("ssl") + @ConfigDefault("false") + public boolean getSsl(); } @Override protected Class<? extends PluginTask> getTaskClass() { @@ -55,26 +58,23 @@ t.getHost(), t.getPort(), t.getDatabase()); Properties props = new Properties(); props.setProperty("user", t.getUser()); props.setProperty("password", t.getPassword()); - props.setProperty("loginTimeout", "300"); // seconds - props.setProperty("socketTimeout", "1800"); // seconds + props.setProperty("loginTimeout", String.valueOf(t.getConnectTimeout())); // seconds + props.setProperty("socketTimeout", String.valueOf(t.getSocketTimeout())); // seconds // Enable keepalive based on tcp_keepalive_time, tcp_keepalive_intvl and tcp_keepalive_probes kernel parameters. // Socket options TCP_KEEPCNT, TCP_KEEPIDLE, and TCP_KEEPINTVL are not configurable. props.setProperty("tcpKeepAlive", "true"); - // TODO - //switch t.getSssl() { - //when "disable": - // break; - //when "enable": - // props.setProperty("sslfactory", "org.postgresql.ssl.NonValidatingFactory"); // disable server-side validation - //when "verify": - // props.setProperty("ssl", "true"); - // break; - //} + if (t.getSsl()) { + // TODO add ssl_verify (boolean) option to allow users to verify certification. + // see embulk-input-ftp for SSL implementation. + props.setProperty("ssl", "true"); + props.setProperty("sslfactory", "org.postgresql.ssl.NonValidatingFactory"); // disable server-side validation + } + // setting ssl=false enables SSL. See org.postgresql.core.v3.openConnectionImpl. props.putAll(t.getOptions()); Connection con = driver.connect(url, props); try {