com.icegreen.greenmail.pop3.commands.PassCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of greenmail Show documentation
Show all versions of greenmail Show documentation
GreenMail - Email Test Servers
/*
* Copyright (c) 2014 Wael Chatila / Icegreen Technologies. All Rights Reserved.
* This software is released under the Apache license 2.0
* This file has been used and modified.
* Original file can be found on http://foedus.sourceforge.net
*/
package com.icegreen.greenmail.pop3.commands;
import com.icegreen.greenmail.pop3.Pop3Connection;
import com.icegreen.greenmail.pop3.Pop3State;
import com.icegreen.greenmail.user.GreenMailUser;
public class PassCommand
extends Pop3Command {
@Override
public boolean isValidForState(Pop3State state) {
return !state.isAuthenticated();
}
@Override
public void execute(Pop3Connection conn, Pop3State state,
String cmd) {
GreenMailUser user = state.getUser();
if (user == null) {
conn.println("-ERR USER required");
return;
}
String[] args = cmd.split(" ");
if (args.length < 2) {
conn.println("-ERR Required syntax: PASS ");
return;
}
try {
String pass = args[1];
state.authenticate(pass);
conn.println("+OK");
} catch (Exception e) {
conn.println("-ERR Authentication failed: " + e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy