Class SPF

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

public class SPF extends Object implements SPFChecker
This class is used to generate a SPF-Test and provided all intressting data.
  • Constructor Details

    • SPF

      public SPF(DNSService dnsProbe)
      Uses passed logger and passed dnsServicer
      Parameters:
      dnsProbe - the dns provider
    • SPF

      public SPF(DNSService dnsProbe, SPFRecordParser parser, MacroExpand macroExpand, SPFExecutor executor)
      Uses passed services
      Parameters:
      dnsProbe - the dns provider
      parser - the parser to use
  • Method Details

    • checkSPF

      public SPFResult checkSPF(String ipAddress, String mailFrom, 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

      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
      NoneException
      TempErrorException - Get thrown if a DNS problem was detected
      NeutralException - Get thrown if the result should be neutral
      See Also:
    • getPolicies

      public LinkedList<SPFChecker> 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(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