private static Socket _createSSLSocket(KeyManager[] keyManagers, TrustManager trustManager, String host, int port, int connectTimeout, int readTimeout, ISVNCanceller cancel, boolean withSNIsupport) throws IOException, SVNException { InetAddress address = createAddres(host); Socket sslSocket = createSSLContext(keyManagers, trustManager).getSocketFactory().createSocket(); int bufferSize = getSocketReceiveBufferSize(); if (bufferSize > 0) { sslSocket.setReceiveBufferSize(bufferSize); } if (withSNIsupport) { sslSocket = setSSLSocketHost(sslSocket, host); } InetSocketAddress socketAddress = new InetSocketAddress(address, port); sslSocket.setReuseAddress(true); sslSocket.setTcpNoDelay(true); sslSocket.setKeepAlive(true); sslSocket.setSoLinger(true, 0); sslSocket.setSoTimeout(readTimeout); sslSocket = configureSSLSocket(sslSocket); connect(sslSocket, socketAddress, connectTimeout, cancel); return sslSocket; }
public static boolean isSocketStale(Socket socket) throws IOException { if (!isSocketStaleCheckEnabled()) { return socket == null || socket.isClosed() || !socket.isConnected();
public static SSLContext createSSLContext(KeyManager[] keyManagers, TrustManager trustManager) throws IOException { final TrustManager[] trustManagers = new TrustManager[] {trustManager != null ? trustManager : getEmptyTrustManager()}; keyManagers = keyManagers != null ? keyManagers : EMPTY_KEY_MANAGERS; try { return createSSLContext(keyManagers, trustManagers, getEnabledSSLProtocols(true)); } catch (NoSuchAlgorithmException e) { try { return createSSLContext(keyManagers, trustManagers, getEnabledSSLProtocols(false)); } catch (NoSuchAlgorithmException e1) { throw new IOException(e1.getMessage()); } } }
public static Socket createSSLSocket(KeyManager[] keyManagers, TrustManager trustManager, String host, int port, Socket socket, int readTimeout) throws IOException { Socket sslSocket = createSSLContext(keyManagers, trustManager).getSocketFactory().createSocket(socket, host, port, true); sslSocket = setSSLSocketHost(sslSocket, host); sslSocket.setReuseAddress(true); sslSocket.setTcpNoDelay(true); sslSocket.setKeepAlive(true); sslSocket.setSoLinger(true, 0); sslSocket.setSoTimeout(readTimeout); sslSocket = configureSSLSocket(sslSocket); return sslSocket; }
public static Socket createPlainSocket(String host, int port, int connectTimeout, int readTimeout, ISVNCanceller cancel) throws IOException, SVNCancelException { InetAddress address = createAddres(host); Socket socket = new Socket(); InetSocketAddress socketAddress = new InetSocketAddress(address, port); connect(socket, socketAddress, connectTimeout, cancel); socket.setReuseAddress(true); socket.setTcpNoDelay(true); socket.setKeepAlive(true); socket.setSoLinger(true, 0); socket.setSoTimeout(readTimeout); return socket; }
private void connect(ISVNSSLManager sslManager) throws IOException, SVNException { SVNURL location = myRepository.getLocation(); if (mySocket == null || SVNSocketFactory.isSocketStale(mySocket)) { close(); String host = location.getHost(); ISVNProxyManager proxyAuth = authManager != null ? authManager.getProxyManager(location) : null; if (proxyAuth != null && proxyAuth.getProxyHost() != null) { mySocket = SVNSocketFactory.createPlainSocket(proxyAuth.getProxyHost(), proxyAuth.getProxyPort()); if (myProxyAuthentication == null) { myProxyAuthentication = new HTTPBasicAuthentication(proxyAuth.getProxyUserName(), proxyAuth.getProxyPassword()); myInputStream = null; myOutputStream = null; mySocket = SVNSocketFactory.createSSLSocket(sslManager, host, port, mySocket); proxyAuth.acknowledgeProxyContext(true, null); return; myIsProxied = false; myProxyAuthentication = null; mySocket = myIsSecured ? SVNSocketFactory.createSSLSocket(sslManager, host, port) : SVNSocketFactory.createPlainSocket(host, port);
public static Socket createSSLSocket(KeyManager[] keyManagers, TrustManager trustManager, String host, int port, int connectTimeout, int readTimeout, ISVNCanceller cancel) throws IOException, SVNCancelException { InetAddress address = createAddres(host); Socket sslSocket = createSSLContext(keyManagers, trustManager).getSocketFactory().createSocket(); int bufferSize = getSocketReceiveBufferSize(); if (bufferSize > 0) { sslSocket.setReceiveBufferSize(bufferSize); } InetSocketAddress socketAddress = new InetSocketAddress(address, port); connect(sslSocket, socketAddress, connectTimeout, cancel); sslSocket.setReuseAddress(true); sslSocket.setTcpNoDelay(true); sslSocket.setKeepAlive(true); sslSocket.setSoLinger(true, 0); sslSocket.setSoTimeout(readTimeout); ((SSLSocket) sslSocket).setEnabledProtocols(new String[] {"SSLv3"}); return sslSocket; }
public static Socket createSSLSocket(KeyManager[] keyManagers, TrustManager trustManager, String host, int port, int connectTimeout, int readTimeout, ISVNCanceller cancel) throws IOException, SVNCancelException { InetAddress address = createAddres(host); Socket sslSocket = createSSLContext(keyManagers, trustManager).getSocketFactory().createSocket(); InetSocketAddress socketAddress = new InetSocketAddress(address, port); connect(sslSocket, socketAddress, connectTimeout, cancel); sslSocket.setReuseAddress(true); sslSocket.setTcpNoDelay(true); sslSocket.setKeepAlive(true); sslSocket.setSoLinger(true, 0); sslSocket.setSoTimeout(readTimeout); ((SSLSocket) sslSocket).setEnabledProtocols(new String[] {"SSLv3"}); return sslSocket; }
public static Socket createPlainSocket(String host, int port, int connectTimeout, int readTimeout, ISVNCanceller cancel) throws IOException, SVNException { InetAddress address = createAddres(host); Socket socket = new Socket(); int bufferSize = getSocketReceiveBufferSize(); if (bufferSize > 0) { socket.setReceiveBufferSize(bufferSize); } InetSocketAddress socketAddress = new InetSocketAddress(address, port); connect(socket, socketAddress, connectTimeout, cancel); socket.setReuseAddress(true); socket.setTcpNoDelay(true); socket.setKeepAlive(true); socket.setSoLinger(true, 0); socket.setSoTimeout(readTimeout); return socket; }
public void open(SVNRepositoryImpl repository) throws SVNException { if (mySocket != null) { return; } SVNURL location = repository.getLocation(); try { mySocket = SVNSocketFactory.createPlainSocket(location.getHost(), location.getPort()); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, e.getLocalizedMessage()); SVNErrorManager.error(err, e); } }
public boolean isStale() { try { SVNDebugLog.getDefaultLog().logFine(SVNLogType.NETWORK, "checking whether connection is stale."); boolean result = mySocket != null && SVNSocketFactory.isSocketStale(mySocket); SVNDebugLog.getDefaultLog().logFine(SVNLogType.NETWORK, "connection is stale: " + result); return result; } catch (IOException e) { SVNDebugLog.getDefaultLog().logFine(SVNLogType.NETWORK, "failure during stale check"); SVNDebugLog.getDefaultLog().logFine(SVNLogType.NETWORK, e); return true; } }
public static Socket createPlainSocket(String host, int port) throws IOException { InetAddress address = createAddres(host); Socket socket = new Socket(address, port); socket.setReuseAddress(true); socket.setTcpNoDelay(true); socket.setKeepAlive(true); return socket; }
public static Socket createSSLSocket(KeyManager[] keyManagers, TrustManager trustManager, String host, int port, Socket socket, int readTimeout) throws IOException { Socket sslSocket = createSSLContext(keyManagers, trustManager).getSocketFactory().createSocket(socket, host, port, true); sslSocket.setReuseAddress(true); sslSocket.setTcpNoDelay(true); sslSocket.setKeepAlive(true); sslSocket.setSoLinger(true, 0); sslSocket.setSoTimeout(readTimeout); ((SSLSocket) sslSocket).setEnabledProtocols(new String[] {"SSLv3"}); return sslSocket; }
private void connect(HTTPSSLKeyManager keyManager, TrustManager trustManager) throws IOException, SVNException { SVNURL location = myRepository.getLocation(); if (mySocket == null || SVNSocketFactory.isSocketStale(mySocket)) { close(); String host = location.getHost(); mySocket = SVNSocketFactory.createPlainSocket(proxyAuth.getProxyHost(), proxyAuth.getProxyPort(), connectTimeout, readTimeout, myRepository.getCanceller()); if (myProxyAuthentication == null) { myProxyAuthentication = new HTTPBasicAuthentication(proxyAuth.getProxyUserName(), proxyAuth.getProxyPassword(), myCharset); myInputStream = null; myOutputStream = null; mySocket = SVNSocketFactory.createSSLSocket(keyManager != null ? new KeyManager[] { keyManager } : new KeyManager[0], trustManager, host, port, mySocket, readTimeout); proxyAuth.acknowledgeProxyContext(true, null); return; myProxyAuthentication = null; mySocket = myIsSecured ? SVNSocketFactory.createSSLSocket(keyManager != null ? new KeyManager[] { keyManager } : new KeyManager[0], trustManager, host, port, connectTimeout, readTimeout, myRepository.getCanceller()) : SVNSocketFactory.createPlainSocket(host, port, connectTimeout, readTimeout, myRepository.getCanceller());
public static Socket createPlainSocket(String host, int port, int connectTimeout, int readTimeout, ISVNCanceller cancel) throws IOException, SVNCancelException { InetAddress address = createAddres(host); Socket socket = new Socket(); int bufferSize = getSocketReceiveBufferSize(); if (bufferSize > 0) { socket.setReceiveBufferSize(bufferSize); } InetSocketAddress socketAddress = new InetSocketAddress(address, port); connect(socket, socketAddress, connectTimeout, cancel); socket.setReuseAddress(true); socket.setTcpNoDelay(true); socket.setKeepAlive(true); socket.setSoLinger(true, 0); socket.setSoTimeout(readTimeout); return socket; }
public void open(SVNRepositoryImpl repository) throws SVNException { if (mySocket != null) { return; } SVNURL location = repository.getLocation(); try { int connectTimeout = repository.getAuthenticationManager() != null ? repository.getAuthenticationManager().getConnectTimeout(repository) : DEFAULT_SVN_TIMEOUT; int readTimeout = repository.getAuthenticationManager() != null ? repository.getAuthenticationManager().getReadTimeout(repository) : DEFAULT_SVN_TIMEOUT; mySocket = SVNSocketFactory.createPlainSocket(location.getHost(), location.getPort(), connectTimeout, readTimeout, repository.getCanceller()); } catch (SocketTimeoutException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, "timed out waiting for server", null, SVNErrorMessage.TYPE_ERROR, e); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } catch (UnknownHostException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, "Unknown host " + e.getMessage(), null, SVNErrorMessage.TYPE_ERROR, e); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } catch (ConnectException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, "connection refused by the server", null, SVNErrorMessage.TYPE_ERROR, e); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, e.getLocalizedMessage()); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } }
public boolean isStale() { try { SVNDebugLog.getDefaultLog().logFine(SVNLogType.NETWORK, "checking whether connection is stale."); boolean result = mySocket != null && SVNSocketFactory.isSocketStale(mySocket); SVNDebugLog.getDefaultLog().logFine(SVNLogType.NETWORK, "connection is stale: " + result); return result; } catch (IOException e) { SVNDebugLog.getDefaultLog().logFine(SVNLogType.NETWORK, "failure during stale check"); SVNDebugLog.getDefaultLog().logFine(SVNLogType.NETWORK, e); return true; } }
public static Socket createSSLSocket(ISVNSSLManager manager, String host, int port) throws IOException { manager = manager == null ? DEFAULT_SSL_MANAGER : manager; Socket sslSocket = manager.getSSLContext().getSocketFactory().createSocket(createAddres(host), port); sslSocket.setReuseAddress(true); sslSocket.setTcpNoDelay(true); sslSocket.setKeepAlive(true); return sslSocket; }
public static Socket createSSLSocket(KeyManager[] keyManagers, TrustManager trustManager, String host, int port, Socket socket, int readTimeout) throws IOException { Socket sslSocket = createSSLContext(keyManagers, trustManager).getSocketFactory().createSocket(socket, host, port, true); sslSocket.setReuseAddress(true); sslSocket.setTcpNoDelay(true); sslSocket.setKeepAlive(true); sslSocket.setSoLinger(true, 0); sslSocket.setSoTimeout(readTimeout); ((SSLSocket) sslSocket).setEnabledProtocols(new String[] {"SSLv3"}); return sslSocket; }
private void connect(HTTPSSLKeyManager keyManager, TrustManager trustManager) throws IOException, SVNException { SVNURL location = myRepository.getLocation(); if (mySocket == null || SVNSocketFactory.isSocketStale(mySocket)) { close(); String host = location.getHost(); mySocket = SVNSocketFactory.createPlainSocket(proxyAuth.getProxyHost(), proxyAuth.getProxyPort(), connectTimeout, readTimeout, myRepository.getCanceller()); if (myProxyAuthentication == null) { myProxyAuthentication = new HTTPBasicAuthentication(proxyAuth.getProxyUserName(), proxyAuth.getProxyPassword(), myCharset); myInputStream = null; myOutputStream = null; mySocket = SVNSocketFactory.createSSLSocket(keyManager != null ? new KeyManager[] { keyManager } : new KeyManager[0], trustManager, host, port, mySocket, readTimeout); proxyAuth.acknowledgeProxyContext(true, null); return; myProxyAuthentication = null; mySocket = myIsSecured ? SVNSocketFactory.createSSLSocket(keyManager != null ? new KeyManager[] { keyManager } : new KeyManager[0], trustManager, host, port, connectTimeout, readTimeout, myRepository.getCanceller()) : SVNSocketFactory.createPlainSocket(host, port, connectTimeout, readTimeout, myRepository.getCanceller());