embulk-input-ftp 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0333d873277223fc5c1d369fa1417e2481df6ac0
4
- data.tar.gz: c3b61c7abde8c581303b993613e788378d133372
3
+ metadata.gz: 84b6cf71034980db6a9d4f78d5affdaae19aa792
4
+ data.tar.gz: 104382478ca9b24c2c08cc839637083a7540b715
5
5
  SHA512:
6
- metadata.gz: 790052dc1eafaaa5aa093fa6ba0d12fe7ccc64b21de203fcbdc8495807b420549176e19524096a4b02765e26470cc7a1d04358c47e3878f59a6288fedb4941c6
7
- data.tar.gz: 5e1755a9388bbeefb9c6a4e6f2c9e96833568a7ab6861fde7985b1c88f6995bd439a65e059f2c73175c102e845a61e35391f20e7f239abe40051aa646ecf405e
6
+ metadata.gz: c98936c59b2c4ea47cb394462a6ab5df1a2d9fa1f4223d2c26ac9d75efde5746dac49267a668bd95657c5b19a797195a573a9984d7cdb6964725fc74cc1ade18
7
+ data.tar.gz: 035fbcd64345982d6370c3e38c607121e5b97a27daf26daf9274f4de441f5a10c4a61fa667120f6d0bbed0d2854a4983c3bb701428cd12d1fb832d4e7b84ddcc
data/ChangeLog CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ Release 0.1.1 - 2015-04-29
3
+
4
+ * Added support for SSL
5
+ * Fixed last_path handling
6
+
2
7
  Release 0.1.0 - 2015-04-29
3
8
 
4
9
  * First release
data/README.md CHANGED
@@ -9,12 +9,14 @@
9
9
  ## Configuration
10
10
 
11
11
  - **host**: FTP server address (string, required)
12
- - **port**: FTP server port number (integer, default: 21)
12
+ - **port**: FTP server port number (integer, default: `21`. `990` if `ssl` is true)
13
13
  - **user**: user name to login (string, optional)
14
14
  - **password**: password to login (string, default: `""`)
15
- - **path_prefix** prefix of target keys (string, required)
15
+ - **path_prefix** prefix of target files (string, required)
16
16
  - **passive_mode**: use passive mode (boolean, default: true)
17
17
  - **ascii_mode**: use ASCII mode instead of binary mode (boolean, default: false)
18
+ - **ssl**: use FTPS (SSL encryption). (boolean, default: false)
19
+ - Currently, it doesn't support certificate checking. Any certificate given by the remote host is trusted.
18
20
 
19
21
  ## Example
20
22
 
data/build.gradle CHANGED
@@ -12,7 +12,7 @@ configurations {
12
12
  provided
13
13
  }
14
14
 
15
- version = "0.1.0"
15
+ version = "0.1.1"
16
16
 
17
17
  dependencies {
18
18
  compile "org.embulk:embulk-core:0.6.5"
@@ -53,8 +53,8 @@ Gem::Specification.new do |spec|
53
53
  spec.name = "${project.name}"
54
54
  spec.version = "${project.version}"
55
55
  spec.authors = ["Sadayuki Furuhashi"]
56
- spec.summary = %[Ftp file input plugin for Embulk]
57
- spec.description = %[Reads files stored on Ftp.]
56
+ spec.summary = %[FTP file input plugin for Embulk]
57
+ spec.description = %[Reads files stored on a FTP server.]
58
58
  spec.email = ["frsyuki@gmail.com"]
59
59
  spec.licenses = ["Apache 2.0"]
60
60
  spec.homepage = "https://github.com/embulk/embulk-input-ftp"
@@ -9,6 +9,14 @@ import java.io.IOException;
9
9
  import java.io.InterruptedIOException;
10
10
  import java.io.InputStream;
11
11
  import java.nio.channels.Channels;
12
+ import java.security.SecureRandom;
13
+ import java.security.KeyManagementException;
14
+ import java.security.NoSuchAlgorithmException;
15
+ import java.security.cert.X509Certificate;
16
+ import javax.net.ssl.SSLContext;
17
+ import javax.net.ssl.SSLSocketFactory;
18
+ import javax.net.ssl.TrustManager;
19
+ import javax.net.ssl.X509TrustManager;
12
20
  import org.slf4j.Logger;
13
21
  import com.google.common.util.concurrent.ThreadFactoryBuilder;
14
22
  import com.google.common.collect.ImmutableList;
@@ -63,8 +71,8 @@ public class FtpFileInputPlugin
63
71
  public String getHost();
64
72
 
65
73
  @Config("port")
66
- @ConfigDefault("21")
67
- public int getPort();
74
+ @ConfigDefault("null")
75
+ public Optional<Integer> getPort();
68
76
 
69
77
  @Config("user")
70
78
  @ConfigDefault("null")
@@ -82,6 +90,10 @@ public class FtpFileInputPlugin
82
90
  @ConfigDefault("false")
83
91
  public boolean getAsciiMode();
84
92
 
93
+ @Config("ssl")
94
+ @ConfigDefault("false")
95
+ public boolean getSsl();
96
+
85
97
  public List<String> getFiles();
86
98
  public void setFiles(List<String> files);
87
99
 
@@ -144,7 +156,10 @@ public class FtpFileInputPlugin
144
156
  {
145
157
  FTPClient client = new FTPClient();
146
158
  try {
147
- // TODO SSL
159
+ if (task.getSsl()) {
160
+ client.setSSLSocketFactory(newSSLSocketFactory(task));
161
+ client.setSecurity(FTPClient.SECURITY_FTPS);
162
+ }
148
163
 
149
164
  client.addCommunicationListener(new LoggingCommunicationListner(log));
150
165
 
@@ -164,7 +179,9 @@ public class FtpFileInputPlugin
164
179
  //client.setAutodetectUTF8
165
180
 
166
181
  log.info("Connecting to "+task.getHost());
167
- client.connect(task.getHost(), task.getPort());
182
+ if (task.getPort().isPresent()) {
183
+ client.connect(task.getHost(), task.getPort().get());
184
+ }
168
185
 
169
186
  if (task.getUser().isPresent()) {
170
187
  log.info("Logging in with user "+task.getUser().get());
@@ -225,6 +242,40 @@ public class FtpFileInputPlugin
225
242
  }
226
243
  }
227
244
 
245
+ private static SSLSocketFactory newSSLSocketFactory(PluginTask task)
246
+ {
247
+ // TODO certificate check
248
+
249
+ TrustManager[] trustManager = new TrustManager[] {
250
+ new X509TrustManager() {
251
+ public X509Certificate[] getAcceptedIssuers()
252
+ {
253
+ return null;
254
+ }
255
+
256
+ public void checkClientTrusted(X509Certificate[] certs, String authType)
257
+ {
258
+ }
259
+
260
+ public void checkServerTrusted(X509Certificate[] certs, String authType)
261
+ {
262
+ }
263
+ }
264
+ };
265
+
266
+ try {
267
+ SSLContext context = SSLContext.getInstance("TLS");
268
+ context.init(null, trustManager, new SecureRandom());
269
+ return context.getSocketFactory();
270
+
271
+ } catch (NoSuchAlgorithmException ex) {
272
+ throw new RuntimeException(ex);
273
+
274
+ } catch (KeyManagementException ex) {
275
+ throw new RuntimeException(ex);
276
+ }
277
+ }
278
+
228
279
  private List<String> listFiles(Logger log, PluginTask task)
229
280
  {
230
281
  FTPClient client = newFTPClient(log, task);
@@ -267,7 +318,7 @@ public class FtpFileInputPlugin
267
318
 
268
319
  for (FTPFile file : client.list()) {
269
320
  if (file.getName().startsWith(fileNamePrefix)) {
270
- listFilesRecursive(client, currentDirectory, file, builder);
321
+ listFilesRecursive(client, currentDirectory, file, lastPath, builder);
271
322
  }
272
323
  }
273
324
 
@@ -300,7 +351,7 @@ public class FtpFileInputPlugin
300
351
  }
301
352
 
302
353
  private static void listFilesRecursive(FTPClient client,
303
- String baseDirectoryPath, FTPFile file,
354
+ String baseDirectoryPath, FTPFile file, Optional<String> lastPath,
304
355
  ImmutableList.Builder<String> builder)
305
356
  throws IOException, FTPException, FTPIllegalReplyException, FTPDataTransferException, FTPAbortedException, FTPListParseException
306
357
  {
@@ -309,6 +360,10 @@ public class FtpFileInputPlugin
309
360
  }
310
361
  String path = baseDirectoryPath + file.getName();
311
362
 
363
+ if (lastPath.isPresent() && path.compareTo(lastPath.get()) <= 0) {
364
+ return;
365
+ }
366
+
312
367
  switch (file.getType()) {
313
368
  case FTPFile.TYPE_FILE:
314
369
  builder.add(path);
@@ -316,7 +371,7 @@ public class FtpFileInputPlugin
316
371
  case FTPFile.TYPE_DIRECTORY:
317
372
  client.changeDirectory(path);
318
373
  for (FTPFile subFile : client.list()) {
319
- listFilesRecursive(client, path, subFile, builder);
374
+ listFilesRecursive(client, path, subFile, lastPath, builder);
320
375
  }
321
376
  client.changeDirectory(baseDirectoryPath);
322
377
  break;
@@ -534,7 +589,7 @@ public class FtpFileInputPlugin
534
589
  this.client = newFTPClient(log, task);
535
590
  this.executor = Executors.newCachedThreadPool(
536
591
  new ThreadFactoryBuilder()
537
- .setNameFormat("embulk-input-ftp-%d")
592
+ .setNameFormat("embulk-input-ftp-transfer-%d")
538
593
  .setDaemon(true)
539
594
  .build());
540
595
  this.path = task.getFiles().get(taskIndex);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-ftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
@@ -38,7 +38,7 @@ dependencies:
38
38
  version: '10.0'
39
39
  prerelease: false
40
40
  type: :development
41
- description: Reads files stored on Ftp.
41
+ description: Reads files stored on a FTP server.
42
42
  email:
43
43
  - frsyuki@gmail.com
44
44
  executables: []
@@ -60,7 +60,7 @@ files:
60
60
  - src/main/java/org/embulk/input/ftp/RetryExecutor.java
61
61
  - src/main/java/org/embulk/input/ftp/RetryableInputStream.java
62
62
  - src/test/java/org/embulk/input/TestFtpFileInputPlugin.java
63
- - classpath/embulk-input-ftp-0.1.0.jar
63
+ - classpath/embulk-input-ftp-0.1.1.jar
64
64
  - classpath/ftp4j-1.7.2.jar
65
65
  homepage: https://github.com/embulk/embulk-input-ftp
66
66
  licenses:
@@ -85,5 +85,5 @@ rubyforge_project:
85
85
  rubygems_version: 2.1.9
86
86
  signing_key:
87
87
  specification_version: 4
88
- summary: Ftp file input plugin for Embulk
88
+ summary: FTP file input plugin for Embulk
89
89
  test_files: []