@Override protected void sslNegotiation() throws IOException { if(protocol.isSecure()) { final SSLSocket socket = (SSLSocket) sslSocketFactory.createSocket(_socket_, _socket_.getInetAddress().getHostAddress(), _socket_.getPort(), false); socket.setEnableSessionCreation(true); socket.setUseClientMode(true); socket.startHandshake(); _socket_ = socket; _controlInput_ = new BufferedReader(new InputStreamReader( socket.getInputStream(), getControlEncoding())); _controlOutput_ = new BufferedWriter(new OutputStreamWriter( socket.getOutputStream(), getControlEncoding())); } }
@Override public void interrupt() throws BackgroundException { if(host.getProtocol().isSecure()) { // The client and the server must share knowledge that the connection is ending in order to avoid a truncation attack. // Either party may initiate the exchange of closing messages. log.warn(String.format("Skip disconnect for %s connection to workaround hang in closing socket", host.getProtocol())); super.disconnect(); } else { super.interrupt(); } }
@Override public void execPBSZ(final long pbsz) throws IOException { if(protocol.isSecure()) { if(FTPReply.COMMAND_OK != this.sendCommand("PBSZ", String.valueOf(pbsz))) { throw new FTPException(this.getReplyCode(), this.getReplyString()); } } }
@Override public void execPROT(final String prot) throws IOException { if(protocol.isSecure()) { if(FTPReply.COMMAND_OK != this.sendCommand("PROT", prot)) { throw new FTPException(this.getReplyCode(), this.getReplyString()); } if("P".equals(prot)) { // Private this.setSocketFactory(sslSocketFactory); } } }
/** * Configure the HTTP Session to proxy through UDT */ public HttpSession<?> configure(final HttpSession<?> session) throws BackgroundException { // Add X-Qloudsonic-* headers final List<Header> headers = provider.headers(); if(log.isInfoEnabled()) { log.info(String.format("Obtained headers %s fro provider %s", headers, provider)); } // Run through secured proxy only if direct connection has transport security final Host proxy = provider.find(location, session.getHost().getProtocol().isSecure()); final HttpConnectionPoolBuilder builder = new UDTHttpConnectionPoolBuilder(session.getHost(), proxy, headers, trust, key, callback); // Inject connection builder into session session.setBuilder(builder); return session; }
@Override protected void execAUTH() throws IOException { if(protocol.isSecure()) { if(FTPReply.SECURITY_DATA_EXCHANGE_COMPLETE != this.sendCommand("AUTH", this.getAuthValue())) { throw new FTPException(this.getReplyCode(), this.getReplyString()); } } }
public boolean alert(final ConnectionCallback callback) throws BackgroundException { if(host.getProtocol().isSecure()) { return false; } if(host.getCredentials().isAnonymousLogin()) { return false; } final Preferences preferences = PreferencesFactory.get(); if(preferences.getBoolean(String.format("connection.unsecure.%s", host.getHostname()))) { return false; } return preferences.getBoolean( String.format("connection.unsecure.warning.%s", host.getProtocol().getScheme())); }
try { if(client.login(host.getCredentials().getUsername(), host.getCredentials().getPassword())) { if(host.getProtocol().isSecure()) { client.execPBSZ(0);
@Override public Registry<ConnectionSocketFactory> createRegistry() { final RegistryBuilder<ConnectionSocketFactory> registry = RegistryBuilder.create(); if(proxy.getProtocol().isSecure()) { registry.register(proxy.getProtocol().getScheme().toString(), new SSLConnectionSocketFactory( new CustomTrustSSLProtocolSocketFactory(trust, key),