/** * Send the AUTH command with the specified mechanism. * @param mechanism The mechanism name to send with the command. * @return server reply. * @throws IOException If an I/O error occurs while sending * the command. * @since 3.0 */ public int execAUTH(String mechanism) throws IOException { return sendCommand(CMD_AUTH, mechanism); }
/** * Send the CCC command to the server. * The CCC (Clear Command Channel) command causes the underlying {@link SSLSocket} instance to be assigned * to a plain {@link Socket} instances * @return server reply. * @throws IOException If an I/O error occurs while sending * the command. * @since 3.0 */ public int execCCC() throws IOException { int repCode = sendCommand(CMD_CCC); // This will be performed by sendCommand(String, String) // if (FTPReply.isPositiveCompletion(repCode)) { // _socket_.close(); // _socket_ = plainSocket; // _controlInput_ = new BufferedReader( // new InputStreamReader( // _socket_.getInputStream(), getControlEncoding())); // _controlOutput_ = new BufferedWriter( // new OutputStreamWriter( // _socket_.getOutputStream(), getControlEncoding())); // } return repCode; }
/** * Send the MIC command with the specified data. * @param data The data to send with the command. * @return server reply. * @throws IOException If an I/O error occurs while sending * the command. * @since 3.0 */ public int execMIC(byte[] data) throws IOException { if (data != null) { return sendCommand(CMD_MIC, Base64.encodeBase64StringUnChunked(data)); } else { return sendCommand(CMD_MIC, ""); // perhaps "=" or just sendCommand(String)? } }
/** * Send the ADAT command with the specified authentication data. * @param data The data to send with the command. * @return server reply. * @throws IOException If an I/O error occurs while sending * the command. * @since 3.0 */ public int execADAT(byte[] data) throws IOException { if (data != null) { return sendCommand(CMD_ADAT, Base64.encodeBase64StringUnChunked(data)); } else { return sendCommand(CMD_ADAT); } }
/** * Send the CONF command with the specified data. * @param data The data to send with the command. * @return server reply. * @throws IOException If an I/O error occurs while sending * the command. * @since 3.0 */ public int execCONF(byte[] data) throws IOException { if (data != null) { return sendCommand(CMD_CONF, Base64.encodeBase64StringUnChunked(data)); } else { return sendCommand(CMD_CONF, ""); // perhaps "=" or just sendCommand(String)? } }
/** * Send the ENC command with the specified data. * @param data The data to send with the command. * @return server reply. * @throws IOException If an I/O error occurs while sending * the command. * @since 3.0 */ public int execENC(byte[] data) throws IOException { if (data != null) { return sendCommand(CMD_ENC, Base64.encodeBase64StringUnChunked(data)); } else { return sendCommand(CMD_ENC, ""); // perhaps "=" or just sendCommand(String)? } }
/** * 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()); } }
throw new IllegalArgumentException(); if (FTPReply.COMMAND_OK != sendCommand(CMD_PROT, prot)) { throw new SSLException(getReplyString());
@Override public String executeCommand( String command ) throws FileTransferException { log.info("Run '" + command + "'"); String returnCode = ""; try { this.ftpsConnection.sendCommand(command); returnCode = String.valueOf(this.ftpsConnection.sendCommand(command)); } catch (IOException e) { log.error("Error running command: '" + command + "'", e); throw new FileTransferException(e); } log.info("Return code is '" + returnCode + "'"); return returnCode; }
/** * 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()); } }
/** * 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); } }