james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r453520 - in /james/jspf/trunk/src/main/java/org/apache/james/jspf: SPF.java policies/local/FallbackPolicy.java
Date Fri, 06 Oct 2006 07:22:52 GMT
Author: norman
Date: Fri Oct  6 00:22:51 2006
New Revision: 453520

URL: http://svn.apache.org/viewvc?view=rev&rev=453520
Log:
Add support for Override. See JSPF-36 and JSPF-32

Modified:
    james/jspf/trunk/src/main/java/org/apache/james/jspf/SPF.java
    james/jspf/trunk/src/main/java/org/apache/james/jspf/policies/local/FallbackPolicy.java

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=453520&r1=453519&r2=453520
==============================================================================
--- 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 Fri Oct  6 00:22:51 2006
@@ -44,6 +44,7 @@
 import org.apache.james.jspf.policies.local.BestGuessPolicy;
 import org.apache.james.jspf.policies.local.DefaultExplanationPolicy;
 import org.apache.james.jspf.policies.local.FallbackPolicy;
+import org.apache.james.jspf.policies.local.OverridePolicy;
 import org.apache.james.jspf.policies.local.TrustedForwarderPolicy;
 import org.apache.james.jspf.wiring.DNSServiceEnabled;
 import org.apache.james.jspf.wiring.LogEnabled;
@@ -76,6 +77,8 @@
 
     private FallbackPolicy fallBack;
     
+    private OverridePolicy override;
+    
     private boolean useTrustedForwarder = false;
 
     /**
@@ -193,6 +196,10 @@
 
         ArrayList policies = new ArrayList();
         
+        if (override != null) {
+            policies.add(override);
+        }
+        
         policies.add(new SPFRetriever(dnsProbe));
         
         if (useBestGuess) {
@@ -277,5 +284,18 @@
      */
     public synchronized void setUseTrustedForwarder(boolean useTrustedForwarder) {
         this.useTrustedForwarder = useTrustedForwarder;
+    }
+    
+    /**
+     * Return the OverridePolicy object which can be used to
+     * override spfRecords for hosts
+     * 
+     * @return the OverridePolicy object
+     */
+    public synchronized OverridePolicy getOverridePolicy() {
+        if (override == null) {
+            override = new OverridePolicy(this.log, parser);
+        }
+        return override;
     }
 }

Modified: james/jspf/trunk/src/main/java/org/apache/james/jspf/policies/local/FallbackPolicy.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/policies/local/FallbackPolicy.java?view=diff&rev=453520&r1=453519&r2=453520
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/policies/local/FallbackPolicy.java
(original)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/policies/local/FallbackPolicy.java
Fri Oct  6 00:22:51 2006
@@ -35,7 +35,7 @@
  */
 public class FallbackPolicy extends AbstractNestedPolicy {
 
-    private Map fallBackMap;
+    private Map entryMap;
 
     private SPFRecordParser parser;
 
@@ -43,12 +43,12 @@
 
     public FallbackPolicy(Logger log, SPFRecordParser parser) {
         this.log = log;
-        fallBackMap = Collections.synchronizedMap(new HashMap());
+        entryMap = Collections.synchronizedMap(new HashMap());
         this.parser = parser;
     }
 
     /**
-     * Add a fallback entry.
+     * Add a entry.
      * 
      * @param rawHost
      *            the host or ipaddress for which the entry should be added.
@@ -57,7 +57,7 @@
      * @throws IllegalArgumentException
      *             get thrown on invalid spfRecord
      */
-    public void addFallBackEntry(String rawHost, String rawSpfRecord)
+    public void addEntry(String rawHost, String rawSpfRecord)
             throws IllegalArgumentException {
         String host;
         try {
@@ -74,8 +74,8 @@
                 host = rawHost;
             }
 
-            synchronized (fallBackMap) {
-                fallBackMap.put(host, spfRecord);
+            synchronized (entryMap) {
+                entryMap.put(host, spfRecord);
             }
         } catch (SPFResultException e) {
             throw new IllegalArgumentException("Invalid SPF-Record: "
@@ -85,26 +85,26 @@
     }
 
     /**
-     * Clear all fallBack entries
+     * Clear all entries
      * 
      */
-    public void clearFallBackEntrys() {
-        log.debug("Clear all fallback entries");
-        synchronized (fallBackMap) {
-            fallBackMap.clear();
+    public void clearEntrys() {
+        log.debug("Clear all entries");
+        synchronized (entryMap) {
+            entryMap.clear();
         }
     }
 
     /**
-     * Remove fallBack entry
+     * Remove entry
      * 
      * @param host
      *            The host
      */
-    public void removeFallBackEntrys(String host) {
+    public void removeEntry(String host) {
         log.debug("Remove fallback entry for host: " + host);
-        synchronized (fallBackMap) {
-            fallBackMap.remove(getRawFallBackEntry(host));
+        synchronized (entryMap) {
+            entryMap.remove(getRawEntry(host));
         }
     }
 
@@ -124,14 +124,14 @@
      *         the given host
      */
     protected SPF1Record getMySPFRecord(String host) {
-        Object fallBack = null;
+        Object entry = null;
 
-        synchronized (fallBackMap) {
-            fallBack = getRawFallBackEntry(host);
+        synchronized (entryMap) {
+            entry = getRawEntry(host);
         }
 
-        if (fallBack != null) {
-            return (SPF1Record) fallBack;
+        if (entry != null) {
+            return (SPF1Record) entry;
         } else {
             return null;
         }
@@ -146,15 +146,15 @@
      *            the host
      * @return the stored object for the given host or null
      */
-    private Object getRawFallBackEntry(String host) {
-        Iterator fallBackIt = fallBackMap.keySet().iterator();
+    private Object getRawEntry(String host) {
+        Iterator fallBackIt = entryMap.keySet().iterator();
 
         while (fallBackIt.hasNext()) {
             String rawHost = fallBackIt.next().toString();
 
             if ((rawHost.startsWith(".") && host.startsWith(rawHost))
                     || rawHost.endsWith(".") && host.endsWith(rawHost)) {
-                return fallBackMap.get(rawHost);
+                return entryMap.get(rawHost);
             }
         }
         return null;



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message