/** * Closes the connection to the FTP server and restores * connection parameters to the default values. * <p> * Calls {@code setSocketFactory(null)} and {@code setServerSocketFactory(null)} * to reset the factories that may have been changed during the session, * e.g. by {@link #execPROT(String)} * @throws IOException If an error occurs while disconnecting. * @since 3.0 */ @Override public void disconnect() throws IOException { super.disconnect(); if (plainSocket != null) { plainSocket.close(); } setSocketFactory(null); setServerSocketFactory(null); }
setServerSocketFactory(null); } else { setSocketFactory(new FTPSSocketFactory(context)); setServerSocketFactory(new FTPSServerSocketFactory(context)); initSslContext();
@Override public void setServerSocketFactory(ServerSocketFactory factory) { if (factory == null){ factory = ServerSocketFactory.getDefault(); } if(myServerSocketFactoryWrapper != null){ factory = myServerSocketFactoryWrapper.wrap(factory); } super.setServerSocketFactory(factory); } // Ability to encrypt data channel + PROT changes socket factory +++++++++++++
/** * PROT command.</br> * C - Clear</br> * S - Safe(SSL protocol only)</br> * E - Confidential(SSL protocol only)</br> * P - Private * @param prot Data Channel Protection Level. * @throws SSLException If it server reply code not equal "200". * @throws IOException If an I/O error occurs while either sending * the command. */ public void execPROT(String prot) throws SSLException, IOException { if (prot == null) prot = DEFAULT_PROT; if (!checkPROTValue(prot)) throw new IllegalArgumentException(); if (FTPReply.COMMAND_OK != sendCommand( FTPSCommand._commands[FTPSCommand.PROT], prot)) throw new SSLException(getReplyString()); if (DEFAULT_PROT.equals(prot)) { setSocketFactory(null); setServerSocketFactory(null); } else { setSocketFactory(new FTPSSocketFactory(context)); initSslContext(); SSLServerSocketFactory ssf = context.getServerSocketFactory(); setServerSocketFactory(ssf); } }