Project

General

Profile

1
package eu.dnetlib.data.collector.plugins.sftp;
2

    
3
import java.util.Set;
4

    
5
import eu.dnetlib.rmi.data.CollectorServiceException;
6
import eu.dnetlib.rmi.data.InterfaceDescriptor;
7
import org.apache.commons.lang3.StringUtils;
8
import org.apache.commons.logging.Log;
9
import org.apache.commons.logging.LogFactory;
10
import org.springframework.beans.factory.annotation.Value;
11

    
12
/**
13
 * Created by alessia on 15/03/17.
14
 */
15
public class SftpPubKeyCollectorPlugin extends AbstractSftpCollectorPlugin {
16

    
17
	private static final Log log = LogFactory.getLog(SftpPubKeyCollectorPlugin.class);
18
	@Value("${collector.sftp.auth.prvKeyPath}")
19
	private String prvKeyFilePath;
20
	@Value("${collector.sftp.auth.passphrase}")
21
	private String passphrase;
22
	@Value("${collector.sftp.auth.knownHostsPath}")
23
	private String knownHostsFile;
24

    
25
	@Override
26
	protected Iterable<String> getIterable(final InterfaceDescriptor interfaceDescriptor,
27
			final String baseUrl,
28
			final boolean isRecursive,
29
			final Set<String> extensionSet,
30
			final String fromDate) throws CollectorServiceException {
31

    
32
		String username = interfaceDescriptor.getParams().get("username");
33
		if(StringUtils.isBlank(username)) {
34
			log.warn("Param 'username' is null or empty");
35
		}
36
		return () -> getSftpIteratorFactory().newIteratorPubKeyAuth(baseUrl, username, prvKeyFilePath, passphrase, knownHostsFile, isRecursive, extensionSet, fromDate);
37
	}
38

    
39
}
(5-5/5)