List of usage examples for org.apache.commons.net ProtocolCommandEvent getCommand
public String getCommand()
From source file:com.sos.VirtualFileSystem.FTP.SOSFtpClientLogger.java
@Override public void protocolCommandSent(final ProtocolCommandEvent event) { if (event.getCommand() != "PASS") { logger.debug(clientId + " > " + event.getMessage().trim()); }/*ww w . j a v a 2 s . c o m*/ }
From source file:net.metanotion.emailqueue.SmtpSender.java
@Override public Connection getConnection() { AuthenticatingSMTPClient client = null; try {// w w w . j a v a 2 s. co m client = new AuthenticatingSMTPClient(); client.addProtocolCommandListener(new ProtocolCommandListener() { @Override public void protocolCommandSent(final ProtocolCommandEvent event) { logger.trace(COMMAND_LOG_FORMAT, event.getCommand(), event.getMessage()); } @Override public void protocolReplyReceived(final ProtocolCommandEvent event) { logger.trace(COMMAND_LOG_FORMAT, event.getCommand(), event.getMessage()); } }); logger.trace("Connecting"); client.connect(this.server, this.port); if (!SMTPReply.isPositiveCompletion(client.getReplyCode())) { logger.error("Did not get positive completion."); throw new IOException("Could not complete SMTP connection."); } startTls(client); logger.trace("Authenticating"); client.auth(AuthenticatingSMTPClient.AUTH_METHOD.PLAIN, username, password); logger.trace("Login"); client.login(host); return new Connection(client); } catch (final IOException | NoSuchAlgorithmException | InvalidKeyException | InvalidKeySpecException ex) { logger.debug("Error", ex); try { if (client != null) { client.disconnect(); } } catch (final IOException ex2) { } throw new RuntimeException(ex); } }
From source file:com.consol.citrus.ftp.client.FtpClient.java
@Override public void afterPropertiesSet() throws Exception { if (ftpClient == null) { ftpClient = new FTPClient(); }/* www. j av a 2s . co m*/ ftpClient.configure(config); ftpClient.addProtocolCommandListener(new ProtocolCommandListener() { @Override public void protocolCommandSent(ProtocolCommandEvent event) { log.info("Send FTP command: " + event.getCommand()); } @Override public void protocolReplyReceived(ProtocolCommandEvent event) { log.info("Received FTP command reply: " + event.getReplyCode()); } }); }
From source file:adams.core.io.lister.FtpDirectoryLister.java
/*** * This method is invoked by a ProtocolCommandEvent source after * sending a protocol command to a server. * * @param event The ProtocolCommandEvent fired. *//* w w w . j a v a 2s . c o m*/ public void protocolCommandSent(ProtocolCommandEvent event) { if (isLoggingEnabled()) getLogger().info("cmd sent: " + event.getCommand() + "/" + event.getReplyCode()); else if (event.getReplyCode() >= 400) getLogger().severe("cmd sent: " + event.getCommand() + "/" + event.getReplyCode()); }
From source file:com.symbian.driver.plugins.ftptelnet.FtpTransfer.java
/** * connectFTP : connects to ftp server/* w ww . j a v a2 s. c om*/ * * @return boolean success/fail */ public boolean connectFTP() { if (isFTPConnected()) { return true; } // Connect to FTP try { // 1. create an apache client iFTP = new FTPClient(); iFTP.addProtocolCommandListener(new ProtocolCommandListener() { public void protocolCommandSent(ProtocolCommandEvent aProtocolCommandEvent) { LOGGER.fine("FTP Command Send: (" + aProtocolCommandEvent.getCommand() + ") " + aProtocolCommandEvent.getMessage()); } public void protocolReplyReceived(ProtocolCommandEvent aProtocolCommandEvent) { LOGGER.fine("FTP Command Recieved: (" + aProtocolCommandEvent.getMessage() + ") Returned Code " + aProtocolCommandEvent.getReplyCode()); } }); FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX); iFTP.configure(conf); // 2. connect iFTP.connect(iIP, iPort); // 3. check connection done. int reply = iFTP.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { disconnectFTP(); LOGGER.log(Level.SEVERE, "FTP error: " + reply); return false; } // 4. Login if (!iFTP.login(iUserName, iPassword)) { LOGGER.log(Level.SEVERE, "FTP failed to login, Username: " + iUserName + " Password: " + iPassword); disconnectFTP(); return false; } else { if (iPassive.equalsIgnoreCase("true")) { iFTP.enterLocalPassiveMode(); } iFTP.setFileType(FTP.BINARY_FILE_TYPE); iFTP.setBufferSize(iBufferSize); } } catch (SocketException lSocketException) { LOGGER.log(Level.SEVERE, "Socket exception ", lSocketException); return false; } catch (IOException lIOException) { LOGGER.log(Level.SEVERE, "Socket exception ", lIOException); return false; } LOGGER.info("FTP connection established with transport : " + iIP + ":" + iPort); return true; }
From source file:ConnectionInfo.java
/** * @param parentShell//from w w w . ja v a2s .co m */ public FTPWindow(Shell parentShell) { super(parentShell); createActions(); addStatusLine(); //addCoolBar(SWT.FLAT | SWT.RIGHT); addToolBar(SWT.FLAT); addMenuBar(); ftp = new FTPClient(); ftp.addProtocolCommandListener(new ProtocolCommandListener() { public void protocolCommandSent(ProtocolCommandEvent e) { logMessage("> " + e.getCommand(), false); } public void protocolReplyReceived(ProtocolCommandEvent e) { logMessage("< " + e.getMessage(), false); } }); }
From source file:uk.ac.manchester.cs.datadesc.validator.rdftools.FtpListener.java
@Override public void protocolCommandSent(ProtocolCommandEvent event) { if (logger.isDebugEnabled()) { String cmd = event.getCommand(); if ("PASS".equalsIgnoreCase(cmd) || "USER".equalsIgnoreCase(cmd)) { logger.debug(cmd + " *******"); } else {//from www . java2 s. c o m final String IMAP_LOGIN = "LOGIN"; if (IMAP_LOGIN.equalsIgnoreCase(cmd)) { // IMAP String msg = event.getMessage(); msg = msg.substring(0, msg.indexOf(IMAP_LOGIN) + IMAP_LOGIN.length()); logger.debug(msg + " *******"); // Don't bother with EOL marker for this! } else { logPrintableString(event.getMessage()); } } } }
From source file:uk.co.marcoratto.net.PrintCommandListener.java
public void protocolCommandSent(ProtocolCommandEvent arg0) { logger.info(arg0.getCommand()); }
From source file:uk.co.marcoratto.net.PrintCommandListener.java
public void protocolReplyReceived(ProtocolCommandEvent arg0) { logger.info(arg0.getCommand()); }
From source file:uk.me.sa.android.notify_smtp.net.AuthSMTPTLSClient.java
@Override public void protocolCommandSent(ProtocolCommandEvent event) { command = event.getCommand(); }