in resolver/src/main/java/org/apache/james/jspf/core/MacroExpand.java [407:462]
private String matchMacro(String macro, MacroData macroData) throws PermErrorException, RequireClientDomainException {
String rValue = null;
String variable = macro.toLowerCase();
if (variable.equalsIgnoreCase("i")) {
rValue = macroData.getMacroIpAddress();
} else if (variable.equalsIgnoreCase("s")) {
rValue = macroData.getMailFrom();
} else if (variable.equalsIgnoreCase("h")) {
rValue = macroData.getHostName();
} else if (variable.equalsIgnoreCase("l")) {
rValue = macroData.getCurrentSenderPart();
} else if (variable.equalsIgnoreCase("d")) {
rValue = macroData.getCurrentDomain();
} else if (variable.equalsIgnoreCase("v")) {
rValue = macroData.getInAddress();
} else if (variable.equalsIgnoreCase("t")) {
rValue = Long.toString(macroData.getTimeStamp());
} else if (variable.equalsIgnoreCase("c")) {
rValue = macroData.getReadableIP();
} else if (variable.equalsIgnoreCase("p")) {
rValue = macroData.getClientDomain();
if (rValue == null) {
throw new RequireClientDomainException();
}
} else if (variable.equalsIgnoreCase("o")) {
rValue = macroData.getSenderDomain();
} else if (variable.equalsIgnoreCase("r")) {
rValue = macroData.getReceivingDomain();
if (rValue == null) {
rValue = "unknown";
List<String> dNames = dnsProbe.getLocalDomainNames();
for (int i = 0; i < dNames.size(); i++) {
// check if the domainname is a FQDN
if (SPF1Utils.checkFQDN(dNames.get(i).toString())) {
rValue = dNames.get(i).toString();
if (macroData instanceof SPFSession) {
((SPFSession) macroData).setReceivingDomain(rValue);
}
break;
}
}
}
}
if (rValue == null) {
throw new PermErrorException("Unknown command : " + variable);
} else {
LOGGER.debug("Used macro: {} replaced with: {}", macro, rValue);
return rValue;
}
}