}
private Session createSession(ScpConfiguration config) {
ObjectHelper.notNull(config, "ScpConfiguration");
try {
final JSch jsch = new JSch();
// get from configuration
if (ObjectHelper.isNotEmpty(config.getCiphers())) {
LOG.debug("Using ciphers: {}", config.getCiphers());
Hashtable<String, String> ciphers = new Hashtable<String, String>();
ciphers.put("cipher.s2c", config.getCiphers());
ciphers.put("cipher.c2s", config.getCiphers());
JSch.setConfig(ciphers);
}
if (ObjectHelper.isNotEmpty(config.getPrivateKeyFile())) {
LOG.debug("Using private keyfile: {}", config.getPrivateKeyFile());
String pkfp = config.getPrivateKeyFilePassphrase();
jsch.addIdentity(config.getPrivateKeyFile(), ObjectHelper.isNotEmpty(pkfp) ? pkfp : null);
}
String knownHostsFile = config.getKnownHostsFile();
jsch.setKnownHosts(ObjectHelper.isEmpty(knownHostsFile) ? DEFAULT_KNOWN_HOSTS : knownHostsFile);
session = jsch.getSession(config.getUsername(), config.getHost(), config.getPort());
session.setTimeout(config.getTimeout());
session.setUserInfo(new SessionUserInfo(config));
if (ObjectHelper.isNotEmpty(config.getStrictHostKeyChecking())) {
LOG.debug("Using StrickHostKeyChecking: {}", config.getStrictHostKeyChecking());