index++;
} while (!token.equals("from") && index < split.length);
// If we weren't the first token, throw an exception
if(index > 1) {
throw new JasenParseException("'from' token out of place",ParseErrorType.PARSE_ERROR);
}
// We should now be at the sender host
if (index < split.length && token.equals("from")) {
boolean hostSet = false;
boolean ipSet = false;
do {
token = split[index];
// See if we are a hostname
if (DNSUtils.isDomain(token) && !hostSet) {
// We have the sender host
data.setSenderHostName(token);
hostSet = true;
} else if (DNSUtils.isIPAddress(token)) {
// If this is the first ip.. assume its the host
if (!hostSet) {
data.setSenderHostName(token);
} else if(!ipSet){
// Assume its the real ip
data.setSenderIPAddress(token);
ipSet = true;
}
}
index++;
} while (!token.equals("by") && index < split.length);
// Now, look for the recipient data
if (index < split.length && token.equals("by")) {
// Assmume that the next token is the receiver
token = split[index];
data.setReceiverHostName(token);
}
} else {
throw new JasenParseException("Couldn't locate 'from' token",
ParseErrorType.PARSE_ERROR);
}
} else {
throw new JasenParseException(
"Couldn't parse header. No tokens found",
ParseErrorType.PARSE_ERROR);
}
if(data.getSenderIPAddress() == null && data.getSenderHostName() != null) {