You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2006/09/20 17:12:01 UTC
svn commit: r448232 - in /james/jspf/trunk/src:
main/java/org/apache/james/jspf/ main/java/org/apache/james/jspf/core/
main/java/org/apache/james/jspf/macro/
main/java/org/apache/james/jspf/parser/
main/java/org/apache/james/jspf/terms/ main/java/org/a...
Author: norman
Date: Wed Sep 20 08:12:00 2006
New Revision: 448232
URL: http://svn.apache.org/viewvc?view=rev&rev=448232
Log:
Fix/add javadocs
Replace catch Exception with the right Exception types
Reformat some stuff
Modified:
james/jspf/trunk/src/main/java/org/apache/james/jspf/DNSServiceXBillImpl.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/SPF.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/SPF1Utils.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFInternalResult.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFResult.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/core/Configurable.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/core/Directive.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/core/Modifier.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPF1Constants.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPF1Data.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/macro/MacroExpand.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/parser/SPF1Parser.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/AMechanism.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/GenericMechanism.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/IncludeMechanism.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/MXMechanism.java
james/jspf/trunk/src/main/java/org/apache/james/jspf/util/ConfigurationMatch.java
james/jspf/trunk/src/test/java/org/apache/james/jspf/DNSServiceXBillImplTest.java
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/DNSServiceXBillImpl.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/DNSServiceXBillImpl.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/DNSServiceXBillImpl.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/DNSServiceXBillImpl.java Wed Sep 20 08:12:00 2006
@@ -48,12 +48,12 @@
* for SPF
*
*/
-
public class DNSServiceXBillImpl implements DNSService {
// Set seconds after which we return and TempError
private static int timeOut = 20;
+ // The logger
private Logger log;
/**
@@ -93,13 +93,13 @@
returnValue = compare;
} else {
throw new PermErrorException(
- "More than 1 SPF record found");
+ "More than 1 SPF record found for host: " + hostname);
}
}
}
}
if (returnValue == null) {
- throw new NoneException("No SPF record found");
+ throw new NoneException("No SPF record found for host: " + hostname);
}
return returnValue;
}
@@ -137,14 +137,13 @@
for (int i = 0; i < records.length; i++) {
TXTRecord txt = (TXTRecord) records[i];
- log
- .debug("Add txt " + txt.rdataToString()
+ log.debug("Add txt " + txt.rdataToString()
+ " to list");
txtR.add(txt.rdataToString());
}
} else {
- throw new NoneException("No TXTRecord found for: "
+ throw new NoneException("No TXTRecord found for host: "
+ hostname);
}
} else {
@@ -153,7 +152,7 @@
}
} catch (TextParseException e) {
// I think thats the best we could do
- throw new NoneException("No TXTRecord found for: " + hostname);
+ throw new NoneException("No TXTRecord found for host: " + hostname);
}
return txtR;
}
@@ -197,7 +196,7 @@
listTxtData.add(ip);
}
} else {
- throw new NoneException("No A record found for: "
+ throw new NoneException("No A record found for host: "
+ strServer);
}
} else {
@@ -206,7 +205,7 @@
}
} catch (TextParseException e) {
// i think this is the best we could do
- throw new NoneException("No A Record found for: " + strServer);
+ throw new NoneException("No A Record found for host: " + strServer);
}
}
return listTxtData;
@@ -252,7 +251,7 @@
listTxtData.add(ip);
}
} else {
- throw new NoneException("No AAAA record found for: "
+ throw new NoneException("No AAAA record found for host: "
+ strServer);
}
} else {
@@ -261,7 +260,7 @@
}
} catch (TextParseException e) {
// i think this is the best we could do
- throw new NoneException("No AAAA Record found for: "
+ throw new NoneException("No AAAA Record found for host: "
+ strServer);
}
}
@@ -279,20 +278,22 @@
* @return ArrayList of the conversion
* @throws PermErrorException
* if an PermError should be returned
+ * @throws TempErrorException if the lookup result was "TRY_AGAIN"
*/
private ArrayList getAList(ArrayList addressList)
- throws PermErrorException {
+ throws PermErrorException, TempErrorException {
ArrayList listAddresses = new ArrayList();
String aValue;
for (int i = 0; i < addressList.size(); i++) {
aValue = addressList.get(i).toString();
+
try {
listAddresses.addAll(getARecords(aValue));
- } catch (Exception e) {
- // Carry on regardless?
- }
+ } catch (NoneException e) {
+ // ignore
+ }
}
return listAddresses;
}
@@ -353,7 +354,7 @@
+ " to list");
}
} else {
- throw new NoneException("No PTRRecord found for: "
+ throw new NoneException("No PTRRecord found for host: "
+ ipAddress);
}
} else {
@@ -362,7 +363,7 @@
}
} catch (TextParseException e) {
// i think this is the best we could do
- throw new NoneException("No PTRRecord found for: " + ipAddress);
+ throw new NoneException("No PTRRecord found for host: " + ipAddress);
}
return ptrR;
@@ -422,7 +423,7 @@
}
} else {
- throw new NoneException("No MX Record found for: " + host);
+ throw new NoneException("No MX Record found for host: " + host);
}
} else {
throw new TempErrorException("DNS Server returns RCODE: "
@@ -430,7 +431,7 @@
}
} catch (TextParseException e) {
// i think this is the best we could do
- throw new NoneException("No MX Record found for: " + host);
+ throw new NoneException("No MX Record found for host: " + host);
}
return mxR;
}
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/SPF.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/SPF.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/SPF.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/SPF.java Wed Sep 20 08:12:00 2006
@@ -58,15 +58,18 @@
/**
* Uses passed logger and DNSJava based dns resolver
- * @param logger logger
+ *
+ * @param logger the logger to use
*/
public SPF(Logger logger) {
this(new DNSServiceXBillImpl(logger), logger);
}
/**
- * @param dnsProbe
- * the dns provider
+ * Uses passed logger and passed dnsServicer
+ *
+ * @param dnsProbe the dns provider
+ * @param logger the logger to use
*/
public SPF(DNSService dnsProbe, Logger logger) {
super();
@@ -84,8 +87,7 @@
* The mailFrom which was provided
* @param hostName
* The hostname which was provided as HELO/EHLO
- * @return result. Possible results are: pass, neutral, fail,
- * softfail, error,temperror, none
+ * @return result The SPFResult
*/
public SPFResult checkSPF(String ipAddress, String mailFrom, String hostName) {
SPF1Data spfData = null;
@@ -102,15 +104,15 @@
explanation = res.getExplanation();
} catch (PermErrorException e) {
log.warn(e.getMessage(),e);
- result = SPF1Utils.PERM_ERROR;
+ result = SPF1Utils.PERM_ERROR_CONV;
} catch (NoneException e) {
log.warn(e.getMessage(),e);
- result = SPF1Utils.NONE;
+ result = SPF1Utils.NONE_CONV;
} catch (NeutralException e) {
result = SPF1Utils.NEUTRAL_CONV;
} catch (TempErrorException e) {
log.warn(e.getMessage(),e);
- result = SPF1Utils.TEMP_ERROR;
+ result = SPF1Utils.TEMP_ERROR_CONV;
} catch (IllegalStateException e) {
// this should never happen at all. But anyway we will set the
// result to neutral. Safety first ..
@@ -131,14 +133,17 @@
* Run check for SPF with the given values.
*
* @param spfData
- * The SPF1Data which should be used to run the check
+ * The SPF1Data which should be used to run the check
+ * @return result
+ * The SPFInternalResult
* @throws PermErrorException
* Get thrown if an error was detected
* @throws NoneException
* Get thrown if no Record was found
* @throws TempErrorException
* Get thrown if a DNS problem was detected
- * @throws NeutralException
+ * @throws NeutralException
+ * Get thrown if the result should be neutral
*/
public SPFInternalResult checkSPF(SPF1Data spfData) throws PermErrorException,
NoneException, TempErrorException, NeutralException {
@@ -252,10 +257,7 @@
* Set the amount of time (in seconds) before an TermError is returned when
* the dnsserver not answer. Default is 20 seconds.
*
- * TempError should be returned
- *
- * @param timeOut
- * The timout in seconds
+ * @param timeOut The timout in seconds
*/
public synchronized void setTimeOut(int timeOut) {
log.debug("TimeOut was set to: " + timeOut);
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/SPF1Utils.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/SPF1Utils.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/SPF1Utils.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/SPF1Utils.java Wed Sep 20 08:12:00 2006
@@ -30,16 +30,11 @@
*/
public class SPF1Utils {
- public static final String PERM_ERROR = "error";
public static final String PERM_ERROR_CONV = "error";
- public static final String NONE = "none";
-
public static final String NONE_CONV = "none";
- public static final String TEMP_ERROR = "temperror";
-
public static final String TEMP_ERROR_CONV = "temperror";
public static final String PASS_CONV = "pass";
@@ -55,8 +50,7 @@
/**
* Convert raw SPF results to SPF names
*
- * @param result
- * The result which should converted
+ * @param result The result which should converted
* @return coverted result
*/
protected static String resultToName(String result) {
@@ -69,11 +63,11 @@
return NEUTRAL_CONV;
} else if (result.equals(SPF1Constants.SOFTFAIL)) {
return SOFTFAIL_CONV;
- } else if (result.equals(PERM_ERROR)) {
+ } else if (result.equals(PERM_ERROR_CONV)) {
return PERM_ERROR_CONV;
- } else if (result.equals(TEMP_ERROR)) {
+ } else if (result.equals(TEMP_ERROR_CONV)) {
return TEMP_ERROR_CONV;
- } else if (result.equals(NONE)) {
+ } else if (result.equals(NONE_CONV)) {
return NONE_CONV;
} else {
return NEUTRAL_CONV;
@@ -84,8 +78,7 @@
/**
* Covert SPF names to raw SPF results
*
- * @param result
- * The result which should converted
+ * @param result The result which should converted
* @return coverted result
*/
protected static String nameToResult(String result) {
@@ -99,11 +92,11 @@
} else if (result.equals(SOFTFAIL_CONV)) {
return SPF1Constants.SOFTFAIL;
} else if (result.equals(PERM_ERROR_CONV)) {
- return PERM_ERROR;
+ return PERM_ERROR_CONV;
} else if (result.equals(TEMP_ERROR_CONV)) {
- return TEMP_ERROR;
+ return TEMP_ERROR_CONV;
} else if (result.equals(NONE_CONV)) {
- return NONE;
+ return NONE_CONV;
} else {
return SPF1Constants.NEUTRAL;
}
@@ -113,8 +106,7 @@
/**
* Check for valid FQDN
*
- * @param host
- * The hostname to check
+ * @param host The hostname to check
* @return false or true
*/
public static boolean checkFQDN(String host) {
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFInternalResult.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFInternalResult.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFInternalResult.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFInternalResult.java Wed Sep 20 08:12:00 2006
@@ -26,13 +26,18 @@
* This class is used to return the result of an SPF lookup.
*
*/
-
public class SPFInternalResult {
protected String explanation = null;
private String resultChar = null;
+ /**
+ * Construct SPFInternalResult
+ *
+ * @param resultChar The result
+ * @param explanation The explanation
+ */
public SPFInternalResult(String resultChar, String explanation) {
this.resultChar = resultChar;
this.explanation = explanation;
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFResult.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFResult.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFResult.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFResult.java Wed Sep 20 08:12:00 2006
@@ -26,7 +26,6 @@
* This class is used to return the result of an SPF lookup.
*
*/
-
public class SPFResult extends SPFInternalResult {
private String headerTextAsString = "";
@@ -35,6 +34,14 @@
private String result = null;
+ /**
+ * Construct SPFResult
+ *
+ * @param result the result
+ * @param resultChar the rawResult
+ * @param explanation the explanation
+ * @param spf1data the SPF1Data
+ */
public SPFResult(String result, String resultChar, String explanation, SPF1Data spf1data) {
super(resultChar, explanation);
this.result = result;
@@ -71,8 +78,7 @@
/**
* Generate a SPF-Result header
*
- * @param result
- * The result we should use to generate the header
+ * @param result The result we should use to generate the header
*/
private String generateHeader(String result, SPF1Data spfData) {
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/core/Configurable.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/core/Configurable.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/core/Configurable.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/core/Configurable.java Wed Sep 20 08:12:00 2006
@@ -23,13 +23,16 @@
import org.apache.james.jspf.exceptions.PermErrorException;
import org.apache.james.jspf.util.ConfigurationMatch;
+/**
+ *
+ */
public interface Configurable {
/**
* Configuration
*
- * @param params
- * @throws PermErrorException
+ * @param params the ConfigurationMatch which should used
+ * @throws PermErrorException get thrown if a PermError should returned
*/
void config(ConfigurationMatch params) throws PermErrorException;
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/core/Directive.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/core/Directive.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/core/Directive.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/core/Directive.java Wed Sep 20 08:12:00 2006
@@ -24,12 +24,22 @@
import org.apache.james.jspf.exceptions.PermErrorException;
import org.apache.james.jspf.exceptions.TempErrorException;
+/**
+ *
+ */
public class Directive {
protected String qualifier = "+";
private Mechanism mechanism = null;
+ /**
+ * Construct Directive
+ *
+ * @param qualifier The qualifier to use. Valid qualifier are: +, -, ~, ?
+ * @param mechanism The Mechanism
+ * @throws PermErrorException Get thrown if a PermError should returned
+ */
public Directive(String qualifier, Mechanism mechanism)
throws PermErrorException {
super();
@@ -42,6 +52,15 @@
this.mechanism = mechanism;
}
+ /**
+ * Run the Directive
+ *
+ * @param spfData The SPF1Data to use
+ * @return The qualifier which was returned
+ * @throws PermErrorException get thrown if a PermError should returned
+ * @throws TempErrorException get thrown if a TempError should returned
+ * @throws NoneException get thrown if a NoneException should returned;
+ */
public String run(SPF1Data spfData) throws PermErrorException,
TempErrorException, NoneException {
if (mechanism.run(spfData)) {
@@ -51,10 +70,20 @@
}
}
+ /**
+ * Return the Mechanism which should be run
+ *
+ * @return the Mechanism
+ */
public Mechanism getMechanism() {
return mechanism;
}
+ /**
+ * Return the Qualifier
+ *
+ * @return the qualifier
+ */
public String getQualifier() {
return qualifier;
}
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/core/Modifier.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/core/Modifier.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/core/Modifier.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/core/Modifier.java Wed Sep 20 08:12:00 2006
@@ -44,6 +44,8 @@
TempErrorException;
/**
+ * Return true if the Modifier is only allowed once
+ *
* @return true if only one instance of this modifier is allowed
*/
public boolean enforceSingleInstance();
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPF1Constants.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPF1Constants.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPF1Constants.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPF1Constants.java Wed Sep 20 08:12:00 2006
@@ -20,16 +20,34 @@
package org.apache.james.jspf.core;
+/**
+ * Interface which holds Constants for SPF
+ */
public interface SPF1Constants {
+ /**
+ * Qualifier for PASS
+ */
public static final String PASS = "+";
+ /**
+ * Qualifier for NEUTRAL
+ */
public static final String NEUTRAL = "?";
+ /**
+ * Qualifier for FAIL
+ */
public static final String FAIL = "-";
+ /**
+ * Qualifier for SOFTFAIL
+ */
public static final String SOFTFAIL = "~";
+ /**
+ * The valid SPF_VERSION identifier
+ */
public static final String SPF_VERSION = "v=spf1";
}
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPF1Data.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPF1Data.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPF1Data.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPF1Data.java Wed Sep 20 08:12:00 2006
@@ -33,7 +33,6 @@
* values get stored here and get retrieved from here.
*
*/
-
public class SPF1Data implements MacroData {
private DNSService dnsProbe = null;
@@ -62,8 +61,14 @@
private int currentDepth = 0;
+ /**
+ * The maximum mechanismn which are allowed to use
+ */
public static final int MAX_DEPTH = 10;
+ /**
+ * The maximum MX or PTR Records to lookup
+ */
public static final int MAX_DEPTH_DNS = 10;
private String explanation = null;
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/macro/MacroExpand.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/macro/MacroExpand.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/macro/MacroExpand.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/macro/MacroExpand.java Wed Sep 20 08:12:00 2006
@@ -39,7 +39,7 @@
public static final String MACRO_REGEX = "\\%\\{[lsoditpvhcrLSODITPVHCR]\\d*r?[\\.\\-\\+,/_\\=]*\\}";
- private MacroData spfData;
+ private MacroData macroData;
private Pattern inputPattern;
@@ -53,8 +53,14 @@
private Logger log;
- public MacroExpand(MacroData spfData, Logger logger) {
- this.spfData = spfData;
+ /**
+ * Construct MacroExpand
+ *
+ * @param spfData the MacroData to use
+ * @param logger the logget to use
+ */
+ public MacroExpand(MacroData macroData, Logger logger) {
+ this.macroData = macroData;
inputPattern = Pattern.compile(MACRO_REGEX);
log = logger;
}
@@ -232,34 +238,33 @@
String variable = macro.toLowerCase();
if (variable.equalsIgnoreCase("i")) {
- rValue = spfData.getMacroIpAddress();
+ rValue = macroData.getMacroIpAddress();
} else if (variable.equalsIgnoreCase("s")) {
- rValue = spfData.getMailFrom();
+ rValue = macroData.getMailFrom();
} else if (variable.equalsIgnoreCase("h")) {
- rValue = spfData.getHostName();
+ rValue = macroData.getHostName();
} else if (variable.equalsIgnoreCase("l")) {
- rValue = spfData.getCurrentSenderPart();
+ rValue = macroData.getCurrentSenderPart();
} else if (variable.equalsIgnoreCase("d")) {
- rValue = spfData.getCurrentDomain();
+ rValue = macroData.getCurrentDomain();
} else if (variable.equalsIgnoreCase("v")) {
- rValue = spfData.getInAddress();
+ rValue = macroData.getInAddress();
} else if (variable.equalsIgnoreCase("t")) {
- rValue = Long.toString(spfData.getTimeStamp());
+ rValue = Long.toString(macroData.getTimeStamp());
} else if (variable.equalsIgnoreCase("c")) {
- rValue = spfData.getReadableIP();
+ rValue = macroData.getReadableIP();
} else if (variable.equalsIgnoreCase("p")) {
- rValue = spfData.getClientDomain();
+ rValue = macroData.getClientDomain();
} else if (variable.equalsIgnoreCase("o")) {
- rValue = spfData.getSenderDomain();
+ rValue = macroData.getSenderDomain();
} else if (variable.equalsIgnoreCase("r")) {
- rValue = spfData.getReceivingDomain();
+ rValue = macroData.getReceivingDomain();
}
if (rValue == null) {
throw new PermErrorException("Unknown command : " + variable);
} else {
-
log.debug("Used macro: " + macro + " replaced with: " + rValue);
return rValue;
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/parser/SPF1Parser.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/parser/SPF1Parser.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/parser/SPF1Parser.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/parser/SPF1Parser.java Wed Sep 20 08:12:00 2006
@@ -211,6 +211,8 @@
/**
* Constructor. Creates all the values needed to run the parsing
+ *
+ * @param loggerThe logger to use
*/
public SPF1Parser(Logger logger) {
log = logger;
@@ -356,7 +358,7 @@
* classes to analyze
* @param staticFieldName
* static field to concatenate
- * @return regex
+ * @return regex The regex
*/
private String createRegex(Collection commandMap) {
StringBuffer modifierRegex = new StringBuffer();
@@ -377,6 +379,7 @@
}
/**
+ *
* @param classes
* classes to analyze
* @param staticFieldName
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/AMechanism.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/AMechanism.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/AMechanism.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/AMechanism.java Wed Sep 20 08:12:00 2006
@@ -92,10 +92,6 @@
if (aaaaRecords == null) {
return false;
}
-
- // We should match if any A Record was found!
- //if (aaaaRecords.size() > 0 && spfData.matchAnyAAAARecord()) return true;
-
if (checkAddressList(checkAddress, aaaaRecords, getIp6cidr())) {
return true;
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/GenericMechanism.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/GenericMechanism.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/GenericMechanism.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/GenericMechanism.java Wed Sep 20 08:12:00 2006
@@ -59,8 +59,8 @@
/**
* Expand the hostname
*
- * @param spfData
- * @throws PermErrorException
+ * @param spfData The SPF1Data to use
+ * @throws PermErrorException get Thrown if invalid macros are used
*/
protected String expandHost(SPF1Data spfData) throws PermErrorException {
String host = getDomain();
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/IncludeMechanism.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/IncludeMechanism.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/IncludeMechanism.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/IncludeMechanism.java Wed Sep 20 08:12:00 2006
@@ -60,9 +60,9 @@
* @throws PermErrorException
* if an error is in the redirect modifier
* @throws TempErrorException
- * @throws NoneException
+ * if the dns return a temp error
*/
- public boolean run(SPF1Data spfData) throws PermErrorException, TempErrorException, NoneException {
+ public boolean run(SPF1Data spfData) throws PermErrorException, TempErrorException {
String host = getHost();
// update currentDepth
@@ -70,7 +70,7 @@
try {
host = new MacroExpand(spfData, log).expandDomain(host);
- } catch (Exception e) {
+ } catch (PermErrorException e) {
throw new PermErrorException("Error in include modifier: " + host);
}
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/MXMechanism.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/MXMechanism.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/MXMechanism.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/terms/MXMechanism.java Wed Sep 20 08:12:00 2006
@@ -65,20 +65,13 @@
// should never happen.
if (mxRecords == null) return false;
-
-
- try {
- if (checkAddressList(checkAddress, mxRecords, getIp4cidr())) {
- return true;
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw new PermErrorException("No valid ipAddress: "
- + spfData.getIpAddress());
+
+ if (checkAddressList(checkAddress, mxRecords, getIp4cidr())) {
+ return true;
}
-
+
} catch (NoneException e ) {
- e.printStackTrace();
+ // no mx record found
return false;
}
Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/util/ConfigurationMatch.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/util/ConfigurationMatch.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/util/ConfigurationMatch.java (original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/util/ConfigurationMatch.java Wed Sep 20 08:12:00 2006
@@ -23,7 +23,6 @@
import java.util.regex.Matcher;
/**
- * @author Stefano Bagnara
*
* Provides a MatchResult view of a subset of another MatchResult
*/
Modified: james/jspf/trunk/src/test/java/org/apache/james/jspf/DNSServiceXBillImplTest.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/test/java/org/apache/james/jspf/DNSServiceXBillImplTest.java?view=diff&rev=448232&r1=448231&r2=448232
==============================================================================
--- james/jspf/trunk/src/test/java/org/apache/james/jspf/DNSServiceXBillImplTest.java (original)
+++ james/jspf/trunk/src/test/java/org/apache/james/jspf/DNSServiceXBillImplTest.java Wed Sep 20 08:12:00 2006
@@ -22,6 +22,7 @@
import org.xbill.DNS.Lookup;
import org.xbill.DNS.Name;
+import org.xbill.DNS.Record;
import org.xbill.DNS.TextParseException;
import org.xbill.DNS.Type;
@@ -51,8 +52,8 @@
System.out.println(InetAddress.getLocalHost().getCanonicalHostName());
System.out.println(InetAddress.getAllByName(null)[0]
.getCanonicalHostName());
- System.out.println(new Lookup(Name.root, Type.ANY).run()[0]);
-
+ Record[] record = new Lookup(Name.root, Type.ANY).run();
+ if (record !=null) System.out.println(record[0]);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org