* Handles PASS command.
*/
@Override
public void invoke(@NotNull final ClientSession session, @NotNull final String param) {
final FtpUser sessionUser = session.getUser();
if (sessionUser == null) {
session.replyWithSpace(503, "Login with USER first.");
return;
}
if (sessionUser.getPassword() != null) {
session.replyWithSpace(202, "Already logged-in.");
return;
}
final ServerSettings settings = SettingsHolder.getInstance().getSettings();
final FtpUser user = settings.getUserList().get(sessionUser.getUsername());
// Checking password. For anonymous user it doesn't
// matter what password he has.
if (!param.equals(user.getPassword()) &&
!sessionUser.getUsername().equals("anonymous"))
{
session.setUser(null);
session.replyWithSpace(530, "Authentication failed.");
return;
}
sessionUser.setHomeDir(user.getHomeDir());
sessionUser.setPassword(user.getPassword());
sessionUser.setWriteAccess(user.hasWriteAccess());
final FSView fsView = FSViews.newUnixView(sessionUser);
session.setFsView(fsView);
session.replyWithSpace(230, "User logged in, proceed.");