/** * AUTH command. * @throws SSLException If it server reply code not equal "234" and "334". * @throws IOException If an I/O error occurs while either sending * the command. */ protected void execAUTH() throws SSLException, IOException { int replyCode = sendCommand(CMD_AUTH, auth); if (FTPReply.SECURITY_MECHANISM_IS_OK == replyCode) { // replyCode = 334 // I carry out an ADAT command. } else if (FTPReply.SECURITY_DATA_EXCHANGE_COMPLETE != replyCode) { throw new SSLException(getReplyString()); } }
/** * PBSZ command. pbsz value: 0 to (2^32)-1 decimal integer. * @param pbsz Protection Buffer Size. * @throws SSLException If the server reply code does not equal "200". * @throws IOException If an I/O error occurs while sending * the command. * @see #parsePBSZ(long) */ public void execPBSZ(long pbsz) throws SSLException, IOException { if (pbsz < 0 || 4294967295L < pbsz) { // 32-bit unsigned number throw new IllegalArgumentException(); } int status = sendCommand(CMD_PBSZ, String.valueOf(pbsz)); if (FTPReply.COMMAND_OK != status) { throw new SSLException(getReplyString()); } }
_socket_.getOutputStream(), getControlEncoding())); } else { throw new SSLException(getReplyString());
/** * PBSZ command. pbsz value: 0 to (2^32)-1 decimal integer. * Issues the command and parses the response to return the negotiated value. * * @param pbsz Protection Buffer Size. * @throws SSLException If the server reply code does not equal "200". * @throws IOException If an I/O error occurs while sending * the command. * @return the negotiated value. * @see #execPBSZ(long) * @since 3.0 */ public long parsePBSZ(long pbsz) throws SSLException, IOException { execPBSZ(pbsz); long minvalue = pbsz; String remainder = extractPrefixedData("PBSZ=", getReplyString()); if (remainder != null) { long replysz = Long.parseLong(remainder); if (replysz < minvalue) { minvalue = replysz; } } return minvalue; }
throw new SSLException(getReplyString());
/** * PBSZ command. pbsz value: 0 to (2^32)-1 decimal integer. * @param pbsz Protection Buffer Size. * @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 execPBSZ(long pbsz) throws SSLException, IOException { if (pbsz < 0 || 4294967295L < pbsz) throw new IllegalArgumentException(); if (FTPReply.COMMAND_OK != sendCommand( FTPSCommand._commands[FTPSCommand.PBSZ],String.valueOf(pbsz))) throw new SSLException(getReplyString()); }
/** * AUTH command. * @throws SSLException If it server reply code not equal "234" and "334". * @throws IOException If an I/O error occurs while either sending * the command. */ private void execAUTH() throws SSLException, IOException { int replyCode = sendCommand( FTPSCommand._commands[FTPSCommand.AUTH], auth); if (FTPReply.SECURITY_MECHANISM_IS_OK == replyCode) { // replyCode = 334 // I carry out an ADAT command. } else if (FTPReply.SECURITY_DATA_EXCHANGE_COMPLETE != replyCode) { throw new SSLException(getReplyString()); } }
/** * I carry out an ftp command. * When a CCC command was carried out, I steep socket and SocketFactory * in a state of not ssl. * @parm command ftp command. * @return server reply. * @throws IOException If an I/O error occurs while either sending * the command. * @see org.apache.commons.net.ftp.FTP#sendCommand(java.lang.String) */ @Override public int sendCommand(String command, String args) throws IOException { int repCode = super.sendCommand(command, args); if (FTPSCommand._commands[FTPSCommand.CCC].equals(command)) { if (FTPReply.COMMAND_OK == repCode) { // TODO Check this - is this necessary at all? _socket_ = planeSocket; setSocketFactory(null); } else { throw new SSLException(getReplyString()); } } return repCode; }
ftpClient.changeWorkingDirectory("/"); if (ftpClient.getReplyString().contains("250")) { ftpClient.setFileType(FTP.BINARY_FILE_TYPE); ftpClient.enterLocalPassiveMode();
/** * 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); } }