org.apache.james.jspf.impl
Class SPF

java.lang.Object
  extended by org.apache.james.jspf.impl.SPF
All Implemented Interfaces:
SPFChecker
Direct Known Subclasses:
DefaultSPF

public class SPF
extends java.lang.Object
implements SPFChecker

This class is used to generate a SPF-Test and provided all intressting data.


Constructor Summary
SPF(DNSService dnsProbe, Logger logger)
          Uses passed logger and passed dnsServicer
SPF(DNSService dnsProbe, SPFRecordParser parser, Logger logger, MacroExpand macroExpand, SPFExecutor executor)
          Uses passed services
 
Method Summary
 DNSLookupContinuation checkSPF(SPFSession spfData)
          Run check for SPF with the given values.
 SPFResult checkSPF(java.lang.String ipAddress, java.lang.String mailFrom, java.lang.String hostName)
          Run check for SPF with the given values.
 FallbackPolicy getFallbackPolicy()
          Return the FallbackPolicy object which can be used to provide default spfRecords for hosts which have no records
 OverridePolicy getOverridePolicy()
          Return the OverridePolicy object which can be used to override spfRecords for hosts
 java.util.LinkedList getPolicies()
          Return a default policy for SPF
 void setDefaultExplanation(java.lang.String defaultExplanation)
          Set the default explanation which will be used if no explanation is found in the SPF Record
 void setSPFMustEqualsTXT(boolean mustEquals)
          Set to true if a PermError should returned when a domain publish a SPF-Type and TXT-Type SPF-Record and both are not equals.
 void setTimeOut(int timeOut)
          Set the amount of time (in seconds) before an TermError is returned when the dnsserver not answer.
 void setUseBestGuess(boolean useBestGuess)
          Set to true for using best guess.
 void setUseTrustedForwarder(boolean useTrustedForwarder)
          Set to true to enable trusted-forwarder.org whitelist.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SPF

public SPF(DNSService dnsProbe,
           Logger logger)
Uses passed logger and passed dnsServicer

Parameters:
dnsProbe - the dns provider
logger - the logger to use

SPF

public SPF(DNSService dnsProbe,
           SPFRecordParser parser,
           Logger logger,
           MacroExpand macroExpand,
           SPFExecutor executor)
Uses passed services

Parameters:
dnsProbe - the dns provider
parser - the parser to use
logger - the logger to use
Method Detail

checkSPF

public SPFResult checkSPF(java.lang.String ipAddress,
                          java.lang.String mailFrom,
                          java.lang.String hostName)
Run check for SPF with the given values.

Parameters:
ipAddress - The ipAddress the connection is comming from
mailFrom - The mailFrom which was provided
hostName - The hostname which was provided as HELO/EHLO
Returns:
result The SPFResult

checkSPF

public DNSLookupContinuation checkSPF(SPFSession spfData)
                               throws PermErrorException,
                                      NoneException,
                                      TempErrorException,
                                      NeutralException
Description copied from interface: SPFChecker
Run check for SPF with the given values.

Specified by:
checkSPF in interface SPFChecker
Parameters:
spfData - The SPF1Data which should be used to run the check
Throws:
PermErrorException - Get thrown if an error was detected
NoneException - Get thrown if no Record was found
TempErrorException - Get thrown if a DNS problem was detected
NeutralException - Get thrown if the result should be neutral
See Also:
SPFChecker.checkSPF(org.apache.james.jspf.core.SPFSession)

getPolicies

public java.util.LinkedList getPolicies()
Return a default policy for SPF


setTimeOut

public void setTimeOut(int timeOut)
Set the amount of time (in seconds) before an TermError is returned when the dnsserver not answer. Default is 20 seconds.

Parameters:
timeOut - The timout in seconds

setDefaultExplanation

public void setDefaultExplanation(java.lang.String defaultExplanation)
Set the default explanation which will be used if no explanation is found in the SPF Record

Parameters:
defaultExplanation - The explanation to use if no explanation is found in the SPF Record

setUseBestGuess

public void setUseBestGuess(boolean useBestGuess)
Set to true for using best guess. Best guess will set the SPF-Record to "a/24 mx/24 ptr ~all" if no SPF-Record was found for the doamin. When this was happen only pass or netural will be returned. Default is false.

Parameters:
useBestGuess - true to enable best guess

getFallbackPolicy

public FallbackPolicy getFallbackPolicy()
Return the FallbackPolicy object which can be used to provide default spfRecords for hosts which have no records

Returns:
the FallbackPolicy object

setUseTrustedForwarder

public void setUseTrustedForwarder(boolean useTrustedForwarder)
Set to true to enable trusted-forwarder.org whitelist. The whitelist will only be queried if the last Mechanism is -all or ?all. See http://trusted-forwarder.org for more informations Default is false.

Parameters:
useTrustedForwarder - true or false

getOverridePolicy

public OverridePolicy getOverridePolicy()
Return the OverridePolicy object which can be used to override spfRecords for hosts

Returns:
the OverridePolicy object

setSPFMustEqualsTXT

public void setSPFMustEqualsTXT(boolean mustEquals)
Set to true if a PermError should returned when a domain publish a SPF-Type and TXT-Type SPF-Record and both are not equals. Defaults false

Parameters:
mustEquals - true or false


Copyright © 2006-2009 The Apache Software Foundation. All Rights Reserved.