// reset state variables
session.resetState();
// only administrator can execute this
UserManager userManager = context.getUserManager();
boolean isAdmin = userManager.isAdmin(session.getUser().getName());
if (!isAdmin) {
session.write(LocalizedFtpReply.translate(session, request, context,
FtpReply.REPLY_530_NOT_LOGGED_IN, "SITE", null));
return;
}
// get the user name
String argument = request.getArgument();
int spIndex = argument.indexOf(' ');
if (spIndex == -1) {
session.write(LocalizedFtpReply.translate(session, request, context,
FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS,
"SITE.DESCUSER", null));
return;
}
String userName = argument.substring(spIndex + 1);
// check the user existance
UserManager usrManager = context.getUserManager();
User user = null;
try {
if (usrManager.doesExist(userName)) {
user = usrManager.getUserByName(userName);
}
} catch (FtpException ex) {
LOG.debug("Exception trying to get user from user manager", ex);
user = null;
}