Java Code Examples for org.apache.commons.net.ProtocolCommandEvent#getMessage()

The following examples show how to use org.apache.commons.net.ProtocolCommandEvent#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FtpClient.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void processEvent(ProtocolCommandEvent event) {
    String message = event.getMessage();
    if (message.startsWith("PASS ")) { // NOI18N
        // hide password
        message = "PASS ******"; // NOI18N
    }
    OutputWriter writer = null;
    if (event.isReply()
            && (FTPReply.isNegativeTransient(event.getReplyCode()) || FTPReply.isNegativePermanent(event.getReplyCode()))) {
        writer = io.getErr();
    } else {
        writer = io.getOut();
    }
    writer.println(message.trim());
    writer.flush();
    if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.log(Level.FINE, "Command listener: {0}", message.trim());
    }
}
 
Example 2
Source File: BuildLogCommandListener.java    From teamcity-deployer-plugin with Apache License 2.0 6 votes vote down vote up
public void protocolCommandSent(ProtocolCommandEvent event) {
  final StringBuilder sb = new StringBuilder("> ");
  String cmd = event.getCommand();
  if(!"PASS".equalsIgnoreCase(cmd) && !"USER".equalsIgnoreCase(cmd)) {
    if("LOGIN".equalsIgnoreCase(cmd)) {
      String msg = event.getMessage();
      msg = msg.substring(0, msg.indexOf("LOGIN") + "LOGIN".length());
      sb.append(msg).append(" *******");
    } else {
      sb.append(event.getMessage());
    }
  } else {
    sb.append(cmd).append(" *******");
  }
  logInternalMessage(sb.toString());
}
 
Example 3
Source File: PrintCommandListener.java    From anthelion with Apache License 2.0 5 votes vote down vote up
private void __logIt(ProtocolCommandEvent event) throws IOException {
  if (!__logger.isInfoEnabled()) { return; }
  BufferedReader br =
    new BufferedReader(new StringReader(event.getMessage()));
  String line;
  while ((line = br.readLine()) != null) {
    __logger.info("ftp> "+line);
  }
}
 
Example 4
Source File: PrintCommandListener.java    From nutch-htmlunit with Apache License 2.0 5 votes vote down vote up
private void __logIt(ProtocolCommandEvent event) throws IOException {
  if (!__logger.isInfoEnabled()) { return; }
  BufferedReader br =
    new BufferedReader(new StringReader(event.getMessage()));
  String line;
  while ((line = br.readLine()) != null) {
    __logger.info("ftp> "+line);
  }
}