HeloCmdHandlerpublic class HeloCmdHandler extends org.apache.avalon.framework.logger.AbstractLogEnabled implements CommandHandler, org.apache.avalon.framework.configuration.Configurable
Fields Summary |
---|
private static final String | COMMAND_NAMEThe name of the command handled by the command handler | private boolean | checkResolvableHeloset checkValidHelo to false as default value | private boolean | checkAuthNetworks |
Methods Summary |
---|
public void | configure(org.apache.avalon.framework.configuration.Configuration handlerConfiguration)
Configuration configuration = handlerConfiguration.getChild("checkResolvableHelo",false);
if(configuration != null) {
checkResolvableHelo = configuration.getValueAsBoolean();
}
Configuration configRelay = handlerConfiguration.getChild("checkAuthNetworks",false);
if(configRelay != null) {
checkAuthNetworks = configRelay.getValueAsBoolean();
}
| private void | doHELO(SMTPSession session, java.lang.String argument)Handler method called upon receipt of a HELO command.
Responds with a greeting and informs the client whether
client authentication is required.
String responseString = null;
boolean badHelo = false;
// check for resolvable helo if its set in config
if (checkResolvableHelo) {
/**
* don't check if the ip address is allowed to relay. Only check if it is set in the config. ed.
*/
if (!session.isRelayingAllowed() || checkAuthNetworks) {
// try to resolv the provided helo. If it can not resolved do not accept it.
try {
org.apache.james.dnsserver.DNSServer.getByName(argument);
} catch (UnknownHostException e) {
badHelo = true;
responseString = "501 Provided HELO " + argument + " can not resolved";
session.writeResponse(responseString);
getLogger().info(responseString);
}
}
}
if (argument == null) {
responseString = "501 Domain address required: " + COMMAND_NAME;
session.writeResponse(responseString);
getLogger().info(responseString);
} else if (!badHelo) {
session.resetState();
session.getState().put(SMTPSession.CURRENT_HELO_MODE, COMMAND_NAME);
session.getResponseBuffer().append("250 ")
.append(session.getConfigurationData().getHelloName())
.append(" Hello ")
.append(argument)
.append(" (")
.append(session.getRemoteHost())
.append(" [")
.append(session.getRemoteIPAddress())
.append("])");
responseString = session.clearResponseBuffer();
session.writeResponse(responseString);
}
| public void | onCommand(SMTPSession session)
doHELO(session, session.getCommandArgument());
|
|