proxy 셋팅으로 변경
This commit is contained in:
@@ -27,6 +27,7 @@ import com.jcraft.jsch.ChannelSftp;
|
||||
import com.jcraft.jsch.ChannelSftp.LsEntry;
|
||||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.ProxyHTTP;
|
||||
import com.jcraft.jsch.Session;
|
||||
import com.jcraft.jsch.SftpATTRS;
|
||||
import com.jcraft.jsch.SftpException;
|
||||
@@ -216,7 +217,8 @@ public class SFTPAdaptor {
|
||||
* @throws Exception
|
||||
*/
|
||||
protected static long retrieveJSCH(BatchDoc batchDoc, String server, int port, String username,
|
||||
String password, String remote, String remoteFileName, String localPath, int connTimeout, int setTimeout, int bandWidthLimit, Logger logger, String authType) throws Exception {
|
||||
String password, String remote, String remoteFileName, String localPath, int connTimeout, int setTimeout,
|
||||
int bandWidthLimit, Logger logger, String authType, String proxyServer) throws Exception {
|
||||
|
||||
logger.debug("[SFHT retrieve]remote-->" + remote);
|
||||
logger.debug("[SFHT retrieve]localPath-->" + localPath);
|
||||
@@ -239,6 +241,20 @@ public class SFTPAdaptor {
|
||||
if (!StringUtils.equals(authType, Transfer.AUTH_TYPE_KEY)) {
|
||||
session.setPassword(password);
|
||||
}
|
||||
|
||||
if(proxyServer != null && !proxyServer.isEmpty()) {// 20251112
|
||||
try {
|
||||
String[] parts = proxyServer.split(":");
|
||||
String proxyHost = parts[0];
|
||||
int proxyPort = (parts.length > 1) ? Integer.parseInt(parts[1]) : 8080;
|
||||
|
||||
ProxyHTTP proxy = new ProxyHTTP(proxyHost, proxyPort);
|
||||
session.setProxy(proxy);
|
||||
}catch(Exception e) {
|
||||
logger.error("Proxy set ERROR : "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
session.setConfig("StrictHostKeyChecking", "no");
|
||||
session.setConfig("max_input_buffer_size","increased_size");
|
||||
|
||||
@@ -344,7 +360,8 @@ public class SFTPAdaptor {
|
||||
* @throws Exception
|
||||
*/
|
||||
protected static boolean storeJSCH(BatchDoc batchDoc, String server, int port, String username,
|
||||
String password, String remote, String remoteFileName, String localFileName, int connTimeout, int setTimeout, int bandWidthLimit, Logger logger, String authType) throws Exception {
|
||||
String password, String remote, String remoteFileName, String localFileName, int connTimeout, int setTimeout,
|
||||
int bandWidthLimit, Logger logger, String authType, String proxyServer) throws Exception {
|
||||
|
||||
logger.debug("[SFHT storeJSCH]remote-->" + remote);
|
||||
logger.debug("[SFHT storeJSCH]remoteFileName-->" + remoteFileName);
|
||||
@@ -371,6 +388,19 @@ public class SFTPAdaptor {
|
||||
if (!StringUtils.equals(authType, Transfer.AUTH_TYPE_KEY)) {
|
||||
session.setPassword(password);
|
||||
}
|
||||
|
||||
if(proxyServer != null && !proxyServer.isEmpty()) {
|
||||
try {
|
||||
String[] parts = proxyServer.split(":");
|
||||
String proxyHost = parts[0];
|
||||
int proxyPort = (parts.length > 1) ? Integer.parseInt(parts[1]) : 8080;
|
||||
|
||||
ProxyHTTP proxy = new ProxyHTTP(proxyHost, proxyPort);
|
||||
session.setProxy(proxy);
|
||||
}catch(Exception e) {
|
||||
logger.error("Proxy set ERROR : "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
session.setConfig("StrictHostKeyChecking", "no");
|
||||
session.setConfig("max_input_buffer_size","increased_size");
|
||||
@@ -1186,7 +1216,7 @@ public class SFTPAdaptor {
|
||||
|
||||
|
||||
|
||||
protected static FTPFileObject[] listFilesJSCH(String server, int port, String username, String password, String path, Logger logger, String authType) throws IOException {
|
||||
protected static FTPFileObject[] listFilesJSCH(String server, int port, String username, String password, String path, Logger logger, String authType, String proxyServer) throws IOException {
|
||||
logger.debug("[SFHT connect]server -->" + server);
|
||||
logger.debug("[SFHT connect]port -->" + port);
|
||||
logger.debug("[SFHT connect]username-->" + username);
|
||||
@@ -1204,8 +1234,28 @@ public class SFTPAdaptor {
|
||||
|
||||
//JSch.setLogger(new SFTPLogger());
|
||||
|
||||
session = jsch.getSession(username, serverList[inx], port);
|
||||
session.setPassword(password);
|
||||
if (StringUtils.equals(authType, Transfer.AUTH_TYPE_ID)) {
|
||||
session = jsch.getSession(username, serverList[inx], port);
|
||||
session.setPassword(password);
|
||||
// key 방식 인증
|
||||
} else if (StringUtils.equals(authType, Transfer.AUTH_TYPE_KEY)) {
|
||||
jsch.addIdentity(password);
|
||||
session = jsch.getSession(username, serverList[inx], port);
|
||||
}
|
||||
|
||||
if(proxyServer != null && !proxyServer.isEmpty()) {// 20251112
|
||||
try {
|
||||
String[] parts = proxyServer.split(":");
|
||||
String proxyHost = parts[0];
|
||||
int proxyPort = (parts.length > 1) ? Integer.parseInt(parts[1]) : 8080;
|
||||
|
||||
ProxyHTTP proxy = new ProxyHTTP(proxyHost, proxyPort);
|
||||
session.setProxy(proxy);
|
||||
}catch(Exception e) {
|
||||
logger.error("Proxy set ERROR : "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
session.setConfig("StrictHostKeyChecking", "no");
|
||||
session.setConfig("PreferredAuthentications","password");
|
||||
session.setTimeout(300 * 1000);
|
||||
|
||||
Reference in New Issue
Block a user