This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 225885
Collapse All | Expand All

(-)a/php.project/src/org/netbeans/modules/php/project/connections/common/RemoteUtils.java (-4 / +18 lines)
Lines 64-69 Link Here
64
    private static final Logger LOGGER = Logger.getLogger(RemoteUtils.class.getName());
64
    private static final Logger LOGGER = Logger.getLogger(RemoteUtils.class.getName());
65
65
66
    private static final URI URI_FOR_HTTP_PROXY = URI.create("http://oracle.com"); // NOI18N
66
    private static final URI URI_FOR_HTTP_PROXY = URI.create("http://oracle.com"); // NOI18N
67
    private static final URI URI_FOR_SOCKS_PROXY = URI.create("socks://oracle.com"); // NOI18N
67
68
68
69
69
    private RemoteUtils() {
70
    private RemoteUtils() {
Lines 184-204 Link Here
184
    }
185
    }
185
186
186
    @CheckForNull
187
    @CheckForNull
187
    public static HttpProxyInfo getHttpProxy() {
188
    public static ProxyInfo getHttpProxy() {
188
        String proxyHost = NetworkSettings.getProxyHost(URI_FOR_HTTP_PROXY);
189
        String proxyHost = NetworkSettings.getProxyHost(URI_FOR_HTTP_PROXY);
189
        if (proxyHost == null) {
190
        if (proxyHost == null) {
190
            // no proxy
191
            // no proxy
191
            return null;
192
            return null;
192
        }
193
        }
193
        return new HttpProxyInfo(proxyHost,
194
        return new ProxyInfo(proxyHost,
194
                Integer.parseInt(NetworkSettings.getProxyPort(URI_FOR_HTTP_PROXY)),
195
                Integer.parseInt(NetworkSettings.getProxyPort(URI_FOR_HTTP_PROXY)),
195
                NetworkSettings.getAuthenticationUsername(URI_FOR_HTTP_PROXY),
196
                NetworkSettings.getAuthenticationUsername(URI_FOR_HTTP_PROXY),
196
                NetworkSettings.getKeyForAuthenticationPassword(URI_FOR_HTTP_PROXY));
197
                NetworkSettings.getKeyForAuthenticationPassword(URI_FOR_HTTP_PROXY));
197
    }
198
    }
198
199
200
    @CheckForNull
201
    public static ProxyInfo getSocksProxy() {
202
        String proxyHost = NetworkSettings.getProxyHost(URI_FOR_SOCKS_PROXY);
203
        if (proxyHost == null) {
204
            // no proxy
205
            return null;
206
        }
207
        return new ProxyInfo(proxyHost,
208
                Integer.parseInt(NetworkSettings.getProxyPort(URI_FOR_SOCKS_PROXY)),
209
                NetworkSettings.getAuthenticationUsername(URI_FOR_SOCKS_PROXY),
210
                NetworkSettings.getKeyForAuthenticationPassword(URI_FOR_SOCKS_PROXY));
211
    }
212
199
    //~ Inner classes
213
    //~ Inner classes
200
214
201
    public static final class HttpProxyInfo {
215
    public static final class ProxyInfo {
202
216
203
        private final String host;
217
        private final String host;
204
        private final int port;
218
        private final int port;
Lines 206-212 Link Here
206
        private final String passwordKey;
220
        private final String passwordKey;
207
221
208
222
209
        public HttpProxyInfo(String host, int port, String username, String passwordKey) {
223
        public ProxyInfo(String host, int port, String username, String passwordKey) {
210
            this.host = host;
224
            this.host = host;
211
            this.port = port;
225
            this.port = port;
212
            this.username = username;
226
            this.username = username;
(-)a/php.project/src/org/netbeans/modules/php/project/connections/ftp/FtpClient.java (-2 / +2 lines)
Lines 68-74 Link Here
68
import org.netbeans.modules.php.project.connections.RemoteException;
68
import org.netbeans.modules.php.project.connections.RemoteException;
69
import org.netbeans.modules.php.project.connections.common.PasswordPanel;
69
import org.netbeans.modules.php.project.connections.common.PasswordPanel;
70
import org.netbeans.modules.php.project.connections.common.RemoteUtils;
70
import org.netbeans.modules.php.project.connections.common.RemoteUtils;
71
import org.netbeans.modules.php.project.connections.common.RemoteUtils.HttpProxyInfo;
71
import org.netbeans.modules.php.project.connections.common.RemoteUtils.ProxyInfo;
72
import org.netbeans.modules.php.project.connections.ftp.FtpConfiguration.Encryption;
72
import org.netbeans.modules.php.project.connections.ftp.FtpConfiguration.Encryption;
73
import org.netbeans.modules.php.project.connections.spi.RemoteClient;
73
import org.netbeans.modules.php.project.connections.spi.RemoteClient;
74
import org.netbeans.modules.php.project.connections.spi.RemoteFile;
74
import org.netbeans.modules.php.project.connections.spi.RemoteFile;
Lines 136-142 Link Here
136
        FtpConfiguration.Security security = configuration.getSecurity();
136
        FtpConfiguration.Security security = configuration.getSecurity();
137
        if (!security.isPresent()) {
137
        if (!security.isPresent()) {
138
            LOGGER.log(Level.FINE, "No encryption used");
138
            LOGGER.log(Level.FINE, "No encryption used");
139
            HttpProxyInfo proxyInfo = RemoteUtils.getHttpProxy();
139
            ProxyInfo proxyInfo = RemoteUtils.getHttpProxy();
140
            if (proxyInfo != null) {
140
            if (proxyInfo != null) {
141
                LOGGER.log(Level.FINE, "HTTP proxy will be used");
141
                LOGGER.log(Level.FINE, "HTTP proxy will be used");
142
                return new FTPHTTPClient(proxyInfo.getHost(), proxyInfo.getPort(), proxyInfo.getUsername(), proxyInfo.getPassword());
142
                return new FTPHTTPClient(proxyInfo.getHost(), proxyInfo.getPort(), proxyInfo.getUsername(), proxyInfo.getPassword());
(-)a/php.project/src/org/netbeans/modules/php/project/connections/sftp/SftpClient.java (+32 lines)
Lines 46-51 Link Here
46
import com.jcraft.jsch.ChannelSftp;
46
import com.jcraft.jsch.ChannelSftp;
47
import com.jcraft.jsch.JSch;
47
import com.jcraft.jsch.JSch;
48
import com.jcraft.jsch.JSchException;
48
import com.jcraft.jsch.JSchException;
49
import com.jcraft.jsch.Proxy;
50
import com.jcraft.jsch.ProxyHTTP;
51
import com.jcraft.jsch.ProxySOCKS5;
49
import com.jcraft.jsch.Session;
52
import com.jcraft.jsch.Session;
50
import com.jcraft.jsch.SftpATTRS;
53
import com.jcraft.jsch.SftpATTRS;
51
import com.jcraft.jsch.SftpException;
54
import com.jcraft.jsch.SftpException;
Lines 151-156 Link Here
151
            if (StringUtils.hasText(password)) {
154
            if (StringUtils.hasText(password)) {
152
                sftpSession.setPassword(password);
155
                sftpSession.setPassword(password);
153
            }
156
            }
157
            // proxy
158
            setProxy();
154
            sftpSession.setUserInfo(new SftpUserInfo(configuration));
159
            sftpSession.setUserInfo(new SftpUserInfo(configuration));
155
            sftpSession.setTimeout(timeout);
160
            sftpSession.setTimeout(timeout);
156
            // keep-alive
161
            // keep-alive
Lines 175-180 Link Here
175
180
176
    }
181
    }
177
182
183
    private void setProxy() {
184
        Proxy proxy = null;
185
        RemoteUtils.ProxyInfo proxyInfo = RemoteUtils.getHttpProxy();
186
        proxyInfo = RemoteUtils.getSocksProxy();
187
        if (proxyInfo != null) {
188
            LOGGER.log(Level.FINE, "HTTP proxy will be used");
189
            ProxyHTTP httpProxy = new ProxyHTTP(proxyInfo.getHost(), proxyInfo.getPort());
190
            if (StringUtils.hasText(proxyInfo.getUsername())) {
191
                httpProxy.setUserPasswd(proxyInfo.getUsername(), proxyInfo.getPassword());
192
            }
193
            proxy = httpProxy;
194
        } else {
195
            proxyInfo = RemoteUtils.getSocksProxy();
196
            if (proxyInfo != null) {
197
                LOGGER.log(Level.FINE, "SOCKS proxy will be used");
198
                ProxySOCKS5 socksProxy = new ProxySOCKS5(proxyInfo.getHost(), proxyInfo.getPort());
199
                if (StringUtils.hasText(proxyInfo.getUsername())) {
200
                    socksProxy.setUserPasswd(proxyInfo.getUsername(), proxyInfo.getPassword());
201
                }
202
                proxy = socksProxy;
203
            }
204
        }
205
        if (proxy != null) {
206
            sftpSession.setProxy(proxy);
207
        }
208
    }
209
178
    @Override
210
    @Override
179
    public void connect() throws RemoteException {
211
    public void connect() throws RemoteException {
180
        init();
212
        init();

Return to bug 225885