/** * Execute command. */ public void execute(final FtpIoSession session, final FtpServerContext context, final FtpRequest request) throws IOException, FtpException { // reset state variables session.resetState(); // send timezone data String timezone = TIMEZONE_FMT.format(new Date()); session.write(new DefaultFtpReply(FtpReply.REPLY_200_COMMAND_OKAY, timezone)); } }
@Override public FtpletResult beforeCommand(FtpSession session, FtpRequest request) throws FtpException { if (session.getUser() != null) { Class<? extends Authority> authority = commandAuthorityMap.get(request.getCommand()); if (authority != null && session.getUser().getAuthorities(authority).isEmpty()) { session.write(new DefaultFtpReply(FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, "Permission denied")); return FtpletResult.SKIP; } } return null; }
stat.getTotalConnectionNumber()).append('\n'); sb.append('\n'); session.write(new DefaultFtpReply(FtpReply.REPLY_200_COMMAND_OKAY, sb .toString()));
public void exceptionCaught(final FtpIoSession session, final Throwable cause) throws Exception { if(cause instanceof ProtocolDecoderException && cause.getCause() instanceof MalformedInputException) { // client probably sent something which is not UTF-8 and we failed to // decode it LOG.warn( "Client sent command that could not be decoded: {}", ((ProtocolDecoderException)cause).getHexdump()); session.write(new DefaultFtpReply(FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "Invalid character in command")); } else if (cause instanceof WriteToClosedSessionException) { WriteToClosedSessionException writeToClosedSessionException = (WriteToClosedSessionException) cause; LOG.warn( "Client closed connection before all replies could be sent, last reply was {}", writeToClosedSessionException.getRequest()); session.close(false).awaitUninterruptibly(10000); } else { LOG.error("Exception caught, closing session", cause); session.close(false).awaitUninterruptibly(10000); } }
session.write(new DefaultFtpReply(FtpReply.REPLY_200_COMMAND_OKAY, sb .toString()));
session.write(new DefaultFtpReply(FtpReply.REPLY_200_COMMAND_OKAY, sb .toString()));
.getInetAddress(); if (address == null) { session.write(new DefaultFtpReply( FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first")); session.write(new DefaultFtpReply( FtpReply.REPLY_150_FILE_STATUS_OKAY, "FILE: " + fileName));
.getInetAddress(); if (address == null) { session.write(new DefaultFtpReply( FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
.getInetAddress(); if (address == null) { session.write(new DefaultFtpReply( FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
.getInetAddress(); if (address == null) { session.write(new DefaultFtpReply( FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
.getInetAddress(); if (address == null) { session.write(new DefaultFtpReply( FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
.getInetAddress(); if (address == null) { session.write(new DefaultFtpReply( FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
.getInetAddress(); if (address == null) { session.write(new DefaultFtpReply( FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));