proxy 셋팅으로 변경
This commit is contained in:
@@ -20,31 +20,31 @@ public class FTPUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
// 20241008 sftp jsch 방식 list
|
// 20241008 sftp jsch 방식 list
|
||||||
public static FTPFileObject[] listFilesJSCH(String server, int port, String username, String password, String path, boolean isSftp, Logger logger, String authType)
|
public static FTPFileObject[] listFilesJSCH(String server, int port, String username, String password, String path, boolean isSftp, Logger logger, String authType, String proxyServer)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if ( isSftp ){
|
if ( isSftp ){
|
||||||
return SFTPAdaptor.listFilesJSCH(server, port, username, password, path, logger, authType);
|
return SFTPAdaptor.listFilesJSCH(server, port, username, password, path, logger, authType, proxyServer);
|
||||||
}else{
|
}else{
|
||||||
return FTPAdaptor.listFiles2(server, port, username, password, path, logger);
|
return FTPAdaptor.listFiles2(server, port, username, password, path, logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long retrieve(BatchDoc batchDoc, String server, int port, String username, String password, String remote, String remoteFileName, String localPath,
|
// public static long retrieve(BatchDoc batchDoc, String server, int port, String username, String password, String remote, String remoteFileName, String localPath,
|
||||||
int connTimeout, int setTimeout, boolean isSftp, int bandWidth, Logger logger, String authType) throws Exception {
|
// int connTimeout, int setTimeout, boolean isSftp, int bandWidth, Logger logger, String authType) throws Exception {
|
||||||
|
//
|
||||||
if ( isSftp ){
|
// if ( isSftp ){
|
||||||
return SFTPAdaptor.retrieveJSCH(batchDoc, server, port, username, password, remote, remoteFileName, localPath, connTimeout, setTimeout, bandWidth, logger, authType);
|
// return SFTPAdaptor.retrieveJSCH(batchDoc, server, port, username, password, remote, remoteFileName, localPath, connTimeout, setTimeout, bandWidth, logger, authType);
|
||||||
}else{
|
// }else{
|
||||||
return FTPAdaptor.retrieve(batchDoc,server, port, username, password, remote+remoteFileName, localPath, bandWidth, logger, "");
|
// return FTPAdaptor.retrieve(batchDoc,server, port, username, password, remote+remoteFileName, localPath, bandWidth, logger, "");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static long retrieve(BatchDoc batchDoc, String server, int port, String username, String password, String remote, String remoteFileName, String localPath,
|
public static long retrieve(BatchDoc batchDoc, String server, int port, String username, String password, String remote, String remoteFileName, String localPath,
|
||||||
int connTimeout, int setTimeout, int bandWidth, Logger logger, String authType, String fileType) throws Exception {
|
int connTimeout, int setTimeout, int bandWidth, Logger logger, String authType, String fileType, String proxyServer) throws Exception {
|
||||||
if ( "0".equals(authType)) {
|
if ( "0".equals(authType)) {
|
||||||
return FTPAdaptor.retrieve(batchDoc,server, port, username, password, remote+remoteFileName, localPath, bandWidth, logger, fileType);
|
return FTPAdaptor.retrieve(batchDoc,server, port, username, password, remote+remoteFileName, localPath, bandWidth, logger, fileType);
|
||||||
}else {
|
}else {
|
||||||
return SFTPAdaptor.retrieveJSCH(batchDoc, server, port, username, password, remote, remoteFileName, localPath, connTimeout, setTimeout, bandWidth, logger, authType);
|
return SFTPAdaptor.retrieveJSCH(batchDoc, server, port, username, password, remote, remoteFileName, localPath, connTimeout, setTimeout, bandWidth, logger, authType, proxyServer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,10 +58,10 @@ public class FTPUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean store(BatchDoc batchDoc, String server, int port, String username, String password, String remote, String remoteFileName, String localPath,
|
public static boolean store(BatchDoc batchDoc, String server, int port, String username, String password, String remote, String remoteFileName, String localPath,
|
||||||
int connTimeout, int setTimeout, boolean isSftp, int bandWidth, Logger logger, String authType) throws Exception {
|
int connTimeout, int setTimeout, boolean isSftp, int bandWidth, Logger logger, String authType, String proxyServer) throws Exception {
|
||||||
|
|
||||||
if ( isSftp ){
|
if ( isSftp ){
|
||||||
return SFTPAdaptor.storeJSCH(batchDoc, server, port, username, password, remote, remoteFileName, localPath, connTimeout, setTimeout, bandWidth, logger, authType);
|
return SFTPAdaptor.storeJSCH(batchDoc, server, port, username, password, remote, remoteFileName, localPath, connTimeout, setTimeout, bandWidth, logger, authType, proxyServer);
|
||||||
}else{
|
}else{
|
||||||
return FTPAdaptor.store(batchDoc,server, port, username, password, remote+remoteFileName, localPath, bandWidth, logger);
|
return FTPAdaptor.store(batchDoc,server, port, username, password, remote+remoteFileName, localPath, bandWidth, logger);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import com.jcraft.jsch.ChannelSftp;
|
|||||||
import com.jcraft.jsch.ChannelSftp.LsEntry;
|
import com.jcraft.jsch.ChannelSftp.LsEntry;
|
||||||
import com.jcraft.jsch.JSch;
|
import com.jcraft.jsch.JSch;
|
||||||
import com.jcraft.jsch.JSchException;
|
import com.jcraft.jsch.JSchException;
|
||||||
|
import com.jcraft.jsch.ProxyHTTP;
|
||||||
import com.jcraft.jsch.Session;
|
import com.jcraft.jsch.Session;
|
||||||
import com.jcraft.jsch.SftpATTRS;
|
import com.jcraft.jsch.SftpATTRS;
|
||||||
import com.jcraft.jsch.SftpException;
|
import com.jcraft.jsch.SftpException;
|
||||||
@@ -216,7 +217,8 @@ public class SFTPAdaptor {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected static long retrieveJSCH(BatchDoc batchDoc, String server, int port, String username,
|
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]remote-->" + remote);
|
||||||
logger.debug("[SFHT retrieve]localPath-->" + localPath);
|
logger.debug("[SFHT retrieve]localPath-->" + localPath);
|
||||||
@@ -239,6 +241,20 @@ public class SFTPAdaptor {
|
|||||||
if (!StringUtils.equals(authType, Transfer.AUTH_TYPE_KEY)) {
|
if (!StringUtils.equals(authType, Transfer.AUTH_TYPE_KEY)) {
|
||||||
session.setPassword(password);
|
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("StrictHostKeyChecking", "no");
|
||||||
session.setConfig("max_input_buffer_size","increased_size");
|
session.setConfig("max_input_buffer_size","increased_size");
|
||||||
|
|
||||||
@@ -344,7 +360,8 @@ public class SFTPAdaptor {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected static boolean storeJSCH(BatchDoc batchDoc, String server, int port, String username,
|
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]remote-->" + remote);
|
||||||
logger.debug("[SFHT storeJSCH]remoteFileName-->" + remoteFileName);
|
logger.debug("[SFHT storeJSCH]remoteFileName-->" + remoteFileName);
|
||||||
@@ -371,6 +388,19 @@ public class SFTPAdaptor {
|
|||||||
if (!StringUtils.equals(authType, Transfer.AUTH_TYPE_KEY)) {
|
if (!StringUtils.equals(authType, Transfer.AUTH_TYPE_KEY)) {
|
||||||
session.setPassword(password);
|
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("StrictHostKeyChecking", "no");
|
||||||
session.setConfig("max_input_buffer_size","increased_size");
|
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]server -->" + server);
|
||||||
logger.debug("[SFHT connect]port -->" + port);
|
logger.debug("[SFHT connect]port -->" + port);
|
||||||
logger.debug("[SFHT connect]username-->" + username);
|
logger.debug("[SFHT connect]username-->" + username);
|
||||||
@@ -1204,8 +1234,28 @@ public class SFTPAdaptor {
|
|||||||
|
|
||||||
//JSch.setLogger(new SFTPLogger());
|
//JSch.setLogger(new SFTPLogger());
|
||||||
|
|
||||||
session = jsch.getSession(username, serverList[inx], port);
|
if (StringUtils.equals(authType, Transfer.AUTH_TYPE_ID)) {
|
||||||
session.setPassword(password);
|
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("StrictHostKeyChecking", "no");
|
||||||
session.setConfig("PreferredAuthentications","password");
|
session.setConfig("PreferredAuthentications","password");
|
||||||
session.setTimeout(300 * 1000);
|
session.setTimeout(300 * 1000);
|
||||||
|
|||||||
Reference in New Issue
Block a user